csu-hmc / opty

A library for using direct collocation in the optimization of dynamic systems.
http://opty.readthedocs.io
Other
86 stars 20 forks source link

Objective with Abs fails #119

Open moorepants opened 4 months ago

moorepants commented 4 months ago
obj_func = sym.Integral(sym.Abs(T(t)*omega(t)), t)

I guess there is a derivative of one of the variables:

Traceback (most recent call last):
  File "/home/moorepants/src/opty/examples/pendulum_swing_up.py", line 69, in <module>
    solution, info = prob.solve(initial_guess)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "cyipopt/cython/ipopt_wrapper.pyx", line 642, in ipopt_wrapper.Problem.solve
  File "cyipopt/cython/ipopt_wrapper.pyx", line 700, in ipopt_wrapper.gradient_cb
  File "/home/moorepants/src/opty/opty/direct_collocation.py", line 228, in gradient
    return self.obj_grad(free)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/moorepants/src/opty/opty/utils.py", line 326, in obj_grad
    *obj_grad_time_expr_eval(states, inputs, free[r_idx:]),
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<lambdifygenerated-2>", line 16, in _lambdifygenerated
NameError: name 'Derivative' is not defined