Modifying a model with linopy

168 views
Skip to first unread message

Agnès François

unread,
Aug 18, 2023, 6:32:38 AM8/18/23
to pypsa
Good afternoon everyone,

I was wondering if it was possible to modify the model of an already optimised network, and then optimise it again ?
I was doing that and not introducing a new network each time in order to skip the 'network.optimize.create_model' and creation of all my main constraints part, which takes about 10mn. I was then just updating one constraint, and running network.optimize.solve_model() again. However, it seems that results does not change and calling network.X only gave the results of the first optimisation made. Do you know if I have to create a new network every time or if there is something else I can do ?

Thanks in advance,
Agnès

Fabian Neumann

unread,
Aug 19, 2023, 6:24:01 AM8/19/23
to pypsa
Hi Agnès,

The following should work:

n.optimize.create_model(...)
n.optimize.solve_model(...)

# modify n.model

n.optimize.solve_model(...)


If you have different Python scripts, it may be a little more difficult, but you can import/export linopy models as netcdf file.


Best wishes,

Fabian N

christo...@tu-berlin.de

unread,
Aug 21, 2023, 3:44:56 AM8/21/23
to py...@googlegroups.com
Thank you for your mail. I am on vacation until Monday 21st August. I will
respond to you after I return.

Best regards,
Christoph Tries

_________________________
Christoph Tries
er/sein - he/him
Anrede/Form of address: Herr - Mr.

christo...@gmail.com <mailto:christo...@gmail.com>
+49 157 7664 5888


Agnès François

unread,
Aug 21, 2023, 8:29:52 AM8/21/23
to pypsa
Hello Fabian,

Thank you for your answer, I had this in my code already actually. After my script has run, I think the only way to compare the different networks would be as you said to export them during the run (results of a network being overwritten at every step).

Best regards,
Agnès
Reply all
Reply to author
Forward
0 new messages