From a9535bb80cd7ea23c226ee9155cab1ee8bcb9631 Mon Sep 17 00:00:00 2001 From: Thomas Bittar Date: Fri, 3 Jan 2025 18:09:57 +0100 Subject: [PATCH] Implement case-insensitive handling for Xpansion solver names to be passed to Simulator --- src/cpp/lpnamer/main/ProblemGeneration.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cpp/lpnamer/main/ProblemGeneration.cpp b/src/cpp/lpnamer/main/ProblemGeneration.cpp index 6f1d75623..ee7024def 100644 --- a/src/cpp/lpnamer/main/ProblemGeneration.cpp +++ b/src/cpp/lpnamer/main/ProblemGeneration.cpp @@ -61,9 +61,19 @@ ProblemGeneration::ProblemGeneration(ProblemGenerationOptions& options) } } +static std::string lowerCase(std::string data) { + std::transform(data.begin(), data.end(), data.begin(), + [](unsigned char c) { return std::tolower(c); }); + return data; +} + static std::string solverXpansionToSimulator(const std::string& in) { - if (in == "Xpress") return "xpress"; - if (in == "Cbc") return "coin"; + // in could be Cbc or CBC depending on whether it is defined or not in the + // settings file + // Use lowerCase in any case to be robust to these subtleties + std::string lower_case_in = lowerCase(in); + if (lower_case_in == "xpress") return "xpress"; + if (lower_case_in == "cbc" || lower_case_in == "coin") return "coin"; throw std::invalid_argument("Invalid solver"); }