Revert "preprocessor: params_derivs_file: by default, compute second order derivs wrt params; simplify code; #1187"

This reverts commit 1442f83037.
time-shift
Houtan Bastani 2016-05-17 15:37:29 +02:00
parent 626f8af374
commit 308828aa95
2 changed files with 36 additions and 39 deletions

View File

@ -490,11 +490,10 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, bool compute_xr
const bool static_hessian = mod_file_struct.identification_present
|| mod_file_struct.estimation_analytic_derivation;
FileOutputType paramsDerivatives = none;
if (mod_file_struct.identification_present || mod_file_struct.estimation_analytic_derivation)
if (!sec_order_param_deriv)
if (mod_file_struct.estimation_analytic_derivation)
paramsDerivatives = third;
if (mod_file_struct.identification_present || !sec_order_param_deriv)
paramsDerivatives = first;
else
paramsDerivatives = second;
static_model.computingPass(global_eval_context, no_tmp_terms, static_hessian,
false, paramsDerivatives, block, byte_code);
}
@ -528,11 +527,10 @@ ModFile::computingPass(bool no_tmp_terms, FileOutputType output, bool compute_xr
|| mod_file_struct.estimation_analytic_derivation
|| output == third;
FileOutputType paramsDerivatives = none;
if (mod_file_struct.identification_present || mod_file_struct.estimation_analytic_derivation)
if (!sec_order_param_deriv)
if (mod_file_struct.estimation_analytic_derivation)
paramsDerivatives = third;
if (mod_file_struct.identification_present || !sec_order_param_deriv)
paramsDerivatives = first;
else
paramsDerivatives = second;
dynamic_model.computingPass(true, hessian, thirdDerivatives, paramsDerivatives, global_eval_context, no_tmp_terms, block, use_dll, byte_code, compute_xrefs);
}
}

View File

@ -1659,7 +1659,7 @@ ModelTree::sparseHelper(int order, ostream &output, int row_nb, int col_nb, Expr
void
ModelTree::computeParamsDerivatives(FileOutputType paramsDerivatives)
{
if (!(paramsDerivatives == first || paramsDerivatives == second))
if (!(paramsDerivatives == first || paramsDerivatives == second || paramsDerivatives == third))
return;
set<int> deriv_id_set;
addAllParamDerivId(deriv_id_set);
@ -1677,7 +1677,7 @@ ModelTree::computeParamsDerivatives(FileOutputType paramsDerivatives)
residuals_params_derivatives[make_pair(eq, param)] = d1;
}
if (paramsDerivatives == second)
if (paramsDerivatives == second || paramsDerivatives == third)
for (first_derivatives_t::const_iterator it2 = residuals_params_derivatives.begin();
it2 != residuals_params_derivatives.end(); it2++)
{
@ -1704,8 +1704,7 @@ ModelTree::computeParamsDerivatives(FileOutputType paramsDerivatives)
jacobian_params_derivatives[make_pair(eq, make_pair(var, param))] = d2;
}
if (paramsDerivatives == second)
{
if (paramsDerivatives == second || paramsDerivatives == third)
for (second_derivatives_t::const_iterator it2 = jacobian_params_derivatives.begin();
it2 != jacobian_params_derivatives.end(); it2++)
{
@ -1720,6 +1719,7 @@ ModelTree::computeParamsDerivatives(FileOutputType paramsDerivatives)
jacobian_params_second_derivatives[make_pair(eq, make_pair(var, make_pair(param1, param)))] = d2;
}
if (paramsDerivatives == third)
for (second_derivatives_t::const_iterator it2 = second_derivatives.begin();
it2 != second_derivatives.end(); it2++)
{
@ -1734,7 +1734,6 @@ ModelTree::computeParamsDerivatives(FileOutputType paramsDerivatives)
hessian_params_derivatives[make_pair(eq, make_pair(var1, make_pair(var2, param)))] = d2;
}
}
}
}
void