Feed starting solution from construction heuristic
AnsweredI've written a construction heuristic for the SDVRP where a heuristic constructs feasible routes for each vehicle.
My SDVRP model has variables:
# x-variable: 1 when arc (i, j) is traversed on route k; 0 otherwise
x_keys = {(e[0], e[1], k): e[2]["dist"] for e in G.edges(data=True) for k in range(1,K+1)}
x = m.addVars(
x_keys,
obj=x_keys,
vtype=GRB.BINARY,
name="x",
)
# y-variable: 1 when node i is visited on route k; 0 otherwise
y_keys = {(i, k) for i in list(G.predecessors("Stop")) for k in range(1,K+1)}
y = m.addVars(
y_keys,
vtype=GRB.BINARY,
name='y'
)
# v-variable: a variable that denotes the amount of material delivered to node i on route k
v_keys = {(i, k) for i in list(G.predecessors("Stop")) for k in range(1,K+1)}
v = m.addVars(
v_keys,
vtype=GRB.INTEGER,
name='v'
)
This heuristic outputs numpy arrays of v and y in the form:
v=
array([[3,2,7],
[9,1,7],
[0,1,1],
[0,0,0],
[0,0,1],
[7,0,0],
[4,7,2],
[0,9,3],
[0,2,0],
[2,0,4],
[0,5,0],
y=
array([[1,1,1],
[1,1,1],
[0,1,1],
[0,0,0],
[0,0,1],
[1,0,0],
[1,1,1],
[0,1,1],
[0,1,0],
[1,0,1],
[0,1,0],
and a dictionary of x in the form:
x=
{(0, 1): 1.0,
(0, 2): 0.0,
(0, 3): 1.0,
(1, 2): 1.0,
(1, 3): -0.0,
(2, 3): 1.0,
(1, 0): 1.0,
(2, 0): 0.0,
(3, 0): 1.0,
(2, 1): 1.0,
(3, 1): -0.0,
(3, 2): 1.0}
How do I give these values as a starting solution to my SDVRP model?
-
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 Gurobot? -
Hi Lirim,
I think the Knowledge Base article How do I use MIP starts? is what you are looking for.
Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments