From 4ca5c36669d333d0b8628dec661f6f611c38c87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Ry=C3=BBk=29?= <stepan@adjemian.eu> Date: Thu, 14 Oct 2021 19:33:44 +0200 Subject: [PATCH] Fix cherrypick for PAC equations in case of rule of thumb agents. The correction for growth neutrality should be substituted in the optimal part of the PAC equations. (cherry picked from commit 12694ff9347b2191b4e0f6a32cb038956cb38f53) (cherry picked from commit 9acac86bd8371c202e68d653ee4672fb0aae2544) --- matlab/cherrypick.m | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/matlab/cherrypick.m b/matlab/cherrypick.m index 85bfe6af4e..3224d4f45f 100644 --- a/matlab/cherrypick.m +++ b/matlab/cherrypick.m @@ -134,10 +134,22 @@ for i=1:length(eqtags) end if ~isempty(ispac) [rhs, growthneutralitycorrection] = write_expectations(eqtags{i}, ispac.name, 'pac'); - lhs = sprintf('%s_PE', eqtags{i}); - RHS = strrep(RHS, sprintf('pac_expectation(model_name = %s)', ispac.name), lhs); - if ~isempty(growthneutralitycorrection) - RHS = sprintf('%s + %s', RHS, growthneutralitycorrection); + if ~isempty(rhs) + lhs = sprintf('%s_PE', eqtags{i}); + if isempty(growthneutralitycorrection) + RHS = strrep(RHS, sprintf('pac_expectation(model_name = %s)', ispac.name), lhs); + else + RHS = strrep(RHS, sprintf('pac_expectation(model_name = %s)', ispac.name), sprintf('%s+%s', lhs, growthneutralitycorrection)); + end + else + % MCE version of the PAC equation. + [rhs, growthneutralitycorrection] = write_pac_mce_expectations(eqtags{i}, ispac.name); + lhs = sprintf('%s_Z', eqtags{i}); + if isempty(growthneutralitycorrection) + RHS = strrep(RHS, sprintf('pac_expectation(model_name = %s)', ispac.name), lhs); + else + RHS = strrep(RHS, sprintf('pac_expectation(model_name = %s)', ispac.name), sprintf('%s+%s', lhs, growthneutralitycorrection)); + end end end % Print equation for unrolled PAC/VAR-expectation and update -- GitLab