Gurobi Python - RHS "changes" when I move code to a server

118 views Asked by At

I wrote a transportation linear program on my personal computer in python/gurobi. A typical constraint for demand node j might look like this:

m.addConstr(quicksum(x[i1, j1] for (i1, j1) in arcs.select('*', j)) == demand[j])

where

x[i, j] is a decision variable for flow on edge (i,j)

arcs is the set of all edges between supply and demand nodes

demand[j] is a known fractional constant of demand required at j

When I test this code out on my personal computer, it works fine. However, when I move it to my organization's computing cluster and try to run it, the right hand side (demand[j]) is not the same and I get incorrect values for x[i,j]'s.

1

There are 1 answers

0
jason a On

When I add float around the right hand side, it works again.

m.addConstr(quicksum(x[i1, j1] for (i1, j1) in arcs.select('*', j)) == float(demand[j]))

(I don't know why this problem exists or if it's only on Python)