Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
store callback in class
Browse files Browse the repository at this point in the history
  • Loading branch information
shueja committed Nov 14, 2023
1 parent c9962a1 commit 3c1008b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/optimization/CasADiOpti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ void CasADiOpti::SetInitial(const casadi::MX& expression, double value) {
opti.set_initial(expression, value);
}
void CasADiOpti::Solve() {
auto callback = CasADiIterCallback("f", opti.nx(), opti.ng(), opti.np());
callback = CasADiIterCallback("f", opti.nx(), opti.ng(), opti.np());
#ifdef DEBUG_OUTPUT
// I don't try-catch this next line since it should always work.
// I'm assuming the dynamic lib is on the path and casadi can find it.
auto pluginOptions = casadi::Dict();
pluginOptions["iteration_callback"] = &callback;
pluginOptions["iteration_callback"] = callback;
//auto reference = &pluginOptions["iteration_callback"];
opti.solver("ipopt", pluginOptions);
#else
Expand Down
2 changes: 2 additions & 0 deletions src/optimization/CasADiOpti.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <optional>

#include <casadi/casadi.hpp>
#include "CasAdiIterCallback.h"

#include "optimization/OptiSys.h"

Expand All @@ -14,6 +15,7 @@ class CasADiOpti {
private:
casadi::Opti opti;
std::optional<casadi::OptiSol> solution;
CasADiIterCallback callback = null;

public:
casadi::MX DecisionVariable();
Expand Down

0 comments on commit 3c1008b

Please sign in to comment.