From 03f97ce6d65715fe4284c2099a2c6d6bffaf85a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Puck=29?= <stepan@adjemian.eu> Date: Wed, 10 Apr 2024 23:10:30 +0200 Subject: [PATCH] Fix auxiliary variable definitions for PAC/MCE expectations. --- src/DynamicModel.cc | 18 +++++------------- src/SubModel.cc | 3 +-- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index 3d9f2df4..5dee6cb7 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -2147,19 +2147,11 @@ DynamicModel::computePacModelConsistentExpectationSubstitutionWithComponents( { // Create the auxiliary variable for this component int aux_id = symbol_table.addPacExpectationAuxiliaryVar(auxname, component); - expr_t aux_var = AddVariable(aux_id); - - // Add the equation defining the auxiliary variable for this component - expr_t neweq = AddEqual(aux_var, component); - addEquation(neweq, nullopt); - addAuxEquation(neweq); - neqs++; // ₘ // fp = ∑ αᵢβⁱZₜ₊ᵢ // ᵢ₌₁ expr_t fp = Zero; - int mce_z_symb_id = symbol_table.addPacExpectationAuxiliaryVar("mce_Z_" + auxname, nullptr); for (int i = 1; i <= pac_eq_max_lag + 1; i++) { int alpha_i_symb_id = -1; @@ -2174,7 +2166,7 @@ DynamicModel::computePacModelConsistentExpectationSubstitutionWithComponents( } fp = AddPlus(fp, AddTimes(AddTimes(AddVariable(alpha_i_symb_id), AddPower(beta, AddPossiblyNegativeConstant(i))), - AddVariable(mce_z_symb_id, i))); + AddVariable(aux_id, i))); } if (kind != PacTargetKind::ll) // non-stationary component y¹ₜ { @@ -2239,7 +2231,7 @@ DynamicModel::computePacModelConsistentExpectationSubstitutionWithComponents( // Assembling the equation Zₜ¹ = A_1 ( Δyₜ¹ - fs ) - fp_1 auto neweq_1 = AddEqual( - AddVariable(mce_z_symb_id), + AddVariable(aux_id), AddMinus( AddTimes(A_1, AddMinus(const_cast<VariableNode*>(aux_target_ns_var_diff_node), fs)), @@ -2252,7 +2244,7 @@ DynamicModel::computePacModelConsistentExpectationSubstitutionWithComponents( else // Stationary component yₜ⁰ { // Assembling the equation Zₜ⁰ = A_beta A_1 yₜ⁰ - fp - auto neweq_0 = AddEqual(AddVariable(mce_z_symb_id), + auto neweq_0 = AddEqual(AddVariable(aux_id), AddMinus(AddTimes(A_beta, AddTimes(A_1, component)), fp)); addEquation(neweq_0, nullopt); neqs++; @@ -2272,8 +2264,8 @@ DynamicModel::computePacModelConsistentExpectationSubstitutionWithComponents( else growth_neutrality_param = -1; - substexpr = AddPlus( - substexpr, AddTimes(coeff, AddPlus(AddVariable(mce_z_symb_id), growth_correction_term))); + substexpr = AddPlus(substexpr, + AddTimes(coeff, AddPlus(AddVariable(aux_id), growth_correction_term))); component_idx++; } diff --git a/src/SubModel.cc b/src/SubModel.cc index bacd904a..7302bab1 100644 --- a/src/SubModel.cc +++ b/src/SubModel.cc @@ -1722,8 +1722,7 @@ PacModelTable::writeOutput(ostream& output) const h_indices, original_growth_component, growth_component_info] : get<2>(val)) { output << pac_model_name << "z(" << component_idx - << ") = " << symbol_table.getTypeSpecificID("mce_Z_" + auxname) + 1 << ";" - << endl; + << ") = " << symbol_table.getTypeSpecificID(auxname) + 1 << ";" << endl; set<int> params; coeff->collectVariables(SymbolType::parameter, params); /* If the coefficient expression uses numerical constants only, set b to 0 and w to the -- GitLab