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

Linear objective function. More...

#include <ObjectiveFunction.hpp>

Inheritance diagram for SimpleObjective:
Collaboration diagram for SimpleObjective:

Public Member Functions

 SimpleObjective ()
 Constructor of the SimpleObjective class. More...
 
 SimpleObjective (ROCPPExpr_Ptr objFun)
 Constructor of the SimpleObjective class. More...
 
 ~SimpleObjective ()
 Destructor of the SimpleObjective class. More...
 
varsIterator varsBegin () const
 
varsIterator varsEnd () const
 
uncsIterator uncBegin () const
 
uncsIterator uncEnd () const
 
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...
 
void add_vars_involved_in_prod (dvContainer &dvs) const
 
void add_int_vars (dvContainer &dvs) 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...
 
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
 
void convertToEpigraph (ROCPPVarIF_Ptr epigraphVar, vector< ROCPPConstraintIF_Ptr > &epigraphConstraints) const
 Convert the objective function to constraints using an epigraph reformulation. More...
 
vector< ROCPPExpr_PtrgetObj () const
 Get the vector of all objective functions. More...
 
ROCPPExpr_Ptr getSimpleObj () const
 
ROCPPExpr_Ptr getObj (uint i) const
 
size_t getNumTermsMaxObjective () const
 
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...
 
bool isSimpleObjective () const
 
bool hasNonlinearities () const
 
bool hasProdsUncertainties () const
 
bool hasProdsContVars () const
 
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
 
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 isMaxObjective () const
 Return true if this objective function is given as the maximum of finitely many linear functions. More...
 

Private Attributes

ROCPPExpr_Ptr m_pObjFun
 Expression used to define the objective function. More...
 

Additional Inherited Members

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

Detailed Description

Linear objective function.

Constructor & Destructor Documentation

◆ SimpleObjective() [1/2]

SimpleObjective::SimpleObjective ( )

Constructor of the SimpleObjective class.

◆ SimpleObjective() [2/2]

SimpleObjective::SimpleObjective ( ROCPPExpr_Ptr  objFun)

Constructor of the SimpleObjective class.

Parameters
objFunexpression used to define the objective function

◆ ~SimpleObjective()

SimpleObjective::~SimpleObjective ( )
inline

Destructor of the SimpleObjective class.

Member Function Documentation

◆ add_int_vars()

void SimpleObjective::add_int_vars ( dvContainer dvs) const
virtual
Note
Call LHExpression::add_int_vars() on the expression used to define the objective function

Implements ObjectiveFunctionIF.

◆ add_to_obj()

void SimpleObjective::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 SimpleObjective::add_vars_involved_in_prod ( dvContainer dvs) const
virtual
Note
Call LHExpression::add_vars_involved_in_prod() on the expression used to define the objective function

Implements ObjectiveFunctionIF.

◆ Clone()

ROCPPObjectiveIF_Ptr SimpleObjective::Clone ( ) const
virtual

Implements ObjectiveFunctionIF.

◆ convertToEpigraph()

void SimpleObjective::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 SimpleObjective::getNumAdaptiveVars ( ) const
virtual

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

Implements ObjectiveFunctionIF.

◆ getNumTermsMaxObjective()

size_t SimpleObjective::getNumTermsMaxObjective ( ) const
inlinevirtual
Note
Return 1 for SimpleObjective

Implements ObjectiveFunctionIF.

◆ getNumTimesTermAppears()

uint SimpleObjective::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 > SimpleObjective::getObj ( ) const
virtual

Get the vector of all objective functions.

Implements ObjectiveFunctionIF.

◆ getObj() [2/2]

ROCPPExpr_Ptr SimpleObjective::getObj ( uint  i) const
virtual
Warning
The input parameter for SimpleObjective must be 1

Implements ObjectiveFunctionIF.

◆ getSimpleObj()

ROCPPExpr_Ptr SimpleObjective::getSimpleObj ( ) const
inline

◆ getTimeStage()

uint SimpleObjective::getTimeStage ( ) const
virtual

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

Implements ObjectiveFunctionIF.

◆ hasNonlinearities()

bool SimpleObjective::hasNonlinearities ( ) const
virtual
Note
Call LHExpression::hasNonlinearities() on the expression defining the objective function

Implements ObjectiveFunctionIF.

◆ hasProdsContVars()

bool SimpleObjective::hasProdsContVars ( ) const
virtual
Note
Call LHExpression::hasProdsContVars() on the expression defining the objective function

Implements ObjectiveFunctionIF.

◆ hasProdsUncertainties()

bool SimpleObjective::hasProdsUncertainties ( ) const
virtual
Note
Call LHExpression::hasProdsUncertainties() on the expression defining the objective function

Implements ObjectiveFunctionIF.

◆ isDeterministic()

bool SimpleObjective::isDeterministic ( ) const
virtual

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

Implements ObjectiveFunctionIF.

◆ isSimpleObjective()

bool SimpleObjective::isSimpleObjective ( ) const
inlinevirtual
Note
Return true for SimpleObjective

Reimplemented from ObjectiveFunctionIF.

◆ mapObjUnc()

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

Implements ObjectiveFunctionIF.

◆ mapObjVars()

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

Implements ObjectiveFunctionIF.

◆ mapUncs()

ROCPPObjectiveIF_Ptr SimpleObjective::mapUncs ( const map< string, ROCPPExpr_Ptr > &  mapFromUncToExpression) const
virtual
Note
Call LHExpression::mapUncs() for the expression defining the objective function

Implements ObjectiveFunctionIF.

◆ mapVars()

ROCPPObjectiveIF_Ptr SimpleObjective::mapVars ( const map< string, ROCPPExpr_Ptr > &  mapFromVarToExpression) const
virtual
Note
Call LHExpression::mapVars() for the expression defining the objective function

Implements ObjectiveFunctionIF.

◆ replaceTermWithVar()

ROCPPObjectiveIF_Ptr SimpleObjective::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()

uncsIterator SimpleObjective::uncBegin ( ) const
inlinevirtual
Note
Call LHExpression::uncBegin() on the expression used to define the objective function

Implements ObjectiveFunctionIF.

◆ uncEnd()

uncsIterator SimpleObjective::uncEnd ( ) const
inlinevirtual
Note
Call LHExpression::uncEnd() on the expression used to define the objective function

Implements ObjectiveFunctionIF.

◆ varIsInvolved()

bool SimpleObjective::varIsInvolved ( string  varName,
uint  i = 1 
) const
virtual
Warning
The input parameter for SimpleObjective must be 1

Implements ObjectiveFunctionIF.

◆ varsBegin()

varsIterator SimpleObjective::varsBegin ( ) const
inlinevirtual
Note
Call LHExpression::varsBegin() on the expression used to define the objective function

Implements ObjectiveFunctionIF.

◆ varsEnd()

varsIterator SimpleObjective::varsEnd ( ) const
inlinevirtual
Note
Call LHExpression::varsEnd() on the expression used to define the objective function

Implements ObjectiveFunctionIF.

◆ WriteToStream()

void SimpleObjective::WriteToStream ( ofstream &  ofs)
virtual

Write the objective function to a stream.

Parameters
ofsoutput file stream

Implements ObjectiveFunctionIF.

Member Data Documentation

◆ m_pObjFun

ROCPPExpr_Ptr SimpleObjective::m_pObjFun
private

Expression used to define the objective function.