|
18 | 18 | #include "ortools/linear_solver/linear_solver.h" |
19 | 19 |
|
20 | 20 | namespace operations_research { |
21 | | -void RunIntegerProgrammingExample( |
22 | | - const std::string& optimization_problem_type) { |
23 | | - LOG(INFO) << "---- Integer programming example with " |
24 | | - << optimization_problem_type << " ----"; |
| 21 | +void RunIntegerProgrammingExample(const std::string& solver_id) { |
| 22 | + LOG(INFO) << "---- Integer programming example with " << solver_id << " ----"; |
25 | 23 |
|
26 | | - if (!MPSolver::ParseAndCheckSupportForProblemType( |
27 | | - optimization_problem_type)) { |
28 | | - LOG(INFO) << " support for solver not linked in."; |
| 24 | + MPSolver::OptimizationProblemType problem_type; |
| 25 | + if (!MPSolver::ParseSolverType(solver_id, &problem_type)) { |
| 26 | + LOG(INFO) << "Solver id " << solver_id << " not recognized"; |
29 | 27 | return; |
30 | 28 | } |
31 | 29 |
|
32 | | - MPSolver solver("IntegerProgrammingExample", |
33 | | - MPSolver::ParseSolverTypeOrDie(optimization_problem_type)); |
| 30 | + if (!MPSolver::SupportsProblemType(problem_type)) { |
| 31 | + LOG(INFO) << "Supports for solver " << solver_id << " not linked in."; |
| 32 | + return; |
| 33 | + } |
| 34 | + |
| 35 | + MPSolver solver("IntegerProgrammingExample", problem_type); |
34 | 36 |
|
35 | 37 | const double infinity = solver.infinity(); |
36 | 38 | // x and y are integer non-negative variables. |
@@ -80,7 +82,6 @@ void RunAllExamples() { |
80 | 82 | RunIntegerProgrammingExample("GUROBI"); |
81 | 83 | RunIntegerProgrammingExample("GLPK"); |
82 | 84 | RunIntegerProgrammingExample("CPLEX"); |
83 | | - RunIntegerProgrammingExample("XPRESS"); |
84 | 85 | } |
85 | 86 | } // namespace operations_research |
86 | 87 |
|
|
0 commit comments