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

Constraint term interface. More...

#include <ConstraintTerm.hpp>

Inheritance diagram for ConstraintTermIF:

Public Types

typedef dvMapType::const_iterator dvIterator
 Constant iterator for product term decision variable map. More...
 
typedef uncMapType::const_iterator uncIterator
 Constant iterator for product term uncertain parameter map. More...
 

Public Member Functions

 ConstraintTermIF ()
 Constructor of the ConstraintTermIF class. More...
 
virtual ~ConstraintTermIF ()
 Destructor of the ConstraintTermIF class. More...
 
virtual bool operator== (const ProductTerm &other) const
 Check it two terms are equal. More...
 
virtual void operator*= (ROCPPconstCstrTermIF_Ptr term)
 Multiply this object with the given term. More...
 
virtual void operator*= (ROCPPVarIF_Ptr var)
 Multiply this object with the given decision variable. More...
 
virtual void operator*= (ROCPPUnc_Ptr unc)
 Multiply this object with the given uncertainty. More...
 
virtual void operator*= (double a)
 Multiply this object with the given coefficient␐␐␐. More...
 
dvIterator varsBegin () const
 Return a constant iterator pointing to the beginning of the decision variable map (m_pDVContainer) More...
 
dvIterator varsEnd () const
 Return a constant iterator pointing to the end of the decision variable map (m_pDVContainer) More...
 
uncIterator uncBegin () const
 Return a constant iterator pointing to the beginning of the uncertain parameter map (m_pUncContainer) More...
 
uncIterator uncEnd () const
 Return a constant iterator pointing to the end of the uncertain parameter map (m_pUncContainer) More...
 
virtual ROCPPCstrTermIF_Ptr mapTermVars (const map< string, ROCPPVarIF_Ptr > &mapFromOldToNewVars) const =0
 Map the old decision variables in this term to new variables. More...
 
virtual ROCPPCstrTermIF_Ptr mapTermUnc (const map< string, ROCPPUnc_Ptr > &mapFromOldToNewUnc) const =0
 Map the old uncertain parameters in this term to new uncertainties. More...
 
virtual ROCPPExpr_Ptr mapVars (const map< string, ROCPPExpr_Ptr > &mapFromVarToExpression) const =0
 Map the old variables in this term to expressions. More...
 
virtual ROCPPExpr_Ptr mapUncs (const map< string, ROCPPExpr_Ptr > &mapFromUncToExpression) const =0
 Map the old uncertainties in this term to expressions. More...
 
virtual ROCPPCstrTermIF_Ptr replaceTermWithVar (const multimap< string, ROCPPVarIF_Ptr > &term, ROCPPVarIF_Ptr var) const =0
 Replace the given term in this term with the given decision variable. More...
 
virtual pair< bool, ROCPPCstrTermIF_PtrfactorOut (ROCPPUnc_Ptr unc) const
 Calculate the coeffiecient of the given uncertainty. More...
 
virtual void add (ROCPPconstCstrTermIF_Ptr other)
 Add a given constraint term to this term. More...
 
virtual void add_vars_involved_in_prod (dvContainer &dvs) const =0
 Add the decisions variables involved in a product in this term to the given container dvs. More...
 
void add_int_vars (dvContainer &dvs) const
 Add the integer variables in this term to the given container. More...
 
virtual double evaluate (const map< string, double > &valuesMap) const =0
 Calculate the value of this term. More...
 
virtual void getAllProductsOf2Variables (map< pair< string, string >, uint > &freqMap, map< pair< string, string >, multimap< string, ROCPPVarIF_Ptr > > &termMap) const =0
 Get the products of any two variables in this term. More...
 
virtual bool isProductTerm () const
 Return true if and only if the term is of type prodTerm. More...
 
virtual bool isNonlinearProdTerm () const
 Return true if and only if the term is a product term and is nonlinear, i.e., if it involves products of decision variables. More...
 
virtual bool isNormTerm () const
 Return true if and only if the term is of type normTerm. More...
 
virtual constraintTermType getType () const =0
 Return the type of the term. More...
 
virtual bool hasNonlinearities () const =0
 Return true if and only if there is a product between two decision variables in this term. More...
 
virtual bool hasProdsUncertainties () const =0
 Return true if and only if there is a product between two uncertainties in this term. More...
 
virtual bool hasProdsContVars () const =0
 Return true if and only if there is a product between two continuous variables in this term. More...
 
virtual bool isConstant () const
 Return true if and only if the term is just a constant. More...
 
virtual bool isDeterministic () const
 Return true if and only if the term is deterministic. More...
 
virtual bool isLinear () const
 Return true if and only if the term is linear. More...
 
virtual bool isQuadratic () const
 Return true if and only if the term is quadratic. More...
 
virtual bool is_same (ROCPPconstCstrTermIF_Ptr other) const =0
 Return true if and only if the given constraint term is the same as this object. More...
 
virtual bool isWellDefined () const =0
 Return true if and only if this object is not empty. More...
 
ROCPPconstdvContainer_Ptr getDVContainer () const
 Return the decision variable container (m_dvContainer) of this object. More...
 
ROCPPconstuncContainer_Ptr getUncContainer () const
 Return the uncertainty container (m_uncContainer) in this object. More...
 
virtual double getCoeff () const
 Return the coefficient (a double type) of this object. More...
 
uint getNumContVars () const
 Return the number of real-valued decision variables in this term. More...
 
uint getNumIntVars () const
 Return the number of integer decision variables in this term. More...
 
uint getNumBoolVars () const
 Return the number of boolen decision variables in this term. More...
 
uint getNumAdaptiveContVars () const
 Return the number of adaptive real-valued decision variables in this term. More...
 
uint getNumAdaptiveVars () const
 Return the number of adaptive decision variables in this term. More...
 
size_t getNumUncertainties () const
 Return the number of uncertain parameters in this term. More...
 
size_t getNumVars () const
 Return the number of decision variables in this term. More...
 
bool allIntVarsBounded () const
 Return true if and only if all integer decision variables in this term are bounded. More...
 
virtual uint getNumTimesTermAppears (const multimap< string, ROCPPVarIF_Ptr > &term) const =0
 Get the number of times the given term appears in this object. More...
 
virtual ROCPPCstrTermIF_Ptr Clone () const =0
 Clone this term and return a pointer to the clone. More...
 
virtual void WriteToStream (ofstream &ofs) const =0
 Print this term to the stream ofs. More...
 

Protected Attributes

ROCPPdvContainer_Ptr m_pDVContainer
 Decision variable container. More...
 
ROCPPuncContainer_Ptr m_pUncContainer
 Uncertain parameter container. More...
 

Detailed Description

Constraint term interface.

Used to define a term in a constraint or in the objective function

Member Typedef Documentation

◆ dvIterator

typedef dvMapType::const_iterator ConstraintTermIF::dvIterator

Constant iterator for product term decision variable map.

◆ uncIterator

typedef uncMapType::const_iterator ConstraintTermIF::uncIterator

Constant iterator for product term uncertain parameter map.

Constructor & Destructor Documentation

◆ ConstraintTermIF()

ConstraintTermIF::ConstraintTermIF ( )

Constructor of the ConstraintTermIF class.

◆ ~ConstraintTermIF()

virtual ConstraintTermIF::~ConstraintTermIF ( )
inlinevirtual

Destructor of the ConstraintTermIF class.

Member Function Documentation

◆ add()

void ConstraintTermIF::add ( ROCPPconstCstrTermIF_Ptr  other)
virtual

Add a given constraint term to this term.

Note
Only valid in class ProductTerm. Throws an exception if the two terms are not identical

Reimplemented in ProductTerm.

◆ add_int_vars()

void ConstraintTermIF::add_int_vars ( dvContainer dvs) const

Add the integer variables in this term to the given container.

◆ add_vars_involved_in_prod()

virtual void ConstraintTermIF::add_vars_involved_in_prod ( dvContainer dvs) const
pure virtual

Add the decisions variables involved in a product in this term to the given container dvs.

Implemented in NormTerm, and ProductTerm.

◆ allIntVarsBounded()

bool ConstraintTermIF::allIntVarsBounded ( ) const

Return true if and only if all integer decision variables in this term are bounded.

◆ Clone()

virtual ROCPPCstrTermIF_Ptr ConstraintTermIF::Clone ( ) const
pure virtual

Clone this term and return a pointer to the clone.

Implemented in NormTerm, and ProductTerm.

◆ evaluate()

virtual double ConstraintTermIF::evaluate ( const map< string, double > &  valuesMap) const
pure virtual

Calculate the value of this term.

Parameters
valuesMapa map from name of the variable to its value

Implemented in NormTerm, and ProductTerm.

◆ factorOut()

pair< bool, ROCPPCstrTermIF_Ptr > ConstraintTermIF::factorOut ( ROCPPUnc_Ptr  unc) const
virtual

Calculate the coeffiecient of the given uncertainty.

Note
Only valid in class ProductTerm

Reimplemented in ProductTerm.

◆ getAllProductsOf2Variables()

virtual void ConstraintTermIF::getAllProductsOf2Variables ( map< pair< string, string >, uint > &  freqMap,
map< pair< string, string >, multimap< string, ROCPPVarIF_Ptr > > &  termMap 
) const
pure virtual

Get the products of any two variables in this term.

Parameters
freqMapmap from the pair of the variable names in each product to the frequency of this product
termMapmap from the pair of the variable names in each product to the map of the name to the variable involved in the product
Note
The calculated results are stored in the two inputs of this method

Implemented in NormTerm, and ProductTerm.

◆ getCoeff()

double ConstraintTermIF::getCoeff ( ) const
virtual

Return the coefficient (a double type) of this object.

Note
Only valid in class ProductTerm

Reimplemented in ProductTerm.

◆ getDVContainer()

ROCPPconstdvContainer_Ptr ConstraintTermIF::getDVContainer ( ) const
inline

Return the decision variable container (m_dvContainer) of this object.

◆ getNumAdaptiveContVars()

uint ConstraintTermIF::getNumAdaptiveContVars ( ) const

Return the number of adaptive real-valued decision variables in this term.

◆ getNumAdaptiveVars()

uint ConstraintTermIF::getNumAdaptiveVars ( ) const

Return the number of adaptive decision variables in this term.

◆ getNumBoolVars()

uint ConstraintTermIF::getNumBoolVars ( ) const

Return the number of boolen decision variables in this term.

◆ getNumContVars()

uint ConstraintTermIF::getNumContVars ( ) const

Return the number of real-valued decision variables in this term.

◆ getNumIntVars()

uint ConstraintTermIF::getNumIntVars ( ) const

Return the number of integer decision variables in this term.

◆ getNumTimesTermAppears()

virtual uint ConstraintTermIF::getNumTimesTermAppears ( const multimap< string, ROCPPVarIF_Ptr > &  term) const
pure virtual

Get the number of times the given term appears in this object.

Parameters
termmap from name of the variable to the pointer of the variable involved in the term

Implemented in NormTerm, and ProductTerm.

◆ getNumUncertainties()

size_t ConstraintTermIF::getNumUncertainties ( ) const

Return the number of uncertain parameters in this term.

◆ getNumVars()

size_t ConstraintTermIF::getNumVars ( ) const

Return the number of decision variables in this term.

◆ getType()

virtual constraintTermType ConstraintTermIF::getType ( ) const
pure virtual

Return the type of the term.

Returns
enumerated type, term's type

Implemented in NormTerm, and ProductTerm.

◆ getUncContainer()

ROCPPconstuncContainer_Ptr ConstraintTermIF::getUncContainer ( ) const
inline

Return the uncertainty container (m_uncContainer) in this object.

◆ hasNonlinearities()

virtual bool ConstraintTermIF::hasNonlinearities ( ) const
pure virtual

Return true if and only if there is a product between two decision variables in this term.

Implemented in NormTerm, and ProductTerm.

◆ hasProdsContVars()

virtual bool ConstraintTermIF::hasProdsContVars ( ) const
pure virtual

Return true if and only if there is a product between two continuous variables in this term.

Implemented in NormTerm, and ProductTerm.

◆ hasProdsUncertainties()

virtual bool ConstraintTermIF::hasProdsUncertainties ( ) const
pure virtual

Return true if and only if there is a product between two uncertainties in this term.

Implemented in NormTerm, and ProductTerm.

◆ is_same()

virtual bool ConstraintTermIF::is_same ( ROCPPconstCstrTermIF_Ptr  other) const
pure virtual

Return true if and only if the given constraint term is the same as this object.

Implemented in NormTerm, and ProductTerm.

◆ isConstant()

bool ConstraintTermIF::isConstant ( ) const
virtual

Return true if and only if the term is just a constant.

Note
Only valid in class ProductTerm

Reimplemented in ProductTerm.

◆ isDeterministic()

bool ConstraintTermIF::isDeterministic ( ) const
virtual

Return true if and only if the term is deterministic.

Note
Only valid in class ProductTerm

Reimplemented in ProductTerm.

◆ isLinear()

bool ConstraintTermIF::isLinear ( ) const
virtual

Return true if and only if the term is linear.

Note
Only valid in class ProductTerm

Reimplemented in ProductTerm.

◆ isNonlinearProdTerm()

bool ConstraintTermIF::isNonlinearProdTerm ( ) const
virtual

Return true if and only if the term is a product term and is nonlinear, i.e., if it involves products of decision variables.

◆ isNormTerm()

virtual bool ConstraintTermIF::isNormTerm ( ) const
inlinevirtual

Return true if and only if the term is of type normTerm.

Reimplemented in NormTerm.

◆ isProductTerm()

virtual bool ConstraintTermIF::isProductTerm ( ) const
inlinevirtual

Return true if and only if the term is of type prodTerm.

Reimplemented in ProductTerm.

◆ isQuadratic()

bool ConstraintTermIF::isQuadratic ( ) const
virtual

Return true if and only if the term is quadratic.

Note
Only valid in class ProductTerm

Reimplemented in ProductTerm.

◆ isWellDefined()

virtual bool ConstraintTermIF::isWellDefined ( ) const
pure virtual

Return true if and only if this object is not empty.

Implemented in NormTerm, and ProductTerm.

◆ mapTermUnc()

virtual ROCPPCstrTermIF_Ptr ConstraintTermIF::mapTermUnc ( const map< string, ROCPPUnc_Ptr > &  mapFromOldToNewUnc) const
pure virtual

Map the old uncertain parameters in this term to new uncertainties.

Parameters
mapFromOldToNewUncmap from old uncertainty name to new uncertainty pointer

Implemented in NormTerm, and ProductTerm.

◆ mapTermVars()

virtual ROCPPCstrTermIF_Ptr ConstraintTermIF::mapTermVars ( const map< string, ROCPPVarIF_Ptr > &  mapFromOldToNewVars) const
pure virtual

Map the old decision variables in this term to new variables.

Parameters
mapFromOldToNewVarsmap from old variable name to new variable pointer

Implemented in NormTerm, and ProductTerm.

◆ mapUncs()

virtual ROCPPExpr_Ptr ConstraintTermIF::mapUncs ( const map< string, ROCPPExpr_Ptr > &  mapFromUncToExpression) const
pure virtual

Map the old uncertainties in this term to expressions.

Parameters
mapFromUncToExpressionmap from uncertain parameter names to pointers to expressions

Implemented in NormTerm, and ProductTerm.

◆ mapVars()

virtual ROCPPExpr_Ptr ConstraintTermIF::mapVars ( const map< string, ROCPPExpr_Ptr > &  mapFromVarToExpression) const
pure virtual

Map the old variables in this term to expressions.

Parameters
mapFromVarToExpressionmap from old variables names to pointers to expressions

Implemented in NormTerm, and ProductTerm.

◆ operator*=() [1/4]

void ConstraintTermIF::operator*= ( double  a)
virtual

Multiply this object with the given coefficient␐␐␐.

Note
only valid in ProductTerm

Reimplemented in ProductTerm.

◆ operator*=() [2/4]

void ConstraintTermIF::operator*= ( ROCPPconstCstrTermIF_Ptr  term)
virtual

Multiply this object with the given term.

Note
only valid in ProductTerm

Reimplemented in ProductTerm.

◆ operator*=() [3/4]

void ConstraintTermIF::operator*= ( ROCPPUnc_Ptr  unc)
virtual

Multiply this object with the given uncertainty.

Note
only valid in ProductTerm

Reimplemented in ProductTerm.

◆ operator*=() [4/4]

void ConstraintTermIF::operator*= ( ROCPPVarIF_Ptr  var)
virtual

Multiply this object with the given decision variable.

Note
only valid in ProductTerm

Reimplemented in ProductTerm.

◆ operator==()

bool ConstraintTermIF::operator== ( const ProductTerm other) const
virtual

Check it two terms are equal.

Note
only valid in ProductTerm

Reimplemented in ProductTerm.

◆ replaceTermWithVar()

virtual ROCPPCstrTermIF_Ptr ConstraintTermIF::replaceTermWithVar ( const multimap< string, ROCPPVarIF_Ptr > &  term,
ROCPPVarIF_Ptr  var 
) const
pure virtual

Replace the given term in this term with the given decision variable.

Parameters
termmap including the decision variables in the term to be replaced
varvariable used to replace the term
Note
Only replace the nonlinear term with variable

Implemented in NormTerm, and ProductTerm.

◆ uncBegin()

uncIterator ConstraintTermIF::uncBegin ( ) const
inline

Return a constant iterator pointing to the beginning of the uncertain parameter map (m_pUncContainer)

◆ uncEnd()

uncIterator ConstraintTermIF::uncEnd ( ) const
inline

Return a constant iterator pointing to the end of the uncertain parameter map (m_pUncContainer)

◆ varsBegin()

dvIterator ConstraintTermIF::varsBegin ( ) const
inline

Return a constant iterator pointing to the beginning of the decision variable map (m_pDVContainer)

◆ varsEnd()

dvIterator ConstraintTermIF::varsEnd ( ) const
inline

Return a constant iterator pointing to the end of the decision variable map (m_pDVContainer)

◆ WriteToStream()

virtual void ConstraintTermIF::WriteToStream ( ofstream &  ofs) const
pure virtual

Print this term to the stream ofs.

Parameters
ofsoutput file stream

Implemented in NormTerm, and ProductTerm.

Member Data Documentation

◆ m_pDVContainer

ROCPPdvContainer_Ptr ConstraintTermIF::m_pDVContainer
protected

Decision variable container.

◆ m_pUncContainer

ROCPPuncContainer_Ptr ConstraintTermIF::m_pUncContainer
protected

Uncertain parameter container.