Minotaur 0.4.1
Docs for developers
Public Member Functions | List of all members
Minotaur::SOS2Handler Class Reference

#include <SOS2Handler.h>

Inheritance diagram for Minotaur::SOS2Handler:
Inheritance graph
[legend]
Collaboration diagram for Minotaur::SOS2Handler:
Collaboration graph
[legend]

Public Member Functions

 SOS2Handler ()
 Default constructor.
 
 SOS2Handler (EnvPtr env, ProblemPtr problem)
 Constructor.
 
 ~SOS2Handler ()
 Destroy.
 
void relaxInitFull (RelaxationPtr rel, SolutionPool *sp, bool *is_inf)
 Create root relaxation if doing full node relaxations. More...
 
void relaxInitInc (RelaxationPtr rel, SolutionPool *sp, bool *is_inf)
 Create root relaxation if doing incremental node relaxations. More...
 
void relaxNodeFull (NodePtr node, RelaxationPtr rel, bool *is_inf)
 Create a relaxation for a node, building from scratch. More...
 
void relaxNodeInc (NodePtr node, RelaxationPtr rel, bool *is_inf)
 Create an incremental relaxation for a node. More...
 
bool isFeasible (ConstSolutionPtr sol, RelaxationPtr relaxation, bool &should_prune, double &inf_meas)
 Check if a solution is feasible. More...
 
void separate (ConstSolutionPtr sol, NodePtr node, RelaxationPtr rel, CutManager *cutman, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &r_mods, bool *sol_found, SeparationStatus *status)
 Empty method as we do not do any separation in SOS1. More...
 
void getBranchingCandidates (RelaxationPtr rel, const DoubleVector &x, ModVector &mods, BrVarCandSet &cands, BrCandVector &gencands, bool &is_inf)
 find branching candidates. More...
 
ModificationPtr getBrMod (BrCandPtr cand, DoubleVector &x, RelaxationPtr rel, BranchDirection dir)
 Get the modifcation that creates a given (up or down) branch. More...
 
Branches getBranches (BrCandPtr cand, DoubleVector &x, RelaxationPtr rel, SolutionPoolPtr s_pool)
 Return branches for branching. More...
 
bool isNeeded ()
 Return true if this handler is needed for the problem. More...
 
SolveStatus presolve (PreModQ *, bool *, Solution **)
 Presolve. Do not do any presolving. More...
 
void postsolveGetX (const double *, UInt, DoubleVector *)
 Does nothing.
 
bool presolveNode (RelaxationPtr, NodePtr, SolutionPoolPtr, ModVector &, ModVector &)
 Does nothing. More...
 
std::string getName () const
 Return the name of the handler. More...
 
void getNzNumSum_ (SOSPtr sos, const DoubleVector x, int *nz, double *nzsum)
 
void writePreStats (std::ostream &) const
 Does nothing.
 
double getTol () const
 Return the integer tolerance.
 
void setTol (double tol)
 Set the integer tolerance.
 
- Public Member Functions inherited from Minotaur::Handler
 Handler ()
 Default constructor.
 
virtual ~Handler ()
 Destroy.
 
virtual void addConstraint (ConstraintPtr newcon)
 Add constraint to be handled by this handler. More...
 
virtual ConstraintVector::const_iterator consBegin () const
 
virtual ConstraintVector::const_iterator consEnd () const
 
virtual int fixNodeErr (RelaxationPtr, ConstSolutionPtr, SolutionPoolPtr, bool &)
 
virtual Branches getBranches (BrCandPtr cand, DoubleVector &x, RelaxationPtr rel, SolutionPoolPtr s_pool)=0
 Return branches for branching. More...
 
virtual void getBranchingCandidates (RelaxationPtr rel, const DoubleVector &x, ModVector &mods, BrVarCandSet &cands, BrCandVector &gencands, bool &is_inf)=0
 find branching candidates. More...
 
virtual ModificationPtr getBrMod (BrCandPtr cand, DoubleVector &x, RelaxationPtr rel, BranchDirection dir)=0
 Get the modifcation that creates a given (up or down) branch. More...
 
virtual std::string getName () const =0
 Return the name of the handler. More...
 
bool getStrongerMods (RelaxationPtr rel, NodePtr node, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &r_mods)
 do node presolve to get mods for stronger branching All params are presolveNode params.
 
virtual bool isFeasible (ConstSolutionPtr sol, RelaxationPtr rel, bool &should_prune, double &inf_meas)=0
 Check if a solution is feasible. More...
 
virtual bool isNeeded ()
 Return true if this handler is needed for the problem. More...
 
virtual SolveStatus presolve (PreModQ *pre_mods, bool *changed, Solution **sol)=0
 Initial presolve. More...
 
virtual bool presolveNode (RelaxationPtr rel, NodePtr node, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &r_mods)=0
 Presolve the problem and its relaxation at a node. More...
 
virtual bool postSolveRootNode (RelaxationPtr, SolutionPoolPtr, ConstSolutionPtr, ModVector &, ModVector &)
 At the root node post solve the problem and its relaxation. LP based bound tightening (OBBT) is employed here after filtering variables for which no OBBT is required. More...
 
virtual void relaxInitFull (RelaxationPtr rel, SolutionPool *sp, bool *is_inf)=0
 Create root relaxation if doing full node relaxations. More...
 
virtual void relaxInitInc (RelaxationPtr rel, SolutionPool *sp, bool *is_inf)=0
 Create root relaxation if doing incremental node relaxations. More...
 
virtual void relaxNodeFull (NodePtr node, RelaxationPtr rel, bool *is_inf)=0
 Create a relaxation for a node, building from scratch. More...
 
virtual void relaxNodeInc (NodePtr node, RelaxationPtr rel, bool *is_inf)=0
 Create an incremental relaxation for a node. More...
 
virtual void removeCuts (RelaxationPtr, ConstSolutionPtr)
 
virtual void separate (ConstSolutionPtr sol, NodePtr node, RelaxationPtr rel, CutManager *cutman, SolutionPoolPtr s_pool, ModVector &p_mods, ModVector &r_mods, bool *sol_found, SeparationStatus *status)=0
 add cuts to separate a given point. More...
 
virtual void setModFlags (bool mod_prob, bool mod_rel)
 Tell the handler whether the problem will be modified or the relaxation will be modified or both. These modifications will be saved in the tree as well. More...
 
virtual void simplePresolve (ProblemPtr, SolutionPoolPtr, ModVector &, SolveStatus &status)
 
void undoStrongerMods (ProblemPtr p, RelaxationPtr rel, ModVector &p_mods, ModVector &r_mods)
 Undo Modifications made during stronger branching. More...
 
virtual void writeStats (std::ostream &) const
 Write statistics to ostream out. More...
 

Additional Inherited Members

- Protected Attributes inherited from Minotaur::Handler
ConstraintVector cons_
 
bool modProb_
 If true, modify the original (or transformed) problem.
 
bool modRel_
 If true, modify the relaxation of original (or transformed) problem.
 

Detailed Description

SOS2Handler class considers all SOS Type 2 constraints in the problem. It does not implement separate() function. Implements functions for checking feasibility and branching.

Member Function Documentation

◆ getBranches()

Branches SOS2Handler::getBranches ( BrCandPtr  cand,
DoubleVector &  x,
RelaxationPtr  rel,
SolutionPoolPtr  s_pool 
)
virtual

Return branches for branching.

Get branches by branching on the given candidate. In the general scheme for branching, we store only bound changes, though we are also capable of storing other mods.

Parameters
[in]candCandidate on which the brancher wants to branch.
[in]xThe solution of the relaxation at the current node.
[in]relThe relaxation at the current node.
[in]s_poolBest feasible solutions found so far.
Returns
a vector of branch-objects.

Implements Minotaur::Handler.

◆ getBranchingCandidates()

void SOS2Handler::getBranchingCandidates ( RelaxationPtr  rel,
const DoubleVector &  x,
ModVector &  mods,
BrVarCandSet &  cands,
BrCandVector &  gencands,
bool &  is_inf 
)
virtual

find branching candidates.

A brancher will ask each handler by calling this function to list branching candidates.

Parameters
[in]relRelaxation being solved at current node.
[in]xSolution of the relaxation.
[out]modsAny modifications that the handler found (Unused).
[out]candsThe set of candidates to which branching candidates must be inserted. This set has candidates that want to branch on a single variable only. Other candidates must go into gencands.
[out]gencandsThe vector of general branching candidates. All candidates that do not want to branch on a variable dichotomy must be added in this vector.
[out]is_inftrue if the handler finds that the problem is infeasible and the node can be pruned.

Implements Minotaur::Handler.

◆ getBrMod()

ModificationPtr SOS2Handler::getBrMod ( BrCandPtr  cand,
DoubleVector &  x,
RelaxationPtr  rel,
BranchDirection  dir 
)
virtual

Get the modifcation that creates a given (up or down) branch.

If one branch is pruned by the brancher (e.g. strong brancher), then we can apply the modifications of other branch to the relaxation without branching. This routine returns such a modification. This function is also called for obtaining modifications for strong branching on a candidate.

Parameters
[in]candThe candidate for which we want the modification.
[in]xThe solution of relaxation at current node.
[in]relThe relaxation at current node.
[in]dirThe Direction for which we want the modification, Up or Down?.
Returns
Modification that can be applied to the relaxation before re-solving it.

Implements Minotaur::Handler.

◆ getName()

std::string SOS2Handler::getName ( ) const
virtual

Return the name of the handler.

Implements Minotaur::Handler.

◆ isFeasible()

bool SOS2Handler::isFeasible ( ConstSolutionPtr  sol,
RelaxationPtr  rel,
bool &  should_prune,
double &  inf_meas 
)
virtual

Check if a solution is feasible.

Check if a given solution is feasible for the constraints that are handled by this handler. should_prune is true if the handler finds that the problem itself is infeasible and the current node can be pruned (which is different from a solution not being feasible).

Parameters
[in]solThe solution of the relaxation whose feasibility we want to test.
[in]relThe relaxation.
[out]should_pruneTrue if the relaxation is infeasible and we can prune the node associated.
[out]inf_measA measure of infeasibility. It may be used by heuristics and other code to make the tree-search faster. Computing this value is optional.
Returns
True if sol is feasible for constraints/objective asociated with this handler. False if sol is not feasible.

Implements Minotaur::Handler.

◆ isNeeded()

bool SOS2Handler::isNeeded ( )
virtual

Return true if this handler is needed for the problem.

It is useful to know if a handler is required or not. For example, a handler may be deleted if it is not needed.

Reimplemented from Minotaur::Handler.

◆ presolve()

SolveStatus Minotaur::SOS2Handler::presolve ( PreModQ *  ,
bool *  ,
Solution **   
)
inlinevirtual

Presolve. Do not do any presolving.

Implements Minotaur::Handler.

◆ presolveNode()

bool Minotaur::SOS2Handler::presolveNode ( RelaxationPtr  ,
NodePtr  ,
SolutionPoolPtr  ,
ModVector &  ,
ModVector &   
)
inlinevirtual

Does nothing.

Implements Minotaur::Handler.

◆ relaxInitFull()

void SOS2Handler::relaxInitFull ( RelaxationPtr  rel,
SolutionPool sp,
bool *  is_inf 
)
virtual

Create root relaxation if doing full node relaxations.

This method is used to add all the variables and constraints handled by this handler, with the understanding that nodes will also be fully rebuilt. The relaxation is already created, it should not be freed or re-allocated.

Parameters
[in,out]relThe relaxation that is being constructed.
[in]Solutionpool for storing any new solutions found.
[out]is_infis true if the handler finds that the problem is infeasible.

Implements Minotaur::Handler.

◆ relaxInitInc()

void SOS2Handler::relaxInitInc ( RelaxationPtr  rel,
SolutionPool sp,
bool *  is_inf 
)
virtual

Create root relaxation if doing incremental node relaxations.

This method is used to add all the variables and constraints handled by this handler, with the understanding that nodes will incrementally relaxed. The relaxation is already created, it should not be freed or re-allocated.

Parameters
[in,out]relThe relaxation that is being constructed.
[in]Solutionpool for storing any new solutions found.
[out]is_infis true if the handler finds that the problem is infeasible.

Implements Minotaur::Handler.

◆ relaxNodeFull()

void SOS2Handler::relaxNodeFull ( NodePtr  node,
RelaxationPtr  rel,
bool *  is_inf 
)
virtual

Create a relaxation for a node, building from scratch.

Create a relaxation of the constraints. Either this method, or relaxNodeInc should be called at each node. Here, we only make minor modifications to the same relaxation.

Parameters
[in]nodeis the node for which relaxation is to be created.
[in]relis the relaxation that is being constructed. Do not allocate or re-allocate space for it. Just add new variables or constraints to it.
[out]is_infis true if the node can be pruned.

Implements Minotaur::Handler.

◆ relaxNodeInc()

void SOS2Handler::relaxNodeInc ( NodePtr  node,
RelaxationPtr  rel,
bool *  is_inf 
)
virtual

Create an incremental relaxation for a node.

Create a relaxation of the constraints. Either this method, or nodeRelaxFull relax should be called at root node. Usually we only make minor modifications to the same relaxation.

Parameters
[in]nodeis the node for which relaxation is to be created.
[in]relis the relaxation that is being constructed. Do not allocate or re-allocate space for it. Just add new variables or constraints to it.
[out]is_infis true if the node can be pruned.

Implements Minotaur::Handler.

◆ separate()

void SOS2Handler::separate ( ConstSolutionPtr  sol,
NodePtr  node,
RelaxationPtr  rel,
CutManager cutman,
SolutionPoolPtr  s_pool,
ModVector &  p_mods,
ModVector &  r_mods,
bool *  sol_found,
SeparationStatus status 
)
virtual

Empty method as we do not do any separation in SOS1.

Implements Minotaur::Handler.


The documentation for this class was generated from the following files:

Minotaur source code documented by Doxygen 1.9.4 on Thu Apr 24 2025