Skip to content

Commit

Permalink
AMPLModel: pass the status to write_sol()
Browse files Browse the repository at this point in the history
  • Loading branch information
cvanaret committed Oct 23, 2024
1 parent d8571b6 commit f8d86a1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
4 changes: 3 additions & 1 deletion bindings/AMPL/AMPLModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ namespace uno {
}
Option_Info option_info{};
option_info.wantsol = 9; // write the solution without printing the message to stdout
write_sol_ASL(this->asl, "", iterate.primals.data(), iterate.multipliers.constraints.data(), &option_info);
std::string message = "Uno 1.1.0: ";
message.append(status_to_message(termination_status));
write_sol_ASL(this->asl, message.data(), iterate.primals.data(), iterate.multipliers.constraints.data(), &option_info);
}
}

Expand Down
23 changes: 1 addition & 22 deletions uno/optimization/Result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,7 @@

namespace uno {
void Result::print(bool print_primal_dual_solution) const {
DISCRETE << "Status:\t\t\t\t\t";
if (this->solution.status == TerminationStatus::FEASIBLE_KKT_POINT) {
DISCRETE << "Converged with feasible KKT point\n";
}
else if (this->solution.status == TerminationStatus::FEASIBLE_FJ_POINT) {
DISCRETE << "Converged with feasible FJ point\n";
}
else if (this->solution.status == TerminationStatus::INFEASIBLE_STATIONARY_POINT) {
DISCRETE << "Converged with infeasible stationary point\n";
}
else if (this->solution.status == TerminationStatus::FEASIBLE_SMALL_STEP) {
DISCRETE << "Terminated with feasible small step\n";
}
else if (this->solution.status == TerminationStatus::INFEASIBLE_SMALL_STEP) {
DISCRETE << "Failed with infeasible small step\n";
}
else if (this->solution.status == TerminationStatus::UNBOUNDED) {
DISCRETE << "Terminated with unbounded problem\n";
}
else {
DISCRETE << "Failed with suboptimal point\n";
}
DISCRETE << "Status:\t\t\t\t\t" << status_to_message(this->solution.status) << '\n';

DISCRETE << "Objective value:\t\t\t" << std::defaultfloat << std::setprecision(7) << this->solution.evaluations.objective << '\n';
DISCRETE << "Primal feasibility:\t\t\t" << this->solution.primal_feasibility << '\n';
Expand Down
24 changes: 24 additions & 0 deletions uno/optimization/TerminationStatus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,30 @@ namespace uno {
INFEASIBLE_SMALL_STEP,
UNBOUNDED
};

inline std::string status_to_message(TerminationStatus status) {
if (status == TerminationStatus::FEASIBLE_KKT_POINT) {
return "Converged with feasible KKT point";
}
else if (status == TerminationStatus::FEASIBLE_FJ_POINT) {
return "Converged with feasible FJ point";
}
else if (status == TerminationStatus::INFEASIBLE_STATIONARY_POINT) {
return "Converged with infeasible stationary point";
}
else if (status == TerminationStatus::FEASIBLE_SMALL_STEP) {
return "Terminated with feasible small step";
}
else if (status == TerminationStatus::INFEASIBLE_SMALL_STEP) {
return "Failed with infeasible small step";
}
else if (status == TerminationStatus::UNBOUNDED) {
return "Terminated with unbounded problem";
}
else {
return "Failed with suboptimal point";
}
}
} // namespace

#endif // UNO_TERMINATIONSTATUS_H

0 comments on commit f8d86a1

Please sign in to comment.