esa / pagmo_plugins_nonfree

A pagmo affiliated package (https://github.com/esa/pagmo2) adding commercial solvers to the list of solvers/algorithms: SNOPT7, WORHP
GNU General Public License v3.0
10 stars 9 forks source link

SNOPT lib in windows - USE #10

Closed shreya-dupa closed 5 years ago

shreya-dupa commented 5 years ago

I decided to start a new issue for this even though it's more of an SNOPT problem than an interface problems. I was able to compile both the Fortran library and the C-interface ( 2. (snopt/snopt-interface@76b166e)) for SNOPT 7.6.

While the build executes without errors, there are a lot of dependencies missing during runtime. I checked this using the Dependency Walker software. I don't know where these missing libraries are located. Are they Windows DLLs? or MSYS64/MinGW64 DLLs? The screenshot below from the dependency walker shows some but not all of the missing dependencies.

image

Appreciate the help!

darioizzo commented 5 years ago

Not sure this is the right place to seek for help ...

I did compile snopt7.5 on mingw64. In my case the only DLL needed where the mingw ones. And only a few (like 3-4).

A note on dependency walker ... many system libraries are often False negatives as the software is rather old ... my guess is that most of yours are.

https://stackoverflow.com/questions/36240215/dependency-walker-missing-dlls

shreya-dupa commented 5 years ago

@darioizzo That's good to know...

Do you have any sample code that I can use to test the SNOPT pass through?

darioizzo commented 5 years ago

You mean from pagmo plugins?

Sure, I am on the mobile now, will post tomorrow...

shreya-dupa commented 5 years ago

Yes, thanks!

darioizzo commented 5 years ago

Here is a test I normally use:

Python 3.7.2 (default, Jan 10 2019, 23:51:51) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pygmo as pg                                                                                                                                                                                         

In [2]: import pygmo_plugins_nonfree as pnf                                                                                                                                                                        

In [3]: uda = pnf.snopt7(library = r'/usr/local/lib/libsnopt72_c.so', screen_output=True, minor_version=2)                                                                                                         

In [4]: algo = pg.algorithm(uda)                                                                                                                                                                                   

In [5]: prob = pg.problem(pg.ackley(10))                                                                                                                                                                           

In [6]: pop = pg.population(prob, 1)                                                                                                                                                                               

In [7]: pop = algo.evolve(pop)                                                                                                                                                                                     
 ==============================
   SNOPT  C interface  2.0.0   
 ==============================
 S N O P T  7.2-4    (Jun 2006)
 ==============================

 SNMEMA EXIT 100 -- finished successfully
 SNMEMA INFO 104 -- memory requirements estimated

 Nonlinear constraints       0     Linear constraints       1
 Nonlinear variables        10     Linear variables         0
 Jacobian  variables         0     Objective variables     10
 Total constraints           1     Total variables         10

 The user has defined       0   out of      10   first  derivatives

 Major Minors     Step   nObj Feasible  Optimal      Objective    nS
     0     10               1           3.2E-01  2.1009715E+01     8   r
     1      1  3.8E-01      2           4.9E-01  2.0453627E+01     8 n rl
     2      1  1.9E-01      3           1.5E-01  1.9435252E+01     8 s
     3      1  1.0E+00      4           3.1E-01  1.9350316E+01     8
     4      2  1.0E+00      5           1.7E-01  1.9329938E+01     9
     5      2  1.0E+00      6           4.6E-02  1.9319270E+01    10
     6      2  1.0E+00      7           3.1E-02  1.9318807E+01     9
     7      2  1.0E+00      8           6.0E-03  1.9318126E+01    10
     8      1  1.0E+00      9           1.3E-03  1.9318121E+01    10
     9      1  1.0E+00     10           1.8E-04  1.9318117E+01    10

 Major Minors     Step   nObj Feasible  Optimal      Objective    nS
    10      1  4.8E-01     11           5.3E-05  1.9318117E+01    10
    11      1  1.0E+00     12           7.5E-06  1.9318117E+01    10       c
    11      2  1.0E+00     12           4.7E-05  1.9318117E+01    10       c
    12      1  4.8E-01     13           1.9E-05  1.9318117E+01    10       c
    13      1  1.0E+00     14           3.3E-06  1.9318117E+01    10       c
    14      1  1.0E+00     15          (9.1E-09) 1.9318117E+01    10       c

 SNOPTA EXIT   0 -- finished successfully
 SNOPTA INFO   1 -- optimality conditions satisfied

 Problem name                 Ackley F
 No. of iterations                  29   Objective value      1.9318117416E+01
 No. of major iterations            14   Linear objective     0.0000000000E+00
 Penalty parameter           0.000E+00   Nonlinear objective  1.9318117416E+01
 No. of calls to funobj            232   No. of calls to funcon            232
 Calls with modes 1,2 (known g)     15   Calls with modes 1,2 (known g)     15
 Calls for forward differencing    120   Calls for forward differencing    120
 Calls for central differencing     80   Calls for central differencing     80
 No. of superbasics                 10   No. of basic nonlinears             0
 No. of degenerate steps             0   Percentage                       0.00
 Max x                       9 2.8E+01   Max pi                      1 1.0E+00
 Max Primal infeas           0 0.0E+00   Max Dual infeas            10 2.3E-08

 Solution not printed

 Time for MPS input                             0.00 seconds
 Time for solving problem                       0.00 seconds
 Time for solution output                       0.00 seconds
 Time for constraint functions                  0.00 seconds
 Time for objective function                    0.00 seconds
shreya-udupa commented 5 years ago
==============================
   SNOPT  C interface  2.0.0   At line 94 of file src/sn03prnt.f (unit = 219)
Fortran runtime error: Unit number in I/O statement too large

@darioizzo I'm running into this error. Have you encountered it before?

darioizzo commented 5 years ago

No but you can see in your Fortran file why is there. Pagmo plugins is not using most of smooth I/o machinery .... so that if you just suppress the error it could work.

Alternatively you can post here the lines of that file and I can see what happens.

darioizzo commented 5 years ago

I can send you the patched file maybe...

shreya-udupa commented 5 years ago

It's in the snPRNT subroutine... I've put asterisks around the line where the code is erroring out.

Does this error indicate that the libraries have been linked correctly?

    subroutine snPRNT
     &   ( mode, string, iw, leniw )

      implicit
     &     none
      character*(*)
     &     string
      integer
     &     mode, leniw, iw(leniw)

*     ==================================================================
*     snPRNT  prints a trimmed form of "string" on various files.
*     If mode = 0,      nothing is output.
*     If mode = 1,      string is output to iPrint.
*     If mode = 2,      string is output to iSumm.
*     If mode = 3 or 4, string is output to iPrint and iSumm.
*     If mode = 4,      string is output to iStdo (standard output)
*                       if iPrint and iSumm are both zero.  This mode
*                       is intended for error messages.
*     If mode = 5,      string is output to iStdo (standard output)
*                       This mode is to be used when the elements of
*                       the integer work array iw cannot be trusted.
*
*     mode 11-15 are the same as mode 1-5 with blank line before output.
*
*     If mode > 15 then nothing is printed unless  lvlSys > 0.
*     mode 21-25 are the same as mode 1-5
*     mode 31-35 are the same as mode 11-15
*
*     25 Sep 2002: First version of snPRNT.
*     31 Jul 2003: mode 11-14 added.  form introduced.
*     27 Dec 2003: mode 5 added to allow printing before iw is set.
*     12 Mar 2004: s1trim called to trim the string.
*     22 Jun 2004: System printing option added.
*     22 Jun 2004: Current version of snPRNT.
*     ==================================================================
      external
     &     s1outpt
      integer
     &     iPrint, iSumm, iStdo, length, lvlSys, m, s1outpt
      character
     &     form*4, form1*4, form2*4
*     ------------------------------------------------------------------
      parameter   (form1 = '( a)')
      parameter   (form2 = '(/a)')
*     ------------------------------------------------------------------
      lvlSys    = iw( 71) ! > 0   => print system info

      m = 0
      if (mode .le.  0) then
!        Relax
      else if (mode   .lt. 10) then
         m    = mode
         form = form1
      else if (mode   .lt. 20) then ! Blank line first
         m    = mode - 10
         form = form2
      else if (lvlSys .gt.  0) then ! Print system Info
         if (mode .lt. 30) then
            m    = mode - 20
            form = form1
         else
            m    = mode - 30
            form = form2
         end if
      end if

      if (m .gt. 0) then

!        length = len_trim(string)     ! An F90 intrinsic
         call s1trim( string, length ) ! The F77 equivalent

         if (m .eq. 5) then
            iStdo  = s1outpt()
            if (iStdo .gt. 0) write(iStdo, form) string(1:length)
         else
            iStdo  = iw( 10) ! Standard output
            iPrint = iw( 12) ! Print file
            iSumm  = iw( 13) ! Summary file

            if (m .eq. 1  .or.  m .ge. 3) then
               if (iPrint .gt. 0) write(iPrint, form) string(1:length)
            end if

            if (m .eq. 2  .or.  m .ge. 3) then
               *** if (iSumm  .gt. 0) write(iSumm , form) string(1:length) ***         # This is where the error occurs
            end if

            if (m .eq. 4) then
               if (iPrint .le. 0  .and.  iSumm .le. 0) then
                  if (iStdo .gt. 0) write(iStdo, form) string(1:length)
               end if
            end if
         end if
      end if

      end ! subroutine snPRNT
shreya-dupa commented 5 years ago

@darioizzo Still struggling with this error. Were you going to send me a patched file? Not sure how to suppress the error...

darioizzo commented 5 years ago

I have the same identical file in my fortran files. Just checked. Not sure whats happening here ... but it must be some problem of the dll you assembled. Pagmo is only dlopening them and calling the snoptA interface.

darioizzo commented 5 years ago

Will close this. In case some new info arises reopen.