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

Piecewise constant and piecewise linear decision rule approximator. More...

#include <PWDecisionRule.hpp>

Inheritance diagram for PiecewiseDecisionRule:
Collaboration diagram for PiecewiseDecisionRule:

Public Member Functions

 PiecewiseDecisionRule (const map< string, uint > &numPartitionsMap=map< string, uint >(), double bigM=100., bool useExplicitNACs=false, string folder=" ")
 Constructor of the PiecewiseDecisionRule class. More...
 
 ~PiecewiseDecisionRule ()
 Constructor of the PiecewiseApproximator class Directly initialize with the predefined private members (for greater customization) More...
 
ROCPPOptModelIF_Ptr approximate (ROCPPOptModelIF_Ptr pIn)
 Approximate the input model First construct the partition maps, then calculate and robustity the model on each subset, finally add non-anticipativity constraints. More...
 
string getSolutionApproachParameters (string delimiter) const
 Return a new model after fixing the binary variables to the value provided in the input map. More...
 
pair< bool, ROCPPVarIF_PtrfindOrigVariable (ROCPPVarIF_Ptr newdv) const
 Find the variable that new decision variable originated from after LDR and CDR. More...
 
ROCPPVarIF_Ptr getVarOnPartition (string partition, string origVarName) const
 Get the decision variable on the the given subset of the partition for the given original variable. More...
 
void calculateSolution (ROCPPOptModelIF_Ptr pIn, const map< string, double > &resultIn, ROCPPVarIF_Ptr dv, string partition)
 Calculate solution for the given variable on the given subset of the partition. More...
 
void calculateSolution (ROCPPOptModelIF_Ptr pIn, const map< string, double > &resultIn, ROCPPUnc_Ptr unc, string partition)
 Calculate the measurement variable value for the given uncertainty on the given subset of the partition. More...
 
void getWsSolutions (ROCPPOptModelIF_Ptr pIn, const map< string, double > &warmStartResults, const map< string, 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 do not exist in the warm start problem to the solutions on the nearest partition. More...
 
void printParametersToScreen () const
 
void printOut (const ROCPPOptModelIF_Ptr pIn, const map< string, double > &resultIn, ROCPPVarIF_Ptr dv, map< ROCPPUnc_Ptr, uint > partitionIn)
 Print out the solution for the given variable on the given subset of the partition. More...
 
void printOut (const ROCPPOptModelIF_Ptr pIn, const map< string, double > &resultIn, ROCPPVarIF_Ptr dv)
 Print out the solution for the given variable on all subsets of the the partition. More...
 
void printOut (const ROCPPOptModelIF_Ptr pIn, const map< string, double > &resultIn, ROCPPUnc_Ptr unc, map< ROCPPUnc_Ptr, uint > partitionIn)
 Print out whether observe or not the given uncertainty on the given subset of the partition. 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 on all subsets of the partition. 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 ()
 

Private Member Functions

void initialize (ROCPPOptModelIF_Ptr pIn)
 Initialize the class with the given parameters. More...
 
void createVariableMap (ROCPPOptModelIF_Ptr pIn, ROCPPOptModelIF_Ptr pMiddle, vector< ROCPPConstraintIF_Ptr > &vecNACs)
 Create the map from partition to map from variable in original problem to variable on partition. More...
 
void createUncertaintyMap (ROCPPOptModelIF_Ptr pIn)
 Create the map from partition to map from uncertain parameter in original problem to uncertainty on partition. More...
 
pair< double, map< string, ROCPPExpr_Ptr > > calculateMeanAndProb (ROCPPOptModelIF_Ptr pModel, string partition, const map< string, pair< double, double > > &allMap, double allArea)
 Calculate the probability of the given subset of the partition and the means of the uncertain parameters on it. More...
 
ROCPPExpr_Ptr getStochasticObj (const pair< double, map< string, ROCPPExpr_Ptr > > &meanAndProb, const ROCPPObjectiveIF_Ptr oldObj, string partitionSubsetNme)
 Calculate the value of the objective on the given subset of the partition. More...
 

Private Attributes

string m_numPartitionsStr
 String encoding the number of subsets in the partition for every observable uncertainty in the problem, in alphabetical order. More...
 
ROCPPContinuousVarsDR_Ptr m_pCVA
 Linear decision rule converter. More...
 
ROCPPDiscreteVarsDR_Ptr m_pDVA
 Constant decision rule converter. More...
 
ROCPPMItoMB_Ptr m_pMItoMB_Bilinear
 
ROCPPUncSetRealVarApprox_Ptr m_pBPA
 
ROCPPParConstructor_Ptr m_pPartConstructor
 Partition constructor of this approximator. More...
 
ROCPPParConverter_Ptr m_pPartConverter
 Partition converter of this approximator. More...
 
map< string, map< string, ROCPPVarIF_Ptr > > m_VariableMap
 Map from subset of partition to map from variable in original problem to variable on subset of the partition. More...
 
bool m_useExplicitNACs
 Use constraints to describe the non anticipativity constraints. More...
 
double m_bigM
 Value of the big M constant. More...
 
map< string, uintm_numPartitionsMap
 
string m_folder
 Name of the folder where to write the text file. More...
 
uint m_numBits
 Number of bits used to approximate the real valued variables affecting the uncertainty set. More...
 

Additional Inherited Members

- Protected Attributes inherited from DecisionRuleIF
uint m_memory
 Memory of this approximator. More...
 

Detailed Description

Piecewise constant and piecewise linear decision rule approximator.

Warning
: only applies to problems where the uncertainty set only depends on binary variables

Constructor & Destructor Documentation

◆ PiecewiseDecisionRule()

PiecewiseDecisionRule::PiecewiseDecisionRule ( const map< string, uint > &  numPartitionsMap = map<string, uint>(),
double  bigM = 100.,
bool  useExplicitNACs = false,
string  folder = " " 
)

Constructor of the PiecewiseDecisionRule class.

Parameters
numPartitionsMapmap from the name of the uncertain parameter to the number of subsets along that direction (number of breakpoints + 1)
bigMBig-M value used for linearizing the bilinear terms
useExplicitNACsIf true, then two meansurement variables are equal, otherwise use the same measurement variables for the NACs
folderName of folders where to store the log file

◆ ~PiecewiseDecisionRule()

PiecewiseDecisionRule::~PiecewiseDecisionRule ( )
inline

Constructor of the PiecewiseApproximator class Directly initialize with the predefined private members (for greater customization)

Destructor of the PiecewiseApproximator class

Member Function Documentation

◆ approximate()

ROCPPOptModelIF_Ptr PiecewiseDecisionRule::approximate ( ROCPPOptModelIF_Ptr  pIn)
virtual

Approximate the input model First construct the partition maps, then calculate and robustity the model on each subset, finally add non-anticipativity constraints.

Implements DecisionRuleIF.

◆ calculateMeanAndProb()

pair< double, map< string, ROCPPExpr_Ptr > > PiecewiseDecisionRule::calculateMeanAndProb ( ROCPPOptModelIF_Ptr  pModel,
string  partition,
const map< string, pair< double, double > > &  allMap,
double  allArea 
)
private

Calculate the probability of the given subset of the partition and the means of the uncertain parameters on it.

◆ calculateSolution() [1/2]

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

Calculate the measurement variable value for the given uncertainty on the given subset of the partition.

◆ calculateSolution() [2/2]

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

Calculate solution for the given variable on the given subset of the partition.

◆ createUncertaintyMap()

void PiecewiseDecisionRule::createUncertaintyMap ( ROCPPOptModelIF_Ptr  pIn)
private

Create the map from partition to map from uncertain parameter in original problem to uncertainty on partition.

◆ createVariableMap()

void PiecewiseDecisionRule::createVariableMap ( ROCPPOptModelIF_Ptr  pIn,
ROCPPOptModelIF_Ptr  pMiddle,
vector< ROCPPConstraintIF_Ptr > &  vecNACs 
)
private

Create the map from partition to map from variable in original problem to variable on partition.

◆ findOrigVariable()

pair< bool, ROCPPVarIF_Ptr > PiecewiseDecisionRule::findOrigVariable ( ROCPPVarIF_Ptr  newdv) const

Find the variable that new decision variable originated from after LDR and CDR.

◆ getName()

string PiecewiseDecisionRule::getName ( ) const
inlinevirtual

◆ getSolutionApproachParameters()

string PiecewiseDecisionRule::getSolutionApproachParameters ( string  delimiter) const

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

◆ getStochasticObj()

ROCPPExpr_Ptr PiecewiseDecisionRule::getStochasticObj ( const pair< double, map< string, ROCPPExpr_Ptr > > &  meanAndProb,
const ROCPPObjectiveIF_Ptr  oldObj,
string  partitionSubsetNme 
)
private

Calculate the value of the objective on the given subset of the partition.

◆ getVarOnPartition()

ROCPPVarIF_Ptr PiecewiseDecisionRule::getVarOnPartition ( string  partition,
string  origVarName 
) const

Get the decision variable on the the given subset of the partition for the given original variable.

◆ getWsSolutions()

void PiecewiseDecisionRule::getWsSolutions ( ROCPPOptModelIF_Ptr  pIn,
const map< string, double > &  warmStartResults,
const map< string, 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 do not exist in the warm start problem to the solutions on the nearest partition.

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 PiecewiseDecisionRule::initialize ( ROCPPOptModelIF_Ptr  pIn)
private

Initialize the class with the given parameters.

◆ isApplicable()

bool PiecewiseDecisionRule::isApplicable ( ROCPPOptModelIF_Ptr  pIn) const
virtual

◆ printOut() [1/4]

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

Print out whether we observe or not the given uncertainty on all subsets of the partition.

◆ printOut() [2/4]

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

Print out whether observe or not the given uncertainty on the given subset of the partition.

◆ printOut() [3/4]

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

Print out the solution for the given variable on all subsets of the the partition.

◆ printOut() [4/4]

void PiecewiseDecisionRule::printOut ( const ROCPPOptModelIF_Ptr  pIn,
const map< string, double > &  resultIn,
ROCPPVarIF_Ptr  dv,
map< ROCPPUnc_Ptr, uint partitionIn 
)

Print out the solution for the given variable on the given subset of the partition.

◆ printParametersToScreen()

void PiecewiseDecisionRule::printParametersToScreen ( ) const

◆ Reformulate()

ROCPPOptModelIF_Ptr PiecewiseDecisionRule::Reformulate ( ROCPPOptModelIF_Ptr  pIn)
inlinevirtual

Member Data Documentation

◆ m_bigM

double PiecewiseDecisionRule::m_bigM
private

Value of the big M constant.

◆ m_folder

string PiecewiseDecisionRule::m_folder
private

Name of the folder where to write the text file.

◆ m_numBits

uint PiecewiseDecisionRule::m_numBits
private

Number of bits used to approximate the real valued variables affecting the uncertainty set.

◆ m_numPartitionsMap

map<string,uint> PiecewiseDecisionRule::m_numPartitionsMap
private

◆ m_numPartitionsStr

string PiecewiseDecisionRule::m_numPartitionsStr
private

String encoding the number of subsets in the partition for every observable uncertainty in the problem, in alphabetical order.

◆ m_pBPA

ROCPPUncSetRealVarApprox_Ptr PiecewiseDecisionRule::m_pBPA
private

◆ m_pCVA

ROCPPContinuousVarsDR_Ptr PiecewiseDecisionRule::m_pCVA
private

Linear decision rule converter.

◆ m_pDVA

ROCPPDiscreteVarsDR_Ptr PiecewiseDecisionRule::m_pDVA
private

Constant decision rule converter.

◆ m_pMItoMB_Bilinear

ROCPPMItoMB_Ptr PiecewiseDecisionRule::m_pMItoMB_Bilinear
private

◆ m_pPartConstructor

ROCPPParConstructor_Ptr PiecewiseDecisionRule::m_pPartConstructor
private

Partition constructor of this approximator.

◆ m_pPartConverter

ROCPPParConverter_Ptr PiecewiseDecisionRule::m_pPartConverter
private

Partition converter of this approximator.

◆ m_useExplicitNACs

bool PiecewiseDecisionRule::m_useExplicitNACs
private

Use constraints to describe the non anticipativity constraints.

◆ m_VariableMap

map<string, map<string,ROCPPVarIF_Ptr> > PiecewiseDecisionRule::m_VariableMap
private

Map from subset of partition to map from variable in original problem to variable on subset of the partition.