From f8405777635fd964a190a7bf43d886661e9d1844 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Fri, 27 Dec 2024 15:19:25 +0100
Subject: [PATCH] :bug: evaluate_planner_objective.m: account for purely
 forward models

Only try to compute planner welfare related to states if there are any
---
 matlab/optimal_policy/evaluate_planner_objective.m | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/matlab/optimal_policy/evaluate_planner_objective.m b/matlab/optimal_policy/evaluate_planner_objective.m
index cce61b1486..23d43b282f 100644
--- a/matlab/optimal_policy/evaluate_planner_objective.m
+++ b/matlab/optimal_policy/evaluate_planner_objective.m
@@ -265,12 +265,14 @@ else
         oo_.var(isnan(oo_.var)) = options_.huge_number;
 
         Ey = oo_.mean;
-        Eyhat = Ey - ys(dr.order_var(nstatic+(1:nspred)));
 
-        Eyhatyhat = oo_.var(:);
         Euu = M_.Sigma_e(:);
-
-        EU = U + Uy*gy*Eyhat + 0.5*(Uyygygy*Eyhatyhat + Uyygugu*Euu);
+        EU = U + 0.5*Uyygugu*Euu;
+        if M_.maximum_endo_lag
+            Eyhat = Ey - ys(dr.order_var(nstatic+(1:nspred)));
+            Eyhatyhat = oo_.var(:);
+            EU=EU + Uy*gy*Eyhat + 0.5*Uyygygy*Eyhatyhat;
+        end
         EW = EU/(1-beta);
         planner_objective_value.unconditional = EW;
 
-- 
GitLab