preprocessor: check linear model hessian = 0. closes #419

time-shift
Houtan Bastani 2016-07-25 13:43:34 -04:00
parent 8bd4c341fe
commit 7695031e77
2 changed files with 16 additions and 0 deletions

View File

@ -217,6 +217,9 @@ public:
//! Writes model initialization and lead/lag incidence matrix to output
void writeOutput(ostream &output, const string &basename, bool block, bool byte_code, bool use_dll, int order, bool estimation_present, bool compute_xrefs, bool julia) const;
//! Return true if the hessian is equal to zero
inline bool checkHessianZero() const;
//! Adds informations for simulation in a binary file
void Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const string &bin_basename,
const int &num, int &u_count_int, bool &file_open, bool is_two_boundaries) const;
@ -492,6 +495,12 @@ public:
bool isChecksumMatching(const string &basename) const;
};
inline bool
DynamicModel::checkHessianZero() const
{
return second_derivatives.empty();
}
//! Classes to re-order derivatives for various sparse storage formats
class derivative
{

View File

@ -519,6 +519,7 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, bool compute_xr
bool hessian = mod_file_struct.order_option >= 2
|| mod_file_struct.identification_present
|| mod_file_struct.estimation_analytic_derivation
|| linear
|| output == second
|| output == third;
bool thirdDerivatives = mod_file_struct.order_option == 3
@ -532,6 +533,12 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, bool compute_xr
}
else // No computing task requested, compute derivatives up to 2nd order by default
dynamic_model.computingPass(true, true, false, none, global_eval_context, no_tmp_terms, block, use_dll, byte_code, compute_xrefs);
if (linear && !dynamic_model.checkHessianZero())
{
cerr << "ERROR: If the model is declared linear the second derivatives must be equal to zero." << endl;
exit(EXIT_FAILURE);
}
}
for (vector<Statement *>::iterator it = statements.begin();