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

Abstract base class for reformulating a problem so that handlers can be applied to it. More...

#include <Transformer.h>

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

Public Member Functions

 Transformer ()
 Default Constructor.
 
 Transformer (EnvPtr env, ProblemPtr oldp)
 Constructor.
 
virtual ~Transformer ()
 Destroy.
 
virtual std::string getName () const =0
 Get the name of this Transformer. More...
 
virtual SolutionPtr getSolOrig (ConstSolutionPtr sol, int &err)=0
 Translate the solution of reformulated problem into that of original problem. More...
 
virtual SolutionPtr getSolTrans (ConstSolutionPtr sol, int &err)=0
 Translate the solution of originial problem into that of reformulated problem. More...
 
virtual void reformulate (ProblemPtr &newp, HandlerVector &handlers, int &status)=0
 Perform the reformulation, and assign handlers. More...
 

Protected Member Functions

bool allConsAssigned_ (ProblemPtr p, HandlerVector &handlers)
 Check if all constraints in a problem have been assigned to a handler. More...
 
void assignHandler_ (CGraphPtr cg, ConstraintPtr c)
 Assign an appropriate handler to a nonlinear constraint of the form $y_i = f(x)$. More...
 
void clearUnusedHandlers_ (HandlerVector &handlers)
 Delete unused handlers. More...
 
void copyLinear_ (ConstProblemPtr p, ProblemPtr newp)
 Copy all the linear constraints of the problem into the new problem. More...
 
void copyVars_ (ConstProblemPtr p, ProblemPtr newp)
 Copy all the linear constraints of the problem into the new problem. More...
 
virtual void makeObjLin_ ()
 
void minObj_ ()
 Convert a maximization objective into minimization.
 
VariablePtr newVar_ (VariablePtr iv, double d, ProblemPtr newp)
 Find the auxiliary variable associated with $y_i = x_j+d$ or create a new one. More...
 
VariablePtr newVar_ (LinearFunctionPtr lf, double d, ProblemPtr newp)
 Find the auxiliary variable associated with $y_i = c^Tx+d$ or create a new one. More...
 
VariablePtr newVar_ (CGraphPtr cg, ProblemPtr newp)
 Find the auxiliary variable associated with $y_i = f(x)+d$ or create a new one. More...
 

Protected Attributes

EnvPtr env_
 The pointer to environment.
 
LinearHandlerPtr lHandler_
 Handler for linear constraints and variables.
 
LoggerPtr logger_
 Logger.
 
ProblemPtr newp_
 The transformed problem.
 
ProblemPtr p_
 The original problem.
 
kPowHandlerPtr kHandler_
 Handler for y = x^k type constraints.
 
QuadHandlerPtr qHandler_
 Handler for quadratic terms.
 
CxUnivarHandlerPtr uHandler_
 Handler for univariate constraints.
 
UnivarQuadHandlerPtr uqHandler_
 Handler for univariate quadratic constraints.
 
YEqLFsyLfs_
 Storage for auxiliary variables defined by relations of the form $y_i = c^Tx + d$.
 
YEqUCGsyUniExprs_
 Storage for auxiliary variables defined by relations of the form $y_i = f(x_j)$.
 
YEqVarsyVars_
 Storage for auxiliary variables defined by relations of the form $y_i = x_j + d$.
 
const double zTol_
 Tolerance for checking if a value is zero.
 

Detailed Description

Abstract base class for reformulating a problem so that handlers can be applied to it.

A transformer will create a new problem equivalent to a given problem by spliting constraints, adding new variables etc. The end result is a problem whose each constraint can be handled by a specific handler. This class has some abstract virtual methods that must be implemented by a derived class. Other commonly used functions are implemented here.

Member Function Documentation

◆ allConsAssigned_()

bool Transformer::allConsAssigned_ ( ProblemPtr  p,
HandlerVector &  handlers 
)
protected

Check if all constraints in a problem have been assigned to a handler.

Parameters
[in]pProblem whose constraints need to be checked.
Returns
True if all constraints have been assigned. False otherwise.

◆ assignHandler_()

void Transformer::assignHandler_ ( CGraphPtr  cg,
ConstraintPtr  c 
)
protected

Assign an appropriate handler to a nonlinear constraint of the form $y_i = f(x)$.

Parameters
[in]cgA nonlinear function which is be replaced by the auxiliary variable.
[in]cThe nonlinear constraint $y_i = f(x)$ that is being assigned to.

◆ clearUnusedHandlers_()

void Transformer::clearUnusedHandlers_ ( HandlerVector &  handlers)
protected

Delete unused handlers.

Parameters
[in/out]handlers. Contains pointers to each handler. Unused ones are removed from the vector.

◆ copyLinear_()

void Transformer::copyLinear_ ( ConstProblemPtr  p,
ProblemPtr  newp 
)
protected

Copy all the linear constraints of the problem into the new problem.

Parameters
[in]pInput problem
[in]newpThe transformed problem to which new constraints are added.

◆ copyVars_()

void Transformer::copyVars_ ( ConstProblemPtr  p,
ProblemPtr  newp 
)
protected

Copy all the linear constraints of the problem into the new problem.

Parameters
[in]pInput problem
[in]newpThe transformed problem to which new constraints are added.

◆ getName()

virtual std::string Minotaur::Transformer::getName ( ) const
pure virtual

Get the name of this Transformer.

Implemented in Minotaur::QuadTransformer, Minotaur::SimpleTransformer, and Minotaur::TransPoly.

◆ getSolOrig()

virtual SolutionPtr Minotaur::Transformer::getSolOrig ( ConstSolutionPtr  sol,
int &  err 
)
pure virtual

Translate the solution of reformulated problem into that of original problem.

Parameters
[in]solSolution of the reformulated problem.
[out]errZero if no error is encountered, nonzero otherwise.
Returns
Solution of original problem.

Implemented in Minotaur::QuadTransformer, Minotaur::SimpleTransformer, and Minotaur::TransPoly.

◆ getSolTrans()

virtual SolutionPtr Minotaur::Transformer::getSolTrans ( ConstSolutionPtr  sol,
int &  err 
)
pure virtual

Translate the solution of originial problem into that of reformulated problem.

Parameters
[in]solSolution of the original problem.
[out]errZero if no error is encountered, nonzero otherwise.
Returns
Solution of the reformulated problem.

Implemented in Minotaur::QuadTransformer, Minotaur::SimpleTransformer, and Minotaur::TransPoly.

◆ makeObjLin_()

void Transformer::makeObjLin_ ( )
protectedvirtual

Converts the new Problem newp_ into one with a linear objective by adding a new variable if necessary.

◆ newVar_() [1/3]

VariablePtr Transformer::newVar_ ( CGraphPtr  cg,
ProblemPtr  newp 
)
protected

Find the auxiliary variable associated with $y_i = f(x)+d$ or create a new one.

Parameters
[in]Thenonlinear function.
[in]newpThe transformed problem to which the new constraint should be added, in case this constraint is not found.
Returns
The variable $y$. If the constraint is found, it returns the variable found in it, otherwise it addes a new variable to the problem and returns it.

◆ newVar_() [2/3]

VariablePtr Transformer::newVar_ ( LinearFunctionPtr  lf,
double  d,
ProblemPtr  newp 
)
protected

Find the auxiliary variable associated with $y_i = c^Tx+d$ or create a new one.

Parameters
[in/out]lf The linear function $c^Tx$. If a new variable is created, it is also subtracted from lf.
[in]dThe value $d$.
[in]newpThe transformed problem to which the new constraint should be added, in case this constraint is not found.
Returns
The variable $y$. If the constraint is found, it returns the variable found in it, otherwise it addes a new variable to the problem and returns it.

◆ newVar_() [3/3]

VariablePtr Transformer::newVar_ ( VariablePtr  iv,
double  d,
ProblemPtr  newp 
)
protected

Find the auxiliary variable associated with $y_i = x_j+d$ or create a new one.

Parameters
[in]ivThe variable $x_j$.
[in]dThe value $d$.
[in]newpThe transformed problem to which the new constraint should be added, in case this constraint is not found.
Returns
The variable $y$. If the constraint is found, it returns the variable found in it, otherwise it addes a new variable to the problem and returns it.

◆ reformulate()

virtual void Minotaur::Transformer::reformulate ( ProblemPtr newp,
HandlerVector &  handlers,
int &  status 
)
pure virtual

Perform the reformulation, and assign handlers.

Parameters
[out]newpThe new, reformulated problem.
[out]handlersA vector of handlers used to reformulate the problem.
[out]statusZero if reformulated successfully. Nonzero otherwise.

Implemented in Minotaur::QuadTransformer, Minotaur::SimpleTransformer, and Minotaur::TransPoly.


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