Frequently Asked Questions¶
I have the SNOPT source code. How do I get it going?
>> ./configure >> make install >> make examples
will compile the package library and the included examples. See Compiling SNOPT for more information.
I have the SNOPT libraries/mexfiles. How do I use them?
See Linking to the SNOPT Library for more information.
Everything seems to compile correctly, but when I run an example or my own problem, I get the error: Fortran runtime error: Unit number in I/O statement too large. What’s wrong?
This usually happens when there is a compatibility issue with the integers (32-bit vs 64-bit). If you are using the C/C++ interface, do not use 64-bit integers as that is not currently supported.
General SNOPT Question¶
What is the largest number of variables and constraints that SNOPT can handle?
The most important item is the “number of degrees of freedom” at the solution. An optimal basic solution for a linear program has 0 degrees of freedom. This is ideal: the solution is at a vertex of the constraint set. (We can take the constraints to be \(Ax = b, l \le x \le u\) without loss of generality, where \(A\) has \(m\) rows and \(n\) columns, \(m \lt n\).) There will be \(m\) basic variables with values between their bounds, and \(n-m\) nonbasic variables that are equal to one of their bounds.
A nonlinear program will have some of the nonbasic variables strictly between their bounds. We call them superbasic variables, and they measure the number of degrees of freedom (or the distance from a vertex).
SNOPT is “happy” if the number of superbasic variables is not more than a few hundred, because it prefers to work with a dense triangular matrix of that size. Even 2000 is fine – they just slow down accordingly. Subject to that, \(m\) and \(n\) can both be quite large – say 50,000 (but not millions!).
SNOPT makes no progress and fails with the error message: ``EXIT 41 – the current point cannot be improved``. I can solve this problem successfully with another code. Is there a bug in SNOPT?
This is most likely an error in the way that the constraints are defined. First, check the derivatives using the option “Verify level 3”. If the derivatives appear to be correct, take the solution found by the other program and make it the initial point for an SNOPT run. If the problem is defined correctly, SNOPT should terminate successfully at the initial point. (A number of minor iterations may be needed to identify the correct basis, but the number of major iterations should never be more than 1 or 2, depending on the accuracy of your solution). If SNOPT does a significant number of major iterations, the problems solved by the two codes are probably not the same.
I tried to compile the Matlab mex-files on my Linux machine, but I get the error:
/usr/bin/ld: ./lib/libsnmex7.a(snopta.o): relocation R_X86_64_32 against ``.rodata' can not be used when making a shared object; recompile with -fPIC
How do I fix this?
Reconfigure the software package with
--with-picand then recompile. Also make sure to do a
make verycleanbefore you compile again.
I tried to use a precompiled Matlab mexfile on my Windows machine, but I get an error:
Invalid MEX-file 'snoptmex.mexw32': The specified module could not be found.
How do I fix this?
This will happen if you don’t have all of the required runtime libraries. In particular, you should download and install the following redistributable libraries from Microsoft and Intel:
When I try to use the precompiled Matlab mex-file,I get errors like:
Invalid MEX-file ... : Missing dependent shared libraries: 'libgfortran.so.4'
This happens if you do not have the gfortran compiler installed. Installing it will fix this issue.
I’m using Visual Studio to compile SNOPT and its C+ interface but I get the following error: ``fatal error LNK1104: cannot open file ‘ifmodintr.lib’``. How do I fix this?
Mixing Fortran with C/C++ requires some additional configuration in Visual Studio. Please see the following Intel article for more information Configuring Visual Studio for Mixed-Language Applications.
When I try to use SNOPT, I get an error saying I need a license. What do I do?
Trial versions of SNOPT require a license file, which is attached to the email sent to you containing the download link. See License Setup for more information on how to set up your license.
I want to use pyOptSparse, but it requires the source code for SNOPT. Can I use the SNOPT precompiled libraries with pyOptSparse?
Yes, but you need to make a modification to
pyOptSparse. The modification to the file pyoptsparse/pyoptsparse/pySNOPT/setup.py is available here. You will need to appropriately define the location of the SNOPT library and re-build/install pyOptSparse. Make sure you have also set
DYLD_LIBRARY_PATH(on macOS) or
LD_LIBRARY_PATH(on Linux) to the location of the SNOPT library and also make sure to set up the SNOPT license.