lazy01.gms : Test lazy constraints

Description

This model tests the lazy constraints via the dot option .lazy

At the beginning of the MIP solution process, any constraint whose Lazy
attribute is set to 1, 2, or 3 for Gurobi and 1 for Cplex (the default value is
0) is removed from the model and placed in the lazy constraint pool. Lazy
constraints remain inactive until a feasible solution is found, at which point
the solution is checked against the lazy constraint pool. If the solution
violates any lazy constraints, the solution is discarded and one of more of the
violated lazy constraints are pulled into the active model.

Gurobi: Larger values for this attribute cause the constraint to be pulled into
the model more aggressively. With a value of 1, the constraint can be used to
cut off a feasible solution, but it won't necessarily be pulled in if another
lazy constraint also cuts off the solution. With a value of 2, all lazy
constraints that are violated by a feasible solution will be pulled into the
model. With a value of 3, lazy constraints that cut off the relaxation solution
are also pulled in.

Contributor: Michael Bussieck, December 2014


Small Model of Type : GAMS


Category : GAMS Test library


Main file : lazy01.gms

$title Test lazy constraints (LAZY01,SEQ=671)

$onText
This model tests the lazy constraints via the dot option .lazy

At the beginning of the MIP solution process, any constraint whose Lazy
attribute is set to 1, 2, or 3 for Gurobi and 1 for Cplex (the default value is
0) is removed from the model and placed in the lazy constraint pool. Lazy
constraints remain inactive until a feasible solution is found, at which point
the solution is checked against the lazy constraint pool. If the solution
violates any lazy constraints, the solution is discarded and one of more of the
violated lazy constraints are pulled into the active model.

Gurobi: Larger values for this attribute cause the constraint to be pulled into
the model more aggressively. With a value of 1, the constraint can be used to
cut off a feasible solution, but it won't necessarily be pulled in if another
lazy constraint also cuts off the solution. With a value of 2, all lazy
constraints that are violated by a feasible solution will be pulled into the
model. With a value of 3, lazy constraints that cut off the relaxation solution
are also pulled in.

Contributor: Michael Bussieck, December 2014
$offText


$ifThenI %system.mip% == gurobi $set solver gurobi
$elseIfI %system.mip% == cplex  $set solver cplex
$else
$abort 'Lazy constraints not available for %solver%.'
$endIf

$call gamslib -q cube
$onEcho >> cube.gms
abort$(cube.solvestat<>1 or (cube.modelstat<>1 and cube.modelstat<>8)) 'Bad model/solvestatus', cube.modelstat, cube.solvestat;
abort$(abs(num.l-4)>1e-4) 'Bad num.l', num.l;
$offEcho

$ifThenI %solver% == gurobi
$onEcho > gurobi.opt
lazyconstraints yes
ldef.lazy 3
$offEcho
$elseIfI %solver% == cplex
$onEcho > cplex.opt
lazyconstraints yes
ldef.lazy 1
$offEcho
$endIf

$call gams cube lo=2 mip=%solver% optfile=1
$if errorlevel 1 $abort 'problems with cube. Inspect cube.lst'

* Check that we used some Lazy Constraints
$ifThenI %solver% == gurobi
$call grep "Extracted .* lazy constraints" cube.log > %system.nullfile%
$elseIfI %solver% == cplex
$call grep "Problem contains .* lazy constraints" cube.log > %system.nullfile%
$endIf
$if errorlevel 1 $abort 'Solver did not extract lazy constraints'