How to install other packages and use them with CASADI on python

1,227 views
Skip to first unread message

mr feizi

unread,
Nov 1, 2021, 12:02:29 PM11/1/21
to CasADi
Hi
I am trying to use solvers other than IPOPT with CASADI on python with a windows machine.
However I have problems with installing and configuring the libraries for this purpose.
Can someone explain in simple language what the process is, please?

Right now I have downloaded the packages worhp and SNOPT and I want to use them.
I also have the licenses for them.
These librariries are written for C or fortran and as far as I looked in their own website
I couldn't figure out how to use them for python.
Best
Mir

Joel Andersson

unread,
Nov 19, 2021, 10:21:17 AM11/19/21
to CasADi
If you download a binary build of CasADi, it should be enough for them to be in your PATH. You can also set the "CASADIPATH" environment variable.
In general, when you select a solver in the casadi::nlpsol command - say "snopt" - then CasADi will look for a shared library called "casadi_nlpsol_snopt.dll". This shared library contains the interface to SNOPT, and will be distributed along with CasADi. In order to work, it needs to link dynamically to SNOPT itself, which needs to be in your path.

Hope that helps,
Joel

Sönke Bartels

unread,
Dec 1, 2021, 7:12:14 AM12/1/21
to CasADi
Dear Joel,
considering your answer, I have an additional question. When trying to use SNOPT I get the following error:

CasADi - 2021-12-01 13:03:20 WARNING(".../casadi/core/plugin_interface.hpp:322: Assertion "handle!=nullptr" failed: PluginInterface::load_plugin: Cannot load shared library 'libcasadi_nlpsol_snopt.so': ( Searched directories: 1. casadipath from GlobalOptions 2. CASADIPATH env var 3. PATH env var (Windows) 4. LD_LIBRARY_PATH env var (Linux) 5. DYLD_LIBRARY_PATH env var (osx) A library may be 'not found' even if the file exists: * library is not compatible (different compiler/bitness) * the dependencies are not found ) Tried '/home/sba/.local/lib/python3.8/site-packages/casadi' : Error code: /home/sba/.local/lib/python3.8/site-packages/casadi/libcasadi_nlpsol_snopt.so: cannot open shared object file: No such file or directory Tried '' : Error code: libcasadi_nlpsol_snopt.so: cannot open shared object file: No such file or directory Tried '.' : Error code: ./libcasadi_nlp... truncated") [.../casadi/core/plugin_interface.hpp:171]

How comes that the SNOPT interface is not found though it is shipped with CasADi, or am I missing something here? In my case there is no such file in the directory, whereas "libcasadi_nlpsol_ipopt.so" etc. are present.
Thanks in advance,
Sönke

P.S.:
CasADi 3.5.5 (installed using pip)
Python 3.8.10
Ubuntu 20.04.3
SNOPT installed

Joel Andersson

unread,
Jan 10, 2022, 4:15:03 PM1/10/22
to CasADi
Hi Sönke,
Sorry for a very late answer. I'm not sure if CasADi installed via pip will come with an SNOPT interface - looks like it doesn't. You might need to download the binaries for that, which think do include libcasadi_nlpsol_snopt.so . Joris knows what is included in what distribution better. 

Joel



Reply all
Reply to author
Forward
0 new messages