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

Uncertain optimization model. More...

#include <OptimizationModel.hpp>

Inheritance diagram for UncertainOptimizationModel:
Collaboration diagram for UncertainOptimizationModel:

Public Types

typedef vector< ROCPPConstraintIF_Ptr >::const_iterator uncertaintySetIterator
 Const iterator in the uncertainty set constraints of this model. More...
 
- Public Types inherited from OptimizationModelIF
typedef vector< ROCPPConstraintIF_Ptr >::const_iterator constraintIterator
 Constant iterator for optimization model constraints. More...
 
typedef dvMapType::const_iterator varsIterator
 Constant iterator for optimization model decision variable map. More...
 
typedef map< string, ROCPPUnc_Ptr >::const_iterator uncertaintiesIterator
 Constant iterator for optimization model uncertain parameter map. More...
 

Public Member Functions

 UncertainOptimizationModel (uint numTimeStages=1, uncOptModelObjType objType=robust)
 Constructor of the UncertainOptimizationModel class. More...
 
virtual ~UncertainOptimizationModel ()
 Destructor of the UncertainOptimizationModel class. More...
 
uncertaintiesIterator uncertaintiesBegin () const
 Return a constant iterator pointing to the beginning of the uncertain parameter container. More...
 
uncertaintiesIterator uncertaintiesEnd () const
 Return a constant iterator pointing to the end of the uncertain parameter container. More...
 
uncertaintySetIterator uncertaintySetBegin () const
 Return a constant iterator pointing to the beginning of the uncertainty set. More...
 
uncertaintySetIterator uncertaintySetEnd () const
 Return a constant iterator pointing to the end of the uncertainty set. More...
 
uncertaintySetIterator uncertaintySetBegin (string blockNme) const
 Return a constant iterator pointing to the beginning of the uncertainty set for this constraint if the constraint does not have its own uncertainty set, return a pointer to the beginning of the overall uncertainty set. More...
 
uncertaintySetIterator uncertaintySetEnd (string blockNme) const
 Return a constant iterator pointing to the end of the uncertainty set for this constraint if the constraint does not have its own uncertainty set, return a pointer to the end of the overall uncertainty set. More...
 
virtual void checkCompatibility (ROCPPConstraintIF_Ptr pConstraint) const
 
virtual void checkCompatibility (ROCPPObjectiveIF_Ptr pObjFun) const
 Check compatibility for the given objective function of this optimization model. More...
 
virtual map< string, ROCPPUnc_PtrcreateUncMap (ROCPPConstraintIF_Ptr pConstraint)
 Create the uncertain parameter map for the given constraint Iterate through all uncertainties in the given constraint. More...
 
map< string, ROCPPUnc_PtrcreateUncMap (ROCPPObjectiveIF_Ptr objFun)
 Create the uncertainty map for the given objective function Iterate through all uncertainties in the given objective function. More...
 
void set_objType (uncOptModelObjType pType)
 
void getExpectation ()
 Convert the objective function to its expectation. More...
 
size_t getNumUncertainties () const
 Return the number of the uncertain parameters in this model. More...
 
uint getAlphabeticalLocation (ROCPPUnc_Ptr pUncertainty) const
 Return the location of the given uncertain parameter in the uncContainer of this model. More...
 
uint getObservableAlphabeticalLocation (ROCPPUnc_Ptr pUncertainty) const
 Return the location of the given uncertain parameter in the container of the observable uncertainties of this model. More...
 
virtual uint getFirstStageObservable (string uncName) const
 Return 1 for non-ddu model. More...
 
virtual uint getLastStageObservable (string uncName) const
 Return the time stage for non-ddu model. More...
 
void getVarsAffectingUncSet (dvContainer &dvs)
 Return the variables affecting the uncertainty set in the dvContainer. More...
 
size_t getNumUncertaintySetConstraints () const
 Return the number of uncertainty set constraints. More...
 
size_t getNumProblemConstraints () const
 Return the number of problem constraints (constraints that do not define the uncertainty set) More...
 
size_t getNumObsUncertainties () const
 Return the number of observable uncertain parameters. More...
 
bool uncIsDefined (string uncName) const
 Return true if and only if the uncertain parameter is defined in this model. More...
 
bool isUncertainOptimizationModel () const
 Return true if and only if this model is uncertain. More...
 
bool isObservable (string uncName) const
 Return true if and only if the given uncertainty is observable. More...
 
bool hasRectangularUncertaintySet () const
 Return true if the problem has rectangular uncertainty set. More...
 
bool hasRealVarsInUncertaintySet () const
 
bool hasDecisionDependentUncertaintySet () const
 
virtual problemType getType () const
 Return the problem type. More...
 
uncOptModelObjType getObjType () const
 Return the objective type. More...
 
ROCPPUnc_Ptr getUnc (string uncName) const
 Return the uncertain parameter called uncName. More...
 
ROCPPuncContainer_Ptr getUncContainer () const
 Return the uncertainty container (m_uncContainer) of this object. More...
 
ROCPPuncContainer_Ptr getObsUncContainer () const
 
- Public Member Functions inherited from OptimizationModelIF
 OptimizationModelIF (uint numTimeStages=1)
 Constructor of OptimizationModelIF. More...
 
virtual ~OptimizationModelIF ()
 Destructor of OptimizationModelIF. More...
 
constraintIterator constraintBegin () const
 Return a constant iterator pointing to the beginning of the constraint vector. More...
 
constraintIterator constraintEnd () const
 Return a constant iterator pointing to the end of the constraint vector. More...
 
varsIterator varsBegin () const
 Return a constant iterator pointing to the beginning of the decision variable map (m_pDVContainer) More...
 
varsIterator varsEnd () const
 Return a constant iterator pointing to the end of the decision variable map (m_pDVContainer) More...
 
map< string, vector< ROCPPConstraintIF_Ptr > >::const_iterator blockMapBegin () const
 Return a constant iterator pointing to the begining of the block map. More...
 
map< string, vector< ROCPPConstraintIF_Ptr > >::const_iterator blockMapEnd () const
 Return a constant iterator pointing to the end of the block map. More...
 
virtual void checkCompatibility (ROCPPVarIF_Ptr pVariable) const
 Check compatibility for the given decision variable of this optimization model. More...
 
void add_constraint (ROCPPConstraintIF_Ptr pConstraint, string blockNme="main")
 Add a constraint into the optimization model after setting the constraint attributes. More...
 
void add_soc_constraint (ROCPPVarIF_Ptr coneHead, const vector< ROCPPVarIF_Ptr > &otherVars, string blockNme="main")
 Add a soc constraint into the optimization model. More...
 
void add_constraints (vector< ROCPPConstraintIF_Ptr >::const_iterator first, vector< ROCPPConstraintIF_Ptr >::const_iterator last, string blockNme="main")
 Add constraints into the optimization model. More...
 
void add_constraint_uncset (ROCPPConstraintIF_Ptr pUncCstr, string blockNme="main")
 Add a constraint defining the uncertainty set into the model. More...
 
void add_epigraph ()
 Add an epipragh variable as the objective function and an epigraph constraint into this model. More...
 
virtual void add_ddu (ROCPPUnc_Ptr pUncertainty, uint firstTimeStageObservable, uint lastTimeStageObservable, const map< uint, double > &obsCosts)
 
virtual void set_objective (ROCPPObjectiveIF_Ptr pObj)
 Set the given objective as the objective function of the model. More...
 
void set_objective (ROCPPExpr_Ptr objFun)
 Create an objective function using the given expression and add it to the optimization model. More...
 
void set_objective (vector< ROCPPExpr_Ptr > objFuns)
 Create an objective function using the given expressions and add it to the optimization model. More...
 
ROCPPOptModelIF_Ptr replaceTermWithVar (const multimap< string, ROCPPVarIF_Ptr > &term, ROCPPVarIF_Ptr var) const
 Replace the given term in this model with the given decision variable. More...
 
virtual void set_ddu (ROCPPOptModelIF_Ptr pIn)
 Copy the information in the given model and set it to this one, make sure the information of ddu is kept after clone or reformulation. More...
 
virtual void set_ddu (const map< pair< string, uint >, measPair > &dduToMeasMap, const map< string, pair< uint, uint > > &dduStagesObs)
 Copy the information in the given maps and set it to this one, make sure the information of ddu is kept after clone or reformulation. More...
 
map< string, ROCPPVarIF_PtrcreateVarMap (ROCPPConstraintIF_Ptr pConstraint)
 Create the variable map for the given constraint Iterate through all variables in the given constraint. More...
 
map< string, ROCPPVarIF_PtrcreateVarMap (ROCPPObjectiveIF_Ptr objFun)
 Create the variable map for the given objective function Iterate through all variables in the given objective function. More...
 
virtual void pair_uncertainties (ROCPPUnc_Ptr u1, ROCPPUnc_Ptr u2)
 
virtual bool isDDU (string uncName) const
 Return true if and only if the given uncertainty has a time of revelation that is decision-dependent. More...
 
bool isAdaptive (string varName) const
 Return true if and only if the variable with the given name is adaptive. More...
 
bool isInStandardForm () const
 Return true if and only if this model does not include a norm term. More...
 
virtual bool isMultiStageOptModelDDID () const
 Return true if and only if this model is a ddu model. More...
 
bool varIsDefined (string varName) const
 Return true if and only if the decision variable exists in this model. More...
 
bool VarInObj (string varName, uint i=1) const
 Return true if and only if the decision variable exists in the i th objective function of the max term. More...
 
virtual ROCPPVarIF_Ptr getMeasVar (string dduncName, uint timeStage) const
 Return the measurement variable for the given uncertainty and the time stage. More...
 
ROCPPVarIF_Ptr getVar (string varName) const
 Return the variable called varName. More...
 
uint getNumTimesTermAppears (const multimap< string, ROCPPVarIF_Ptr > &term) const
 Return the number of times the given term in the map appears in this model. More...
 
void getAllProductsOf2Variables (map< pair< string, string >, uint > &freqMap, map< pair< string, string >, multimap< string, ROCPPVarIF_Ptr > > &termMap) const
 Return all products of two variables in this model. More...
 
ROCPPObjectiveIF_Ptr getObj () const
 Return a pointer pointing to the objective function of this problem. More...
 
virtual map< pair< string, uint >, measPairgetDDUToMeasMap () const
 Return a map from decision dependent uncertain parameters to associated measurement variables. More...
 
virtual map< string, pair< uint, uint > > getdduStagesObs () const
 Return a map from decision dependent uncertain parameters to the stages when the parameter can be observed. More...
 
ROCPPconstdvContainer_Ptr getDVContainer () const
 Return the decision variable container (m_dvContainer) of this object. More...
 
size_t getNumConstraints () const
 Return the number of constraints in the model. More...
 
uint getNumTimeStages () const
 Return the time stage of the model. 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 getNumVars () const
 Return the number of decision variables in this term. More...
 
bool hasNonlinearities () const
 Return true if and only if there is a product between two decision variables in this optimization model. More...
 
virtual ROCPPOptModelIF_Ptr Clone () const
 Clone this problem. More...
 
virtual void WriteToFile (string folderName, string fileName) const
 

Protected Member Functions

virtual void add_uncertainty (ROCPPUnc_Ptr pUnc)
 Add uncertainty to the m_pUncContainer of this modeel. More...
 
void add_uncertainties (ROCPPconstuncContainer_Ptr pUncContainer)
 Add uncertainties to the m_pUncContainer of this model. More...
 
- Protected Member Functions inherited from OptimizationModelIF
virtual void add_var (ROCPPVarIF_Ptr pVariable)
 Add the given variable into the dvContainer of this model. More...
 
virtual void add_vars (ROCPPconstdvContainer_Ptr pDVcontainer)
 Add the variable in the given container into the dvContainer of this model. More...
 
void add_ddu_obj (ROCPPVarIF_Ptr pVar, double cost)
 Add the information discovery cost to the objective model. More...
 
void push_constraint (ROCPPConstraintIF_Ptr pConstraint)
 Push the constraint back into the vector of constraints of this model. More...
 
ptrdiff_t getConstraintIdx (constraintIterator pConstraintIt) const
 Get index of the given constraint in the m_mapCstrIdxToUncertaintySet map. More...
 

Protected Attributes

uncOptModelObjType m_objType
 Uncertain objective type of this model. More...
 
- Protected Attributes inherited from OptimizationModelIF
uint m_numTimeStages
 Length of planning horizon of this model. More...
 
vector< ROCPPConstraintIF_Ptrm_uncertaintySet
 Vector collecting the uncertainty set constraints of this model. More...
 
ROCPPuncContainer_Ptr m_pUncContainer
 Uncertain parameter container of this model. More...
 
ROCPPuncContainer_Ptr m_dduContainer
 Container of decision dependent uncertain parameters in this model. More...
 
ROCPPuncContainer_Ptr m_nondduContainer
 Container of non decision dependent uncertain parameters in this model. More...
 
map< string, measPairm_measVars
 Map from measurement varaibles to measurement pairs. More...
 
map< pair< string, uint >, measPairm_dduToMeasMap
 Map from pair of uncertain parameter name and time stage to measurement pair. More...
 
map< string, pair< uint, uint > > m_dduStagesObs
 Map from name of the uncertain parameter to the first and last times when it can be observed. More...
 
map< string, vector< ROCPPConstraintIF_Ptr > > m_mapBlockConstraints
 Map from block name to vector of problem constraint indices. More...
 

Detailed Description

Uncertain optimization model.

Member Typedef Documentation

◆ uncertaintySetIterator

Const iterator in the uncertainty set constraints of this model.

Constructor & Destructor Documentation

◆ UncertainOptimizationModel()

UncertainOptimizationModel::UncertainOptimizationModel ( uint  numTimeStages = 1,
uncOptModelObjType  objType = robust 
)

Constructor of the UncertainOptimizationModel class.

Parameters
numTimeStagesPlanning horizon of this model

◆ ~UncertainOptimizationModel()

virtual UncertainOptimizationModel::~UncertainOptimizationModel ( )
inlinevirtual

Destructor of the UncertainOptimizationModel class.

Member Function Documentation

◆ add_uncertainties()

void UncertainOptimizationModel::add_uncertainties ( ROCPPconstuncContainer_Ptr  pUncContainer)
protected

Add uncertainties to the m_pUncContainer of this model.

◆ add_uncertainty()

void UncertainOptimizationModel::add_uncertainty ( ROCPPUnc_Ptr  pUnc)
protectedvirtual

Add uncertainty to the m_pUncContainer of this modeel.

Reimplemented in MultiStageOptModelDDID.

◆ checkCompatibility() [1/2]

void UncertainOptimizationModel::checkCompatibility ( ROCPPConstraintIF_Ptr  pConstraint) const
virtual
Warning
Cannot add constraint which has norm term but does not define uncertainty set into the model

Reimplemented from OptimizationModelIF.

◆ checkCompatibility() [2/2]

void UncertainOptimizationModel::checkCompatibility ( ROCPPObjectiveIF_Ptr  pObjFun) const
virtual

Check compatibility for the given objective function of this optimization model.

Warning
Cannot add objective function which contains products of continuous variables or products of uncertianties or has a larger time stage that the planning horizon into the optimization model

Reimplemented from OptimizationModelIF.

◆ createUncMap() [1/2]

map< string, ROCPPUnc_Ptr > UncertainOptimizationModel::createUncMap ( ROCPPConstraintIF_Ptr  pConstraint)
virtual

Create the uncertain parameter map for the given constraint Iterate through all uncertainties in the given constraint.

If an uncertain parameter with the same name exists in the model, use the old one. If no parameter with the same name exists, create a new one and add it to the model.

Reimplemented from OptimizationModelIF.

◆ createUncMap() [2/2]

map< string, ROCPPUnc_Ptr > UncertainOptimizationModel::createUncMap ( ROCPPObjectiveIF_Ptr  objFun)
virtual

Create the uncertainty map for the given objective function Iterate through all uncertainties in the given objective function.

If an uncertain parameter with the same name exists in the model, use the old one. If no parameter with the same name exists, create a new one and add it to the model.

Reimplemented from OptimizationModelIF.

◆ getAlphabeticalLocation()

uint UncertainOptimizationModel::getAlphabeticalLocation ( ROCPPUnc_Ptr  pUncertainty) const

Return the location of the given uncertain parameter in the uncContainer of this model.

◆ getExpectation()

void UncertainOptimizationModel::getExpectation ( )
virtual

Convert the objective function to its expectation.

Reimplemented from OptimizationModelIF.

◆ getFirstStageObservable()

uint UncertainOptimizationModel::getFirstStageObservable ( string  uncName) const
virtual

Return 1 for non-ddu model.

Reimplemented from OptimizationModelIF.

Reimplemented in MultiStageOptModelDDID.

◆ getLastStageObservable()

uint UncertainOptimizationModel::getLastStageObservable ( string  uncName) const
virtual

Return the time stage for non-ddu model.

Reimplemented from OptimizationModelIF.

Reimplemented in MultiStageOptModelDDID.

◆ getNumObsUncertainties()

size_t UncertainOptimizationModel::getNumObsUncertainties ( ) const

Return the number of observable uncertain parameters.

◆ getNumProblemConstraints()

size_t UncertainOptimizationModel::getNumProblemConstraints ( ) const
inline

Return the number of problem constraints (constraints that do not define the uncertainty set)

◆ getNumUncertainties()

size_t UncertainOptimizationModel::getNumUncertainties ( ) const
virtual

Return the number of the uncertain parameters in this model.

Reimplemented from OptimizationModelIF.

◆ getNumUncertaintySetConstraints()

size_t UncertainOptimizationModel::getNumUncertaintySetConstraints ( ) const
inline

Return the number of uncertainty set constraints.

◆ getObjType()

uncOptModelObjType UncertainOptimizationModel::getObjType ( ) const
inlinevirtual

Return the objective type.

Reimplemented from OptimizationModelIF.

◆ getObservableAlphabeticalLocation()

uint UncertainOptimizationModel::getObservableAlphabeticalLocation ( ROCPPUnc_Ptr  pUncertainty) const

Return the location of the given uncertain parameter in the container of the observable uncertainties of this model.

◆ getObsUncContainer()

ROCPPuncContainer_Ptr UncertainOptimizationModel::getObsUncContainer ( ) const

◆ getType()

virtual problemType UncertainOptimizationModel::getType ( ) const
inlinevirtual

◆ getUnc()

ROCPPUnc_Ptr UncertainOptimizationModel::getUnc ( string  uncName) const
virtual

Return the uncertain parameter called uncName.

Reimplemented from OptimizationModelIF.

◆ getUncContainer()

ROCPPuncContainer_Ptr UncertainOptimizationModel::getUncContainer ( ) const
inlinevirtual

Return the uncertainty container (m_uncContainer) of this object.

Warning
Not valid in deterministic model

Reimplemented from OptimizationModelIF.

◆ getVarsAffectingUncSet()

void UncertainOptimizationModel::getVarsAffectingUncSet ( dvContainer dvs)

Return the variables affecting the uncertainty set in the dvContainer.

◆ hasDecisionDependentUncertaintySet()

bool UncertainOptimizationModel::hasDecisionDependentUncertaintySet ( ) const
virtual

Reimplemented from OptimizationModelIF.

◆ hasRealVarsInUncertaintySet()

bool UncertainOptimizationModel::hasRealVarsInUncertaintySet ( ) const
virtual

Reimplemented from OptimizationModelIF.

◆ hasRectangularUncertaintySet()

bool UncertainOptimizationModel::hasRectangularUncertaintySet ( ) const
virtual

Return true if the problem has rectangular uncertainty set.

Reimplemented from OptimizationModelIF.

◆ isObservable()

bool UncertainOptimizationModel::isObservable ( string  uncName) const
virtual

Return true if and only if the given uncertainty is observable.

Reimplemented from OptimizationModelIF.

◆ isUncertainOptimizationModel()

bool UncertainOptimizationModel::isUncertainOptimizationModel ( ) const
inlinevirtual

Return true if and only if this model is uncertain.

Reimplemented from OptimizationModelIF.

◆ set_objType()

void UncertainOptimizationModel::set_objType ( uncOptModelObjType  pType)
inlinevirtual

Reimplemented from OptimizationModelIF.

◆ uncertaintiesBegin()

OptimizationModelIF::uncertaintiesIterator UncertainOptimizationModel::uncertaintiesBegin ( ) const
virtual

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

Reimplemented from OptimizationModelIF.

◆ uncertaintiesEnd()

OptimizationModelIF::uncertaintiesIterator UncertainOptimizationModel::uncertaintiesEnd ( ) const
virtual

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

Reimplemented from OptimizationModelIF.

◆ uncertaintySetBegin() [1/2]

uncertaintySetIterator UncertainOptimizationModel::uncertaintySetBegin ( ) const
inline

Return a constant iterator pointing to the beginning of the uncertainty set.

◆ uncertaintySetBegin() [2/2]

UncertainOptimizationModel::uncertaintySetIterator UncertainOptimizationModel::uncertaintySetBegin ( string  blockNme) const

Return a constant iterator pointing to the beginning of the uncertainty set for this constraint if the constraint does not have its own uncertainty set, return a pointer to the beginning of the overall uncertainty set.

◆ uncertaintySetEnd() [1/2]

uncertaintySetIterator UncertainOptimizationModel::uncertaintySetEnd ( ) const
inline

Return a constant iterator pointing to the end of the uncertainty set.

◆ uncertaintySetEnd() [2/2]

UncertainOptimizationModel::uncertaintySetIterator UncertainOptimizationModel::uncertaintySetEnd ( string  blockNme) const

Return a constant iterator pointing to the end of the uncertainty set for this constraint if the constraint does not have its own uncertainty set, return a pointer to the end of the overall uncertainty set.

◆ uncIsDefined()

bool UncertainOptimizationModel::uncIsDefined ( string  uncName) const

Return true if and only if the uncertain parameter is defined in this model.

Member Data Documentation

◆ m_objType

uncOptModelObjType UncertainOptimizationModel::m_objType
protected

Uncertain objective type of this model.