calliope-project / calliope

A multi-scale energy systems modelling framework
https://www.callio.pe
Apache License 2.0
277 stars 89 forks source link

Gurobi solver interfaces #349

Open brynpickering opened 3 years ago

brynpickering commented 3 years ago

We want to interface with Gurobi more directly, to leverage performance improvements in the solver backend.

One method is to use the Gurobi Python interface

Another method is the Pyomo Gurobi persisent solver (usage documentation)

The Python interface would probably lead to the greatest improvements, but needs more work to make our mathematical formulation more general (I.e. not written for Pyomo). However, the persistent solver could be a 'quick' fix for models that end up making small changing and then re-solving (cf. SPORES).

This issue can be used to track any updates in Gurobi solver interfaces.

brynpickering commented 3 years ago

I've tested the persistent solver with the national scale example model (3-month, spores run mode, 10 spores) with the following results:

Gurobi wall time: 3min 31s GurobiPersistent wall time: 2min 20s

The first two model runs (cost optimal and spore 0) build a fresh model in Gurobi. It takes approximately 2-3x longer for Pyomo to send the model to Gurobi on a fresh build (~15s instead of ~6s), so GurobiPersistent is probably only worthwhile when n_spores > 3.

brynpickering commented 3 years ago

Extending the model from 3 months to one year, we get:

Gurobi wall time: 35min 27s GurobiPersistent wall time: 24min 7s

So it looks like the savings scale quite well.

brynpickering commented 1 year ago

This is no longer blocked. As of #411 we can write a gurobi solver interface using the gurobi python API