As part of debugging some problems using Optimica, I have stripped away constraints, etc. in my model and ONLY consider simulation of the model.
1. When I use:
from pymodelica import compile_fmu
from pyfmi import FMUModel
etc. and run the code, the correct solution is found in 0.4 seconds.
2. When I use:
from pymodelica import compile_jmu
from pyjmi import JMUModel
etc., attempting to solve the very same model starts an iteration procedure in IPOPT, and the computations stops after 3000 iterations -- with the solution not found and some error messages related to assimulo...
---
I don't understand this -- my previous experience is that simulation using JMU compares favorable with simulation using FMU. I have simulated the very same problem, slightly differently posed, a number of times using JMU, without problems. The only new thing I have introduced is defining a core model class, and reusing this core model by instantiating it three times...
As a simulation problem, this should be extremely simple!!
---
OK -- this description is vague. But does anyone have clues?
JMU vs. FMU?
When simulating a JMU, IPOPT is used to solve the initialization problem. So if IPOPT fails, it's the initialization that failed, and not the actual simulation.
FMI is supposed to be more robust than JMI for simulation, and especially initialization. So I am not at all surprised that FMI succeeds and JMI fails.
As to why IPOPT suddenly fails when solving the initialization problem, I cannot say. IPOPT is not particularly robust, so minor reformulations can lead to divergence. However, if you have exactly the same problem, i.e., the same variables and equations, you should of course get the same solution.
Yes, I developed this theory myself after work hours, and will look into it when in office. I have an idea of where it fails.
I solved the problem. It had to do with that I had given poor initial guesses on a variable. The *simulation* now runs (but not the optimization... see Optimica section...).