Closed traversaro closed 2 years ago
fyi @CarlottaSartore @GiulioRomualdi (as I wanted to open the issue just for the ma27
part that I found via GitHub search, everything else was due to the fact that I wanted to reach the ma27
error but I was not able to reach it).
@traversaro thanks for the feedback! :) I try to replicate the error on my machine.
@traversaro the problem with the attr
import was due to an automatic import in my IDE :disappointed:
field
, indeed, comes from dataclasses
! Solved in a9d072d12ee3a7333c840a711868f41d017b3dee
The error
RuntimeError: Error in Opti::subject_to [OptiNode] at .../casadi/core/optistack.cpp:96:
.../casadi/core/optistack_internal.cpp:905: Assertion "!g.is_constant()" failed:
You passed a constant to `subject_to`. You need a symbol to form a constraint.
instead comes from a change in the API that I did in the last commits: as_quat()
was returning the coefficients of the quaternion, while now it returns a Quaternion
instance (and hence casadi does not recognize it). To access the values you need to use as_quat().coeffs()
.
I also removed the ma27
dep. See 3422e4ff49d822d8ea46080c3fe34b500aa81ea6.
Thanks!
I tried with a superclean conda environment with just python
and pip
, created with:
mamba create -n liecasaditest python=3.9 pip
mamba activate liecasaditest
and then installing:
pip install "liecasadi @ git+https://github.com/ami-iit/lie-casadi.git"
# For the example
pip install matplotlib
After that, the example failed with:
(liecasaditest) traversaro@IITICUBLAP257:~/liecasadi$ python examples/manifold_optimization.py
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************
This is Ipopt version 3.12.3, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).
Number of nonzeros in equality constraint Jacobian...: 814
Number of nonzeros in inequality constraint Jacobian.: 0
Number of nonzeros in Lagrangian Hessian.............: 450
Total number of variables............................: 179
variables with only lower bounds: 0
variables with lower and upper bounds: 0
variables with only upper bounds: 0
Total number of equality constraints.................: 114
Total number of inequality constraints...............: 0
inequality constraints with only lower bounds: 0
inequality constraints with lower and upper bounds: 0
inequality constraints with only upper bounds: 0
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 0.0000000e+00 1.08e+00 0.00e+00 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0
1 1.1226556e+03 4.05e-02 8.17e+04 -1.0 6.10e+00 - 1.00e+00 1.00e+00h 1
2 1.8990559e+03 7.27e-03 9.65e+05 -1.0 8.88e+00 4.0 1.00e+00 1.00e+00h 1
3 1.9436912e+03 1.18e-04 4.44e+05 -1.0 1.55e+00 4.4 1.00e+00 1.00e+00h 1
4 1.9460341e+03 2.52e-08 7.26e+02 -1.0 1.25e-02 3.9 1.00e+00 1.00e+00h 1
5 1.9460360e+03 1.80e-08 7.26e+02 -3.8 5.92e-01 3.5 1.00e+00 3.05e-05h 16
6 1.9452324e+03 1.84e-05 2.90e+01 -3.8 9.33e-03 3.9 1.00e+00 1.00e+00H 1
7 1.7751446e+03 1.50e-03 2.10e+05 -5.7 4.88e+00 - 1.00e+00 1.00e+00f 1
8 1.7801310e+03 1.29e-06 6.20e+02 -5.7 3.33e-02 3.4 1.00e+00 1.00e+00h 1
9 1.7798743e+03 1.58e-09 3.07e+03 -5.7 6.47e-03 2.9 1.00e+00 1.00e+00f 1
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
10 1.7795838e+03 1.64e-05 5.00e+01 -5.7 2.14e-02 3.4 1.00e+00 1.00e+00f 1
11 1.7574171e+03 1.12e-03 1.02e+05 -5.7 3.69e+00 - 1.00e+00 1.00e+00f 1
12 1.7509892e+03 7.26e-07 1.05e+03 -5.7 8.50e-02 2.9 1.00e+00 1.00e+00f 1
13 1.7508191e+03 6.97e-06 1.87e+01 -5.7 8.99e-03 3.3 1.00e+00 1.00e+00f 1
14 1.6973885e+03 3.67e-04 6.98e+04 -5.7 2.09e+00 - 1.00e+00 1.00e+00f 1
15 1.6888633e+03 2.04e-07 4.76e+02 -5.7 4.58e-02 2.8 1.00e+00 1.00e+00f 1
16 1.6885783e+03 7.54e-06 1.58e+01 -5.7 8.56e-03 3.3 1.00e+00 1.00e+00f 1
17 1.6742156e+03 1.30e-04 2.15e+04 -5.7 1.18e+00 - 1.00e+00 1.00e+00f 1
18 1.6727965e+03 1.62e-08 5.71e+00 -5.7 4.67e-03 2.8 1.00e+00 1.00e+00f 1
19 1.6689016e+03 2.74e-05 2.48e+05 -5.7 5.94e-01 - 1.00e+00 1.00e+00f 1
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
20 1.6687812e+03 4.89e-10 4.24e+00 -5.7 7.19e-04 3.2 1.00e+00 1.00e+00f 1
21 1.6687741e+03 5.76e-08 1.36e+00 -5.7 2.47e-02 - 1.00e+00 1.00e+00f 1
22 1.6687737e+03 1.30e-11 5.88e-02 -8.6 5.68e-04 - 1.00e+00 1.00e+00h 1
23 1.6687737e+03 6.77e-15 1.42e-07 -8.6 8.58e-06 - 1.00e+00 1.00e+00h 1
Number of Iterations....: 23
(scaled) (unscaled)
Objective...............: 1.6687736910055917e+03 1.6687736910055917e+03
Dual infeasibility......: 1.4156103134155273e-07 1.4156103134155273e-07
Constraint violation....: 6.7723604502134549e-15 6.7723604502134549e-15
Complementarity.........: 0.0000000000000000e+00 0.0000000000000000e+00
Overall NLP error.......: 1.7590093435680195e-12 1.4156103134155273e-07
Number of objective function evaluations = 41
Number of objective gradient evaluations = 24
Number of equality constraint evaluations = 41
Number of inequality constraint evaluations = 0
Number of equality constraint Jacobian evaluations = 24
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations = 23
Total CPU secs in IPOPT (w/o function evaluations) = 0.018
Total CPU secs in NLP function evaluations = 0.013
EXIT: Optimal Solution Found.
solver : t_proc (avg) t_wall (avg) n_eval
nlp_f | 153.00us ( 3.73us) 154.20us ( 3.76us) 41
nlp_g | 1.41ms ( 34.27us) 1.41ms ( 34.42us) 41
nlp_grad_f | 201.00us ( 8.04us) 197.70us ( 7.91us) 25
nlp_hess_l | 6.64ms (288.83us) 6.65ms (289.13us) 23
nlp_jac_g | 5.42ms (216.80us) 5.43ms (217.16us) 25
total | 33.32ms ( 33.32ms) 33.32ms ( 33.32ms) 1
Traceback (most recent call last):
File "/home/traversaro/mambaforge/envs/liecasaditest/lib/python3.9/site-packages/casadi/casadi.py", line 7605, in tocsc
from scipy.sparse import csc_matrix
ModuleNotFoundError: No module named 'scipy'
The above exception was the direct cause of the following exception:
But this seems more to be a casadi problem. After installing scipy, the example works fine:
(Note: I installed everything via pip just to validate the provided README instructions. Tipically, it is always a good idea to install as much python packages as possible via the "general" package maneger that you are using, i.e. either apt or conda, rather then installing packages via pip, to avoid incompatibilities.)
Hi @Giulero, I just tried and the example still fails due to the missing matplotlib
and scipy
modules, perhaps it could be mentioned at the beginning of the example to install them to correctly run the example? If you prefer not, no problem, but in general it is good practice to always explain why an issue is being closed when you close an issue.
Hi @traversaro! Sure, you're right :) I closed the issue since the problems related to the wrong attr
import and the other the changed API were solved.
I'll add a few lines at the beginning of the example for the installation of matplotlib
and scipy
!
I tried installing the library as documented in the README and running the example.
By installing the example as documented in the README:
You can see that casadi got installed via pip.
Then, I tried to run the example and the example fails with:
This is due to matplotlib missing, and it make sense that this is not part of the dependencies of the library. If I then install matplot lib, then the example fails with:
This is a bit more tricky, as it requires to install the
attrs
package (note the final s, as theattr
package will not work).After installing also
attr
, I get this error:Furthermore, even if I did not reached this point, I noticed that the example refers
ma27
(https://github.com/ami-iit/liecasadi/blob/c79d29e87d6d654e78d258a10bac9b2bbae35773/examples/manifold_optimization.py#L47), but by following the instruction of the repocasadi
gets installed bypip
, and I do not think that that version of casadi has hsl support enabled.Environments in which I run the tests: