diff --git a/src/optimization/CasADiOpti.cpp b/src/optimization/CasADiOpti.cpp index 4a1bbbc8..4c32468c 100644 --- a/src/optimization/CasADiOpti.cpp +++ b/src/optimization/CasADiOpti.cpp @@ -24,14 +24,12 @@ void CasADiOpti::SetInitial(const casadi::MX& expression, double value) { opti.set_initial(expression, value); } void CasADiOpti::Solve() { - const auto callback = CasADiIterCallback("f", opti.nx(), opti.ng(), opti.np()); + const auto callback = new 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; - auto solverOptions = casadi::Dict(); - solverOptions["iteration_callback"] = callback; + pluginOptions["iteration_callback"] = *callback; //auto reference = &pluginOptions["iteration_callback"]; opti.solver("ipopt", pluginOptions, solverOptions); #else