PIPS-NLP
amplGenStochInput_AddSlack.hpp
Go to the documentation of this file.
1 /* PIPS-NLP *
2  * Authors: Nai-Yuan Chiang *
3  * (C) 2015 Argonne National Laboratory */
4 
5 #ifndef NLCROSSHESSIANINPUT_C__HPP
6 #define NLCROSSHESSIANINPUT_C__HPP
7 
8 #include <map>
9 #include <vector>
10 #include <string>
11 
12 #include "stochasticInput.hpp"
13 #include "amplGenStochInput.hpp"
14 #include "AmplData_NL.hpp"
15 
16 #include "mpi.h"
17 
18 
19 struct ASL_pfgh;
20 struct SufDecl;
21 struct SufDesc;
22 
23 
24 // solve problem as
25 // min 1/s f(x_s)
26 // st g(x_s) = 0
27 // M_sx_s = x_0
28 //
29 // this input is differenent from the amplGenStochInput one.
30 // In amplGenStochInput, we do split/reorder the Hessian and Jacobian in this case.
31 // Here we need to add dummy variable/constraint
32 //
33 //
34 // Jacobian looks like
35 // W_1 T_1
36 // W_2 T_1
37 // ...
38 // W_n T_n
39 // A
40 //
41 //
42 // Hessian looks like
43 // QW_1 QT_1
44 // QW_2 QT_1
45 // ...
46 // QW_n QT_n
47 // QA
48 
49 
51 public:
53  amplGenStochInput_AddSlack(const std::string &datarootname, int overrideScenarioNumber = 0,
54  MPI_Comm comm = MPI_COMM_WORLD);
56 
57  virtual int nScenarios() { return nScenarios_; }
58  virtual int nFirstStageVars() { return nFirstStageVars_; }
59  virtual int nFirstStageCons() { return nFirstStageCons_; }
60  virtual int nSecondStageVars(int scen) { return nSecondStageVars_[scen]; }
61  virtual int nSecondStageCons(int scen) { return nSecondStageCons_[scen]; }
62 
63  virtual std::vector<double> getFirstStageColLB(){ return firstStageData.collb; }
64  virtual std::vector<double> getFirstStageColUB(){ return firstStageData.colub; }
65  virtual std::vector<double> getFirstStageObj(){ return firstStageData.objGrad; }
66  virtual std::vector<std::string> getFirstStageColNames(){return firstStageData.colnames;}
67  virtual std::vector<double> getFirstStageRowLB(){ return firstStageData.rowlb; }
68  virtual std::vector<double> getFirstStageRowUB(){ return firstStageData.rowub; }
69  virtual std::vector<std::string> getFirstStageRowNames(){ return firstStageData.rownames; }
70 
71  virtual bool isFirstStageColInteger(int col) { return false; }
72 
73  virtual std::vector<double> getSecondStageColLB(int scen){loadLocalNLdata(scen);return localData[scen].collb;}
74  virtual std::vector<double> getSecondStageColUB(int scen){loadLocalNLdata(scen);return localData[scen].colub;}
75  virtual std::vector<double> getSecondStageObj(int scen){loadLocalNLdata(scen);return localData[scen].objGrad;}
76  virtual std::vector<std::string> getSecondStageColNames(int scen){loadLocalNLdata(scen);return localData[scen].colnames;}
77  virtual std::vector<double> getSecondStageRowLB(int scen){loadLocalNLdata(scen);return localData[scen].rowlb;}
78  virtual std::vector<double> getSecondStageRowUB(int scen){loadLocalNLdata(scen);return localData[scen].rowub;}
79  virtual std::vector<std::string> getSecondStageRowNames(int scen){loadLocalNLdata(scen);return localData[scen].rownames;}
80  virtual double scenarioProbability(int scen) { return 1.0/nScenarios_; }
81  virtual bool isSecondStageColInteger(int scen, int col) { return false; }
82 
83 
84 
85  virtual CoinPackedMatrix getFirstStageConstraints() { return Amat; }
86  virtual CoinPackedMatrix getSecondStageConstraints(int scen) {loadLocalNLdata(scen); return Wmat[scen]; }
87  virtual CoinPackedMatrix getLinkingConstraints(int scen) {loadLocalNLdata(scen); return Tmat[scen]; }
88 
89 
90 
91  virtual CoinPackedMatrix getFirstStageHessian(){return QAmat;}
92  // Q_i
93  virtual CoinPackedMatrix getSecondStageHessian(int scen){loadLocalNLdata(scen);return QWmat[scen];}
94  // column-oriented, \hat Q_i
95  // Note: this has the second-stage variables on the rows and first-stage on the columns
96  virtual CoinPackedMatrix getSecondStageCrossHessian(int scen){loadLocalNLdata(scen);return QTmat[scen];}
97 
98 
99 
100 
101  virtual bool scenarioDimensionsEqual() { return dimsEqual; }
102  virtual bool onlyBoundsVary() { return false; } // no easy way to check
103  virtual bool allProbabilitiesEqual() { return true; }
104  virtual bool continuousRecourse() { return true; }
105 
106  virtual void doNetworkPart(const int scen, AmplSuffix* amplSuffix);
107 
108  virtual void loadLocalNLdata(int scen);
109  virtual void splitMatrices(const int scen);
110 
111  virtual void getRowMap(const int scen);
112 
113  virtual void getJacGoffMap(const int scen);
114 
115 
116  friend class sNlpInfoFromNL;
117 
118 
119 
120 };
121 
122 
123 #endif
124 
125 
std::vector< double > collb
Definition: AmplData_NL.hpp:36
virtual void getJacGoffMap(const int scen)
Definition: amplGenStochInput_AddSlack.cpp:518
std::vector< CoinPackedMatrix > QTmat
Definition: amplGenStochInput.hpp:216
virtual std::vector< double > getSecondStageColUB(int scen)
Definition: amplGenStochInput_AddSlack.hpp:74
AmplData_NL firstStageData
Definition: amplGenStochInput.hpp:210
virtual std::vector< double > getFirstStageRowUB()
Definition: amplGenStochInput_AddSlack.hpp:68
CoinPackedMatrix QAmat
Definition: amplGenStochInput.hpp:215
virtual CoinPackedMatrix getFirstStageHessian()
Definition: amplGenStochInput_AddSlack.hpp:91
std::vector< double > colub
Definition: AmplData_NL.hpp:36
std::vector< double > rowlb
Definition: AmplData_NL.hpp:36
std::vector< CoinPackedMatrix > Tmat
Definition: amplGenStochInput.hpp:216
virtual int nScenarios()
Definition: amplGenStochInput_AddSlack.hpp:57
virtual std::vector< std::string > getFirstStageColNames()
Definition: amplGenStochInput_AddSlack.hpp:66
virtual void doNetworkPart(const int scen, AmplSuffix *amplSuffix)
Definition: amplGenStochInput_AddSlack.cpp:701
std::vector< CoinPackedMatrix > Wmat
Definition: amplGenStochInput.hpp:216
virtual int nFirstStageCons()
Definition: amplGenStochInput_AddSlack.hpp:59
amplGenStochInput_AddSlack()
Definition: amplGenStochInput_AddSlack.hpp:52
virtual double scenarioProbability(int scen)
Definition: amplGenStochInput_AddSlack.hpp:80
virtual std::vector< double > getSecondStageRowUB(int scen)
Definition: amplGenStochInput_AddSlack.hpp:78
bool dimsEqual
Definition: amplGenStochInput.hpp:182
Definition: amplGenStochInput_AddSlack.hpp:50
virtual bool onlyBoundsVary()
Definition: amplGenStochInput_AddSlack.hpp:102
virtual std::vector< double > getSecondStageObj(int scen)
Definition: amplGenStochInput_AddSlack.hpp:75
virtual std::vector< std::string > getSecondStageColNames(int scen)
Definition: amplGenStochInput_AddSlack.hpp:76
virtual std::vector< std::string > getSecondStageRowNames(int scen)
Definition: amplGenStochInput_AddSlack.hpp:79
int nFirstStageCons_
Definition: amplGenStochInput.hpp:187
virtual std::vector< double > getFirstStageColLB()
Definition: amplGenStochInput_AddSlack.hpp:63
virtual bool scenarioDimensionsEqual()
Definition: amplGenStochInput_AddSlack.hpp:101
virtual std::vector< double > getSecondStageRowLB(int scen)
Definition: amplGenStochInput_AddSlack.hpp:77
int nFirstStageVars_
Definition: amplGenStochInput.hpp:187
virtual bool isFirstStageColInteger(int col)
Definition: amplGenStochInput_AddSlack.hpp:71
std::vector< CoinPackedMatrix > QWmat
Definition: amplGenStochInput.hpp:216
virtual int nFirstStageVars()
Definition: amplGenStochInput_AddSlack.hpp:58
std::string datarootname
Definition: stochasticInput.hpp:109
std::vector< int > nSecondStageVars_
Definition: amplGenStochInput.hpp:188
virtual CoinPackedMatrix getLinkingConstraints(int scen)
Definition: amplGenStochInput_AddSlack.hpp:87
std::vector< AmplData_NL > localData
Definition: amplGenStochInput.hpp:209
virtual void loadLocalNLdata(int scen)
Definition: amplGenStochInput_AddSlack.cpp:593
virtual std::vector< double > getSecondStageColLB(int scen)
Definition: amplGenStochInput_AddSlack.hpp:73
std::vector< double > objGrad
Definition: AmplData_NL.hpp:36
virtual CoinPackedMatrix getFirstStageConstraints()
Definition: amplGenStochInput_AddSlack.hpp:85
Definition: sNlpInfoFromNL.h:25
CoinPackedMatrix Amat
Definition: amplGenStochInput.hpp:215
virtual std::vector< double > getFirstStageColUB()
Definition: amplGenStochInput_AddSlack.hpp:64
virtual void splitMatrices(const int scen)
Definition: amplGenStochInput_AddSlack.cpp:262
~amplGenStochInput_AddSlack()
Definition: amplGenStochInput_AddSlack.hpp:55
virtual bool allProbabilitiesEqual()
Definition: amplGenStochInput_AddSlack.hpp:103
virtual bool continuousRecourse()
Definition: amplGenStochInput_AddSlack.hpp:104
virtual int nSecondStageCons(int scen)
Definition: amplGenStochInput_AddSlack.hpp:61
Definition: AmplData_NL.hpp:53
virtual std::vector< double > getFirstStageObj()
Definition: amplGenStochInput_AddSlack.hpp:65
virtual CoinPackedMatrix getSecondStageConstraints(int scen)
Definition: amplGenStochInput_AddSlack.hpp:86
std::vector< std::string > colnames
Definition: AmplData_NL.hpp:38
virtual std::vector< std::string > getFirstStageRowNames()
Definition: amplGenStochInput_AddSlack.hpp:69
Definition: amplGenStochInput.hpp:42
virtual bool isSecondStageColInteger(int scen, int col)
Definition: amplGenStochInput_AddSlack.hpp:81
virtual void getRowMap(const int scen)
Definition: amplGenStochInput_AddSlack.cpp:500
int nScenarios_
Definition: amplGenStochInput.hpp:187
virtual int nSecondStageVars(int scen)
Definition: amplGenStochInput_AddSlack.hpp:60
virtual CoinPackedMatrix getSecondStageCrossHessian(int scen)
Definition: amplGenStochInput_AddSlack.hpp:96
std::vector< std::string > rownames
Definition: AmplData_NL.hpp:38
std::vector< double > rowub
Definition: AmplData_NL.hpp:36
std::vector< int > nSecondStageCons_
Definition: amplGenStochInput.hpp:188
virtual std::vector< double > getFirstStageRowLB()
Definition: amplGenStochInput_AddSlack.hpp:67
virtual CoinPackedMatrix getSecondStageHessian(int scen)
Definition: amplGenStochInput_AddSlack.hpp:93