Skip to content

Commit

Permalink
Overloaded Uno::solve() with no user callbacks (this passes a NoUserC…
Browse files Browse the repository at this point in the history
…allbacks object that does nothing)
  • Loading branch information
cvanaret committed Nov 20, 2024
1 parent 6060c49 commit f3c2191
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions uno/Uno.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ namespace uno {

Level Logger::level = INFO;

// solve without user callbacks
void Uno::solve(const Model& model, Iterate& current_iterate, const Options& options) {
// pass user callbacks that do nothing
NoUserCallbacks user_callbacks{};
this->solve(model, current_iterate, options, user_callbacks);
}

// solve with user callbacks
void Uno::solve(const Model& model, Iterate& current_iterate, const Options& options, UserCallbacks& user_callbacks) {
Timer timer{};
Statistics statistics = Uno::create_statistics(model, options);
Expand Down
2 changes: 2 additions & 0 deletions uno/Uno.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ namespace uno {
public:
Uno(GlobalizationMechanism& globalization_mechanism, const Options& options);

// solve with or without user callbacks
void solve(const Model& model, Iterate& initial_iterate, const Options& options);
void solve(const Model& model, Iterate& initial_iterate, const Options& options, UserCallbacks& user_callbacks);

static std::string current_version();
Expand Down
9 changes: 9 additions & 0 deletions uno/tools/UserCallbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ namespace uno {
virtual void notify_new_primals(const Vector<double>& primals) = 0;
virtual void notify_new_multipliers(const Multipliers& multipliers) = 0;
};

class NoUserCallbacks: public UserCallbacks {
public:
NoUserCallbacks(): UserCallbacks() { }

void notify_acceptable_iterate(const Vector<double>& /*primals*/, const Multipliers& /*multipliers*/, double /*objective_multiplier*/) override { }
void notify_new_primals(const Vector<double>& /*primals*/) override { }
void notify_new_multipliers(const Multipliers& /*multipliers*/) override { }
};
} // namespace

#endif //UNO_USERCALLBACKS_H

0 comments on commit f3c2191

Please sign in to comment.