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

Objective function interface class. More...

#include <ObjectiveFunction.hpp>

Inheritance diagram for ObjectiveFunctionIF:

Public Types

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

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

Private Attributes

const objType m_type
 Type of this objective function. More...
 

Detailed Description

Objective function interface class.

Member Typedef Documentation

◆ obj_fun_iterator

typedef vector<ROCPPExpr_Ptr>::const_iterator ObjectiveFunctionIF::obj_fun_iterator

Constant iterator to a collection of LHSExpressions defining the objective function.

◆ uncsIterator

typedef uncMapType::const_iterator ObjectiveFunctionIF::uncsIterator

Constant iterator to uncertain parameter map.

◆ varsIterator

typedef dvMapType::const_iterator ObjectiveFunctionIF::varsIterator

Constant iterator to decision variable map.

Constructor & Destructor Documentation

◆ ObjectiveFunctionIF()

ObjectiveFunctionIF::ObjectiveFunctionIF ( objType  type)
inline

Constructor of the objective function interface class.

Parameters
typetype of the objective function (linear or piecewise linear and convex)

◆ ~ObjectiveFunctionIF()

virtual ObjectiveFunctionIF::~ObjectiveFunctionIF ( )
inlinevirtual

Destructor of the objective function interface class.

Member Function Documentation

◆ add_int_vars()

virtual void ObjectiveFunctionIF::add_int_vars ( dvContainer dvs) const
pure virtual

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

Implemented in MaxObjective, and SimpleObjective.

◆ add_to_obj()

virtual void ObjectiveFunctionIF::add_to_obj ( ROCPPVarIF_Ptr  pVar,
double  cost 
)
pure 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

Implemented in MaxObjective, and SimpleObjective.

◆ add_vars_involved_in_prod()

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

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

Implemented in MaxObjective, and SimpleObjective.

◆ checkCompatibility()

void ObjectiveFunctionIF::checkCompatibility ( ROCPPExpr_Ptr  pExpression) const

Check compatibility for the given expression to be given as (one of the) objective functions.

Parameters
pExpressionexpression of the objective function
Note
throws an exception if pExpression is nonlinear (has products of decision variables, products of uncertain parameters, or norm terms)

◆ Clone()

virtual ROCPPObjectiveIF_Ptr ObjectiveFunctionIF::Clone ( ) const
pure virtual

Implemented in MaxObjective, and SimpleObjective.

◆ convertToEpigraph()

virtual void ObjectiveFunctionIF::convertToEpigraph ( ROCPPVarIF_Ptr  epigraphVar,
vector< ROCPPConstraintIF_Ptr > &  epigraphConstraints 
) const
pure 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

Implemented in MaxObjective, and SimpleObjective.

◆ getNumAdaptiveVars()

virtual uint ObjectiveFunctionIF::getNumAdaptiveVars ( ) const
pure virtual

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

Implemented in MaxObjective, and SimpleObjective.

◆ getNumTermsMaxObjective()

virtual size_t ObjectiveFunctionIF::getNumTermsMaxObjective ( ) const
pure virtual

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)

Implemented in MaxObjective, and SimpleObjective.

◆ getNumTimesTermAppears()

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

Implemented in MaxObjective, and SimpleObjective.

◆ getObj() [1/2]

virtual vector<ROCPPExpr_Ptr> ObjectiveFunctionIF::getObj ( ) const
pure virtual

Get the vector of all objective functions.

Implemented in MaxObjective, and SimpleObjective.

◆ getObj() [2/2]

virtual ROCPPExpr_Ptr ObjectiveFunctionIF::getObj ( uint  i) const
pure virtual

Get the i th objective function expression.

Parameters
iNumber of the objective function

Implemented in MaxObjective, and SimpleObjective.

◆ getObjType()

objType ObjectiveFunctionIF::getObjType ( ) const
inline

Get the objective function type (linear or piecewise linear and convex)

◆ getTimeStage()

virtual uint ObjectiveFunctionIF::getTimeStage ( ) const
pure virtual

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

Implemented in MaxObjective, and SimpleObjective.

◆ hasNonlinearities()

virtual bool ObjectiveFunctionIF::hasNonlinearities ( ) const
pure virtual

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

Implemented in MaxObjective, and SimpleObjective.

◆ hasProdsContVars()

virtual bool ObjectiveFunctionIF::hasProdsContVars ( ) const
pure virtual

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

Implemented in MaxObjective, and SimpleObjective.

◆ hasProdsUncertainties()

virtual bool ObjectiveFunctionIF::hasProdsUncertainties ( ) const
pure virtual

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

Implemented in MaxObjective, and SimpleObjective.

◆ isDeterministic()

virtual bool ObjectiveFunctionIF::isDeterministic ( ) const
pure virtual

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

Implemented in MaxObjective, and SimpleObjective.

◆ isMaxObjective()

virtual bool ObjectiveFunctionIF::isMaxObjective ( ) const
inlinevirtual

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

Reimplemented in MaxObjective.

◆ isSimpleObjective()

virtual bool ObjectiveFunctionIF::isSimpleObjective ( ) const
inlinevirtual

Return true if this objective function is linear.

Reimplemented in SimpleObjective.

◆ mapObjUnc()

virtual ROCPPObjectiveIF_Ptr ObjectiveFunctionIF::mapObjUnc ( const map< string, ROCPPUnc_Ptr > &  mapFromOldToNewUnc) const
pure virtual

Map the uncertain parameters in this objective function to new uncertain parameters.

Implemented in MaxObjective, and SimpleObjective.

◆ mapObjVars()

virtual ROCPPObjectiveIF_Ptr ObjectiveFunctionIF::mapObjVars ( const map< string, ROCPPVarIF_Ptr > &  mapFromOldToNewVars) const
pure virtual

Map the decision variables in this objective function to new variables.

Implemented in MaxObjective, and SimpleObjective.

◆ mapUncs()

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

Map the uncertain parameters in this objective function to an expression.

Implemented in MaxObjective, and SimpleObjective.

◆ mapVars()

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

Map the decision variables in this objective function to an expression.

Implemented in MaxObjective, and SimpleObjective.

◆ replaceTermWithVar()

virtual ROCPPObjectiveIF_Ptr ObjectiveFunctionIF::replaceTermWithVar ( const multimap< string, ROCPPVarIF_Ptr > &  term,
ROCPPVarIF_Ptr  var 
) const
pure 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

Implemented in MaxObjective, and SimpleObjective.

◆ uncBegin()

virtual uncsIterator ObjectiveFunctionIF::uncBegin ( ) const
pure virtual

Return a constant iterator pointing to the beginning of the uncertain parameter map.

Implemented in MaxObjective, and SimpleObjective.

◆ uncEnd()

virtual uncsIterator ObjectiveFunctionIF::uncEnd ( ) const
pure virtual

Return a constant iterator pointing to the end of the uncertain parameter map.

Implemented in MaxObjective, and SimpleObjective.

◆ varIsInvolved()

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

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

Implemented in MaxObjective, and SimpleObjective.

◆ varsBegin()

virtual varsIterator ObjectiveFunctionIF::varsBegin ( ) const
pure virtual

Return a constant iterator pointing to the beginning of the decision variable map.

Implemented in MaxObjective, and SimpleObjective.

◆ varsEnd()

virtual varsIterator ObjectiveFunctionIF::varsEnd ( ) const
pure virtual

Return a constant iterator pointing to the end of the decision variable map.

Implemented in MaxObjective, and SimpleObjective.

◆ WriteToStream()

virtual void ObjectiveFunctionIF::WriteToStream ( ofstream &  ofs)
pure virtual

Write the objective function to a stream.

Parameters
ofsoutput file stream

Implemented in MaxObjective, and SimpleObjective.

Member Data Documentation

◆ m_type

const objType ObjectiveFunctionIF::m_type
private

Type of this objective function.