Skip to content

Commit

Permalink
Implement case-insensitive handling for Xpansion solver names to be p…
Browse files Browse the repository at this point in the history
…assed to Simulator
  • Loading branch information
tbittar committed Jan 3, 2025
1 parent 26f3828 commit a9535bb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/cpp/lpnamer/main/ProblemGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit a9535bb

Please sign in to comment.