Topic
• Latest Post - ‏2018-10-13T19:42:39Z by open_ball
open_ball
23 Posts

# Pinned topic CPLEX first integer solution

‏2018-10-12T17:12:08Z |

Hi,

If I create cplex, set intsollim parameter as 1, and call cplex.solve() function twice, does cplex respond in the following way?

1) Start solving the problem, find the first integer solution.

2) Continue the branch and cut tree and find the second integer solution.

So basically, would that be the same with setting intsollim=2 and calling  cplex.solve() only once?

• AlexFleischer
631 Posts

#### Re: CPLEX first integer solution

‏2018-10-12T20:20:57Z

Hi

you re right and let me give you an example out of the warehouse example in OPL:

int Fixed        = 100;
int NbWarehouses = 200;
int NbStores     = 600;

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;

subject to {

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];
}

execute
{
writeln("Obj=",TotalFixedCost + TotalSupplyCost);
writeln("cplex.status=",cplex.status);
}

main
{
thisOplModel.generate();
cplex.intsollim=2;
cplex.solve();
thisOplModel.postProcess();
}

gives

Obj=16890
cplex.status=104

but if for the main block you write

main
{
thisOplModel.generate();
cplex.intsollim=1;
cplex.solve();
thisOplModel.postProcess();
cplex.solve();
thisOplModel.postProcess();
}

then you ll get

Obj=17300
cplex.status=104
Obj=16890
cplex.status=104

regards

• AlexFleischer
631 Posts

#### Re: CPLEX first integer solution

‏2018-10-12T20:20:57Z

Hi

you re right and let me give you an example out of the warehouse example in OPL:

int Fixed        = 100;
int NbWarehouses = 200;
int NbStores     = 600;

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;

subject to {

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];
}

execute
{
writeln("Obj=",TotalFixedCost + TotalSupplyCost);
writeln("cplex.status=",cplex.status);
}

main
{
thisOplModel.generate();
cplex.intsollim=2;
cplex.solve();
thisOplModel.postProcess();
}

gives

Obj=16890
cplex.status=104

but if for the main block you write

main
{
thisOplModel.generate();
cplex.intsollim=1;
cplex.solve();
thisOplModel.postProcess();
cplex.solve();
thisOplModel.postProcess();
}

then you ll get

Obj=17300
cplex.status=104
Obj=16890
cplex.status=104

regards