[Python] Python GEKKO MPC IPOPT older version might cause the optimization not to converge

Discussão em 'Python' iniciado por Stack, Junho 6, 2025.

  1. Stack

    Stack Membro Participativo

    Context:

    Hello to everybody and to Prof. John Hedengren, I am using the Python Gekko library to use MPC with a heating system of a multi-zone building. The objective is to either minimize a combination of maximum power peak and energy consumed (objective 1) or to minimize just the energy while staying below a certain total power consumption (objective 2). The building and its mechanical systems are simulated with a software called TRNSYS and I can call Python within TRNSYS with a CFFI connection. The python script interacts with the building by operating MPC every 24 hours with a prediction horizon of 48 hours. Gekko will be called every simulated day during a simulation period of 2 months.

    Problem:

    Before the end, the simulation stops and there is no convergence (it reaches the 500 custom iterations limit) whenever there is an optimization problem with an IPOPT solving time (with linear solver mumps) that would be above 30 seconds. I know this because I have a separate python notebook which recreate the same optimization problems of different simulation days. I obtain the same exact results with the same exact inputs therefore it is indeed dealing with the same problem.. but in the python notebook that particular day, which doesn't converge in the simulation,converges in about 35 seconds (with 141 iterations). This day comes after about 20 successful optimization problems solved, most of them solved in 8-15 seconds and some with 25 or 28 seconds of IPOPT solving time (objective 2 is more demanding because of the more constraints).

    Here comes the more interesting part.. if I put Remote = True and use the mumps solver as well (with the linear ma57 it just stops and not converge very soon in the simulation) the simulation goes through the whole 2 months of simulation successfully. The solutions are almost identical to the ones i obtain in the separate python notebook with a difference in the objective value only at the 4th decimal. It also takes less iterations to arrive to solution (but very long IPOPT solving times I suppose because of the delay with the internet connection and the server). These small difference indicates a slight difference in the solver that is indeed in IPOPT version 3.12.10:

    This is Ipopt version 3.12.10, running with linear solver mumps.


    While the local solver says this:

    This is Ipopt version 3.10.2, running with linear solver mumps.


    I first checked if Gekko had updates and indeed there was the 1.3.0 version out. But even after updating from 1.2.1 the same problem persists and the IPOPT version is not updated.

    Question:

    What is going on in there (Python connection to the energy simulation software) is of course out of scope of the Gekko library since Gekko solves the problem in the separate python notebook. Even though it would be interesting to investigate what is happening there. But I was wondering.. is it possible to update IPOPT in my local machine (or the mumps solver)? Because the newer 3.12.10 version seems to be indeed better and it might solve my local non convergence issues. Local solve seems to be way faster so it would help me doing simulations faster other than also not solely rely on the online server to do my research.

    Thanks in advance for any answer to this post and thanks Prof. Hedengren for all the usuful answers here in Stack Overflow.

    I can provide more context or code if that could be useful.

    Continue reading...

Compartilhe esta Página