Revert "preprocessor: params_derivs_file: by default, compute second order derivs wrt params; simplify code; #1187"
This reverts commit 1442f83037
.
time-shift
parent
626f8af374
commit
308828aa95
|
@ -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)
|
||||
paramsDerivatives = first;
|
||||
else
|
||||
paramsDerivatives = second;
|
||||
if (mod_file_struct.estimation_analytic_derivation)
|
||||
paramsDerivatives = third;
|
||||
if (mod_file_struct.identification_present || !sec_order_param_deriv)
|
||||
paramsDerivatives = first;
|
||||
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)
|
||||
paramsDerivatives = first;
|
||||
else
|
||||
paramsDerivatives = second;
|
||||
if (mod_file_struct.estimation_analytic_derivation)
|
||||
paramsDerivatives = third;
|
||||
if (mod_file_struct.identification_present || !sec_order_param_deriv)
|
||||
paramsDerivatives = first;
|
||||
dynamic_model.computingPass(true, hessian, thirdDerivatives, paramsDerivatives, global_eval_context, no_tmp_terms, block, use_dll, byte_code, compute_xrefs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,36 +1704,35 @@ ModelTree::computeParamsDerivatives(FileOutputType paramsDerivatives)
|
|||
jacobian_params_derivatives[make_pair(eq, make_pair(var, param))] = d2;
|
||||
}
|
||||
|
||||
if (paramsDerivatives == second)
|
||||
{
|
||||
for (second_derivatives_t::const_iterator it2 = jacobian_params_derivatives.begin();
|
||||
it2 != jacobian_params_derivatives.end(); it2++)
|
||||
{
|
||||
int eq = it2->first.first;
|
||||
int var = it2->first.second.first;
|
||||
int param1 = it2->first.second.second;
|
||||
expr_t d1 = it2->second;
|
||||
if (paramsDerivatives == second || paramsDerivatives == third)
|
||||
for (second_derivatives_t::const_iterator it2 = jacobian_params_derivatives.begin();
|
||||
it2 != jacobian_params_derivatives.end(); it2++)
|
||||
{
|
||||
int eq = it2->first.first;
|
||||
int var = it2->first.second.first;
|
||||
int param1 = it2->first.second.second;
|
||||
expr_t d1 = it2->second;
|
||||
|
||||
expr_t d2 = d1->getDerivative(param);
|
||||
if (d2 == Zero)
|
||||
continue;
|
||||
jacobian_params_second_derivatives[make_pair(eq, make_pair(var, make_pair(param1, param)))] = d2;
|
||||
}
|
||||
expr_t d2 = d1->getDerivative(param);
|
||||
if (d2 == Zero)
|
||||
continue;
|
||||
jacobian_params_second_derivatives[make_pair(eq, make_pair(var, make_pair(param1, param)))] = d2;
|
||||
}
|
||||
|
||||
for (second_derivatives_t::const_iterator it2 = second_derivatives.begin();
|
||||
it2 != second_derivatives.end(); it2++)
|
||||
{
|
||||
int eq = it2->first.first;
|
||||
int var1 = it2->first.second.first;
|
||||
int var2 = it2->first.second.second;
|
||||
expr_t d1 = it2->second;
|
||||
if (paramsDerivatives == third)
|
||||
for (second_derivatives_t::const_iterator it2 = second_derivatives.begin();
|
||||
it2 != second_derivatives.end(); it2++)
|
||||
{
|
||||
int eq = it2->first.first;
|
||||
int var1 = it2->first.second.first;
|
||||
int var2 = it2->first.second.second;
|
||||
expr_t d1 = it2->second;
|
||||
|
||||
expr_t d2 = d1->getDerivative(param);
|
||||
if (d2 == Zero)
|
||||
continue;
|
||||
hessian_params_derivatives[make_pair(eq, make_pair(var1, make_pair(var2, param)))] = d2;
|
||||
}
|
||||
}
|
||||
expr_t d2 = d1->getDerivative(param);
|
||||
if (d2 == Zero)
|
||||
continue;
|
||||
hessian_params_derivatives[make_pair(eq, make_pair(var1, make_pair(var2, param)))] = d2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue