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

K-adaptability approximator. More...

#include <Kadaptability.hpp>

Inheritance diagram for Kadaptability:
Collaboration diagram for Kadaptability:

Public Member Functions

 Kadaptability (const map< uint, uint > &numPartitionsMap=map< uint, uint >(), double bigM=100.0, double epsilon=0.0001, string folder=" ")
 Constructor of K-Adaptability approximator. More...
 
 ~Kadaptability ()
 Destructor of K-Adaptability approximator. More...
 
void checkWsCompatability (const map< uint, uint > &wsMap)
 Check the compatability of the given model. More...
 
void createVariableAndUncMap (dvContainer::const_iterator varsBegin, dvContainer::const_iterator varsEnd, uncContainer::const_iterator uncBegin, uncContainer::const_iterator uncEnd)
 Create the map from the original decision variable and uncertainty to the new variable and uncertainty for each plan and pair of partition and time stage respectively. More...
 
ROCPPOptModelIF_Ptr approximate (ROCPPOptModelIF_Ptr pIn)
 Check the compatability of the input model and check whether the model has constraint uncertainty to choose the appropriate method. More...
 
ROCPPOptModelIF_Ptr fixSecondStageVariablesToWarmStart (ROCPPOptModelIF_Ptr pIn, ROCPPOptModelIF_Ptr pKadaptModel, const map< string, double > &warmStartResults, const map< uint, uint > &wsMap)
 Return a new model after fixing second stage variables which are solved by the warm start problem to the value provided in the input map. More...
 
ROCPPOptModelIF_Ptr fixBinaryVariableValues (ROCPPOptModelIF_Ptr pKadaptModel, const map< string, bool > &varValues) const
 Return a new model after fixing second stage variables to the value provided in the input map. More...
 
virtual ROCPPOptModelIF_Ptr addProblemSpecificConstraints (ROCPPOptModelIF_Ptr pKadapt) const
 
string getSolutionApproachParameters (string delimiter) const
 
ROCPPVarIF_Ptr getDVonPartition (string partition, string OrigDVname) const
 Get the new variable associated with the given original variable on the given contingency plan. More...
 
ROCPPUnc_Ptr getUncOnPartition (string OrigUncName, string partition, uint t) const
 Get the new uncertain parameter associated with the given original uncertainty on the given contingency plan at time stage t. More...
 
void getWsSolutions (ROCPPOptModelIF_Ptr pIn, const map< string, double > &warmStartResults, const map< uint, uint > &wsMap, map< string, double > &wsSolutions)
 Return the warm start solution of this problem by setting the variables which exist in the warm start problem to their solutions and assigning the variables which don't exist in the warm start problem to the biggest solved kth solutions. More...
 
void printParametersToScreen () const
 
void printOut (const ROCPPOptModelIF_Ptr pIn, const map< string, double > &resultIn, ROCPPVarIF_Ptr dv, string partition)
 Print out the solution for the given variable for the given plan. More...
 
void printOut (const ROCPPOptModelIF_Ptr pIn, const map< string, double > &resultIn, ROCPPVarIF_Ptr dv)
 Print out the solution for the given variable for all plans. More...
 
void printOut (const ROCPPOptModelIF_Ptr pIn, const map< string, double > &resultIn, ROCPPUnc_Ptr unc, string partition)
 Print out whether observe or not the given uncertainty for the given plan. More...
 
void printOut (const ROCPPOptModelIF_Ptr pIn, const map< string, double > &resultIn, ROCPPUnc_Ptr unc)
 Print out whether we observe or not the given uncertainty for all cases. More...
 
ROCPPOptModelIF_Ptr Reformulate (ROCPPOptModelIF_Ptr pIn)
 
bool isApplicable (ROCPPOptModelIF_Ptr pIn) const
 
string getName () const
 
- Public Member Functions inherited from DecisionRuleIF
 DecisionRuleIF (uint memory=1000)
 Constructor of the DecisionRuleIF class. More...
 
virtual ~DecisionRuleIF ()
 Destructor of the DecisionRuleIF class. More...
 
uint getMemory () const
 
- Public Member Functions inherited from ReformulationStrategyIF
 ReformulationStrategyIF ()
 
 ~ReformulationStrategyIF ()
 

Protected Member Functions

void initialize (ROCPPOptModelIF_Ptr pIn)
 Initialize the class ith the given parameters. More...
 
ROCPPOptModelIF_Ptr approxObjUnc (ROCPPOptModelIF_Ptr pIn)
 Method for multistage model with only objective uncertainty. More...
 
ROCPPOptModelIF_Ptr approxCstrUnc (ROCPPOptModelIF_Ptr pIn)
 Method for two stage model with both objective and constraint uncertainty. More...
 

Protected Attributes

ROCPPKadaptEncoder_Ptr m_pPartitionEncoder
 
map< string, map< string, ROCPPVarIF_Ptr > > m_DVmap
 Map from original decision variable name to partition string to new decision variable. More...
 
map< string, map< string, ROCPPVarIF_Ptr > > m_mapPartitionEnc_mapOrigDVtoDVonPartition
 Map from partition to map from original variable name to new variable on that partition. More...
 
map< pair< string, uint >, map< string, ROCPPUnc_Ptr > > m_mapPartitionEncandt_mapOrigUnctoUnconPartition
 Map from pair of partition and time stage to the map from uncertainty name to the uncertainty on that partition at specific time stage. More...
 
ROCPPBilinearReform_Ptr m_pBTR
 
double m_epsilon
 Small values used to deal with the infeasible constraint in constraint uncertainty. More...
 
string m_folder
 
map< uint, uintm_numPartitionsMap
 Map from time period to value of K for that time-period. More...
 
- Protected Attributes inherited from DecisionRuleIF
uint m_memory
 Memory of this approximator. More...
 

Detailed Description

K-adaptability approximator.

Constructor & Destructor Documentation

◆ Kadaptability()

Kadaptability::Kadaptability ( const map< uint, uint > &  numPartitionsMap = map<uintuint>(),
double  bigM = 100.0,
double  epsilon = 0.0001,
string  folder = " " 
)

Constructor of K-Adaptability approximator.

Parameters
numPartitionsMapMap from time period to value of K for that time-period
bigMBig-M constant value for linearizing the bilinear terms
epsilonValue of epsilon to build the strictly inequality in the constraint uncertainty case
folderName of the folders where to save the log file

◆ ~Kadaptability()

Kadaptability::~Kadaptability ( )
inline

Destructor of K-Adaptability approximator.

Member Function Documentation

◆ addProblemSpecificConstraints()

virtual ROCPPOptModelIF_Ptr Kadaptability::addProblemSpecificConstraints ( ROCPPOptModelIF_Ptr  pKadapt) const
inlinevirtual

◆ approxCstrUnc()

ROCPPOptModelIF_Ptr Kadaptability::approxCstrUnc ( ROCPPOptModelIF_Ptr  pIn)
protected

Method for two stage model with both objective and constraint uncertainty.

Warning
Only two stage model is allowed here

◆ approximate()

ROCPPOptModelIF_Ptr Kadaptability::approximate ( ROCPPOptModelIF_Ptr  pIn)
virtual

Check the compatability of the input model and check whether the model has constraint uncertainty to choose the appropriate method.

Implements DecisionRuleIF.

◆ approxObjUnc()

ROCPPOptModelIF_Ptr Kadaptability::approxObjUnc ( ROCPPOptModelIF_Ptr  pIn)
protected

Method for multistage model with only objective uncertainty.

Warning
No uncertainty in constraint is allowed here

◆ checkWsCompatability()

void Kadaptability::checkWsCompatability ( const map< uint, uint > &  wsMap)

Check the compatability of the given model.

Warning
Only binary variables are allowed in the K-adaptability approximator Check the compatability of the given warm start map
Note
the value of K in each time stage must be less than or equal to that in the original approximator; at least one K must be strictly less than the one in the original problem

◆ createVariableAndUncMap()

void Kadaptability::createVariableAndUncMap ( dvContainer::const_iterator  varsBegin,
dvContainer::const_iterator  varsEnd,
uncContainer::const_iterator  uncBegin,
uncContainer::const_iterator  uncEnd 
)

Create the map from the original decision variable and uncertainty to the new variable and uncertainty for each plan and pair of partition and time stage respectively.

◆ fixBinaryVariableValues()

ROCPPOptModelIF_Ptr Kadaptability::fixBinaryVariableValues ( ROCPPOptModelIF_Ptr  pKadaptModel,
const map< string, bool > &  varValues 
) const

Return a new model after fixing second stage variables to the value provided in the input map.

◆ fixSecondStageVariablesToWarmStart()

ROCPPOptModelIF_Ptr Kadaptability::fixSecondStageVariablesToWarmStart ( ROCPPOptModelIF_Ptr  pIn,
ROCPPOptModelIF_Ptr  pKadaptModel,
const map< string, double > &  warmStartResults,
const map< uint, uint > &  wsMap 
)

Return a new model after fixing second stage variables which are solved by the warm start problem to the value provided in the input map.

Parameters
pInModel before approximating
pKadaptModelModel after approximating
warmStartResultsResults of the warm start problem
wsMapMap from time stage to number of k in the warm start problem

◆ getDVonPartition()

ROCPPVarIF_Ptr Kadaptability::getDVonPartition ( string  partition,
string  OrigDVname 
) const

Get the new variable associated with the given original variable on the given contingency plan.

◆ getName()

string Kadaptability::getName ( ) const
inlinevirtual

◆ getSolutionApproachParameters()

string Kadaptability::getSolutionApproachParameters ( string  delimiter) const

◆ getUncOnPartition()

ROCPPUnc_Ptr Kadaptability::getUncOnPartition ( string  OrigUncName,
string  partition,
uint  t 
) const

Get the new uncertain parameter associated with the given original uncertainty on the given contingency plan at time stage t.

◆ getWsSolutions()

void Kadaptability::getWsSolutions ( ROCPPOptModelIF_Ptr  pIn,
const map< string, double > &  warmStartResults,
const map< uint, uint > &  wsMap,
map< string, double > &  wsSolutions 
)

Return the warm start solution of this problem by setting the variables which exist in the warm start problem to their solutions and assigning the variables which don't exist in the warm start problem to the biggest solved kth solutions.

Parameters
pInModel before approximating
warmStartResultsResults of the warm start problem
wsMapMap from time stage to number of k in the warm start problem
wsSolutionsMap from variable name to its warm start solution for all variables in the problem to be solved

◆ initialize()

void Kadaptability::initialize ( ROCPPOptModelIF_Ptr  pIn)
protected

Initialize the class ith the given parameters.

◆ isApplicable()

bool Kadaptability::isApplicable ( ROCPPOptModelIF_Ptr  pIn) const
virtual

◆ printOut() [1/4]

void Kadaptability::printOut ( const ROCPPOptModelIF_Ptr  pIn,
const map< string, double > &  resultIn,
ROCPPUnc_Ptr  unc 
)

Print out whether we observe or not the given uncertainty for all cases.

◆ printOut() [2/4]

void Kadaptability::printOut ( const ROCPPOptModelIF_Ptr  pIn,
const map< string, double > &  resultIn,
ROCPPUnc_Ptr  unc,
string  partition 
)

Print out whether observe or not the given uncertainty for the given plan.

◆ printOut() [3/4]

void Kadaptability::printOut ( const ROCPPOptModelIF_Ptr  pIn,
const map< string, double > &  resultIn,
ROCPPVarIF_Ptr  dv 
)

Print out the solution for the given variable for all plans.

◆ printOut() [4/4]

void Kadaptability::printOut ( const ROCPPOptModelIF_Ptr  pIn,
const map< string, double > &  resultIn,
ROCPPVarIF_Ptr  dv,
string  partition 
)

Print out the solution for the given variable for the given plan.

◆ printParametersToScreen()

void Kadaptability::printParametersToScreen ( ) const

◆ Reformulate()

ROCPPOptModelIF_Ptr Kadaptability::Reformulate ( ROCPPOptModelIF_Ptr  pIn)
inlinevirtual

Member Data Documentation

◆ m_DVmap

map<string, map<string, ROCPPVarIF_Ptr> > Kadaptability::m_DVmap
protected

Map from original decision variable name to partition string to new decision variable.

◆ m_epsilon

double Kadaptability::m_epsilon
protected

Small values used to deal with the infeasible constraint in constraint uncertainty.

◆ m_folder

string Kadaptability::m_folder
protected

◆ m_mapPartitionEnc_mapOrigDVtoDVonPartition

map< string, map<string, ROCPPVarIF_Ptr> > Kadaptability::m_mapPartitionEnc_mapOrigDVtoDVonPartition
protected

Map from partition to map from original variable name to new variable on that partition.

◆ m_mapPartitionEncandt_mapOrigUnctoUnconPartition

map< pair<string,uint> , map<string, ROCPPUnc_Ptr> > Kadaptability::m_mapPartitionEncandt_mapOrigUnctoUnconPartition
protected

Map from pair of partition and time stage to the map from uncertainty name to the uncertainty on that partition at specific time stage.

◆ m_numPartitionsMap

map<uint,uint> Kadaptability::m_numPartitionsMap
protected

Map from time period to value of K for that time-period.

◆ m_pBTR

ROCPPBilinearReform_Ptr Kadaptability::m_pBTR
protected

◆ m_pPartitionEncoder

ROCPPKadaptEncoder_Ptr Kadaptability::m_pPartitionEncoder
protected