Closed APMonitor closed 3 years ago
It's probably difficult, otherwise it would be done already, but this would be an excellent addition.
I think that wheels seem to be the path forward for platform specific binary distributions on pypi:
Hello,
I also have issues to run IPOPT solver using the option remote=True. I have installed IPOPT but Gekko seems does not find it.
As you can see below:
$ ipopt -v Ipopt 3.12 (Linux x86_64), ASL(20180528)
Example of a problem:
from gekko import GEKKO
m = GEKKO(remote=False)
m.options.SOLVER=3
eq = m.Param(value=40)
x1,x2,x3,x4 = [m.Var(lb=1, ub=5) for i in range(4)]
x1.value = 1 x2.value = 5 x3.value = 5 x4.value = 1
m.Equation(x1x2x3*x4>=25) m.Equation(x12+x22+x32+x42==eq)
m.Obj(x1x4(x1+x2+x3)+x3)
m.options.IMODE = 3 #steady state optimization
m.solve()
print('') print('Results') print('x1: ' + str(x1.value)) print('x2: ' + str(x2.value)) print('x3: ' + str(x3.value)) print('x4: ' + str(x4.value))
And the output is the following:
--------- APM Model Size ------------ Each time step contains Objects : 0 Constants : 0 Variables : 6 Intermediates: 0 Connections : 0 Equations : 3 Residuals : 3
Degrees of freedom : 2
Iter Objective Convergence 0 1.67676E+01 1.87500E-01 1 2.04736E+01 4.88281E-02 2 1.75530E+01 2.17630E-02 3 1.70459E+01 9.65302E-03 4 1.70140E+01 2.04419E-04 5 1.70140E+01 4.22153E-08 6 1.70140E+01 6.48259E-13 7 1.70140E+01 6.48259E-13 Successful solution
Results x1: [1.0] x2: [4.742999637] x3: [3.8211499845] x4: [1.3794082931]
It ended up solver with Solver 1 (ADOPT) instead of Solver 3 (IPOPT), as is not supported.
@phisolani There are currently two options for using IPOPT in Gekko. The first is to use remote=True
where the latest version of IPOPT is available. A second option is to use remote=False
with a Windows computer. The version of IPOPT on a local Windows computer includes the MUMPS linear solver that is freely distributed but often slower than other linear solvers. The Linux, MacOS, and ARM versions of the local executable do not currently have IPOPT. The reason is that IPOPT on POSIX (MacOS, Linux) requires many additional libraries that make the local executable very large (~50 MB). We are currently distributing without IPOPT on those operating systems to limit the size of the package (~10 MB total without IPOPT versus ~160 MB total with IPOPT). If we can figure out a way to reduce the package size then I'll include IPOPT for local MacOS and Linux distributions.
Thanks for the quick response.
Is there a way to get the version with IPOPT local for MacOs or Linux, besides its package size? I'm interested because I would like to compare the execution time of both IPOPT and ADOPT against another algorithm. However, if I have to run IPOPT on the remote server, the solution time would not be consistent with the one running locally.
Note that, at the beginning of the previous comment of mine, I showed that I have IPOPT installed (downloaded and installed from https://www.coin-or.org/download/source/Ipopt/). However, it seems that Gekko is not able to use it.
IPOPT and APMonitor are compiled together to have strong coupling between the modeling language and solvers. Using a local version of IPOPT that is compiled separately won't help. One way that you could get timing results is to solve with APOPT locally and on the server and then use a scaling factor to (e.g. server is 1.3x slower) to approximate what IPOPT would be on your local computer. You can get the CPU solve time in Gekko with m.options.SOLVETIME: https://gekko.readthedocs.io/en/latest/global.html#solvetime Using the solve time instead of the total time removes any dependence on network overhead and should be very reproducible.
Is there a way that I could compile the apm linux binary myself, so that IPOPT is available locally?
@mdclemen It isn't a matter of compiling with IPOPT but of distributing the solver. The way the Linux compilers work on Linux, it requires about 50 MB of libraries, even when I signal to the compiler to include static libraries. The public servers run Linux and they have IPOPT. I'll try to work on something more compact. The APM executable isn't open source.
50 MB is larger than might be desired, but actually isn't far out of line with other common scientific Python packages.
31M /usr/local/lib/python3.6/site-packages/matplotlib 35M /usr/local/lib/python3.6/site-packages/numpy 96M /usr/local/lib/python3.6/site-packages/pandas 134M /usr/local/lib/python3.6/site-packages/scipy
It seems like space is more likely to be an issue on ARM systems. Platform specific wheels would help, so that each system would only download its own executables through pip. Another option might be to advise users to delete the uneeded binaries if space is a problem.
On Sat, Sep 21, 2019, 1:13 PM APMonitor notifications@github.com wrote:
@mdclemen https://github.com/mdclemen It isn't a matter of compiling with IPOPT but of distributing the solver. The way the Linux compilers work on Linux, it requires about 50 MB of libraries, even when I signal to the compiler to include static libraries. The public servers run Linux and they have IPOPT. I'll try to work on something more compact. The APM executable isn't open source.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/BYU-PRISM/GEKKO/issues/50?email_source=notifications&email_token=AEUJHIM22CSCLCS33SIQRPDQKZ56BA5CNFSM4GOOAPB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7IY4GA#issuecomment-533827096, or mute the thread https://github.com/notifications/unsubscribe-auth/AEUJHIJUQ4BXXKGZ274CUSLQKZ56BANCNFSM4GOOAPBQ .
It is 50 MB for each distribution (MacOS, ARM, Linux, and maybe others) so it would turn into a very large distribution. Distribution specific wheel files should also work but I think I just need to figure out how to make it just a 2-3 MB add-on like it is with the Windows executable. IPOPT is accessible as a local server or through the public servers (with better linear solvers as well). If it is a local server, the linear solver (MUMPS) that can be distributed with IPOPT won't be that good either.
As a stopgap, would it be possible to provide an option to install the 50mb version inclusive of IPOPT when installing gekko?
Following the instructions here, that might mean cloning a different repo and installing a different set of dependencies.
https://gekko.wizb.it/docs/installation/installing_gekko.html
The link that you posted is for gekko
the bitcoin trading bot. IPOPT is available from with a remote server option and as a local option with Windows. One of the options with distributing IPOPT is that I can only include one of the free linear solvers (MUMPS) that is not as good as the Harwell Subroutine Libraries (HSL). Even if I distribute Linux and MacOS versions, the IPOPT executable wouldn't perform as well.
I am a Linux user who previously used JModelica. I transferred part of my code to GEKKO and like the framework very much. I need access to local optimization and have installed IPOPT with hsl on my system. Is there a way to link GEKKO to my local installation? Windows is not an option, especially since I need the hsl solver.
The solvers and model framework are tightly coupled into one executable. You can use HSL through remote=True
with m.options.SOLVER=3
. For local solve on Linux, there is only APOPT
and BPOPT
solvers currently. I can't distribute HSL
without a commercial license.
I would suggest adding this information in the error message or in the documentation, maybe in the description of the SOLVE
option. It was quite frustrating to get only a general error solver 3 not supported
. Reaching this issue page was not straight forward.
Thanks for the suggestion, Pietro. I've added additional discussion here: https://apmonitor.com/wiki/index.php/Main/OptionApmSolver and in the Gekko documentation.
Currently, I have a raspberry pi board used for MPC using IPOPT. If I check the solvertime option of Gekko, it gives me a time value. I could conclude that this time depends on my internet connection and the server features where IPOPT is running. Could you tell me what are those server's features?
It is a server with the following specifications: Dell R815 Server AMD Opteron Processor 6276, 64 CPUs 64 GB RAM RAID array 15k RPM hard drives
You can also run locally on the Raspberry Pi with m = GEKKO(remote=False)
but this will likely be 10x slower and switch over to the APOPT solver.
I tried running IPOPT remotely.
m = GEKKO(remote=True) # Initialize gekko
# IPOPT Solver
m.options.SOLVER = 3
m.options.MAX_ITER = 70000
m.options.IMODE = 3
But still can't run the IPOPT solver:
apm 205.201.17.225_gk_model0 <br><pre> ----------------------------------------------------------------
APMonitor, Version 1.0.0
APMonitor Optimization Suite
----------------------------------------------------------------
--------- APM Model Size ------------
Each time step contains
Objects : 0
Constants : 0
Variables : 48
Intermediates: 0
Connections : 0
Equations : 29
Residuals : 29
Number of state variables: 48
Number of total equations: - 29
Number of slack variables: - 20
---------------------------------------
Degrees of freedom : -1
* Warning: DOF <= 0
----------------------------------------------
Steady State Optimization with APOPT Solver
----------------------------------------------
Iter: 1 I: -1 Tm: 0.48 NLPi: 706 Dpth: 0 Lvs: 0 Obj: 0.00E+00 Gap: NaN
Warning: no more possible trial points and no integer solution
Maximum iterations
---------------------------------------------------
Solver : APOPT (v1.0)
Solution time : 0.487400000012713 sec
Objective : 0.000000000000000E+000
Unsuccessful with error code 0
---------------------------------------------------
If you are using m.if3()
, m.sign3
, m.abs3()
or other models that require a mixed integer solver, then Gekko automatically changes the solver to APOPT
. To override this, switch the solver to m.options.SOLVER=3
right before the m.solve()
command. If you use IPOPT
for a mixed-integer problem, there is no guarantee that it will return an integer solution.
If you are using
m.if3()
,m.sign3
,m.abs3()
or other models that require a mixed integer solver, then Gekko automatically changes the solver toAPOPT
. To override this, switch the solver tom.options.SOLVER=3
right before them.solve()
command. If you useIPOPT
for a mixed-integer problem, there is no guarantee that it will return an integer solution.
At this time, if GEKKO(remote=True) is performed, the code is executed and does not progress further (bug)
The server is back up again. It needed maintenance and is running again. You can always switch to remote=False
if the public server is not available or set up a local server in Windows or Linux. https://apmonitor.com/wiki/index.php/Main/APMonitorServer
It was active in the afternoon, it has gone down again. Diego Armando Pérez Rosero Ingeniero Electrónico Estudiante de Maestría en Ingeniería- Automatización Industrial Universidad Nacional de Colombia- Sede Manizales Grupo de Control y Procesamiento Digital de Señales
El mar, 28 nov 2023 a las 11:01, APMonitor @.***>) escribió:
The server is back up again. It needed maintenance and is running again. You can always switch to remote=False if the public server is not available or set up a local server in Windows or Linux. https://apmonitor.com/wiki/index.php/Main/APMonitorServer
— Reply to this email directly, view it on GitHub https://github.com/BYU-PRISM/GEKKO/issues/50#issuecomment-1830154719, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMEPNWMYB7MK64ZLSXWBNHDYGYDGPAVCNFSM4GOOAPB2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBTGAYTKNBXGE4Q . You are receiving this because you commented.Message ID: @.***>
-- Aviso legal: El contenido de este mensaje y los archivos adjuntos son confidenciales y de uso exclusivo de la Universidad Nacional de Colombia. Se encuentran dirigidos sólo para el uso del destinatario al cual van enviados. La reproducción, lectura y/o copia se encuentran prohibidas a cualquier persona diferente a este y puede ser ilegal. Si usted lo ha recibido por error, infórmenos y elimínelo de su correo. Los Datos Personales serán tratados conforme a la Ley 1581 de 2012 y a nuestra Política de Datos Personales que podrá consultar en la página web www.unal.edu.co http://www.unal.edu.co/. Las opiniones, informaciones, conclusiones y cualquier otro tipo de dato contenido en este correo electrónico, no relacionados con la actividad de la Universidad Nacional de Colombia, se entenderá como personales y de ninguna manera son avaladas por la Universidad.
Thanks for letting us know. It looks like the server is getting high traffic right now. I'd recommend switching to remote=False
.
Right now, I am finishing the final exercises for my master's thesis. The thesis aims to use a neural network to mimic the functioning of Gekko in optimizing optimal gas flows for electricity generation in Colombia. All the results were obtained under strict conditions, including setting 'remote=True' for a balanced comparison. Do you know if the service will return to normal in the next few hours? Diego Armando Pérez Rosero Ingeniero Electrónico Estudiante de Maestría en Ingeniería- Automatización Industrial Universidad Nacional de Colombia- Sede Manizales Grupo de Control y Procesamiento Digital de Señales
El mar, 28 nov 2023 a las 21:00, APMonitor @.***>) escribió:
Thanks for letting us know. It looks like the server is getting high traffic right now. I'd recommend switching to remote=False.
— Reply to this email directly, view it on GitHub https://github.com/BYU-PRISM/GEKKO/issues/50#issuecomment-1831072230, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMEPNWKSECY6KRMRDHNQWDTYG2JNLAVCNFSM4GOOAPB2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBTGEYDOMRSGMYA . You are receiving this because you commented.Message ID: @.***>
-- Aviso legal: El contenido de este mensaje y los archivos adjuntos son confidenciales y de uso exclusivo de la Universidad Nacional de Colombia. Se encuentran dirigidos sólo para el uso del destinatario al cual van enviados. La reproducción, lectura y/o copia se encuentran prohibidas a cualquier persona diferente a este y puede ser ilegal. Si usted lo ha recibido por error, infórmenos y elimínelo de su correo. Los Datos Personales serán tratados conforme a la Ley 1581 de 2012 y a nuestra Política de Datos Personales que podrá consultar en la página web www.unal.edu.co http://www.unal.edu.co/. Las opiniones, informaciones, conclusiones y cualquier otro tipo de dato contenido en este correo electrónico, no relacionados con la actividad de la Universidad Nacional de Colombia, se entenderá como personales y de ninguna manera son avaladas por la Universidad.
Add IPOPT to Linux and ARM versions of local executables. IPOPT still works with the default option (remote=True). However, the IPOPT solver is not available when remote=False for a local solve.