From 8f51dc890b5de25e40b386e44f421b3f53b94be0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Scylla=29?=
 <stephane.adjemian@univ-lemans.fr>
Date: Wed, 19 Feb 2014 10:34:15 +0100
Subject: [PATCH] Fixed homotopy for stochastic extended path.

(cherry picked from commit e1308a8192b9dbb800b281580e1d1cc6c040e3b9)
---
 matlab/ep/homotopic_steps.m | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/matlab/ep/homotopic_steps.m b/matlab/ep/homotopic_steps.m
index 80e455c66..21a88d767 100644
--- a/matlab/ep/homotopic_steps.m
+++ b/matlab/ep/homotopic_steps.m
@@ -60,7 +60,18 @@ while weight<1
         flag = 1;
     end
     if flag
-        [flag,tmp] = solve_perfect_foresight_model(endo_simul0,exo_simul0,pfm);
+        if ~options_.ep.stochastic.order
+            [flag,tmp,err] = solve_perfect_foresight_model(endo_simul0,exo_simul0,pfm);
+        else
+            switch options_.ep.stochastic.algo
+              case 0
+                [flag,tmp] = ...
+                    solve_stochastic_perfect_foresight_model(endo_simul0,exo_simul0,pfm,options_.ep.stochastic.quadrature.nodes,options_.ep.stochastic.order);
+              case 1
+                [flag,tmp] = ...
+                    solve_stochastic_perfect_foresight_model_1(endo_simul0,exo_simul0,options_.ep,pfm,options_.ep.stochastic.order);
+            end
+        end
     end
     info.convergence = ~flag;% Equal to one if the perfect foresight solver converged for the current value of weight.
     if verbose
@@ -133,7 +144,18 @@ if weight<1
         flag = 1;
     end
     if flag
-        [flag,tmp] = solve_perfect_foresight_model(endo_simul0,exo_simul0,pfm);
+        if ~options_.ep.stochastic.order
+            [flag,tmp,err] = solve_perfect_foresight_model(endo_simul0,exo_simul0,pfm);
+        else
+            switch options_.ep.stochastic.algo
+              case 0
+                [flag,tmp] = ...
+                    solve_stochastic_perfect_foresight_model(endo_simul0,exo_simul0,pfm,options_.ep.stochastic.quadrature.nodes,options_.ep.stochastic.order);
+              case 1
+                [flag,tmp] = ...
+                    solve_stochastic_perfect_foresight_model_1(endo_simul0,exo_simul0,options_.ep,pfm,options_.ep.stochastic.order);
+            end
+        end
     end
     info.convergence = ~flag;
     if info.convergence
-- 
GitLab