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

A MultilinearHandler handles terms like $x_0x_1^2$. More...

#include <MultilinearHandler.h>

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

Public Member Functions

 MultilinearHandler (EnvPtr env, ProblemPtr problem)
 Default constructor.
 
virtual ~MultilinearHandler ()
 Destroy.
 
bool findOriginalVariable (ConstVariablePtr rv, ConstVariablePtr &ov) const
 
virtual void getBranchingCandidates (RelaxationPtr rel, const DoubleVector &x, ModVector &mods, BrVarCandSet &cands, BrCandVector &gencands, bool &is_inf)
 
bool isFeasible (ConstSolutionPtr, RelaxationPtr, bool &should_prune, double &inf_meas)
 
void relax (RelaxationPtr relaxation, bool &isInfeasible)
 
void relaxInitFull (RelaxationPtr, bool *)
 
void relaxInitInc (RelaxationPtr, bool *)
 
void relaxNodeFull (NodePtr, RelaxationPtr, bool *)
 Create a relaxation for a node, building from scratch. More...
 
void relaxNodeInc (NodePtr, RelaxationPtr, bool *)
 Create an incremental relaxation for a node. More...
 
void relaxNode (NodePtr node, RelaxationPtr relaxation, bool &isInfeasible)
 
std::map< std::vector< ConstVariablePtr >, ConstVariablePtrgetRevMlterms ()
 
std::map< ConstVariablePtr, std::vector< ConstVariablePtr > > getMlterms ()
 
std::map< ConstVariablePtr, UIntgetMaxPow ()
 
std::map< ConstVariablePtr, ConstVariablePair > getBlterms ()
 
std::map< ConstVariablePair, ConstVariablePtrgetRevBlterms ()
 
std::map< VarIntMap, ConstVariablePtrgetMonomialterms ()
 
std::map< ConstVariablePtr, ConstVariablePair > getSqterms ()
 
std::map< ConstVariablePair, ConstVariablePtrgetRevSqterms ()
 
std::vector< std::vector< ConstVariablePtr > > getGroups ()
 
std::vector< std::vector< ConstVariablePtr > > getAllLambdas ()
 
std::map< ConstVariablePtr, ConstVariablePtrgetOriginalVariablesMap ()
 
std::map< ConstVariablePtr, ConstVariablePtrgetRevOriginalVariablesMap ()
 
std::map< ConstVariablePtr, std::vector< ConstVariablePtr > > getNewCopyVariables ()
 
std::map< VarIntMap, ConstVariablePtrgetMonomialTerms ()
 
std::map< ConstVariablePair, ConstVariablePtrgetRevBilinearTerms ()
 
void separate (ConstSolutionPtr, NodePtr, RelaxationPtr, CutManager *, SolutionPoolPtr, bool *, SeparationStatus *)
 Can not return any cuts for this case.
 
virtual ModificationPtr getBrMod (BrCandPtr, DoubleVector &, RelaxationPtr, BranchDirection)
 Get the modifcation that creates a given (up or down) branch. More...
 
virtual Branches getBranches (BrCandPtr cand, DoubleVector &x, RelaxationPtr rel, SolutionPoolPtr s_pool)
 Return branches for branching. More...
 
virtual SolveStatus presolve (PreModQ *, bool *changed, Solution **)
 Initial presolve. More...
 
virtual bool presolveNode (RelaxationPtr, NodePtr, SolutionPoolPtr, ModVector &, ModVector &)
 Presolve the problem and its relaxation at a node. More...
 
std::string getName () const
 Return the name of the handler. More...
 
- 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...
 

Protected Attributes

EnvPtr env_
 Environment.
 
ConstProblemPtr problem_
 
ProblemPtr workingProblem_
 
- 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

A MultilinearHandler handles terms like $x_0x_1^2$.

Member Function Documentation

◆ getAllLambdas()

std::vector< std::vector< ConstVariablePtr > > Minotaur::MultilinearHandler::getAllLambdas ( )
inline

Return the lambda variables introduced for the Grouped Convex Hull relaxation

◆ getBlterms()

std::map< ConstVariablePtr, ConstVariablePair > Minotaur::MultilinearHandler::getBlterms ( )
inline

Retrun the blterms_

◆ getBranches()

Branches MultilinearHandler::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 MultilinearHandler::getBranchingCandidates ( RelaxationPtr  rel,
const DoubleVector &  x,
ModVector &  mods,
BrVarCandSet &  cands,
BrCandVector &  gencands,
bool &  is_inf 
)
virtual

Both $x_0, x_1$ are branching candidates. The McCormick inequalities must be updated after branching.

Implements Minotaur::Handler.

◆ getBrMod()

ModificationPtr MultilinearHandler::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.

◆ getGroups()

std::vector< std::vector< ConstVariablePtr > > Minotaur::MultilinearHandler::getGroups ( )
inline

Return the groups of variables that are made for the Grouped Convex Hull relaxation

◆ getMaxPow()

std::map< ConstVariablePtr, UInt > Minotaur::MultilinearHandler::getMaxPow ( )
inline

Retrun the max_pow_

◆ getMlterms()

std::map< ConstVariablePtr, std::vector< ConstVariablePtr > > Minotaur::MultilinearHandler::getMlterms ( )
inline

Return mlterms_

◆ getMonomialterms()

std::map< VarIntMap, ConstVariablePtr > Minotaur::MultilinearHandler::getMonomialterms ( )
inline

Retrun the monomial_terms__

◆ getMonomialTerms()

std::map< VarIntMap, ConstVariablePtr > Minotaur::MultilinearHandler::getMonomialTerms ( )
inline

Retrun the map of monomial terms

◆ getName()

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

Return the name of the handler.

Implements Minotaur::Handler.

◆ getNewCopyVariables()

std::map< ConstVariablePtr, std::vector< ConstVariablePtr > > Minotaur::MultilinearHandler::getNewCopyVariables ( )
inline

Return the map between the original variables and the copy variables for its exponents

◆ getOriginalVariablesMap()

std::map< ConstVariablePtr, ConstVariablePtr > Minotaur::MultilinearHandler::getOriginalVariablesMap ( )
inline

Return the map between the original variables and the variables in the relaxation

◆ getRevBilinearTerms()

std::map< ConstVariablePair, ConstVariablePtr > Minotaur::MultilinearHandler::getRevBilinearTerms ( )
inline

Return the map of bilinear terms (map of a variable pair and a substiture variable)

◆ getRevBlterms()

std::map< ConstVariablePair, ConstVariablePtr > Minotaur::MultilinearHandler::getRevBlterms ( )
inline

Retrun the rev_blterms_

◆ getRevMlterms()

std::map< std::vector< ConstVariablePtr >, ConstVariablePtr > Minotaur::MultilinearHandler::getRevMlterms ( )
inline

Return rev_mlterms_

◆ getRevOriginalVariablesMap()

std::map< ConstVariablePtr, ConstVariablePtr > Minotaur::MultilinearHandler::getRevOriginalVariablesMap ( )
inline

Return the REVERSE map between the original variables and the variables in the relaxation

◆ getRevSqterms()

std::map< ConstVariablePair, ConstVariablePtr > Minotaur::MultilinearHandler::getRevSqterms ( )
inline

Retrun the rev_sqterms_

◆ getSqterms()

std::map< ConstVariablePtr, ConstVariablePair > Minotaur::MultilinearHandler::getSqterms ( )
inline

Retrun the sqterms_

◆ isFeasible()

bool MultilinearHandler::isFeasible ( ConstSolutionPtr  ,
RelaxationPtr  ,
bool &  should_prune,
double &  inf_meas 
)
virtual

Check if each multilinear constraint is satisfied. Stops on the first violated constraint.

Implements Minotaur::Handler.

◆ presolve()

virtual SolveStatus Minotaur::MultilinearHandler::presolve ( PreModQ *  pre_mods,
bool *  changed,
Solution **  sol 
)
inlinevirtual

Initial presolve.

Do the initial presolve. For now we will assume that presolve modifies the given problem. We do not create a new problem. All modifications that require post-processing for getting the solution back are prepended to 'pre_mods' by the handler.

Parameters
[in]pre_modsA pointer to a queue of PreMod objects. Modifications made by the presolver must be prepended (not appended) to pre_mods. The order is important for post-solve.
[out]changedTrue if the presolve modified the problem.
Returns
status of presolve.
Parameters
[out]solOptimal solution found by the handler, if any. The status must be SolvedOptimal if and only if sol is created.

Implements Minotaur::Handler.

◆ presolveNode()

virtual bool Minotaur::MultilinearHandler::presolveNode ( RelaxationPtr  rel,
NodePtr  node,
SolutionPoolPtr  s_pool,
ModVector &  p_mods,
ModVector &  r_mods 
)
inlinevirtual

Presolve the problem and its relaxation at a node.

Presolve the problem and its relaxation at a given node. Bound propagation and other simple modifications can be made in this function. It is called after the node relaxation is setup but before it is solved. Both the problem and its relaxation are presolved. Changes to the problem are stored in the tree. Changes to the relaxation are optional and may or may not be stored in the tree.

Parameters
[in]relRelaxation at the current node.
[in]nodeCurrent node.
[in]s_poolPool of solutions.
[in]p_modsUnused. Modifications to the problem that must be stored in this node so that they are applied to all descendant nodes as well. All modifications must be appended not prepended.
[out]r_modsModifications to the relaxation that must be stored in this node so that they are applied to all descendant nodes as well. All modifications must be appended not prepended. This may be unnecessary in certain algorithms.
Returns
true if Node can be pruned because infeasibility is detected.

Implements Minotaur::Handler.

◆ relaxNodeFull()

void Minotaur::MultilinearHandler::relaxNodeFull ( NodePtr  node,
RelaxationPtr  rel,
bool *  is_inf 
)
inlinevirtual

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 Minotaur::MultilinearHandler::relaxNodeInc ( NodePtr  node,
RelaxationPtr  rel,
bool *  is_inf 
)
inlinevirtual

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.


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