Hi,
let me give you a small example derived from scalableWarehouse.mod
// The scalable warehouse example has been artificially increased in size
// so that the search is long enough for you to have time to interrupt it and look at feasible solutions.
// The resulting size is greater than the size allowed in trial mode.
// If you want to run this example, you need a commercial edition of CPLEX Studio to run this example.
// If you are a student or teacher, you can also get a full version through the IBM Academic Initiative.
int Fixed = 50;
int NbWarehouses = 50;
int NbStores = 100;
//execute
//{
//cplex.bendersstrategy=3;
//}
//execute{
// cplex.bendersstrategy = 3;
//}
assert( NbStores > NbWarehouses );
range Warehouses = 1..NbWarehouses;
range Stores = 1..NbStores;
int Capacity[w in Warehouses] =
NbStores div NbWarehouses +
w % ( NbStores div NbWarehouses );
int SupplyCost[s in Stores][w in Warehouses] =
1 + ( ( s + 10 * w ) % 100 );
dvar int Open[Warehouses] in 0..1;
dvar float Supply[Stores][Warehouses] in 0..1;
dexpr int TotalFixedCost = sum( w in Warehouses ) Fixed * Open[w];
dexpr float TotalSupplyCost = sum( w in Warehouses, s in Stores ) SupplyCost[s][w] * Supply[s][w];
//minimize TotalFixedCost + TotalSupplyCost;
dvar float obj;
minimize obj;
subject to {
ctObj:obj==TotalFixedCost + TotalSupplyCost;
forall( s in Stores )
ctStoreHasOneWarehouse:
sum( w in Warehouses )
Supply[s][w] == 1;
forall( w in Warehouses )
ctOpen:
sum( s in Stores )
Supply[s][w] <= Open[w] * Capacity[w];
}
main
{
thisOplModel.generate();
cplex.intsollim=1;
for(var i=1;i<=4;i++)
{
cplex.solve();
writeln("sol ",i);
writeln("getBestObjValue",cplex.getBestObjValue());
writeln("getObjValue",cplex.getObjValue());
}
}
gives
sol 1
getBestObjValue2633.333333333
getObjValue2900
sol 2
getBestObjValue2633.333333333
getObjValue2730
sol 3
getBestObjValue2633.333333333
getObjValue2680
sol 4
getBestObjValue2643.333333333
getObjValue2670
regards
#CPLEXOptimizers#DecisionOptimization