OpenModelica / OMPython

A Python interface to OpenModelica communicating via CORBA or ZeroMQ
Other
107 stars 58 forks source link

Fetch information from IPOPT solver #192

Open LukasKoenemann opened 11 months ago

LukasKoenemann commented 11 months ago

I'm currently using ModelicaSystem via OMPython to optimize my modelica model using "Built-in Dynamic Optimization using Annotations". After calling the simulate function I get the simulation results correctly (via mat.file). In addition to that, is it possible to fetch the information of the IPOPT solver (e.g. "No optimal solution found")? Afterwards I want to use the information in the postprocessing of the simulation. If I set the verbosity of the IPOPT-LOG on (-lv=LOG_IPOPT), I can see the output of the IPOPT solver in the prompt. But I want to fetch the information via OMPython.

Steps to Reproduce:

from OMPython import ModelicaSystem
model = ModelicaSystem(...)
model.setSimulationOptions('solver=optimization')
results = {}
for i in range(10):
    resultfile=f"{i}.mat"
    model.setParameters(f'p={i}')
    model.simulate(resultfile=resultfile, simflags='-optimizerNP=1')