Skip to content

Commit

Permalink
Added subproblem solvers in list of strategies (--strategies) + fixed…
Browse files Browse the repository at this point in the history
… list of linear solvers
  • Loading branch information
cvanaret committed Oct 17, 2024
1 parent 1f373ce commit 73fa292
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
30 changes: 15 additions & 15 deletions uno/Uno.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "ingredients/subproblems/SubproblemFactory.hpp"
#include "model/Model.hpp"
#include "optimization/Iterate.hpp"
#include "solvers/QPSolverFactory.hpp"
#include "solvers/LPSolverFactory.hpp"
#include "solvers/SymmetricIndefiniteLinearSolverFactory.hpp"
#include "tools/Logger.hpp"
#include "tools/Options.hpp"
#include "tools/Statistics.hpp"
Expand Down Expand Up @@ -113,13 +116,15 @@ namespace uno {
Iterate::number_eval_jacobian, number_hessian_evaluations, number_subproblems_solved};
}

void join(const std::vector<std::string>& vector, char separator) {
std::string join(const std::vector<std::string>& vector, const std::string& separator) {
std::string result{};
if (not vector.empty()) {
std::cout << vector[0];
result = vector[0];
for (size_t variable_index: Range(1, vector.size())) {
std::cout << separator << ' ' << vector[variable_index];
result += separator + vector[variable_index];
}
}
return result;
}

void Uno::print_uno_version() {
Expand All @@ -137,18 +142,13 @@ namespace uno {

void Uno::print_available_strategies() {
std::cout << "Available strategies:\n";
std::cout << "Constraint relaxation strategies: ";
join(ConstraintRelaxationStrategyFactory::available_strategies(), ',');
std::cout << '\n';
std::cout << "Globalization mechanisms: ";
join(GlobalizationMechanismFactory::available_strategies(), ',');
std::cout << '\n';
std::cout << "Globalization strategies: ";
join(GlobalizationStrategyFactory::available_strategies(), ',');
std::cout << '\n';
std::cout << "Subproblems: ";
join(SubproblemFactory::available_strategies(), ',');
std::cout << '\n';
std::cout << "- Constraint relaxation strategies: " << join(ConstraintRelaxationStrategyFactory::available_strategies(), ", ") << '\n';
std::cout << "- Globalization mechanisms: " << join(GlobalizationMechanismFactory::available_strategies(), ", ") << '\n';
std::cout << "- Globalization strategies: " << join(GlobalizationStrategyFactory::available_strategies(), ", ") << '\n';
std::cout << "- Subproblems: " << join(SubproblemFactory::available_strategies(), ", ") << '\n';
std::cout << "- QP solvers: " << join(QPSolverFactory::available_solvers(), ", ") << '\n';
std::cout << "- LP solvers: " << join(LPSolverFactory::available_solvers(), ", ") << '\n';
std::cout << "- Linear solvers: " << join(SymmetricIndefiniteLinearSolverFactory::available_solvers(), ", ") << '\n';
}

void Uno::print_strategy_combination(const Options& options) {
Expand Down
9 changes: 9 additions & 0 deletions uno/solvers/LPSolverFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ namespace uno {
#endif
throw std::invalid_argument("LP solver not found");
}

// return the list of available LP solvers
static std::vector<std::string> available_solvers() {
std::vector<std::string> solvers{};
#ifdef HAS_BQPD
solvers.emplace_back("BQPD");
#endif
return solvers;
}
};
} // namespace

Expand Down
3 changes: 3 additions & 0 deletions uno/solvers/SymmetricIndefiniteLinearSolverFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ namespace uno {
std::vector<std::string> solvers{};
#ifdef HAS_MA57
solvers.emplace_back("MA57");
#endif
#ifdef HAS_MUMPS
solvers.emplace_back("MUMPS");
#endif
return solvers;
}
Expand Down

0 comments on commit 73fa292

Please sign in to comment.