Skip to content

Commit

Permalink
Possibly set a preset in the default options, based on the available …
Browse files Browse the repository at this point in the history
…subproblem solvers
  • Loading branch information
cvanaret committed Oct 24, 2024
1 parent df18261 commit 737c298
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
5 changes: 2 additions & 3 deletions bindings/AMPL/uno_ampl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "options/Options.hpp"
#include "options/DefaultOptions.hpp"
#include "tools/Logger.hpp"
#include "Uno.hpp"

/*
size_t memory_allocation_amount = 0;
Expand Down Expand Up @@ -100,8 +99,8 @@ int main(int argc, char* argv[]) {
throw std::runtime_error("The second command line argument should be -AMPL");
}

// determine the default solvers based on the available libraries
Options solvers_options = DefaultOptions::determine_solvers();
// determine the default solvers based on the available libraries and possibly set a preset
Options solvers_options = DefaultOptions::determine_solvers_and_preset();
options.overwrite_with(solvers_options);

// overwrite the default options with the command line arguments
Expand Down
19 changes: 9 additions & 10 deletions uno/options/DefaultOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ namespace uno {
return options;
}

Options DefaultOptions::determine_solvers() {
Options DefaultOptions::determine_solvers_and_preset() {
Options options(false);

/** solvers: check the available solvers **/
Expand All @@ -209,15 +209,14 @@ namespace uno {
options["linear_solver"] = linear_solvers[0];
}

/** ingredients **/
// default constraint relaxation strategy (feasibility_restoration|l1_relaxation)
options["constraint_relaxation_strategy"] = "feasibility_restoration";
// default subproblem (QP|LP|primal_dual_interior_point)
options["subproblem"] = "QP";
// default globalization strategy (l1_merit|fletcher_filter_method|waechter_filter_method)
options["globalization_strategy"] = "fletcher_filter_method";
// default globalization mechanism (TR|LS)
options["globalization_mechanism"] = "TR";
/** default preset **/
if (not QP_solvers.empty()) {
Options::set_preset(options, "filtersqp");
}
else if (not linear_solvers.empty()) {
Options::set_preset(options, "ipopt");
}
// note: byrd is not very robust and is not considered as a default preset

return options;
}
Expand Down
2 changes: 1 addition & 1 deletion uno/options/DefaultOptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace uno {
class DefaultOptions {
public:
[[nodiscard]] static Options load();
[[nodiscard]] static Options determine_solvers();
[[nodiscard]] static Options determine_solvers_and_preset();
};
} // namespace

Expand Down

0 comments on commit 737c298

Please sign in to comment.