BYU-PRISM / GEKKO

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

Disable output after solving an optimization problem #83

Closed gy2256 closed 4 years ago

gy2256 commented 4 years ago

I am trying to iteratively solve a sequence of Quadratic Programs for my research. However, I notice the running speed is quite slow (1~1.5s between each QP and I am using MacBook Pro 16 with 6 cores i7 processor). I suspect the slowing down is coming from all the outputs showing in terminal after each solving. Is there a way for me to disable it? All I need is to have the QP solving in the background.

Screen Shot 2020-05-01 at 2 47 43 PM
dhill2522 commented 4 years ago

You should be able to disable the output by including disp=False when solving the problem.

For example m.solve(disp=False). There are a number of examples on this page in the docs that demonstrate this as well.

Does that fix your issue?

APMonitor commented 4 years ago

@dhill2522 is correct. Another thing to try is switch to local solve so that it doesn't send the problem to a remote server. Use m=GEKKO(remote=False). Also, you can try turning debug off to not stop the program if one of the solutions fails with m.solve(disp=False,debug=0). If you don't fail on a bad solution then you'll need to check that it was successful programmatically with m.options.APPSTATUS==1 with a successful solution.

gy2256 commented 4 years ago

Thanks for the help. My program runs much faster in offline mode now.