28#include <adolc_sparse.h>
59 virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
60 Index& nnz_h_lag, IndexStyleEnum& index_style);
63 Index m, Number* g_l, Number* g_u);
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);
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);
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);
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);
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=
"");
150template<
class T> vector < vector < vector < vector <int> > > >
buildPositionVector(
const T &v_or_c,
int dType);
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);};
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);
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);
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;
This file is the header of BaseClass and it is included by ALL compiled code.
@ DATA_NOW
The required data is for the current year.
#define UBOUND_MAX
Upper bound in optimisation 10^19.
Base class for the regmas application.
ThreadManager * MTHREAD
Pointer to the Thread manager.
void setProdData(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 double getForData(const string &type_h, const int ®Id_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW)
void setForData(const double &value_h, const string &type_h, const int ®Id_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW, const bool &allowCreate=false)
const bool assessProdPossibility(const string &prod_h, const string &forType_h, const string &dClass_h)
A simple function to assess if a specified product can be made by a certain forest type and diameter ...
const double getProdData(const string &type_h, const int ®Id_h, const string &prodId_h, const int &year=DATA_NOW, const string &freeDim_h="")
int nLowerEqualZeroConstrains
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
map< string, vector< vector< vector< vector< int > > > > > vpositions
cached position in the concatenated vector for each variables. Dimensions are l1reg,...
const int gix(const string &varName, const int &r1Ix, const int &r2Ix, const int &prIx, const int &r2IxTo=0) const
Get the index in the concatenated array gived a certain var name, the reg lev1 index,...
vector< vector< int > > priPrCombs
A vector with all the possible combinations of primary products.
vector< vector< vector< double > > > ins
A copy of the inventoried resourses by region and primary product combination. It works also with dyn...
int nGreaterEqualZeroConstrains
constrain * getConstrainByIndex(int idx)
void declareVariables()
declare the variables, their domains and their bounds
unsigned int * cind_L_total
int getDomainElements(int domain)
return the number of elements of a domain
vector< vector< int > > l2r
void calculateSparsityPatternH()
virtual bool intermediate_callback(AlgorithmMode mode, Index iter, Number obj_value, Number inf_pr, Number inf_du, Number mu, Number d_norm, Number regularization_size, Number alpha_du, Number alpha_pr, Index ls_trials, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)
bool eval_obj(Index n, const T *x, T &obj_value)
virtual bool get_bounds_info(Index n, Number *x_l, Number *x_u, Index m, Number *g_l, Number *g_u)
map< int, string > initPos_rev
A map with the name of the variable keyed by its initial position in the index.
void cacheInitialPosition()
cache the initial positions of the variables and the constrains
double getBoundByIndex(const int &bound_type, const int &idx)
Return the bound of a given variable (by index)
int getConstrainDirectionByIndex(int idx)
Return the direction of a given constrain.
const int gip(const string &varName) const
Get the initial index position of a given variable in the concatenated array.
virtual bool eval_f(Index n, const Number *x, bool new_x, Number &obj_value)
double overharvestingAllowance
Allows to harvest more than the resources available. Useful when resources got completelly exausted a...
map< string, int > initPos
A map that returns the initial index position in the concatenated array for each variable.
unsigned int * rind_L_total
virtual bool get_starting_point(Index n, bool init_x, Number *x, bool init_z, Number *z_L, Number *z_U, Index m, bool init_lambda, Number *lambda)
void cachePositions()
cache the exact position index (initial+f(r1,r2,p,r2To) for each variable and constrain
virtual bool get_nlp_info(Index &n, Index &m, Index &nnz_jac_g, Index &nnz_h_lag, IndexStyleEnum &index_style)
virtual bool eval_jac_g(Index n, const Number *x, bool new_x, Index m, Index nele_jac, Index *iRow, Index *jCol, Number *values)
void debugPrintParameters()
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="")
Declare a single variable, its domain and its bounds.
vector< vector< vector< vector< int > > > > buildPositionVector(const T &v_or_c, int dType)
build the matrix of the positions for a given variable or contrain
virtual bool eval_g(Index n, const Number *x, bool new_x, Index m, Number *g)
void calculateNumberVariablesConstrains()
calculate the number of variables and constrains
void copyInventoryResourses()
Copy the inventoried resources in the in vector for better performances.
void calculateSparsityPatternJ()
vector< vector< Index > > nzhelements
nzero elements for the hessian matrix
map< string, endvar > vars
List of variables in the model and their domain: pr product, sec prod, all products or all products o...
int getConNumber(constrain *con)
Return the position in the cons vector.
bool app(const string &prod_h, const string &forType_h, const string &dClass_h) const
bool eval_constraints(Index n, const T *x, Index m, T *g)
int getVarInstances(const string &varName)
build the matrix of the positions for a given variable or contrain
void unpack(int ix_h, int domain, int initial, int &r1_h, int &r2_h, int &p_h, int &r2to_h, bool fullp=false)
Return the dimensions given a certain index, domain type and initial position.
virtual void finalize_solution(SolverReturn status, Index n, const Number *x, const Number *z_L, const Number *z_U, Index m, const Number *g, const Number *lambda, Number obj_value, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq)
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
virtual bool eval_h(Index n, const Number *x, bool new_x, Number obj_factor, Index m, const Number *lambda, bool new_lambda, Index nele_hess, Index *iRow, Index *jCol, Number *values)
const int gdt(const string &varName)
Get the domain type of a given variable.
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
virtual void generate_tapes(Index n, Index m, Index &nnz_jac_g, Index &nnz_h_lag)
vector< int > cInitPos
A vector that returns the initial index position in the concatenated array for each constrain.
void declareConstrains()
declare the constrains, their domain, their direction and their associated evaluation function
double getDetailedBoundByVarAndIndex(const endvar &var, const int &idx, const int &bType)
Return the bound of a given variable given the variable and the required index. Called by getBoundByI...
const int gix_uncached(const T &v_or_c, int r1Ix, int r2Ix, int prIx, int r2IxTo=0)
Get the index in the concatenated array gived a certain var name (string) or constrain index (int),...
vector< vector< vector< vector< vector< int > > > > > cpositions
cached position in the concatenated vector for each variables. Dimensions are contrain number,...
const Number & mymax(const Number &a, const Number &b)
Opt & operator=(const Opt &)
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
virtual bool eval_grad_f(Index n, const Number *x, bool new_x, Number *grad_f)
vector< vector< Index > > nzjelements
nzero elements for the jacobian matrix. nzelements[i][0] -> row (constrain), nzelements[i][1] -> colu...
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
ModelData * MD
the model data object
string l_bound_var
A variable giving the lower bound. If present, the value defined in the variable overrides l_bound.
double u_bound
A fixed numerical upper bound for all the domain.
string u_bound_var
A variable giving the upper bound. If present, the value defined in the variable overrides u_bound.
string desc
Description of the variable.
double l_bound
A fixed numerical lower bound for all the domain.