You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "C:\Software\mambaforge\envs\hippopt_dev\Lib\site-packages\IPython\core\interactiveshell.py", line 3577, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-19-fbf0b281ebea>", line 1, in <module>
opti.to_function("test",[v,p], [v,p], {"allow_free": True})
File "C:\Software\mambaforge\envs\hippopt_dev\Lib\site-packages\casadi\casadi.py", line 48679, in to_function
return _casadi.Opti_to_function(self, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Error in Opti::to_function [OptiNode] at D:\bld\casadi_1709758764158\work\casadi\core\optistack.cpp:331:
Error in Opti::to_function [OptiNode] at D:\bld\casadi_1709758764158\work\casadi\core\optistack.cpp:331:
Error in Function::Function for 'helper' [MXFunction] at D:\bld\casadi_1709758764158\work\casadi\core\function.cpp:280:
D:\bld\casadi_1709758764158\work\casadi\core\function_internal.cpp:147: Error calling MXFunction::init for 'helper':
D:\bld\casadi_1709758764158\work\casadi\core\mx_function.cpp:409: helper::init: Initialization failed since variables [opti0_p_1] are free. These symbols occur in the output expressions but you forgot to declare these as inputs. Set option 'allow_free' to allow free variables.
I am using version 3.6.5.
The text was updated successfully, but these errors were encountered:
Tbh I think that isn't possible with Opti to_function, but I'm not sure.
import casadi as cs
opti = cs.Opti()
v = opti.variable(1)
p = opti.parameter(1)
opti.minimize(v**2+p)
opti.solver("ipopt")
f = opti.to_function("test",[v], [v,p], {"allow_free": True,})
# f = cs.Function("test",[v], [v+p,p], {"allow_free": True})
cs.Function('bla',[v,p],[*f(v)])(1,2)
This raises no error but still doesn't work for the optimization. You might want to play around with this or try the nlpsol function instead (I have no idea whether that will be any better).
I have the following snippet of code
but it fails with the error
I am using version
3.6.5
.The text was updated successfully, but these errors were encountered: