ROC++  v1.2
Automatic Robust Optimization in C++
ClassicConstraintIF Class Referenceabstract

Classic constraint interface class. More...

#include <Constraint.hpp>

Inheritance diagram for ClassicConstraintIF:
Collaboration diagram for ClassicConstraintIF:

Public Types

typedef ConstraintLHS_const_iterator const_iterator
 Constant iterator in LHSExpression terms. More...
 
typedef uncMapType::const_iterator uncertaintiesIterator
 Constant iterator in the uncertain parameter map. More...
 
- Public Types inherited from ConstraintIF
typedef dvMapType::const_iterator varsIterator
 Constant iterator in decision variable map. More...
 

Public Member Functions

 ClassicConstraintIF (bool definesUncertaintySet, bool isNAC=false)
 Constructor of classic constraint class. More...
 
 ~ClassicConstraintIF ()
 Destructor of classic constraint class. More...
 
const_iterator begin () const
 
const_iterator end () const
 
varsIterator varsBegin () const
 
varsIterator varsEnd () const
 
uncertaintiesIterator uncertaintiesBegin () const
 
uncertaintiesIterator uncertaintiesEnd () const
 
void add_lhs (double c)
 Create a new ProductTerm using the given input and add it to the left hand side of this constraint. More...
 
void add_lhs (double c, ROCPPVarIF_Ptr pVariable)
 Create a new ProductTerm using the given inputs and add it to the left hand side of this constraint. More...
 
void add_lhs (double c, ROCPPUnc_Ptr pUncertainty, ROCPPVarIF_Ptr pVariable)
 Create a new ProductTerm using the given inputs and add it to the left hand side of this constraint. More...
 
void add_lhs (double c, ROCPPUnc_Ptr pUncertainty)
 Create a new ProductTerm using the given inputs and add it to the left hand side of this constraint. More...
 
void add_lhs (double c, ROCPPVarIF_Ptr pVariable1, ROCPPVarIF_Ptr pVariable2)
 Create a new ProductTerm using the given inputs and add it to the left hand side of this constraint. More...
 
void add_lhs (double c, ROCPPUnc_Ptr pUncertainty, ROCPPVarIF_Ptr pVariable1, ROCPPVarIF_Ptr pVariable2)
 Create a new ProductTerm using the given inputs and add it to the left hand side of this constraint. More...
 
void add_lhs (ROCPPconstCstrTermIF_Ptr term)
 Add the given term to the left hand side of this constraint. More...
 
void add_lhs (double c, ROCPPconstCstrTermIF_Ptr term)
 Add the product of the given inputs into the left hand side of this constraint. More...
 
void add_lhs (ROCPPconstExpr_Ptr pExpression)
 Add the given expression to the left hand side of this constraint. More...
 
void add_lhs (double c, ROCPPconstExpr_Ptr pExpression)
 Add the given expression multiplied by c to the left hand side of this constraint. More...
 
void add_lhs (double c, ROCPPconstExpr_Ptr pExpression, ROCPPVarIF_Ptr pVariable)
 Add the product of the given inputs to the left hand side of this constraint. More...
 
void set_rhs (pair< double, bool > rhs)
 Set right-hand side parameter of this constraint. More...
 
ROCPPConstraintIF_Ptr mapVars (const map< string, ROCPPExpr_Ptr > &mapFromVarToExpression) const
 
ROCPPConstraintIF_Ptr mapUncs (const map< string, ROCPPExpr_Ptr > &mapFromUncToExpression) const
 
ROCPPConstraintIF_Ptr replaceTermWithVar (const multimap< string, ROCPPVarIF_Ptr > &term, ROCPPVarIF_Ptr var) const
 
ROCPPConstraintIF_Ptr replaceBilinearTerm (map< pair< string, string >, ROCPPVarIF_Ptr > &allTerm, uint &count) const
 
ROCPPConstraintIF_Ptr mapVars (const map< string, ROCPPVarIF_Ptr > &mapFromOldToNewVars) const
 
ROCPPConstraintIF_Ptr mapUnc (const map< string, ROCPPUnc_Ptr > &mapFromOldToNewUnc) const
 
void add_vars_involved_in_prod (dvContainer &dvs) const
 
void add_int_vars (dvContainer &dvs) const
 
uint getNumTimesTermAppears (const multimap< string, ROCPPVarIF_Ptr > &term) const
 
void getAllProductsOf2Variables (map< pair< string, string >, uint > &freqMap, map< pair< string, string >, multimap< string, ROCPPVarIF_Ptr > > &termMap) const
 
ROCPPconstdvContainer_Ptr getDVContainer () const
 Get the decision variable container of this constraint. More...
 
ROCPPconstuncContainer_Ptr getUncContainer () const
 Get the uncertain parameter container of this constraint. More...
 
uint getNumContVars () const
 Get the number of real-valued decision variables in this constraint. More...
 
uint getNumIntVars () const
 Get the number of integer decision variables in this constraint. More...
 
uint getNumBoolVars () const
 Get the number of boolean variables in this constraint. More...
 
uint getNumAdaptiveContVars () const
 Get the number of adaptive real-valued decision variables in this constraint. More...
 
uint getNumAdaptiveVars () const
 Get the number of adaptive decision variables in this constraint. More...
 
uint getTimeStage () const
 Get the maximum time-stage of any decision variable in the constraint. More...
 
size_t getNumUncertainties () const
 Get the number of uncertaint parameters in the constraint. More...
 
bool hasNonlinearities () const
 
bool hasProdsUncertainties () const
 
bool hasProdsContVars () const
 
bool isWellDefined () const
 Return true if the LHExpression::isWellDefined() is true and the right-hand side parameter is set. More...
 
bool hasNoDVs () const
 Return true if and only if the constraint has no decision variables. More...
 
bool isClassicConstraint () const
 Return true if and only if the constraint is a classic (equality or inequality) constraint. More...
 
virtual bool isEqConstraint () const =0
 
bool AnyVarIsInvolved (dvContainer &dvs) const
 
bool hasNormTerm () const
 Return true if and only if the constraint has a norm term. More...
 
bool isLinear () const
 
bool isQuadratic () const
 
pair< double, bool > get_rhs () const
 
ROCPPExpr_Ptr getLHS () const
 
ROCPPExpr_Ptr getLinearPart () const
 Get the part without norm term in the left-hand side expression of this constraint. More...
 
ROCPPNormTerm_Ptr getNormTerm () const
 Get the norm term in the left-hand side expression of this constraint. More...
 
ROCPPConstraintIF_Ptr Clone () const
 Set the right hand side of this constraint. More...
 
void WriteToStream (ofstream &ofs, uint cnt) const
 Write the constraint to a stream. More...
 
- Public Member Functions inherited from ConstraintIF
 ConstraintIF (bool definesUncertaintySet, bool isNAC=false)
 Constructor of the constraint interface class. More...
 
virtual ~ConstraintIF ()
 Destructor of the constraint interface class. More...
 
bool definesUncertaintySet () const
 Return true if and only if this constraint defines the uncertainty set. More...
 
bool isDeterministic () const
 Return true if and only if this constraint does not involve any uncertain parameters. More...
 
virtual bool isUseful (double epsilon=1.e-10) const
 Return false if and only if the left hand side is constant and the left and right hand side constants are equal, within epsilon (this constraint can be deleted) More...
 
bool isNAC () const
 Return true if and only if the constraint is a non-anticipativity constraint (useful for problems with decision-dependent information discovery) More...
 
virtual bool isSOSConstraint () const
 Return true if and only if the constraint is SOS. More...
 
virtual bool isIfThenConstraint () const
 Return true if and only if the constraint is a logical if then constraint (useful in CPLEX solver) More...
 
void setParams (bool defUncertaintyset, bool isNAC)
 Set the paramaters of this constraint. More...
 

Private Attributes

ROCPPExpr_Ptr m_pLHS
 Left-hand side expression of this constraint. More...
 
rhsParams m_rhsParams
 Right-hand side parameter of this constraint. More...
 

Additional Inherited Members

- Protected Attributes inherited from ConstraintIF
bool m_definesUncertaintySet
 Indicate whether this constraint defines uncertainty set or not. More...
 
bool m_isNAC
 Indicate whether this constraint is a non-anticipativity constraint or not. More...
 

Detailed Description

Classic constraint interface class.

Member Typedef Documentation

◆ const_iterator

◆ uncertaintiesIterator

typedef uncMapType::const_iterator ClassicConstraintIF::uncertaintiesIterator

Constant iterator in the uncertain parameter map.

Constructor & Destructor Documentation

◆ ClassicConstraintIF()

ClassicConstraintIF::ClassicConstraintIF ( bool  definesUncertaintySet,
bool  isNAC = false 
)

Constructor of classic constraint class.

Parameters
definesUncertaintySettrue if and only if this constraint is used to define the uncertainty set
isNACtrue if and only if this constraint is a non-anticipativity constraint

◆ ~ClassicConstraintIF()

ClassicConstraintIF::~ClassicConstraintIF ( )
inline

Destructor of classic constraint class.

Member Function Documentation

◆ add_int_vars()

void ClassicConstraintIF::add_int_vars ( dvContainer dvs) const
virtual
Note
Call LHExpression::add_int_vars() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ add_lhs() [1/11]

void ClassicConstraintIF::add_lhs ( double  c)

Create a new ProductTerm using the given input and add it to the left hand side of this constraint.

Parameters
cconstant to add to the expression

◆ add_lhs() [2/11]

void ClassicConstraintIF::add_lhs ( double  c,
ROCPPconstCstrTermIF_Ptr  term 
)

Add the product of the given inputs into the left hand side of this constraint.

Parameters
ccoefficient
termterm to add to expression after multiplying it by coefficient
Note
Call LHExpression::add(ROCPPconstCstrTermIF_Ptr) after multiplying term by c

◆ add_lhs() [3/11]

void ClassicConstraintIF::add_lhs ( double  c,
ROCPPconstExpr_Ptr  pExpression 
)

Add the given expression multiplied by c to the left hand side of this constraint.

Parameters
ccoefficient
pExpressionexpression to add to this expression after multiplying it by coefficient c
Note
Call LHExpression::add(ROCPPconstExpr_Ptr) after scaled

◆ add_lhs() [4/11]

void ClassicConstraintIF::add_lhs ( double  c,
ROCPPconstExpr_Ptr  pExpression,
ROCPPVarIF_Ptr  pVariable 
)

Add the product of the given inputs to the left hand side of this constraint.

Parameters
ccoefficient
pVariabledecision variable
pExpressionexpression to add to this expression after multiplying it by coefficient c and by decision variable pVariable
Note
Call LHExpression::add(ROCPPconstExpr_Ptr)

◆ add_lhs() [5/11]

void ClassicConstraintIF::add_lhs ( double  c,
ROCPPUnc_Ptr  pUncertainty 
)

Create a new ProductTerm using the given inputs and add it to the left hand side of this constraint.

Parameters
ccoefficient of the term to add
pUncertaintyuncertain parameter of the term to add

◆ add_lhs() [6/11]

void ClassicConstraintIF::add_lhs ( double  c,
ROCPPUnc_Ptr  pUncertainty,
ROCPPVarIF_Ptr  pVariable 
)

Create a new ProductTerm using the given inputs and add it to the left hand side of this constraint.

Parameters
ccoefficient of the term to add
pUncertaintyuncertain parameter of the term to add
pVariabledecision variable of the term to add

◆ add_lhs() [7/11]

void ClassicConstraintIF::add_lhs ( double  c,
ROCPPUnc_Ptr  pUncertainty,
ROCPPVarIF_Ptr  pVariable1,
ROCPPVarIF_Ptr  pVariable2 
)

Create a new ProductTerm using the given inputs and add it to the left hand side of this constraint.

Parameters
ccoefficient of the term to add
pUncertaintyuncertain parameter of the term to add
pVariable1first decision variable of the term to add
pVariable2second decision variable of the term to add

◆ add_lhs() [8/11]

void ClassicConstraintIF::add_lhs ( double  c,
ROCPPVarIF_Ptr  pVariable 
)

Create a new ProductTerm using the given inputs and add it to the left hand side of this constraint.

Parameters
ccoefficient of the term to add
pVariabledecision variable of the term to add

◆ add_lhs() [9/11]

void ClassicConstraintIF::add_lhs ( double  c,
ROCPPVarIF_Ptr  pVariable1,
ROCPPVarIF_Ptr  pVariable2 
)

Create a new ProductTerm using the given inputs and add it to the left hand side of this constraint.

Parameters
ccoefficient of the term to add
pVariable1first decision variable of the term to add
pVariable2second decision variable of the term to add

◆ add_lhs() [10/11]

void ClassicConstraintIF::add_lhs ( ROCPPconstCstrTermIF_Ptr  term)

Add the given term to the left hand side of this constraint.

Note
If the term already exists, change the coefficient
Warning
One expression can only have one norm term with coefficient equal to 1

◆ add_lhs() [11/11]

void ClassicConstraintIF::add_lhs ( ROCPPconstExpr_Ptr  pExpression)

Add the given expression to the left hand side of this constraint.

Parameters
pExpressionexpression to add to this expression after multiplying it by coefficient c
Note
Call LHExpression::add(ROCPPconstExpr_Ptr) after scaling it by

◆ add_vars_involved_in_prod()

void ClassicConstraintIF::add_vars_involved_in_prod ( dvContainer dvs) const
virtual
Note
Call LHExpression::hasProdsContVars() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ AnyVarIsInvolved()

bool ClassicConstraintIF::AnyVarIsInvolved ( dvContainer dvs) const
virtual
Note
Call LHExpression::AnyVarIsInvolved() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ begin()

ClassicConstraintIF::const_iterator ClassicConstraintIF::begin ( ) const
Note
Call LHExpression::begin() for the left-hand side expression of this constraint

◆ Clone()

ROCPPConstraintIF_Ptr ClassicConstraintIF::Clone ( ) const
virtual

Set the right hand side of this constraint.

Note
Only valid in classic constraint Return a copy of this constraint

Implements ConstraintIF.

◆ end()

ClassicConstraintIF::const_iterator ClassicConstraintIF::end ( ) const
Note
Call LHExpression::end() for the left-hand side expression of this constraint

◆ get_rhs()

pair< double, bool > ClassicConstraintIF::get_rhs ( ) const

◆ getAllProductsOf2Variables()

void ClassicConstraintIF::getAllProductsOf2Variables ( map< pair< string, string >, uint > &  freqMap,
map< pair< string, string >, multimap< string, ROCPPVarIF_Ptr > > &  termMap 
) const
virtual
Note
Call LHExpression::getAllProductsOf2Variables() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ getDVContainer()

ROCPPconstdvContainer_Ptr ClassicConstraintIF::getDVContainer ( ) const
virtual

Get the decision variable container of this constraint.

Implements ConstraintIF.

◆ getLHS()

ROCPPExpr_Ptr ClassicConstraintIF::getLHS ( ) const

◆ getLinearPart()

ROCPPExpr_Ptr ClassicConstraintIF::getLinearPart ( ) const

Get the part without norm term in the left-hand side expression of this constraint.

Note
Call LHExpression::getLineatPart()

◆ getNormTerm()

ROCPPNormTerm_Ptr ClassicConstraintIF::getNormTerm ( ) const

Get the norm term in the left-hand side expression of this constraint.

Note
Call LHExpression::getNormTerm()

◆ getNumAdaptiveContVars()

uint ClassicConstraintIF::getNumAdaptiveContVars ( ) const
virtual

Get the number of adaptive real-valued decision variables in this constraint.

Implements ConstraintIF.

◆ getNumAdaptiveVars()

uint ClassicConstraintIF::getNumAdaptiveVars ( ) const
virtual

Get the number of adaptive decision variables in this constraint.

Implements ConstraintIF.

◆ getNumBoolVars()

uint ClassicConstraintIF::getNumBoolVars ( ) const
virtual

Get the number of boolean variables in this constraint.

Implements ConstraintIF.

◆ getNumContVars()

uint ClassicConstraintIF::getNumContVars ( ) const
virtual

Get the number of real-valued decision variables in this constraint.

Implements ConstraintIF.

◆ getNumIntVars()

uint ClassicConstraintIF::getNumIntVars ( ) const
virtual

Get the number of integer decision variables in this constraint.

Implements ConstraintIF.

◆ getNumTimesTermAppears()

uint ClassicConstraintIF::getNumTimesTermAppears ( const multimap< string, ROCPPVarIF_Ptr > &  term) const
virtual
Note
Call LHExpression::getNumTimesTermAppears() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ getNumUncertainties()

size_t ClassicConstraintIF::getNumUncertainties ( ) const
virtual

Get the number of uncertaint parameters in the constraint.

Implements ConstraintIF.

◆ getTimeStage()

uint ClassicConstraintIF::getTimeStage ( ) const
virtual

Get the maximum time-stage of any decision variable in the constraint.

Implements ConstraintIF.

◆ getUncContainer()

ROCPPconstuncContainer_Ptr ClassicConstraintIF::getUncContainer ( ) const
virtual

Get the uncertain parameter container of this constraint.

Implements ConstraintIF.

◆ hasNoDVs()

bool ClassicConstraintIF::hasNoDVs ( ) const
virtual

Return true if and only if the constraint has no decision variables.

Implements ConstraintIF.

◆ hasNonlinearities()

bool ClassicConstraintIF::hasNonlinearities ( ) const
virtual
Note
Call LHExpression::hasNonlinearities() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ hasNormTerm()

bool ClassicConstraintIF::hasNormTerm ( ) const
virtual

Return true if and only if the constraint has a norm term.

Implements ConstraintIF.

◆ hasProdsContVars()

bool ClassicConstraintIF::hasProdsContVars ( ) const
virtual
Note
Call LHExpression::hasProdsContVars() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ hasProdsUncertainties()

bool ClassicConstraintIF::hasProdsUncertainties ( ) const
virtual
Note
Call LHExpression::hasProdsUncertainties() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ isClassicConstraint()

bool ClassicConstraintIF::isClassicConstraint ( ) const
inlinevirtual

Return true if and only if the constraint is a classic (equality or inequality) constraint.

Reimplemented from ConstraintIF.

◆ isEqConstraint()

virtual bool ClassicConstraintIF::isEqConstraint ( ) const
pure virtual

Implemented in EqConstraint, and IneqConstraint.

◆ isLinear()

bool ClassicConstraintIF::isLinear ( ) const

◆ isQuadratic()

bool ClassicConstraintIF::isQuadratic ( ) const

◆ isWellDefined()

bool ClassicConstraintIF::isWellDefined ( ) const
virtual

Return true if the LHExpression::isWellDefined() is true and the right-hand side parameter is set.

Implements ConstraintIF.

◆ mapUnc()

ROCPPConstraintIF_Ptr ClassicConstraintIF::mapUnc ( const map< string, ROCPPUnc_Ptr > &  mapFromOldToNewUnc) const
virtual
Note
Call LHExpression::mapUnc() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ mapUncs()

ROCPPConstraintIF_Ptr ClassicConstraintIF::mapUncs ( const map< string, ROCPPExpr_Ptr > &  mapFromUncToExpression) const
virtual
Note
Call LHExpression::mapUncs() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ mapVars() [1/2]

ROCPPConstraintIF_Ptr ClassicConstraintIF::mapVars ( const map< string, ROCPPExpr_Ptr > &  mapFromVarToExpression) const
virtual
Note
Call LHExpression::mapVars(const map<string, ROCPPExpr_Ptr>) for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ mapVars() [2/2]

ROCPPConstraintIF_Ptr ClassicConstraintIF::mapVars ( const map< string, ROCPPVarIF_Ptr > &  mapFromOldToNewVars) const
virtual
Note
Call LHExpression::mapVars(const map<string,ROCPPVarIF_Ptr>) for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ replaceBilinearTerm()

ROCPPConstraintIF_Ptr ClassicConstraintIF::replaceBilinearTerm ( map< pair< string, string >, ROCPPVarIF_Ptr > &  allTerm,
uint count 
) const
virtual
Note
Call LHExpression::replaceBilinearTerm() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ replaceTermWithVar()

ROCPPConstraintIF_Ptr ClassicConstraintIF::replaceTermWithVar ( const multimap< string, ROCPPVarIF_Ptr > &  term,
ROCPPVarIF_Ptr  var 
) const
virtual
Note
Call LHExpression::replaceTermWithVar() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ set_rhs()

void ClassicConstraintIF::set_rhs ( pair< double, bool >  rhs)

Set right-hand side parameter of this constraint.

Parameters
rhsfirst element of the pair is the right-hand side parameter, the second one is true if the parameter is 0, false otherwise

◆ uncertaintiesBegin()

ClassicConstraintIF::uncertaintiesIterator ClassicConstraintIF::uncertaintiesBegin ( ) const
Note
Call LHExpression::uncBegin() for the left-hand side expression of this constraint

◆ uncertaintiesEnd()

ClassicConstraintIF::uncertaintiesIterator ClassicConstraintIF::uncertaintiesEnd ( ) const
Note
Call LHExpression::uncEnd() for the left-hand side expression of this constraint

◆ varsBegin()

ConstraintIF::varsIterator ClassicConstraintIF::varsBegin ( ) const
virtual
Note
Call LHExpression::varsBegin() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ varsEnd()

ConstraintIF::varsIterator ClassicConstraintIF::varsEnd ( ) const
virtual
Note
Call LHExpression::varsEnd() for the left-hand side expression of this constraint

Implements ConstraintIF.

◆ WriteToStream()

void ClassicConstraintIF::WriteToStream ( ofstream &  ofs,
uint  cnt 
) const
virtual

Write the constraint to a stream.

Parameters
ofsoutput file stream
cntnumber (counter) of the constraint

Implements ConstraintIF.

Member Data Documentation

◆ m_pLHS

ROCPPExpr_Ptr ClassicConstraintIF::m_pLHS
private

Left-hand side expression of this constraint.

◆ m_rhsParams

rhsParams ClassicConstraintIF::m_rhsParams
private

Right-hand side parameter of this constraint.