BYU-PRISM / GEKKO

GEKKO Python for Machine Learning and Dynamic Optimization
https://machinelearning.byu.edu
Other
594 stars 104 forks source link

Local mode #110

Closed MichaelMMeskhi closed 3 years ago

MichaelMMeskhi commented 3 years ago

Hello,

Using m=model(remote=False) runs the APOPT solver on my local CPU as I understand. I get an error that no path was found to results.json. How to fix this?

APMonitor commented 3 years ago

You may get this error if no solution is found. Please try this code:

from gekko import GEKKO
m = GEKKO(remote=False)            # create GEKKO model
x = m.Var()            # define new variable, default=0
y = m.Var()            # define new variable, default=0
m.Equations([3*x+2*y==1, x+2*y==0])  # equations
m.solve(disp=False)    # solve
print(x.value,y.value) # print solution

If there is still a problem with the above code then please let me know what is the Operating System (OS) and other machine specifications.

MichaelMMeskhi commented 3 years ago

I usually use remote = True by default, and been solving the same objective but recently need local. Why would local solver not find a solution? Is this possible? I’ll test that out now.

OS: MacOS (dev source) and Windows (target)

MichaelMMeskhi commented 3 years ago

You may get this error if no solution is found. Please try this code:

from gekko import GEKKO
m = GEKKO(remote=False)            # create GEKKO model
x = m.Var()            # define new variable, default=0
y = m.Var()            # define new variable, default=0
m.Equations([3*x+2*y==1, x+2*y==0])  # equations
m.solve(disp=False)    # solve
print(x.value,y.value) # print solution

If there is still a problem with the above code then please let me know what is the Operating System (OS) and other machine specifications.

The code works fine. The program I have is later compiled using pyinstaller into an exec. Would that be an issue?

APMonitor commented 3 years ago

Here is some help with pyinstaller and gekko: https://stackoverflow.com/questions/66181211/compiling-gekko-with-pyinstaller You need to let pyinstaller know about the local run directory m.path.