Skip to content

Commit dce7202

Browse files
authored
Merge branch 'main' into main
2 parents d1bb7ba + cf7ccd1 commit dce7202

36 files changed

+152
-258
lines changed

uno/Uno.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ namespace uno {
6666
model.reset_number_evaluations();
6767
// pick the ingredients based on the user-defined options
6868
Uno::pick_ingredients(model, options);
69-
Statistics statistics = Uno::create_statistics(model, options);
69+
Statistics statistics = Uno::create_statistics(model);
7070
WarmstartInformation warmstart_information{};
7171
warmstart_information.whole_problem_changed();
7272

@@ -91,7 +91,7 @@ namespace uno {
9191
while (!termination) {
9292
++major_iterations;
9393
statistics.start_new_line();
94-
statistics.set("iter", major_iterations);
94+
statistics.set("Major", major_iterations);
9595
DEBUG << "\n### Outer iteration " << major_iterations << '\n';
9696

9797
// compute an acceptable iterate by solving a subproblem at the current point
@@ -111,7 +111,7 @@ namespace uno {
111111
}
112112
catch (std::exception& exception) {
113113
statistics.start_new_line();
114-
statistics.set("status", exception.what());
114+
statistics.set("Status", exception.what());
115115
if (Logger::level == INFO) statistics.print_current_line();
116116
DEBUG << exception.what() << '\n';
117117
optimization_status = OptimizationStatus::ALGORITHMIC_ERROR;
@@ -152,33 +152,33 @@ namespace uno {
152152

153153
void Uno::initialize(Statistics& statistics, const Model& model, Iterate& current_iterate, const Options& options) {
154154
statistics.start_new_line();
155-
statistics.set("iter", 0);
156-
statistics.set("status", "initial point");
155+
statistics.set("Major", 0);
156+
statistics.set("Status", "initial point");
157157

158158
model.project_onto_variable_bounds(current_iterate.primals);
159-
this->globalization_mechanism->initialize(statistics, model, current_iterate, this->direction, options);
159+
this->globalization_mechanism->initialize(statistics, model, current_iterate, this->direction);
160160
GlobalizationMechanism::set_primal_statistics(statistics, model, current_iterate);
161161
GlobalizationMechanism::set_dual_residuals_statistics(statistics, current_iterate);
162162

163-
options.print_used_overwritten();
163+
options.print_non_default();
164164
if (Logger::level == INFO) {
165165
statistics.print_header();
166166
statistics.print_current_line();
167167
}
168168
current_iterate.status = SolutionStatus::NOT_OPTIMAL;
169169
}
170170

171-
Statistics Uno::create_statistics(const Model& model, const Options& options) {
171+
Statistics Uno::create_statistics(const Model& model) {
172172
Statistics statistics{};
173-
statistics.add_column("iter", Statistics::int_width, options.get_int("statistics_major_column_order"));
174-
statistics.add_column("step norm", Statistics::double_width, options.get_int("statistics_step_norm_column_order"));
175-
statistics.add_column("objective", Statistics::double_width, options.get_int("statistics_objective_column_order"));
173+
statistics.add_column("Major", Statistics::int_width, 3, Statistics::column_order.at("Major"));
174+
statistics.add_column("||Step||", Statistics::double_width, 2, Statistics::column_order.at("||Step||"));
175+
statistics.add_column("Objective", Statistics::double_width + 1, 3, Statistics::column_order.at("Objective"));
176176
if (model.is_constrained()) {
177-
statistics.add_column("primal feas", Statistics::double_width + 1, options.get_int("statistics_primal_feasibility_column_order"));
177+
statistics.add_column("Infeas", Statistics::double_width, 2, Statistics::column_order.at("Infeas"));
178178
}
179-
statistics.add_column("stationarity", Statistics::double_width + 2, options.get_int("statistics_stationarity_column_order"));
180-
statistics.add_column("complementarity", Statistics::double_width + 5, options.get_int("statistics_complementarity_column_order"));
181-
statistics.add_column("status", Statistics::string_width, options.get_int("statistics_status_column_order"));
179+
statistics.add_column("Statio", Statistics::double_width, 2, Statistics::column_order.at("Statio"));
180+
statistics.add_column("Compl", Statistics::double_width, 2, Statistics::column_order.at("Compl"));
181+
statistics.add_column("Status", Statistics::string_width, 3, Statistics::column_order.at("Status"));
182182
return statistics;
183183
}
184184

uno/Uno.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace uno {
3636

3737
void pick_ingredients(const Model& model, const Options& options);
3838
void initialize(Statistics& statistics, const Model& model, Iterate& current_iterate, const Options& options);
39-
[[nodiscard]] static Statistics create_statistics(const Model& model, const Options& options);
39+
[[nodiscard]] static Statistics create_statistics(const Model& model);
4040
[[nodiscard]] static bool termination_criteria(SolutionStatus solution_status, size_t iteration, size_t max_iterations,
4141
double current_time, double time_limit, bool user_termination, OptimizationStatus& optimization_status);
4242
[[nodiscard]] Result uno_solve(const Model& model, const Options& options, UserCallbacks& user_callbacks);

uno/ingredients/constraint_relaxation_strategies/ConstraintRelaxationStrategy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace uno {
2626
virtual ~ConstraintRelaxationStrategy();
2727

2828
virtual void initialize(Statistics& statistics, const Model& model, Iterate& initial_iterate, Direction& direction,
29-
double trust_region_radius, const Options& options) = 0;
29+
double trust_region_radius) = 0;
3030

3131
// direction computation
3232
virtual void compute_feasible_direction(Statistics& statistics, Iterate& current_iterate, Direction& direction,

uno/ingredients/constraint_relaxation_strategies/FeasibilityRestoration.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace uno {
4343
}
4444

4545
void FeasibilityRestoration::initialize(Statistics& statistics, const Model& model, Iterate& initial_iterate,
46-
Direction& direction, double trust_region_radius, const Options& options) {
46+
Direction& direction, double trust_region_radius) {
4747
this->reference_optimality_primals.resize(this->optimality_problem.number_variables);
4848

4949
// memory allocation
@@ -55,12 +55,12 @@ namespace uno {
5555
);
5656

5757
// statistics
58-
this->optimality_inertia_correction_strategy->initialize_statistics(statistics, options);
59-
this->optimality_inequality_handling_method->initialize_statistics(statistics, options);
60-
this->feasibility_inertia_correction_strategy->initialize_statistics(statistics, options);
61-
this->feasibility_inequality_handling_method->initialize_statistics(statistics, options);
62-
statistics.add_column("phase", Statistics::int_width - 1, options.get_int("statistics_restoration_phase_column_order"));
63-
statistics.set("phase", "OPT");
58+
this->optimality_inertia_correction_strategy->initialize_statistics(statistics);
59+
this->optimality_inequality_handling_method->initialize_statistics(statistics);
60+
this->feasibility_inertia_correction_strategy->initialize_statistics(statistics);
61+
this->feasibility_inequality_handling_method->initialize_statistics(statistics);
62+
statistics.add_column("Phase", Statistics::int_width - 1, 3, Statistics::column_order.at("Phase"));
63+
statistics.set("Phase", "OPT");
6464

6565
// initial iterate
6666
this->optimality_inequality_handling_method->generate_initial_iterate(initial_iterate);
@@ -71,23 +71,23 @@ namespace uno {
7171
this->optimality_problem.evaluate_lagrangian_gradient(initial_iterate.residuals.lagrangian_gradient,
7272
evaluation_space, initial_iterate);
7373
ConstraintRelaxationStrategy::compute_primal_dual_residuals(this->optimality_problem, initial_iterate);
74-
this->optimality_globalization_strategy->initialize(statistics, initial_iterate, options);
75-
this->feasibility_globalization_strategy.initialize(statistics, initial_iterate, options);
74+
this->optimality_globalization_strategy->initialize(statistics, initial_iterate);
75+
this->feasibility_globalization_strategy.initialize(statistics, initial_iterate);
7676
}
7777

7878
void FeasibilityRestoration::compute_feasible_direction(Statistics& statistics, Iterate& current_iterate, Direction& direction,
7979
double trust_region_radius, WarmstartInformation& warmstart_information) {
8080
direction.reset();
8181
// if we are in the optimality phase, solve the optimality problem
8282
if (this->current_phase == Phase::OPTIMALITY) {
83-
statistics.set("phase", "OPT");
83+
statistics.set("Phase", "OPT");
8484
try {
8585
DEBUG << "Solving the optimality subproblem\n";
8686
this->solve_subproblem(statistics, *this->optimality_inequality_handling_method, this->optimality_problem,
8787
current_iterate, direction, trust_region_radius, warmstart_information);
8888
if (direction.status == SubproblemStatus::INFEASIBLE) {
8989
// switch to the feasibility problem, starting from the current direction
90-
statistics.set("status", std::string("infeasible"));
90+
statistics.set("Status", std::string("infeasible"));
9191
DEBUG << "/!\\ The subproblem is infeasible\n";
9292
this->switch_to_feasibility_problem(statistics, current_iterate, trust_region_radius, warmstart_information);
9393
this->feasibility_inequality_handling_method->set_initial_point(direction.primals);
@@ -104,7 +104,7 @@ namespace uno {
104104

105105
// solve the feasibility problem (minimize the constraint violation)
106106
DEBUG << "Solving the feasibility subproblem\n";
107-
statistics.set("phase", "FEAS");
107+
statistics.set("Phase", "FEAS");
108108
// note: failure of regularization should not happen here, since the feasibility Jacobian has full rank
109109
this->feasibility_problem.set_proximal_coefficient(this->optimality_inequality_handling_method->proximal_coefficient());
110110
this->solve_subproblem(statistics, *this->feasibility_inequality_handling_method, this->feasibility_problem,

uno/ingredients/constraint_relaxation_strategies/FeasibilityRestoration.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace uno {
2525
~FeasibilityRestoration() override = default;
2626

2727
void initialize(Statistics& statistics, const Model& model, Iterate& initial_iterate, Direction& direction,
28-
double trust_region_radius, const Options& options) override;
28+
double trust_region_radius) override;
2929

3030
// direction computation
3131
void compute_feasible_direction(Statistics& statistics, Iterate& current_iterate, Direction& direction,

uno/ingredients/constraint_relaxation_strategies/NoRelaxation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ namespace uno {
2323
}
2424

2525
void NoRelaxation::initialize(Statistics& statistics, const Model& model, Iterate& initial_iterate,
26-
Direction& direction, double trust_region_radius, const Options& options) {
26+
Direction& direction, double trust_region_radius) {
2727
// memory allocation
2828
this->inequality_handling_method->initialize(this->problem, initial_iterate, *this->hessian_model,
2929
*this->inertia_correction_strategy, trust_region_radius);
3030
direction = Direction(this->problem.number_variables, this->problem.number_constraints);
3131

3232
// statistics
33-
this->inertia_correction_strategy->initialize_statistics(statistics, options);
34-
this->inequality_handling_method->initialize_statistics(statistics, options);
33+
this->inertia_correction_strategy->initialize_statistics(statistics);
34+
this->inequality_handling_method->initialize_statistics(statistics);
3535

3636
// initial iterate
3737
this->inequality_handling_method->generate_initial_iterate(initial_iterate);
@@ -41,7 +41,7 @@ namespace uno {
4141
const auto& evaluation_space = this->inequality_handling_method->get_evaluation_space();
4242
this->problem.evaluate_lagrangian_gradient(initial_iterate.residuals.lagrangian_gradient, evaluation_space, initial_iterate);
4343
this->compute_primal_dual_residuals(this->problem, initial_iterate);
44-
this->globalization_strategy.initialize(statistics, initial_iterate, options);
44+
this->globalization_strategy.initialize(statistics, initial_iterate);
4545
}
4646

4747
void NoRelaxation::compute_feasible_direction(Statistics& statistics, Iterate& current_iterate, Direction& direction,

uno/ingredients/constraint_relaxation_strategies/NoRelaxation.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace uno {
1818
~NoRelaxation() override = default;
1919

2020
void initialize(Statistics& statistics, const Model& model, Iterate& initial_iterate, Direction& direction,
21-
double trust_region_radius, const Options& options) override;
21+
double trust_region_radius) override;
2222

2323
// direction computation
2424
void compute_feasible_direction(Statistics& statistics, Iterate& current_iterate, Direction& direction,

uno/ingredients/globalization_mechanisms/BacktrackingLineSearch.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ namespace uno {
2525
}
2626

2727
void BacktrackingLineSearch::initialize(Statistics& statistics, const Model& model, Iterate& current_iterate,
28-
Direction& direction, const Options& options) {
29-
this->constraint_relaxation_strategy->initialize(statistics, model, current_iterate, direction, INF<double>, options);
30-
statistics.add_column("LS iter", Statistics::int_width + 2, options.get_int("statistics_minor_column_order"));
31-
statistics.add_column("step length", Statistics::double_width + 1, options.get_int("statistics_LS_step_length_column_order"));
28+
Direction& direction) {
29+
this->constraint_relaxation_strategy->initialize(statistics, model, current_iterate, direction, INF<double>);
30+
statistics.add_column("Minor", Statistics::int_width, 3, Statistics::column_order.at("Minor"));
31+
statistics.add_column("Steplength", Statistics::double_width + 1, 2, Statistics::column_order.at("Steplength"));
3232
}
3333

3434
void BacktrackingLineSearch::compute_next_iterate(Statistics& statistics, const Model& model, Iterate& current_iterate,
@@ -58,22 +58,22 @@ namespace uno {
5858
++number_iterations;
5959
DEBUG << "\n\tLine-search iteration " << number_iterations << ", step_length " << step_length << '\n';
6060
if (1 < number_iterations) { statistics.start_new_line(); }
61-
statistics.set("step length", step_length);
61+
statistics.set("Steplength", step_length);
6262

6363
bool is_acceptable = false;
6464
try {
6565
// take a step as a fraction of the direction
6666
GlobalizationMechanism::assemble_trial_iterate(model, current_iterate, trial_iterate, direction, step_length,
6767
// scale or not the constraint dual direction with the LS step length
6868
this->scale_duals_with_step_length ? step_length : 1.);
69-
statistics.set("step norm", step_length * direction.norm);
69+
statistics.set("||Step||", step_length * direction.norm);
7070

7171
is_acceptable = this->constraint_relaxation_strategy->is_iterate_acceptable(statistics, model, current_iterate,
7272
trial_iterate, direction, step_length, warmstart_information, user_callbacks);
7373
GlobalizationMechanism::set_primal_statistics(statistics, model, trial_iterate);
7474
}
7575
catch (const EvaluationError&) {
76-
statistics.set("status", "eval. error");
76+
statistics.set("Status", "eval. error");
7777
}
7878
BacktrackingLineSearch::set_LS_statistics(statistics, number_iterations);
7979

@@ -97,7 +97,7 @@ namespace uno {
9797
throw std::runtime_error("LS failed");
9898
}
9999
// switch to solving the feasibility problem
100-
statistics.set("status", "small step length");
100+
statistics.set("Status", "small step length");
101101
this->constraint_relaxation_strategy->switch_to_feasibility_problem(statistics, current_iterate, INF<double>,
102102
warmstart_information);
103103
this->constraint_relaxation_strategy->compute_feasible_direction(statistics, current_iterate, direction,
@@ -116,7 +116,7 @@ namespace uno {
116116
bool termination = false;
117117
trial_iterate.status = this->constraint_relaxation_strategy->check_termination(model, trial_iterate);
118118
if (trial_iterate.status != SolutionStatus::NOT_OPTIMAL) {
119-
statistics.set("status", "accepted (small step length)");
119+
statistics.set("Status", "accepted (small step length)");
120120
GlobalizationMechanism::set_dual_residuals_statistics(statistics, trial_iterate);
121121
termination = true;
122122
}
@@ -138,6 +138,6 @@ namespace uno {
138138
}
139139

140140
void BacktrackingLineSearch::set_LS_statistics(Statistics& statistics, size_t number_iterations) {
141-
statistics.set("LS iter", number_iterations);
141+
statistics.set("Minor", number_iterations);
142142
}
143143
} // namespace

uno/ingredients/globalization_mechanisms/BacktrackingLineSearch.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ namespace uno {
1212
BacktrackingLineSearch(const Model& model, const Options& options);
1313
~BacktrackingLineSearch() override = default;
1414

15-
void initialize(Statistics& statistics, const Model& model, Iterate& current_iterate, Direction& direction,
16-
const Options& options) override;
15+
void initialize(Statistics& statistics, const Model& model, Iterate& current_iterate, Direction& direction) override;
1716
void compute_next_iterate(Statistics& statistics, const Model& model, Iterate& current_iterate, Iterate& trial_iterate,
1817
Direction& direction, WarmstartInformation& warmstart_information, UserCallbacks& user_callbacks) override;
1918

uno/ingredients/globalization_mechanisms/GlobalizationMechanism.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ namespace uno {
4040

4141
void GlobalizationMechanism::set_primal_statistics(Statistics& statistics, const Model& model, const Iterate& iterate) {
4242
if (iterate.is_objective_computed) {
43-
statistics.set("objective", iterate.evaluations.objective);
43+
statistics.set("Objective", iterate.evaluations.objective);
4444
}
4545
if (model.is_constrained()) {
46-
statistics.set("primal feas", iterate.progress.infeasibility);
46+
statistics.set("Infeas", iterate.progress.infeasibility);
4747
}
4848
}
4949

5050
void GlobalizationMechanism::set_dual_residuals_statistics(Statistics& statistics, const Iterate& iterate) {
51-
statistics.set("stationarity", iterate.residuals.stationarity);
52-
statistics.set("complementarity", iterate.residuals.complementarity);
51+
statistics.set("Statio", iterate.residuals.stationarity);
52+
statistics.set("Compl", iterate.residuals.complementarity);
5353
}
5454

5555
size_t GlobalizationMechanism::get_number_subproblems_solved() const {

0 commit comments

Comments
 (0)