Skip to content

Commit

Permalink
Moved current Uno version number into own static function
Browse files Browse the repository at this point in the history
  • Loading branch information
cvanaret committed Oct 23, 2024
1 parent f8d86a1 commit ae46646
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions bindings/AMPL/AMPLModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "tools/Infinity.hpp"
#include "options/Options.hpp"
#include "symbolic/Concatenation.hpp"
#include "Uno.hpp"

namespace uno {
ASL* generate_asl(std::string file_name) {
Expand Down Expand Up @@ -374,8 +375,8 @@ namespace uno {
}
Option_Info option_info{};
option_info.wantsol = 9; // write the solution without printing the message to stdout
std::string message = "Uno 1.1.0: ";
message.append(status_to_message(termination_status));
std::string message = "Uno ";
message.append(Uno::current_version()).append(": ").append(status_to_message(termination_status));
write_sol_ASL(this->asl, message.data(), iterate.primals.data(), iterate.multipliers.constraints.data(), &option_info);
}
}
Expand Down
3 changes: 2 additions & 1 deletion bindings/AMPL/uno_ampl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#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 @@ -56,7 +57,7 @@ namespace uno {
}

void print_uno_instructions() {
std::cout << "Welcome in Uno 1.1.0\n";
std::cout << "Welcome in Uno " << Uno::current_version() << '\n';
std::cout << "To solve an AMPL model, type ./uno_ampl model.nl -AMPL [option_name=option_value ...]\n";
std::cout << "To choose a constraint relaxation strategy, use the argument constraint_relaxation_strategy="
"[feasibility_restoration|l1_relaxation]\n";
Expand Down
6 changes: 5 additions & 1 deletion uno/Uno.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ namespace uno {
Iterate::number_eval_jacobian, number_hessian_evaluations, number_subproblems_solved};
}

std::string Uno::current_version() {
return "1.1.0";
}

void Uno::print_available_strategies() {
std::cout << "Available strategies:\n";
std::cout << "- Constraint relaxation strategies: " << join(ConstraintRelaxationStrategyFactory::available_strategies(), ", ") << '\n';
Expand All @@ -136,7 +140,7 @@ namespace uno {
}

void Uno::print_optimization_summary(const Result& result) {
DISCRETE << "\nUno 1.1.0 (" << this->strategy_combination << ")\n";
DISCRETE << "\nUno " << Uno::current_version() << " (" << this->strategy_combination << ")\n";
DISCRETE << Timer::get_current_date();
DISCRETE << "────────────────────────────────────────\n";
result.print(this->print_solution);
Expand Down
1 change: 1 addition & 0 deletions uno/Uno.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace uno {

[[nodiscard]] Result solve(const Model& model, Iterate& initial_iterate, const Options& options);

static std::string current_version();
static void print_available_strategies();
static std::string get_strategy_combination(const Options& options);
void print_optimization_summary(const Result& result);
Expand Down

0 comments on commit ae46646

Please sign in to comment.