ROC++  v1.2
Automatic Robust Optimization in C++
NormTerm Class Reference

Norm term (norm of vector of left hand-side expressions) More...

#include <ConstraintTerm.hpp>

Inheritance diagram for NormTerm:
Collaboration diagram for NormTerm:

Public Types

typedef vector< ROCPPExpr_Ptr >::const_iterator const_iterator
 Constant iterator in vector of LHSExpression. More...
 
- Public Types inherited from ConstraintTermIF
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

 NormTerm (const vector< ROCPPExpr_Ptr > &pExpressionVec)
 Constructor of NormTerm. More...
 
 ~NormTerm ()
 Destructor of NormTerm. More...
 
const_iterator begin () const
 Return a const iterator pointing to the begin of the m_pExpressionVec. More...
 
const_iterator end () const
 Return a const iterator pointing to the end of the m_pExpressionVec. More...
 
ROCPPCstrTermIF_Ptr mapTermVars (const map< string, ROCPPVarIF_Ptr > &mapFromOldToNewVars) const
 Map the old decision variables in this term to new variables. More...
 
ROCPPCstrTermIF_Ptr mapTermUnc (const map< string, ROCPPUnc_Ptr > &mapFromOldToNewUnc) const
 Map the old uncertain parameters in this term to new uncertainties. More...
 
ROCPPExpr_Ptr mapVars (const map< string, ROCPPExpr_Ptr > &mapFromVarToExpression) const
 Map the old variables in this term to expressions. More...
 
ROCPPExpr_Ptr mapUncs (const map< string, ROCPPExpr_Ptr > &mapFromUncToExpression) const
 Map the old uncertainties in this term to expressions. More...
 
ROCPPCstrTermIF_Ptr replaceTermWithVar (const multimap< string, ROCPPVarIF_Ptr > &term, ROCPPVarIF_Ptr var) const
 Replace the given term in this term with the given decision variable. More...
 
void add_vars_involved_in_prod (dvContainer &dvs) const
 Add the decisions variables involved in a product in this term to the given container dvs. More...
 
bool isNormTerm () const
 Return true if and only if the term is of type normTerm. More...
 
constraintTermType getType () const
 Return the type of the term. More...
 
size_t getNumTerms () const
 Return the number of elements in the norm term. More...
 
bool hasNonlinearities () const
 Return true if and only if there is a product between two decision variables in this term. More...
 
bool hasProdsUncertainties () const
 Return true if and only if there is a product between two uncertainties in this term. More...
 
bool hasProdsContVars () const
 Return true if and only if there is a product between two continuous variables in this term. More...
 
bool isWellDefined () const
 Return true if and only if this object is not empty. More...
 
bool is_same (ROCPPconstCstrTermIF_Ptr other) const
 Return true if and only if the given constraint term is the same as this object. More...
 
uint getNumTimesTermAppears (const multimap< string, ROCPPVarIF_Ptr > &term) const
 Get the number of times the given term appears in this object. More...
 
void getAllProductsOf2Variables (map< pair< string, string >, uint > &freqMap, map< pair< string, string >, multimap< string, ROCPPVarIF_Ptr > > &termMap) const
 Get the products of any two variables in this term. More...
 
double evaluate (const map< string, double > &valuesMap) const
 Calculate the value of this term. More...
 
ROCPPCstrTermIF_Ptr Clone () const
 Clone this term and return a pointer to the clone. More...
 
void WriteToStream (ofstream &ofs) const
 Print this term to the stream ofs. More...
 
- Public Member Functions inherited from ConstraintTermIF
 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 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...
 
void add_int_vars (dvContainer &dvs) const
 Add the integer variables in this term to the given container. 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 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...
 
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...
 

Private Attributes

vector< ROCPPExpr_Ptrm_pExpressionVec
 Vector of elements(expressions) involved in this norm term. More...
 

Additional Inherited Members

- Protected Attributes inherited from ConstraintTermIF
ROCPPdvContainer_Ptr m_pDVContainer
 Decision variable container. More...
 
ROCPPuncContainer_Ptr m_pUncContainer
 Uncertain parameter container. More...
 

Detailed Description

Norm term (norm of vector of left hand-side expressions)

Member Typedef Documentation

◆ const_iterator

Constant iterator in vector of LHSExpression.

Constructor & Destructor Documentation

◆ NormTerm()

NormTerm::NormTerm ( const vector< ROCPPExpr_Ptr > &  pExpressionVec)

Constructor of NormTerm.

Parameters
pExpressionVecvector of expressions, every expression is an element in the norm term

◆ ~NormTerm()

NormTerm::~NormTerm ( )
inline

Destructor of NormTerm.

Member Function Documentation

◆ add_vars_involved_in_prod()

void NormTerm::add_vars_involved_in_prod ( dvContainer dvs) const
virtual

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

Implements ConstraintTermIF.

◆ begin()

const_iterator NormTerm::begin ( ) const
inline

Return a const iterator pointing to the begin of the m_pExpressionVec.

◆ Clone()

ROCPPCstrTermIF_Ptr NormTerm::Clone ( ) const
virtual

Clone this term and return a pointer to the clone.

Implements ConstraintTermIF.

◆ end()

const_iterator NormTerm::end ( ) const
inline

Return a const iterator pointing to the end of the m_pExpressionVec.

◆ evaluate()

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

Calculate the value of this term.

Parameters
valuesMapa map from name of the variable to its value

Implements ConstraintTermIF.

◆ getAllProductsOf2Variables()

void NormTerm::getAllProductsOf2Variables ( map< pair< string, string >, uint > &  freqMap,
map< pair< string, string >, multimap< string, ROCPPVarIF_Ptr > > &  termMap 
) const
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

Implements ConstraintTermIF.

◆ getNumTerms()

size_t NormTerm::getNumTerms ( ) const
inline

Return the number of elements in the norm term.

◆ getNumTimesTermAppears()

uint NormTerm::getNumTimesTermAppears ( const multimap< string, ROCPPVarIF_Ptr > &  term) const
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

Implements ConstraintTermIF.

◆ getType()

constraintTermType NormTerm::getType ( ) const
virtual

Return the type of the term.

Returns
enumerated type, term's type

Implements ConstraintTermIF.

◆ hasNonlinearities()

bool NormTerm::hasNonlinearities ( ) const
virtual

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

Implements ConstraintTermIF.

◆ hasProdsContVars()

bool NormTerm::hasProdsContVars ( ) const
virtual

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

Implements ConstraintTermIF.

◆ hasProdsUncertainties()

bool NormTerm::hasProdsUncertainties ( ) const
virtual

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

Implements ConstraintTermIF.

◆ is_same()

bool NormTerm::is_same ( ROCPPconstCstrTermIF_Ptr  other) const
virtual

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

Implements ConstraintTermIF.

◆ isNormTerm()

bool NormTerm::isNormTerm ( ) const
inlinevirtual

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

Reimplemented from ConstraintTermIF.

◆ isWellDefined()

bool NormTerm::isWellDefined ( ) const
virtual

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

Implements ConstraintTermIF.

◆ mapTermUnc()

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

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

Parameters
mapFromOldToNewUncmap from old uncertainty name to new uncertainty pointer

Implements ConstraintTermIF.

◆ mapTermVars()

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

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

Parameters
mapFromOldToNewVarsmap from old variable name to new variable pointer

Implements ConstraintTermIF.

◆ mapUncs()

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

Map the old uncertainties in this term to expressions.

Parameters
mapFromUncToExpressionmap from uncertain parameter names to pointers to expressions

Implements ConstraintTermIF.

◆ mapVars()

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

Map the old variables in this term to expressions.

Parameters
mapFromVarToExpressionmap from old variables names to pointers to expressions

Implements ConstraintTermIF.

◆ replaceTermWithVar()

ROCPPCstrTermIF_Ptr NormTerm::replaceTermWithVar ( const multimap< string, ROCPPVarIF_Ptr > &  term,
ROCPPVarIF_Ptr  var 
) const
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

Implements ConstraintTermIF.

◆ WriteToStream()

void NormTerm::WriteToStream ( ofstream &  ofs) const
virtual

Print this term to the stream ofs.

Parameters
ofsoutput file stream

Implements ConstraintTermIF.

Member Data Documentation

◆ m_pExpressionVec

vector<ROCPPExpr_Ptr> NormTerm::m_pExpressionVec
private

Vector of elements(expressions) involved in this norm term.