BYU-PRISM / GEKKO

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

Logging (output message) control #77

Closed guoquan closed 4 years ago

guoquan commented 4 years ago

Hi, is there a way to control the logging messages? What can I do if I want to log to a file or have less log (for example different logging levels)?

APMonitor commented 4 years ago

You can change the diagnostic level with m.options.DIAGLEVEL=2 where the number is between 0 and 6. If you don't want any output then set disp=False when you solve such as m.solve(disp=False). You could log to a file with something like

output = m.solve()

And then write output to a file. Here are a couple other suggestions for writing the output to a file: https://stackoverflow.com/questions/4675728/redirect-stdout-to-a-file-in-python