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

Piecewise linear convex objective function. More...

#include <ObjectiveFunction.hpp>

Inheritance diagram for MaxObjective:
Collaboration diagram for MaxObjective:

Public Types

typedef vector< ROCPPExpr_Ptr >::const_iterator obj_iterator
 Constant iterator on the parts of the objective function. More...
 
- Public Types inherited from ObjectiveFunctionIF
typedef dvMapType::const_iterator varsIterator
 Constant iterator to decision variable map. More...
 
typedef uncMapType::const_iterator uncsIterator
 Constant iterator to uncertain parameter map. More...
 
typedef vector< ROCPPExpr_Ptr >::const_iterator obj_fun_iterator
 Constant iterator to a collection of LHSExpressions defining the objective function. More...
 

Public Member Functions

 MaxObjective ()
 Constructor of the MaxObjective class. More...
 
 MaxObjective (vector< ROCPPExpr_Ptr > objFuns)
 Constructor of the MaxObjective class. More...
 
 ~MaxObjective ()
 Destructor of the MaxObjective class. More...
 
varsIterator varsBegin () const
 
varsIterator varsEnd () const
 
uncsIterator uncBegin () const
 
uncsIterator uncEnd () const
 
obj_iterator objectiveBegin () const
 Return a constant iterator pointing to the beginning of the vector of objective functions. More...
 
obj_iterator objectiveEnd () const
 Return a constant iterator pointing to the end of the vector of objective functions. More...
 
void add_to_obj (ROCPPVarIF_Ptr pVar, double cost)
 Add the product of the inputs as a new term to all parts of the objective function. More...
 
virtual void add_vars_involved_in_prod (dvContainer &dvs) const
 
virtual void add_int_vars (dvContainer &dvs) const
 
ROCPPObjectiveIF_Ptr mapObjVars (const map< string, ROCPPVarIF_Ptr > &mapFromOldToNewVars) const
 
ROCPPObjectiveIF_Ptr mapObjUnc (const map< string, ROCPPUnc_Ptr > &mapFromOldToNewUnc) const
 
ROCPPObjectiveIF_Ptr mapVars (const map< string, ROCPPExpr_Ptr > &mapFromVarToExpression) const
 
ROCPPObjectiveIF_Ptr mapUncs (const map< string, ROCPPExpr_Ptr > &mapFromUncToExpression) const
 
ROCPPObjectiveIF_Ptr replaceTermWithVar (const multimap< string, ROCPPVarIF_Ptr > &term, ROCPPVarIF_Ptr var) const
 Replace in this objective function the term given with the decision variable provided. More...
 
void convertToEpigraph (ROCPPVarIF_Ptr epigraphVar, vector< ROCPPConstraintIF_Ptr > &epigraphConstraints) const
 Convert the objective function to constraints using an epigraph reformulation. More...
 
size_t getNumTermsMaxObjective () const
 Get the number of terms in the objective function. More...
 
uint getNumTimesTermAppears (const multimap< string, ROCPPVarIF_Ptr > &term) const
 Get the number of times the term given in the multimap appears in this objective function. More...
 
vector< ROCPPExpr_PtrgetObj () const
 Get the vector of all objective functions. More...
 
ROCPPExpr_Ptr getObj (uint i) const
 Get the i th objective function expression. More...
 
bool isMaxObjective () const
 Return true if this objective function is given as the maximum of finitely many linear functions. More...
 
bool hasNonlinearities () const
 Return true if there is a product between two decision variables in this objective function. More...
 
bool hasProdsUncertainties () const
 Return true if there is a product between two uncertain parameters in this objective function. More...
 
bool hasProdsContVars () const
 Return true if there is a product between two continuous variables in this objective function. More...
 
bool isDeterministic () const
 Return true if this objective function does not involve any uncertain parameters. More...
 
uint getNumAdaptiveVars () const
 Get the number of adaptive decision variables in this objective function. More...
 
uint getTimeStage () const
 Get the maximum time-stage of any decision variable in the constraint. More...
 
bool varIsInvolved (string varName, uint i=1) const
 Check whether the given variable is involved in the specific objective. More...
 
ROCPPObjectiveIF_Ptr Clone () const
 
void WriteToStream (ofstream &ofs)
 Write the objective function to a stream. More...
 
- Public Member Functions inherited from ObjectiveFunctionIF
 ObjectiveFunctionIF (objType type)
 Constructor of the objective function interface class. More...
 
virtual ~ObjectiveFunctionIF ()
 Destructor of the objective function interface class. More...
 
void checkCompatibility (ROCPPExpr_Ptr pExpression) const
 Check compatibility for the given expression to be given as (one of the) objective functions. More...
 
objType getObjType () const
 Get the objective function type (linear or piecewise linear and convex) More...
 
virtual bool isSimpleObjective () const
 Return true if this objective function is linear. More...
 

Private Attributes

vector< ROCPPExpr_Ptrm_pObjFuns
 Vector of the objective expressions. More...
 
ROCPPdvContainer_Ptr m_dvContainer
 Decision variable container. More...
 
ROCPPuncContainer_Ptr m_uncContainer
 Uncertain parameter container. More...
 

Detailed Description

Piecewise linear convex objective function.

Member Typedef Documentation

◆ obj_iterator

typedef vector<ROCPPExpr_Ptr>::const_iterator MaxObjective::obj_iterator

Constant iterator on the parts of the objective function.

Constructor & Destructor Documentation

◆ MaxObjective() [1/2]

MaxObjective::MaxObjective ( )

Constructor of the MaxObjective class.

◆ MaxObjective() [2/2]

MaxObjective::MaxObjective ( vector< ROCPPExpr_Ptr objFuns)

Constructor of the MaxObjective class.

◆ ~MaxObjective()

MaxObjective::~MaxObjective ( )
inline

Destructor of the MaxObjective class.

Member Function Documentation

◆ add_int_vars()

void MaxObjective::add_int_vars ( dvContainer dvs) const
virtual
Note
Call dvContainter::add_int_vars() on the dvContainer of this objective

Implements ObjectiveFunctionIF.

◆ add_to_obj()

void MaxObjective::add_to_obj ( ROCPPVarIF_Ptr  pVar,
double  cost 
)
virtual

Add the product of the inputs as a new term to all parts of the objective function.

Parameters
pVardecision variable in the ProductTerm to add to all parts of the objective function
costcost in the ProductTerm to add to all parts of the objective function

Implements ObjectiveFunctionIF.

◆ add_vars_involved_in_prod()

void MaxObjective::add_vars_involved_in_prod ( dvContainer dvs) const
virtual
Note
Call dvContainter::add_vars_involved_in_prod() on the dvContainer of this objective

Implements ObjectiveFunctionIF.

◆ Clone()

ROCPPObjectiveIF_Ptr MaxObjective::Clone ( ) const
virtual

Implements ObjectiveFunctionIF.

◆ convertToEpigraph()

void MaxObjective::convertToEpigraph ( ROCPPVarIF_Ptr  epigraphVar,
vector< ROCPPConstraintIF_Ptr > &  epigraphConstraints 
) const
virtual

Convert the objective function to constraints using an epigraph reformulation.

Parameters
epigraphVarepigraph variable used to write the problem in epigraph form
epigraphConstraintswill contain all the constraints used to write the objective function in epigraph form

Implements ObjectiveFunctionIF.

◆ getNumAdaptiveVars()

uint MaxObjective::getNumAdaptiveVars ( ) const
virtual

Get the number of adaptive decision variables in this objective function.

Implements ObjectiveFunctionIF.

◆ getNumTermsMaxObjective()

size_t MaxObjective::getNumTermsMaxObjective ( ) const
inlinevirtual

Get the number of terms in the objective function.

Returns
1 if the objective function is linear (simple objective function); else return the number of terms in the piecewise linear function (max objective)

Implements ObjectiveFunctionIF.

◆ getNumTimesTermAppears()

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

Get the number of times the term given in the multimap appears in this objective function.

Parameters
termmultimap from the name of the decision variable to the desicion variable used to define this term
Note
The same decision variable may appear many times in a term (indicating that we have a product of the same variable)

Implements ObjectiveFunctionIF.

◆ getObj() [1/2]

vector< ROCPPExpr_Ptr > MaxObjective::getObj ( ) const
virtual

Get the vector of all objective functions.

Implements ObjectiveFunctionIF.

◆ getObj() [2/2]

ROCPPExpr_Ptr MaxObjective::getObj ( uint  i) const
virtual

Get the i th objective function expression.

Parameters
iNumber of the objective function

Implements ObjectiveFunctionIF.

◆ getTimeStage()

uint MaxObjective::getTimeStage ( ) const
virtual

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

Implements ObjectiveFunctionIF.

◆ hasNonlinearities()

bool MaxObjective::hasNonlinearities ( ) const
virtual

Return true if there is a product between two decision variables in this objective function.

Implements ObjectiveFunctionIF.

◆ hasProdsContVars()

bool MaxObjective::hasProdsContVars ( ) const
virtual

Return true if there is a product between two continuous variables in this objective function.

Implements ObjectiveFunctionIF.

◆ hasProdsUncertainties()

bool MaxObjective::hasProdsUncertainties ( ) const
virtual

Return true if there is a product between two uncertain parameters in this objective function.

Implements ObjectiveFunctionIF.

◆ isDeterministic()

bool MaxObjective::isDeterministic ( ) const
virtual

Return true if this objective function does not involve any uncertain parameters.

Implements ObjectiveFunctionIF.

◆ isMaxObjective()

bool MaxObjective::isMaxObjective ( ) const
inlinevirtual

Return true if this objective function is given as the maximum of finitely many linear functions.

Reimplemented from ObjectiveFunctionIF.

◆ mapObjUnc()

ROCPPObjectiveIF_Ptr MaxObjective::mapObjUnc ( const map< string, ROCPPUnc_Ptr > &  mapFromOldToNewUnc) const
virtual
Note
Call LHExpression::mapExprUnc() on every expression of the objective function

Implements ObjectiveFunctionIF.

◆ mapObjVars()

ROCPPObjectiveIF_Ptr MaxObjective::mapObjVars ( const map< string, ROCPPVarIF_Ptr > &  mapFromOldToNewVars) const
virtual
Note
Call LHExpression::mapExprVars() on every expression of the objective function

Implements ObjectiveFunctionIF.

◆ mapUncs()

ROCPPObjectiveIF_Ptr MaxObjective::mapUncs ( const map< string, ROCPPExpr_Ptr > &  mapFromUncToExpression) const
virtual
Note
Call LHExpression::mapUncs() on every expression of the objective function

Implements ObjectiveFunctionIF.

◆ mapVars()

ROCPPObjectiveIF_Ptr MaxObjective::mapVars ( const map< string, ROCPPExpr_Ptr > &  mapFromVarToExpression) const
virtual
Note
Call LHExpression::mapVars() on every expression of the objective function

Implements ObjectiveFunctionIF.

◆ objectiveBegin()

obj_iterator MaxObjective::objectiveBegin ( ) const
inline

Return a constant iterator pointing to the beginning of the vector of objective functions.

◆ objectiveEnd()

obj_iterator MaxObjective::objectiveEnd ( ) const
inline

Return a constant iterator pointing to the end of the vector of objective functions.

◆ replaceTermWithVar()

ROCPPObjectiveIF_Ptr MaxObjective::replaceTermWithVar ( const multimap< string, ROCPPVarIF_Ptr > &  term,
ROCPPVarIF_Ptr  var 
) const
virtual

Replace in this objective function the term given with the decision variable provided.

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 ObjectiveFunctionIF.

◆ uncBegin()

ObjectiveFunctionIF::uncsIterator MaxObjective::uncBegin ( ) const
virtual
Note
Call uncContainer::begin() on the uncContainer of this objective

Implements ObjectiveFunctionIF.

◆ uncEnd()

ObjectiveFunctionIF::uncsIterator MaxObjective::uncEnd ( ) const
virtual
Note
Call uncContainer::end() on the uncContainer of this objective

Implements ObjectiveFunctionIF.

◆ varIsInvolved()

bool MaxObjective::varIsInvolved ( string  varName,
uint  i = 1 
) const
virtual

Check whether the given variable is involved in the specific objective.

Implements ObjectiveFunctionIF.

◆ varsBegin()

ObjectiveFunctionIF::varsIterator MaxObjective::varsBegin ( ) const
virtual
Note
Call dvContainer::begin() on the dvContainer of this objective

Implements ObjectiveFunctionIF.

◆ varsEnd()

ObjectiveFunctionIF::varsIterator MaxObjective::varsEnd ( ) const
virtual
Note
Call dvContainer::end() on the dvContainer of this objective

Implements ObjectiveFunctionIF.

◆ WriteToStream()

void MaxObjective::WriteToStream ( ofstream &  ofs)
virtual

Write the objective function to a stream.

Parameters
ofsoutput file stream

Implements ObjectiveFunctionIF.

Member Data Documentation

◆ m_dvContainer

ROCPPdvContainer_Ptr MaxObjective::m_dvContainer
private

Decision variable container.

◆ m_pObjFuns

vector<ROCPPExpr_Ptr> MaxObjective::m_pObjFuns
private

Vector of the objective expressions.

◆ m_uncContainer

ROCPPuncContainer_Ptr MaxObjective::m_uncContainer
private

Uncertain parameter container.