oemof / oemof-solph

A model generator for energy system modelling and optimisation (LP/MILP).
https://oemof.org
MIT License
297 stars 125 forks source link

Test vcxpy as an alternative to pyomo #586

Open p-snft opened 5 years ago

p-snft commented 5 years ago

According to its self-description, "CVXPY is a Python-embedded modeling language for convex optimization problems." It is reported to be faster and maintained at a higher quality than pyomo. There are several reasons that would explain this, at it is newer (2015 vs. 2008) and breaks with the modularity of using an underlying lp-solver.

At the 2019 spring meeting, @gnn and me agreed to look into this packages based on a rather trivial example.

uvchik commented 5 years ago

You may contact the developer, to get some additional informations about models with a time dimension.

To assess whether you can build constraints fast it is import to get to know how they loop along time series.

p-snft commented 5 years ago

I will, as soon there are questions. The library is very well documented. (In fact, time is a dimension as any other. There should be no difference.)

For rolling horizon one should note that problems are immutable. So, it is impossible to just update objectives or constraints. However, there are mutable parameters, that seem to perfectly fit the purpose. Also, CVXPY works with numpy arrays.

You can use your numeric library of choice to construct matrix and vector constants. For instance, if x is a CVXPY Variable in the expression A*x + b, A and b could be Numpy ndarrays, SciPy sparse matrices, etc. A and b could even be different types. Currently the following types may be used as constants:

  • NumPy ndarrays
  • NumPy matrices
  • SciPy sparse matrices

This means, creating (new) problems should be rather fast.

simnh commented 5 years ago

Sounds interesting, though transforming solph to this one will be a major one. However, maybe it some parts would be enough, because for MILP Problems, building time of the model is not really a problem. For large pure LP files it definitely makes sense!

p-snft commented 5 years ago

We currently have a many applications that create the same model over and over again, e.g. rolling horizon simulations. These would profit a lot from the ability to change parameters. Of course, a replacement is a lot of work, so the idea was to start with making this a drop-in replacement for solph which, however, is not guaranteed to support the same set of features. We would start with something very easy and expand it slowly if it works out. From our side, dispatch optimization is way more important than invest. So, we will not push the support for the latter.

PS: I suggest to codename this solver for convex optimisation problems (scoop). There will be a branch after the v0.3 release. So there should be a codename at this point in time.

uvchik commented 5 years ago

scoop for convex problems is pretty smart :smile: even though a not existing word makes it easy to be found in search engines. If you search for oemof you do not get anything else than our stuff. Furthermore, it is not a solver but something like a model generator. model generator for convex optimisation problems (mgcoop) is more difficult to say :sweat_smile: even though it is unique :smirk:

I think we do not have to set a final goal. It could be parallel to solph, it could end after a while or it could replace solph in the future. Whatever will happen I think it is worth to give it a try.

It would be nice to keep the approach open for investment models so that other users can add such components.