Skip to content

FAQ: how to get third party solvers to work?

jgillis edited this page Sep 8, 2020 · 12 revisions

Starting from CasADi 3.5.5, the release notes contain necessary information in tabular form.

For example:

software version library license env build env
ipopt 3.12.3 shipped / /
snopt 7.7 libsnopt7.so/snopt7.dll SNOPT_LICENSE SNOPT
worhp 1.13 libworhp.so/worhp.dll WORHP_LICENSE_FILE WORHP
knitro 10.3 libknitro1030.so/knitro1032.dll / KNITRO
cplex windows/mac: 12.8.0, linux:12.6.3 libcplex1263.so / libcplex1280.dll ILOG_LICENSE_FILE CPLEX
gurobi 6.5.0 libgurobi65.so/gurobi65.dll GRB_LICENSE_FILE GUROBI_HOME
  • When you do nlpsol('solver','<software>',...), CasADi attempts to load in a shared library named libcasadi_nlpsol_<software>.so (linux)/ libcasadi_nlpsol_<software>.dll (windows)/ libcasadi_nlpsol_<software>.dylib (mac) (or 'conic' instead of 'nlpsol' when it's a QP/structured convex solver). Your copy of CasADi likely has this file lying around. It is just an interface file though, which in turn depends on the actual third-party library. The loading fails when that library is not found.

  • CasADi should be run from an environment where the corresponding table entry library is found.

    In practice, amend/set environmental variable LD_LIBRARY_PATH (linux), PATH (windows) or DYLD_LIBRARY_PATH (mac) with the folder on your computer that contains the .so/.dll/.dylib. It is not enough to update this environmental variable in an already-running Python/Matlab session. You need to start a fresh session from an environment that already correct. Do inspect with getenv (Matlab)/os.environ (Python) that the variable was correctly set. If you have a slightly differently versioned library at your disposal, you might get lucky renaming it to the expected library The table is manually updated and might have mistakes in it. You can verify exactly which library your copy of CasADi requires by inspecting the interface library e.g. libcasadi_nlpsol_worhp.so with ldd (linux), or libcasadi_nlpsol_worhp.dll with depends.exe, or libcasadi_nlpsol_worhp.dylib with otool -L. The third-party library itself may have further dependencies that need to be in the search path. To be sure, check with the above-mentioned inspection tools.

  • For some software, a license file should be declared by means of an environmental variable named license var.

  • For source builds, you need to run cmake from an environment that declares the corresponding build env If things fail, do have a look into e.g. <casadi_source>/cmake/Find<software>.cmake to see which libraries and headers need to be found in which location (HINT).