PyPSA/linopy

How are "0" coefficient passed to gurobi?

Closed this issue · 3 comments

Hi to everyone!
I have a model that has some calculations that yield some variables to be multiplied by 0, like this:
0*y(1,2)+22*y(1,3)+....>=1000
The values are chosen at random for this example.
I want to make sure that sending that to gurobi does not create problems, my ideal behavior would be that the expression is treated as this:
22*y(1,3)+....>=1000
Ergo, to just omit the ones that have 0s.
Does it work similar to this? Does anyone know if it's not a problem?
Thanks in advance!

Hey @KanaBaradei, zeros are dropped in the export to the solvers :) hope that solves your issue. Reopen if there is anything left.

Thank you very much for your help!
Just another quick question:
I have an obj function that is very large so I divided it in pieces depending on what type of cost it is, for example variable cost, fix cost, etc
Some expression have repeated variables with different coeff:
fix=3y(1,1)+y(1,2)+....
var=.....+6
y(1,1)+.....
obj=fix+var
does that cause problems? should I try to define everything in one coefficient like this?:
obj=.....+(3+6)*y(1,1)+....
I assume that if the model aggregates the expressions into one this should not be a problem but just want to make sure, thank you @FabianHofmann

Yes, that should be fine, but have a look at the resulting objective to make sure the expressions are added correctly.