How to get the total costs of the optimized model?

I have combined components (source, consumer, transformer) with different variable costs to an energy system and optimized through the solver (CBC and/or Gurobi).

Is it possible to get the total costs of the optimized energy system model (after this model was successfully solved to the minimal total costs)?

In the results matrix (python dictionary) I could calculate the total cost based on my energy system structure and the transferred energy (with the variable costs) between the components.
But this is very time-consuming if the energy system is constantly being changed or when a new energy system will be optimized.

So, is there already a function to determine the total cost of an optimized energy system?

Maybe a printed value from the solver in the debug window or log file?

Thanks a lot for your help.

Is it a very big model? I have a model with about 500 nodes and it is very fast to calculate the total costs. You can use list comprehensions as it is explained in the documentation. You can just loop over all flows and filter the flows with variable_costs. Then you can multiply the variable_costs with the value of the flow and sum it up.

The result of the objective function also reflects the sum of all variable_costs and investment cost in case of an investment model. But I prefer to use my calculations, because I normally have chp-plants in my model and I have to distinguish between heat and electricity cost. But in a pure electricity model the result of the objective will be fine.

thanks a lot for your answer and the link to the documentation.

The model is very small, only around 20 nodes but I just wanted to ask if there is already an existing function for the total costs calculation of specific flows.

First, the “objective”-result from the solver is okay for me, because i does not have any investment costs in this energy model.
But if i have free time, i will write a function to calculate the total costs from a specific flow.

Thanks for your ideas and your help.

Hi @c-franz

Two responses. First, there are at least two projects to build smart tooling for model‑servicing data storage:

Even if these data systems do not (currently) output the costs you wish directly — total monetary cost in your case — writing some code to loop through all the utilized assets — or some filtered subsets, say heat and power — should be straightforward. A few lines of julia in the case of PowerSystems.jl, assuming that your “world view” and the type hierarchy built into that tooling aligns sufficiently well.

Second, model frameworks need only consider decision‑relevant costs. So to equate the solved object function value to the total system cost might well fall short! Therefore a clear advantage of using one of the data systems indicated is that they can easily support a more encompassing view of costs than that embedded in the modeling frameworks they are coupled to. These data systems might, for instance, also report greenhouse gas metrics — both operational and embodied (or can be extended thus). Ditto for other classes of cost such as depletable resource consumption or wildlife impacts. And, if you are lucky, the tooling will also report and plot these aggregate results for you.

Indeed I think this separation of framework and data system could prove quite a useful approach for this community.

Not related to your question, but this kind of tooling is also designed to facilitate much the same models — or scenarios to take a higher view — being run on different frameworks. And if you push that idea out as far as it will go, you might well arrive at the SzenarienDB project:

Hope ths helps. R

Text and images licensed under CC BY 4.0Data licensed under CC0 1.0Code licensed under MITSite terms of serviceOpenmod mailing list.