BYU-PRISM / GEKKO

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

Server unreachable : Both “m= gekko(remote=False)” and “m= gekko(remote=True)” are not working #117

Closed ZinebF closed 3 years ago

ZinebF commented 3 years ago

I am solving a MINLP problem using Gekko. Since a few days, when I use "m= gekko(remote = True)", I get the following error: "urllib.error.HTTPError: HTTP Error 404: Not Found" then "ImportError: No solution or server unreachable." When I run it locally using "m= gekko(remote = False)", I get "Exception: Access Violation At line 359 of file ./f90/cqp.f90 Traceback: not available, compile with -ftrace=frame or -ftrace=full Error: 'results.json' not found."

According to @dhill2522, it seems that this is an error occurring in APMonitor, which is the underlying executable used by GEKKO for solving the optimization problems. APMonitor or the underlying solver must be crashing and so it is not returning the results.json containing the solution.

dhill2522 commented 3 years ago

Thanks for posting this @ZinebF. I get the same issue with a number of my problems. Fixing remote=True should be pretty simple, but the Access violation error may take a little longer.

For reference here are the two stackoverflow questions relevant to this bug report: Gekko - Both “m= gekko(remote=False)” and “m= gekko(remote=True)” are not working GEKKO - timeout error - ImportError: No solution or server unreachable

While it cannot handle mixed-integer problems, you could try using IPOPT on a local Windows machine while waiting for the APOPT issue to be resolved.

APMonitor commented 3 years ago

A new remote server is available until the main server can be restored. The option remote=True should work.

The error with APOPT is different than the server issue. Does this error also occur with the remote server (remote=True) or the only for the local solve (remote=False)? What is your operating system (Windows, MacOS, Linux)? The remote server is running Linux. Here is a simple test to see if the remote server is working:

from gekko import GEKKO
m = GEKKO()            # 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

When the APOPT solver crashes, it is because of some unhandled exception. I typically see that error for ill-conditioned problems that are very difficult to solve or may have no solution.

ZinebF commented 3 years ago

@APMonitor Thanks for your answer, and I am sorry for answering late.

My operating system is Windows, and I don't get the same error when working with (remote = True) or (remote = False). When I run my code locally, it says that the 'results.json' file is not found so I was never able to run locally. I always worked with (remote = True) and until a week ago, the optimization was able to find a solution.

Now, since there is a new server, I can run the optimization again and it is able to find a solution. So, the simple test code is also running. The only problem I am facing is that it's taking a lot more time than before and after a few hours, the simulation just stops even though it is not finished, and I don't understand why. I didn't face this problem before, it was able to run until the end.

Concerning the following error: ImportError: No solution or server unreachable, I still get it for one case that I am running even though it's the same code as for the others, just a different configuration and it shouldn't be a more difficult problem to solve.

APMonitor commented 3 years ago

Could you post you code with your question to Stack Overflow with tag gekko? You just need a minimal, complete, and verifiable example that shows the issue. The community of users may be able to give a more specific suggestion to help. If you are running simulation, IMODE=7 with disp=False often helps to speed up the code. The original server is restored so it shouldn't be an issue with the server. You are likely getting the error with the local solve because the local solver options aren't as good as the more powerful online server options for IPOPT. The local version of IPOPT uses the MUMPS linear solver that isn't as good as the online server options for linear solvers. The results.json not found is because the solver failed to find a solution locally.

ZinebF commented 3 years ago

Thanks for your answer ! I will post the question on Stack Overflow