oemof / oemof-solph

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

Objective function for flows without variable_costs #337

Closed uvchik closed 5 years ago

uvchik commented 6 years ago

If a flow does not have the variable_costs defined it does not make sense to add it to the objective function. Nevertheless we loop through every time step.

for i, o in m.FLOWS:
        for t in m.TIMESTEPS:
            # add variable costs
            if m.flows[i, o].variable_costs[0] is not None:
                variable_costs += (m.flow[i, o, t] * m.timeincrement[t] *
                                   m.flows[i, o].variable_costs[t])

Wouldn't it be consistent to create a set with all flows with costs set as we do it with the constraint definition?

However, we should check for variable_costs before the time-loop.

@oemof/oemof-solph Do you agree, or did I forget something?

ckaldemeyer commented 6 years ago

Another option would be to loop only if variable costs are set:

for i, o in m.FLOWS if m.flows[i, o].variable_costs[0] is not None:
    for t in m.TIMESTEPS:
         # bla

We could also use hasattr() to check this.

uvchik commented 6 years ago

Another option would be to loop only if variable costs are set:

That's what I meant with "However, we should check for variable_costs before the time-loop.".

But it is still inconsistent because for all constraints we build sets and loop over the sets, so maybe we should keep this way for all loops.

ckaldemeyer commented 6 years ago

Another option would be to loop only if variable costs are set: That's what I meant with "However, we should check for variable_costs before the time-loop.".

But it is still inconsistent because for all constraints we build sets and loop over the sets, so maybe we should keep this way for all loops.

I agree but wouldn't spend time on this task speaking for myself.

simnh commented 6 years ago

I guess it's enough for now to not create a new set, I will move the if condition a few lines up.

uvchik commented 6 years ago

Of course it is enough but it is still confusing.

uvchik commented 6 years ago

Is there a reason why we sometimes create a set and sometimes not?

miraStud commented 6 years ago

Hello everyone I am new here and unfortunately it is not possible to contact you with a private message. My issue is a little of the topic, but has to do with the objective function. How can I contact you?

uvchik commented 6 years ago

Actually it is possible to contact us if you visit our website. But for questions like this we have a forum and I would therefore ask you to copy your question there as it really does not belong to this issue.

https://forum.openmod-initiative.org/tags/c/qa/oemof

We will try to help you there 😄

By the way cost are not necessarily monetary costs but can also be emissions or exergy factors. We just had to find a naming but it also could something like "weight".

uvchik commented 6 years ago

It is not urgent, but I would like to understand which way is better and why we use sets in some cases and if statements in other cases. Therefore I will postpone it.

jnnr commented 6 years ago

If you are ok, I will postpone again. Or rather close?

simnh commented 6 years ago

Relates to internal refactoring...nothing important for now, as functionality works fine. Postpone is the right way I think.

uvchik commented 5 years ago

I will try to check it on Friday otherwise I will postpone it to v0.3.1

p-snft commented 5 years ago

If this is not important enough to be tackled, I would suggest to add the "wontfix" tag and close the issue.

p-snft commented 5 years ago

As this seems not to be important enough to be tackled, I suggest to be so honest to add the wontfix tag and close this issue.