Originally posted by: max__x
dear all,
currently, I am doing integrate the the Single-commodity flow of tsp formulation with wagner-whitin inventory model, the solution gives the T tsp tour (where T is number of periods) each tsp tour visits all of the shops rather than the shops need replenishment at that period. I hope some one can correct my code. I will very appreciate it. I think the problem is in the sub-tour elimination constraint:
​ //objective function
dexpr float Inventorycost = ( sum( t in Periods , c in Cities) Orderdecision[t][c] * Orderingcost[t][c])+
( sum(t in Periods, c in Cities ) Inv[t][c]* InventoryCost[c] );
dexpr float Transportationcost = (sum(i in Cities, j in Cities, t in Periods) Distance[i][j]*x[t][i][j]);
minimize (Inventorycost+Transportationcost);
//constraint
subject to {
//initial inventory level
InitialInventorylevel:
forall(c in Cities)
Inv[0][c] == InitialInventory[c];
// inventory capacity
forall( t in Periods, c in Cities )
InventoryCapacity:
Inv[t][c] >=0;
forall (t in Periods, c in Cities)
Inv[t-1][c] + Orderdecision[t][c]*Orderquantity[t][c] <= Capacity[c] ;
//flow conservation
forall( t in Periods, c in Cities)
BalanceEquation:
Orderdecision[t][c]* Orderquantity[t][c] + Inv[t-1][c] == Inv[t][c] + Demand[t][c];
//force that if there is a shop j need services, then there must be a shop from shop i to shop j at time t
forall (j in Cities, t in Periods)
sum(i in Cities) x[t][i][j] >= Orderdecision[t][j];
//flow conservation
forall(t in Periods, j in Cities)
sum(i in Cities)x[t][i][j]==sum(i in Cities)x[t][j][i];
//subtour elimination
forall (t in Periods, i in Cities: i>1)
sum(j in Cities) y[t][j][i] - sum(j in Cities) y[t][i][j] == 1;
forall(i in Cities, j in Cities, t in Periods)
y[t][i][j]-(m-1)*x[t][i][j] <=0;
}
for the sub-tour elimination constraint, which states: forall (t in Periods, i in Cities: i>1) sum(j in Cities) y[t][j][i] - sum(j in Cities) y[t][i][j] == 1; this makes every city i have to be visited, but my ideal tsp tour is to visits the Cities they need replenishment at that period. when Orderdecision[t][i] =1, then at period t, city i need replenishment, and 0 shop i do not need replenishment.
I hope someone can correct my code, I will very appreciate with it.
Thank you!
#DecisionOptimization#MathematicalProgramming-General