| 16 | |
| 17 | namespace uno { |
| 18 | std::unique_ptr<QPSolver> QPSolverFactory::create([[maybe_unused]] const Options& options) { |
| 19 | try { |
| 20 | [[maybe_unused]] const std::string& QP_solver_name = options.get_string("QP_solver"); |
| 21 | #ifdef HAS_BQPD |
| 22 | if (QP_solver_name == "BQPD") { |
| 23 | return std::make_unique<BQPDSolver>(options); |
| 24 | } |
| 25 | #endif |
| 26 | #ifdef HAS_HIGHS |
| 27 | if (QP_solver_name == "HiGHS") { |
| 28 | return std::make_unique<HiGHSSolver>(options); |
| 29 | } |
| 30 | #endif |
| 31 | std::string message = "The QP solver "; |
| 32 | message.append(QP_solver_name).append(" is unknown").append("\n").append("The following values are available: ") |
| 33 | .append(join(QPSolverFactory::available_solvers, ", ")); |
| 34 | throw std::invalid_argument(message); |
| 35 | } |
| 36 | catch (const std::out_of_range& exception) { |
| 37 | std::string message = exception.what(); |
| 38 | message.append("\n").append("The following values are available: ").append(join(QPSolverFactory::available_solvers, ", ")); |
| 39 | throw std::out_of_range(message); |
| 40 | } |
| 41 | } |
| 42 | } // namespace |