snopt / snopt-matlab

Matlab interface for sparse nonlinear optimizer SNOPT
MIT License
55 stars 23 forks source link

Matlab 2021b on Ubuntu 20.04 LTS Error #20

Closed csuf-dr-k closed 2 years ago

csuf-dr-k commented 2 years ago

I have been using snopt7.5-1.4 for several years. I was recently upgraded to Ubuntu 20.04 LTS and Matlab 2021b but I was unable to use its precompiled mex files or make the compiled mex files work for that version (they compiled fine but killed Matlab when run due to the segmentation violation) despite the fact that I used only the compilers supported by Matlab 2021b (gcc 9.x and gfortran 8.x) and followed: https://ccom.ucsd.edu/~optimizers/docs/snopt/install.html#compiling-for-matlab. I tried

So, I have downloaded the new snopt master and copied the files to /opt/snopt7 folder where my was and compiled the mex files again and ran runNPexamples.m.

This time, there was no hard-stop but I got the following error: Error using snoptmex Workspace size must be at least 500 Error in snsetwork (line 9) ... Not sure what is causing it. I am using the default workspace settings for Matlab.

gnowzil commented 2 years ago

I tried this out with SNOPT 7.5 and Matlab 2019b (I can't install 2021b at the moment, but will try as soon as I can), replacing the mex and matlab directories with the ones from this repo.

It seemed to work. I was able to runNPexamples.

My configure options were: ./configure --with-matlab=/usr/local --with-64 --with-pic

Can you verify that Matlab is using the new m-files that go with this repo and also that the above configure options were used?

csuf-dr-k commented 2 years ago

Thank you for getting back to me, Elizabeth.

The older folders compiled but matab would hard-crash when I called SNOPT. I merged instead of replacing the folders because Submakefile was missing from the mex folder. I have my SNOPT in /opt/snopt7 folder.

Then I ran this: sudo ./configure --with-matlab=/usr/local/MATLAB/R2021b --with-64 --with-pic followed by sudo make matlab which resulted in

Unfortunately, I get the error: Error using snoptmex Workspace size must be at least 500 Error in snsetwork (line 9) ...

This error message comes from your Fortran source, so I think I got the mex files compiled correctly. I think it might be an issue with 20.04 LTS. I can't downgrade at this time

Thank you, again for your help.

gnowzil commented 2 years ago

You can request a precompiled matlab file from our website: https://ccom.ucsd.edu/~optimizers/downloads/

The error is coming from the Fortran source, but it's the Matlab files that control the input. I moved the old files out of the way rather than replace, and then copied the old Submakefile. Let me try doing a replace. Maybe there's some overlap of the files that's causing this.

gnowzil commented 2 years ago

Ah. Actually I think you should move the old m-files away and then copy the new matlab directory in. The new directory has a different structure and some of the m-files are in a subdirectory now.

If you did a replace, then Matlab is likely picking up the old files which are still in the top directory.

csuf-dr-k commented 2 years ago

Following your recommendation, I replaced (rather than merged) the folders and the libraries compiled but make matlab resulted in the following error: GNUmakefile:193: mex/Submakefile: No such file or directory make: *** No rule to make target 'mex/Submakefile'. Stop.

So, I copied the Submakefile from the original mex directory and re-run: make matlab snoptmex.mexa64 and sqoptmex.mexa64 were created in the matlab folder and the examples worked. However, my code which ran fine on the older SNOPT/MATLAB does not work due to errors using vertcat (I use snsolve for all my code) but this is another issue.