28 #include <adolc_sparse.h> 38 #define HPOFF 30 //original: 30 47 using namespace Ipopt;
59 virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
60 Index& nnz_h_lag, IndexStyleEnum& index_style);
62 virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
63 Index m, Number* g_l, Number* g_u);
66 virtual bool get_starting_point(Index n,
bool init_x, Number* x,
67 bool init_z, Number* z_L, Number* z_U,
68 Index m,
bool init_lambda,
71 template<
class T>
bool eval_obj(Index n,
const T *x, T& obj_value);
74 template<
class T>
bool eval_constraints(Index n,
const T *x, Index m, T *g);
78 virtual bool eval_f(Index n,
const Number* x,
bool new_x, Number& obj_value);
82 virtual bool eval_grad_f(Index n,
const Number* x,
bool new_x, Number* grad_f);
86 virtual bool eval_g(Index n,
const Number* x,
bool new_x, Index m, Number* g);
93 virtual bool eval_jac_g(Index n,
const Number* x,
bool new_x,
94 Index m, Index nele_jac, Index* iRow, Index *jCol,
102 virtual bool eval_h(Index n,
const Number* x,
bool new_x,
103 Number obj_factor, Index m,
const Number* lambda,
104 bool new_lambda, Index nele_hess, Index* iRow,
105 Index* jCol, Number* values);
112 virtual void finalize_solution(SolverReturn status,
113 Index n,
const Number* x,
const Number* z_L,
const Number* z_U,
114 Index m,
const Number* g,
const Number* lambda,
116 const IpoptData* ip_data,
117 IpoptCalculatedQuantities* ip_cq);
121 virtual bool intermediate_callback(AlgorithmMode mode,
128 Number regularization_size,
132 const IpoptData *ip_data,
133 IpoptCalculatedQuantities *ip_cq);
138 virtual void generate_tapes(Index n, Index m, Index& nnz_jac_g, Index& nnz_h_lag);
143 void declareVariables();
144 void declareVariable(
const string &name,
const int & domain,
const string &desc=
"",
const double & l_bound=0.0,
const double & u_bound=
UBOUND_MAX,
const string & l_bound_var=
"",
const string & u_bound_var=
"");
145 void declareConstrains();
146 void cacheInitialPosition();
147 void calculateNumberVariablesConstrains();
148 void cachePositions();
149 int getDomainElements(
int domain);
150 template<
class T> vector < vector < vector < vector <int> > > > buildPositionVector(
const T &v_or_c,
int dType);
151 int getVarInstances(
const string& varName);
153 void calculateSparsityPatternJ();
154 void calculateSparsityPatternH();
157 const Number& mymax(
const Number& a,
const Number& b);
158 const adouble& mymax(
const adouble& a,
const adouble& b);
168 const double gpd(
const string &type_h,
const int& regId_h,
const string &prodId_h,
const int& year=
DATA_NOW,
const string &freeDim_h=
"")
const {
return MTHREAD->MD->getProdData(type_h, regId_h, prodId_h, year, freeDim_h);};
169 const double gfd(
const string &type_h,
const int& regId_h,
const string &forType_h,
const string &diamClass_h,
const int& year=
DATA_NOW)
const {
return MTHREAD->MD->getForData(type_h, regId_h, forType_h, diamClass_h, year);};
170 void spd(
const double& value_h,
const string &type_h,
const int& regId_h,
const string &prodId_h,
const int& year=
DATA_NOW,
const bool& allowCreate=
false,
const string &freeDim_h=
"")
const {MTHREAD->MD->setProdData(value_h, type_h, regId_h, prodId_h, year, allowCreate, freeDim_h);};
171 void sfd(
const double& value_h,
const string &type_h,
const int& regId_h,
const string &forType_h,
const string &diamClass_h,
const int& year=
DATA_NOW,
const bool& allowCreate=
false)
const {MTHREAD->MD->setForData(value_h, type_h, regId_h, forType_h, diamClass_h, year, allowCreate);};
172 bool app(
const string &prod_h,
const string &forType_h,
const string &dClass_h)
const {
return MTHREAD->MD->assessProdPossibility(prod_h, forType_h, dClass_h);};
173 const int gip(
const string &varName)
const;
174 const int gip(
const int &cn)
const;
175 template<
class T>
const int gix_uncached(
const T &v_or_c,
int r1Ix,
int r2Ix,
int prIx,
int r2IxTo=0);
176 const int gix(
const string &varName,
const int& r1Ix,
const int& r2Ix,
const int& prIx,
const int& r2IxTo=0)
const;
177 const int gix(
const int &cn,
const int& r1Ix,
const int& r2Ix,
const int& prIx,
const int& r2IxTo=0)
const;
178 const int gdt(
const string &varName);
179 const int gdt(
const int &cn);
180 int getConstrainDirectionByIndex(
int idx);
181 double getBoundByIndex(
const int & bound_type,
const int & idx);
182 double getDetailedBoundByVarAndIndex(
const endvar & var,
const int & idx,
const int & bType);
184 void unpack(
int ix_h,
int domain,
int initial,
int &r1_h,
int &r2_h,
int&p_h,
int&r2to_h,
bool fullp=
false);
187 void copyInventoryResourses();
197 vector < vector <int> >
l2r;
199 vector < vector < vector <double> > >
ins;
204 map <string, vector < vector < vector < vector <int> > > > >
vpositions;
205 vector < vector < vector < vector < vector <int> > > > >
cpositions;
223 void debugPrintParameters();
243 Opt& operator=(
const Opt&);
The required data is for the current year.
double l_bound
A fixed numerical lower bound for all the domain.
double u_bound
A fixed numerical upper bound for all the domain.
const double gfd(const string &type_h, const int ®Id_h, const string &forType_h, const string &diamClass_h, const int &year=DATA_NOW) const
string desc
Description of the variable.
vector< int > cInitPos
A vector that returns the initial index position in the concatenated array for each constrain...
unsigned int * rind_L_total
double overharvestingAllowance
Allows to harvest more than the resources available. Useful when resources got completelly exausted a...
vector< vector< int > > priPrCombs
A vector with all the possible combinations of primary products.
vector< vector< int > > l2r
void spd(const double &value_h, const string &type_h, const int ®Id_h, const string &prodId_h, const int &year=DATA_NOW, const bool &allowCreate=false, const string &freeDim_h="") const
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
int nGreaterEqualZeroConstrains
vector< vector< vector< double > > > ins
A copy of the inventoried resourses by region and primary product combination. It works also with dyn...
bool app(const string &prod_h, const string &forType_h, const string &dClass_h) const
map< string, endvar > vars
List of variables in the model and their domain: pr product, sec prod, all products or all products o...
vector< vector< Index > > nzhelements
nzero elements for the hessian matrix
string u_bound_var
A variable giving the upper bound. If present, the value defined in the variable overrides u_bound...
int nLowerEqualZeroConstrains
map< int, string > initPos_rev
A map with the name of the variable keyed by its initial position in the index.
void sfd(const double &value_h, const string &type_h, const int ®Id_h, const string &forType_h, const string &diamClass_h, const int &year=DATA_NOW, const bool &allowCreate=false) const
Base class for the regmas application.
const double gpd(const string &type_h, const int ®Id_h, const string &prodId_h, const int &year=DATA_NOW, const string &freeDim_h="") const
vector< vector< Index > > nzjelements
nzero elements for the jacobian matrix. nzelements[i][0] -> row (constrain), nzelements[i][1] -> colu...
unsigned int * cind_L_total
string l_bound_var
A variable giving the lower bound. If present, the value defined in the variable overrides l_bound...
#define UBOUND_MAX
Upper bound in optimisation 10^19.
map< string, vector< vector< vector< vector< int > > > > > vpositions
cached position in the concatenated vector for each variables. Dimensions are l1reg, l2reg, prod, (l2To region).
This file is the header of BaseClass and it is included by ALL compiled code.
map< string, int > initPos
A map that returns the initial index position in the concatenated array for each variable.
vector< vector< vector< vector< vector< int > > > > > cpositions
cached position in the concatenated vector for each variables. Dimensions are contrain number...