Procedure GMP::SolverSession::AddBendersOptimalityCut(solverSession, GMP, solution, local, purgeable)

The procedure `GMP::SolverSession::AddBendersOptimalityCut` generates an optimality cut for a Benders’ master problem using the (dual) solution of a Benders’ subproblem. The Benders’ master problem must be a MIP problem. The cut is typically added as a lazy constraint in a callback during the MIP branch-and-cut search. This procedure is typically used in a Benders’ decomposition algorithm in which a single master MIP problem is solved.

```GMP::SolverSession::AddBendersOptimalityCut(
solverSession,    ! (input) a solver session
GMP,              ! (input) a generated mathematical program
solution,         ! (input) a solution
[local],          ! (optional, default 0) a scalar binary expression
[purgeable]       ! (optional, default 0) a scalar binary expression
)
```

Arguments

solverSession

An element in the set `AllSolverSessions` representing a solver session for the Benders’ master problem.

GMP

An element in the set `AllGeneratedMathematicalPrograms` representing a Benders’ subproblem.

solution

An integer scalar reference to a solution of GMP2.

local

A scalar binary value to indicate whether the cut is valid for the local problem (i.e. the problem corresponding to the current node in the solution process and all its descendant nodes) only (value 1) or for the global problem (value 0).

purgeable

A scalar binary value to indicate whether the solver is allowed to purge the cut if it deems it ineffective. If the value is 1, then it is allowed.

Return Value

The procedure returns 1 on success, or 0 otherwise.

Note

Example

In the example below we solve only one Benders’ master problem (which is a MIP). During the solve, whenever the solver finds an integer (incumbent) solution we want to run a callback for lazy constraints. Therefore we install a callback for it.

```myGMP := GMP::Instance::Generated( MP );

gmpM := GMP::Benders::CreateMasterProblem( myGMP, AllIntegerVariables,
'BendersMasterProblem', 0, 0 );

gmpS := GMP::Benders::CreateSubProblem( myGMP, masterGMP, 'BendersSubProblem',
0, 0 );

GMP::Instance::Solve( gmpM );
```

The callback procedure `LazyCallback` has one argument, namely `ThisSession` which is an element parameter with range `AllSolverSessions`. Inside the callback procedure we solve the Benders’ subproblem. We assume that the Benders’ subproblem is always feasible. The program status of the subproblem is stored in the element parameter `ProgramStatus` with range `AllSolutionStates`. Note that the subproblem is updated before it is solved.

```! Get MIP incumbent solution.
GMP::Solution::RetrieveFromSolverSession( ThisSession, 1 );
GMP::Solution::SendToModel( gmpM, 1 );

GMP::Benders::UpdateSubProblem( gmpS, gmpM, 1, round : 1 );

GMP::Instance::Solve( gmpS );

ProgramStatus := GMP::Solution::GetProgramStatus( gmpS, 1 ) ;
if ( ProgramStatus = 'Optimal' ) then