Network flow and Truck capacity
AnsweredHi,
We have built a multi-objective supply chain model in Gurobi. The current model executes.
However, we wish to get a more accurate assessment of the cost of shipping. We want to round up partly filled trucks to the next whole number. i.e 2.3 to 3. Here is the code:
cost = ((gp.quicksum((flow[p,a[0],a[1]]/TruckCapacity[a]) *FixedCost[a] for p in Products for a in arcs )
We have tried to include math.ceil, but it says it is not a Gurobi LinExpr.
Would we be able to implement a constraint that forces Gurobi to do it?
If anybody can help, it would be greatly appreciated?
Tim
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Tim,
There is no built in rounding function for mathematical programming. You can however, introduce auxiliary integer variables to force the cost of shipping to attain integer values, i.e., add constraints
cost_of_shipping = auxiliary_integer_variable
If your current model does not allow for integer value of \(\texttt{cost_of_shipping}\) you could introduce auxiliary continuous variables \(x \in [0,0.999]\) to represent the offset to the next integer value. Rounding up could then be modeled as
cost_of_shipping + x = auxiliary_integer_variable
In your example, when cost of shipping equals \(2.3\), \(x\) would be \(0.7\) and the auxiliary integer vairable then \(3\).
Best regards,
JaromiłBest regards,
Jaromił0
Post is closed for comments.
Comments
2 comments