Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
212e49b
Support mixed finite/infinite horizon problems
MichaelTiemann Jan 22, 2026
228f86b
Re-merge master for take 2
MichaelTiemann Jan 29, 2026
b7ecf49
Improve lowmemory==2 for ExpAssets
MichaelTiemann Feb 12, 2026
681e0c1
Support CustomModelStat variables for PTypes
MichaelTiemann Mar 1, 2026
add9455
Create a working OLGModel14 with mixed horizon transition paths
MichaelTiemann Mar 3, 2026
007dc98
Fix II1, IIone calcs for Gammatranspose
MichaelTiemann Mar 3, 2026
efeb223
More mixed horizon fixes
MichaelTiemann Mar 3, 2026
dd8f466
Don't try to look for age-shaped vectors when InfHorz
MichaelTiemann Mar 5, 2026
92143bb
Update vestigial `transpathoptions.maxiterations` to maxiter
MichaelTiemann Mar 6, 2026
1151b95
Rework guts of TransitionPath_InfHorz_PType_singlepath; PType support…
MichaelTiemann Mar 7, 2026
43cb440
Fix code drift in setupGEnewprice3_shooting.m
MichaelTiemann Mar 8, 2026
c174d23
Fixed AgeWeights merge and other fixes
MichaelTiemann Mar 8, 2026
85c4854
Use ttr as varname walking backward from V_final
MichaelTiemann Mar 8, 2026
78abb87
Fix typos
MichaelTiemann Mar 12, 2026
bd87f3e
Efficient z reshape
MichaelTiemann Mar 12, 2026
73b5fe1
Enable reshaping StationaryDist with nans
MichaelTiemann Mar 12, 2026
bcb2d55
Don't error early when searching for parameters in PTypes
MichaelTiemann Mar 12, 2026
9760f18
Fix case where n_z==1
MichaelTiemann Mar 12, 2026
1076437
Incrementally push AggVars into PType parameter lists
MichaelTiemann Mar 12, 2026
b75ae64
Improve lowmemory==2 effectiveness
MichaelTiemann Mar 12, 2026
bf9d646
Revert making StationaryDist a full matrix for GPU's sake
MichaelTiemann Mar 13, 2026
bd3ff08
Support larger ExpAsset models
MichaelTiemann Mar 15, 2026
7bae273
Additional support for larger ExpAsset models
MichaelTiemann Mar 15, 2026
ba3cb3f
Knocking out l_daprime=7 in favor of l_daprime=6
MichaelTiemann Mar 16, 2026
e5db55d
Pre-merge checkpoint
MichaelTiemann Mar 19, 2026
2e9ac40
Fix missing polindorval in ValueFnIter_Case1
MichaelTiemann Mar 19, 2026
d5b249a
Fix l_ze calculation, and other needs
MichaelTiemann Mar 20, 2026
7aa32ae
Translate the ExpAsset _e codes to work without `e`
MichaelTiemann Mar 20, 2026
014fe33
Reharmonize with new CustomModelStats
MichaelTiemann Mar 24, 2026
a27e353
Parameters are the one element that is supra-PType
MichaelTiemann Mar 24, 2026
3534007
Need to initialize PTypeStructure.(iistr).Parameters before use
MichaelTiemann Mar 24, 2026
c0ec397
More merge cleanups
MichaelTiemann Mar 24, 2026
0e367ee
Need to initialize PTypeStructure.(iistr).Parameters before use
MichaelTiemann Mar 24, 2026
80e8899
Fix merge error...and minor
MichaelTiemann Mar 24, 2026
032d7a5
Revert stylistic change
MichaelTiemann Mar 24, 2026
8235966
Remaining PType and TPath changes (no ExpAsset)
MichaelTiemann Mar 24, 2026
12b333d
Re-align with InfHorz ExpAsset changes in main
MichaelTiemann Apr 5, 2026
703e9ca
Fix half of EvalFnOnAgentDist_AggVars_FHorz_ExpAsset_fastOLG.m
MichaelTiemann Apr 8, 2026
a70096a
minor
MichaelTiemann Apr 9, 2026
a8c4507
minor revert
MichaelTiemann Apr 12, 2026
4d2ffd1
Revert deletion of extra space at EOL
MichaelTiemann Apr 14, 2026
de88803
Fix calls to PolicyInd2Val_InfHorz_TPath when n_d1 is zero
MichaelTiemann Apr 14, 2026
c56b2cc
Final reharmonization with latest VFI Toolkit merges
MichaelTiemann Apr 14, 2026
32682a1
Remove unnecessary ExpAsset files in KronPolicyIndexes
MichaelTiemann Apr 14, 2026
686ff5d
Tidy and regularize ExpAsset raw handlers
MichaelTiemann Apr 15, 2026
efcb3c7
Add missing comma to ValueFnIter_FHorz_TPath_SingleStep_ExpAsset_e_ra…
MichaelTiemann Apr 15, 2026
571aa32
Remove unnecessary ExpAsset files
MichaelTiemann Apr 16, 2026
903e53b
Integration with new 5-step refactorization
MichaelTiemann Apr 25, 2026
3a95d32
Remove unneeded files.
MichaelTiemann Apr 25, 2026
8c0bc88
Fixes and cleanups
MichaelTiemann May 3, 2026
ccc246f
Establish MixHorz changes
MichaelTiemann May 7, 2026
d8823b8
Version 2.5: switch to _InfHorz
robertdkirkby May 4, 2026
d1bf81a
d_gridvals for InfHorz, including TPath
robertdkirkby May 5, 2026
5c52f95
relocate pi_z to appropriate input location
robertdkirkby May 6, 2026
913c915
refactor InfHorz TPath to use five steps approach
robertdkirkby May 7, 2026
ff817a5
Completed run through Electrify code
MichaelTiemann May 7, 2026
e8369a6
Revert FHorz_PType changes now part of MixHorz changes
MichaelTiemann May 7, 2026
88ad9c9
Merge pull request #6 from vfitoolkit/master
MichaelTiemann May 9, 2026
0436f41
Fix redundancies and resync
MichaelTiemann May 9, 2026
d010a49
Fix PVP_ii_t logic
MichaelTiemann May 10, 2026
cfa533e
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 10, 2026
e801f7c
Pre-merge PRs 89 and 90
MichaelTiemann May 10, 2026
2399d23
Expand fixes for `e` grids
MichaelTiemann May 11, 2026
bacb5bd
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 11, 2026
e1f407c
Reshape V_final regardless of fastOLG
MichaelTiemann May 11, 2026
7645fc1
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 12, 2026
ec04d47
Restore fixes to make Electrify complete when fastOLG==0
MichaelTiemann May 13, 2026
15efce1
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 13, 2026
bf8655c
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 13, 2026
327f98e
Additional fixes when not N_Z>0 && N_e>0
MichaelTiemann May 13, 2026
ea6fbe2
rename _Case1_MixHorz to _MixHorz
MichaelTiemann May 13, 2026
0b103ca
Change _Case1_MixHorz interfaces to _MixHorz
MichaelTiemann May 13, 2026
d989794
Adjust parameter order based on new AgentDistOnTransPath_InfHorz
MichaelTiemann May 13, 2026
c60da50
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 13, 2026
e28f34c
Fixes from stash
MichaelTiemann May 13, 2026
7569fdb
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 14, 2026
64b8270
Add missing call to SetupNonStandardEndoStates_InfHorz_TPath
MichaelTiemann May 14, 2026
cbaf273
Fix bad merge into TransitionPath_MixHorz_PType
MichaelTiemann May 14, 2026
6b4b336
Check existence of Idependsonptype
MichaelTiemann May 14, 2026
633abed
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 14, 2026
f887d3e
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 15, 2026
25c0682
Absorb e_grid and pi_e changes
MichaelTiemann May 15, 2026
a8022f4
Potential lowmemory improvements
MichaelTiemann May 15, 2026
bb8d397
Initialize transpathoptions.trivialjequalonedist=0
MichaelTiemann May 15, 2026
55bcfff
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 15, 2026
539e5d3
Fix more merge problems
MichaelTiemann May 15, 2026
7fb704d
Merge fixes and prep
MichaelTiemann May 15, 2026
604f367
More merge cleanups and fixups
MichaelTiemann May 15, 2026
953f15d
Copy in verbose logic from FHorz case
MichaelTiemann May 15, 2026
ef8dd99
More merge fixes and simplifications
MichaelTiemann May 15, 2026
1fdb3ba
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 19, 2026
d9ae43d
Resync PolicyInd2Val_FHorz_TPath.m with master.
MichaelTiemann May 19, 2026
09c8ce5
Resync EvalFnOnTransPath_AggVars_InfHorz.m with master
MichaelTiemann May 19, 2026
e1f8f00
Resync with master
MichaelTiemann May 19, 2026
abfccc7
Integrate PR 94
MichaelTiemann May 20, 2026
b0c476b
Add missing lowmemory==3
MichaelTiemann May 20, 2026
52dc627
Update from HeteroAgentStationaryEqm_merge
MichaelTiemann May 20, 2026
ac6ff21
More merge fixes
MichaelTiemann May 20, 2026
6852e69
Move d_grid and a_grid to GPU
MichaelTiemann May 20, 2026
c795d26
Fixes needed for full z and e end-to-end
MichaelTiemann May 20, 2026
f43bb3d
Changes needed for fastOLG Scenario 3
MichaelTiemann May 21, 2026
194fb4c
Merge branch 'master' into mixed-horizon-tpath
MichaelTiemann May 21, 2026
0325384
e_gridvals_J and lowmemory==3 issues
MichaelTiemann May 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
if simoptions.alreadygridvals==0
% gridpiboth=1: only need z_gridvals_J (and e_gridvals_J if N_e>0)
[z_gridvals_J, ~, ~, e_gridvals_J, ~, ~, ~, transpathoptions, simoptions]=ExogShockSetup_FHorz_TPath(n_z,z_grid,[],N_a,N_j,Parameters,PricePathNames,ParamPathNames,transpathoptions,simoptions,1);
simoptions.alreadygridvals=1; % we call down with z_gridvals_J, so those are already gridvals
elseif simoptions.alreadygridvals==1
z_gridvals_J=z_grid;
e_gridvals_J=simoptions.e_gridvals_J;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
heteroagentoptions.useCustomModelStats=1;
% Stash some of the inputs so they can be passed to CustomModelStats later (only things we otherwise override).
% So that user gets exactly what they input, not any internally reworked things
% In this (non-PType) context, these assignments are arrays or other simple types
heteroagentoptions.CustomModelStatsInputs.z_grid=z_grid;
heteroagentoptions.CustomModelStatsInputs.pi_z=pi_z;
% Need the following two as otherwise they would contain alreadygridvals=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@
%% Parameter Structure
% Parameters are allowed to be given as structure, or as vector/matrix
% (in terms of their dependence on permanent type). So go through each of
% these in term.
% these in turn.
% ie. Parameters.alpha=[0;1]; or Parameters.alpha.ptype1=0; Parameters.alpha.ptype2=1;
PTypeStructure.(iistr).Parameters=Parameters;
FullParamNames=fieldnames(Parameters); % all the different parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
Parameters.(GEPriceParamNames{pp})=GEpricesvec(GEpriceindexes(pp,1):GEpriceindexes(pp,2));
end

AggVars_ConditionalOnPType=zeros(PTypeStructure.numFnsToEvaluate,PTypeStructure.N_i,'gpuArray'); % Create AggVars conditional on ptype.
AggVars_ConditionalOnPType=zeros(PTypeStructure.numFnsToEvaluate,PTypeStructure.N_i); % Create AggVars conditional on ptype.

for ii=1:PTypeStructure.N_i

Expand Down Expand Up @@ -76,17 +76,29 @@
Policy.(iistr)=Policy_ii;
StationaryDist.(iistr)=StationaryDist_ii;
end

warning("do we still need this?")
% Put updated AggVars into subsequent PTypeStructure Parameters, so they can be used for subsequent PType evaluations
FnsToEvaluate_aa=fieldnames(PTypeStructure.(iistr).FnsToEvaluate);
for jj=ii+1:PTypeStructure.N_i
jjstr=PTypeStructure.iistr{jj};
for aa=1:length(AggVars_ii)
PTypeStructure.(jjstr).Parameters.(FnsToEvaluate_aa{aa})=AggVars_ii(aa);
end
end
end
AggVars=sum(AggVars_ConditionalOnPType.*PTypeStructure.ptweights',2);
% Note: AggVars is a vector



%% Put GE parameters and AggVars in structure, so they can be used for intermediateEqns and GeneralEqmEqns
%% Put GE parameters and AggVars in structure, so they can be used for intermediateEqns and GeneralEqmEqns
% already did the basic GE params
% for pp=1:nGEprices
% Parameters.(GEPriceParamNames{pp})=GEprices(GEpriceindexes(pp,1):GEpriceindexes(pp,2));
% end

% We pushed AggVars down into the PTypeStructure parameters; this puts them into the unified Parameter structure
for aa=1:length(AggVarNames)
Parameters.(AggVarNames{aa})=AggVars(aa);
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,41 @@
heteroagentparamsvecindex=0:1:length(GEpricesvec);
[GEpricesvec,penalty]=ParameterConstraints_TransformParamsToOriginal(GEpricesvec,heteroagentparamsvecindex,GEPriceParamNames,heteroagentoptions);

if heteroagentoptions.verbose>0
GEpricesvec_tminus1=zeros(nGEprices,1);
AggVars_tminus1=NaN(length(AggVarNames),1);

for pp=1:nGEprices
GEpricesvec_tminus1(pp)=Parameters.(GEPriceParamNames{pp});
end
GEpricesvec_delta=GEpricesvec-GEpricesvec_tminus1;
for aa=1:length(AggVarNames)
if isfield(Parameters,AggVarNames{aa})
AggVars_tminus1(aa)=Parameters.(AggVarNames{aa});
end
end
if heteroagentoptions.useintermediateEqns==1
intEqnnames=fieldnames(heteroagentoptions.intermediateEqns);
intermediateEqns_tminus1=zeros(length(intEqnnames),1);
for aa=1:length(intEqnnames)
if isfield(Parameters,intEqnnames{aa})
intEqns_tminus1(aa)=Parameters.(intEqnnames{aa});
end
end
end
% We don't do anything special for CustomModelStats, which are not as easily done as others above.
end

if heteroagentoptions.verbose==2
[~,maxidx]=max(GEpricesvec_delta.^2);
fprintf(' \n')
fprintf('Current GE prices: \n')
for pp=1:nGEprices
fprintf(' %s: %8.4f \n',GEPriceParamNames{pp},GEpricesvec(pp))
if pp==maxidx
cprintf('err',' %s: %8.4f \n',GEPriceParamNames{pp},GEpricesvec(pp))
else
fprintf(' %s: %8.4f \n',GEPriceParamNames{pp},GEpricesvec(pp))
end
end
end

Expand All @@ -18,7 +48,7 @@


%%
AggVars_ConditionalOnPType=zeros(PTypeStructure.numFnsToEvaluate,PTypeStructure.N_i,'gpuArray'); % Create AggVars conditional on ptype.
AggVars_ConditionalOnPType=zeros(PTypeStructure.numFnsToEvaluate,PTypeStructure.N_i); % Create AggVars conditional on ptype.

for ii=1:PTypeStructure.N_i

Expand Down Expand Up @@ -56,17 +86,36 @@
Policy.(iistr)=Policy_ii;
StationaryDist.(iistr)=StationaryDist_ii;
end

warning("do we still need to do this for AggVars?")
% Put updated AggVars into subsequent PTypeStructure Parameters, so they can be used for subsequent PType evaluations
FnsToEvaluate_aa=fieldnames(PTypeStructure.(iistr).FnsToEvaluate);
for jj=ii+1:PTypeStructure.N_i
jjstr=PTypeStructure.iistr{jj};
for aa=1:length(AggVars_ii)
PTypeStructure.(jjstr).Parameters.(FnsToEvaluate_aa{aa})=AggVars_ii(aa);
end
end

warning("do we need CustomModelStats here?")
if heteroagentoptions.useCustomModelStats==1
V.(iistr)=V_ii;
Policy.(iistr)=Policy_ii;
StationaryDist.(iistr)=StationaryDist_ii;
end
end
AggVars=gather(sum(AggVars_ConditionalOnPType.*PTypeStructure.ptweights',2));
AggVars=sum(AggVars_ConditionalOnPType.*PTypeStructure.ptweights',2);
% Note: AggVars is a vector



%% Put GE parameters and AggVars in structure, so they can be used for intermediateEqns and GeneralEqmEqns
%% Put GE parameters and AggVars in structure, so they can be used for intermediateEqns and GeneralEqmEqns
% already did the basic GE params
% for pp=1:nGEprices
% Parameters.(GEPriceParamNames{pp})=GEprices(pp);
% end

% We pushed AggVars down into the PTypeStructure parameters; this puts them into the unified Parameter structure
for aa=1:length(AggVarNames)
Parameters.(AggVarNames{aa})=AggVars(aa);
end
Expand Down Expand Up @@ -132,32 +181,52 @@

%% Feedback on progress
if heteroagentoptions.verbose==1 % When=2, we report these earlier
[~,maxidx]=max(GEpricesvec_delta.^2);
fprintf(' \n')
fprintf('Current GE prices: \n')
for pp=1:nGEprices
fprintf(heteroagentoptions.verboseaccuracy1,GEPriceParamNames{pp},GEpricesvec(pp))
if pp==maxidx
cprintf('err',heteroagentoptions.verboseaccuracy1,GEPriceParamNames{pp},GEpricesvec(pp))
else
fprintf(heteroagentoptions.verboseaccuracy1,GEPriceParamNames{pp},GEpricesvec(pp))
end
end
end
if heteroagentoptions.verbose>=1
fprintf('Current aggregate variables: \n')
for aa=1:length(AggVarNames)
fprintf(heteroagentoptions.verboseaccuracy1,AggVarNames{aa},AggVars(aa)) % Note, this is done differently here because AggVars itself has been set as a matrix
if ~isnan(AggVars_tminus1(aa))
cprintf('comment',heteroagentoptions.verboseaccuracy1,AggVarNames{aa},AggVars(aa)) % Note, this is done differently here because AggVars itself has been set as a matrix
else
fprintf(heteroagentoptions.verboseaccuracy1,AggVarNames{aa},AggVars(aa)) % Note, this is done differently here because AggVars itself has been set as a matrix
end
end
if heteroagentoptions.useintermediateEqns==1
intEqns_delta=intermediateEqnsVec-intermediateEqns_tminus1;
[~,maxidx]=max(intEqns_delta.^2);
fprintf('Current intermediateEqn variables: \n')
for aa=1:length(intEqnnames)
fprintf(heteroagentoptions.verboseaccuracy1,intEqnnames{aa},intermediateEqnsVec(aa)) % Note, this is done differently here because AggVars itself has been set as a matrix
if aa==maxidx
cprintf('err',heteroagentoptions.verboseaccuracy1,intEqnnames{aa},intermediateEqnsVec(aa)) % Note, this is done differently here because AggVars itself has been set as a matrix
else
fprintf(heteroagentoptions.verboseaccuracy1,intEqnnames{aa},intermediateEqnsVec(aa)) % Note, this is done differently here because AggVars itself has been set as a matrix
end
end
end
if heteroagentoptions.useCustomModelStats==1
fprintf('Current CustomModelStats variables: \n')
for ii=1:length(customstatnames)
fprintf(heteroagentoptions.verboseaccuracy1,customstatnames{ii},CustomStats.(customstatnames{ii}))
for aa=1:length(customstatnames)
fprintf(heteroagentoptions.verboseaccuracy1,customstatnames{aa},CustomStats.(customstatnames{aa})) % Note, this is done differently here because AggVars itself has been set as a matrix
end
end
fprintf('Current GeneralEqmEqns: \n')
[~,maxidx]=max(GeneralEqmConditionsVec.^2);
for gg=1:length(GEeqnNames)
fprintf(heteroagentoptions.verboseaccuracy2,GEeqnNames{gg},GeneralEqmConditionsVec(gg))
if gg==maxidx
cprintf('err', heteroagentoptions.verboseaccuracy2,GEeqnNames{gg},GeneralEqmConditionsVec(gg))
else
fprintf(heteroagentoptions.verboseaccuracy2,GEeqnNames{gg},GeneralEqmConditionsVec(gg))
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
%% Parameter Structure
% Parameters are allowed to be given as structure, or as vector/matrix
% (in terms of their dependence on permanent type). So go through each of
% these in term.
% these in turn.
% ie. Parameters.alpha=[0;1]; or Parameters.alpha.ptype1=0; Parameters.alpha.ptype2=1;
PTypeStructure.(iistr).Parameters=Parameters;
FullParamNames=fieldnames(Parameters); % all the different parameters
Expand Down Expand Up @@ -405,12 +405,26 @@
if isstruct(z_grid)
PTypeStructure.(iistr).z_grid=z_grid.(iistr);
else
PTypeStructure.(iistr).z_grid=z_grid;
% If the last dimension is of length N_i, this indicates dependence on ptype
nn=size(z_grid,ndims(z_grid));
if nn==N_i
otherdims = repmat({':'},1,ndims(z_grid)-1);
PTypeStructure.(iistr).z_grid=z_grid(otherdims{:},ii);
else
PTypeStructure.(iistr).z_grid=z_grid;
end
end
if isstruct(pi_z)
PTypeStructure.(iistr).pi_z=pi_z.(iistr);
else
PTypeStructure.(iistr).pi_z=pi_z;
% If the last dimension is of length N_i, this indicates dependence on ptype
nn=size(pi_z,ndims(pi_z));
if nn==N_i
otherdims = repmat({':'},1,ndims(pi_z)-1);
PTypeStructure.(iistr).pi_z=pi_z(otherdims{:},ii);
else
PTypeStructure.(iistr).pi_z=pi_z;
end
end

% Check if using ExogShockFn or EiidShockFn, and if so, do these use a
Expand All @@ -430,7 +444,7 @@
heteroagentoptions.gridsinGE(ii)=1;
end
end
% If z (and e) are not determined in GE, then compute z_gridvals_J and pi_z_J now (and e_gridvals_J and pi_e_J)
% If z (and e) are not determined in GE, then compute z_gridvals and pi_z now (and e_gridvals and pi_e)
if heteroagentoptions.gridsinGE(ii)==0
% Some of the shock grids depend on parameters that are determined in general eqm
[PTypeStructure.(iistr).z_grid, PTypeStructure.(iistr).pi_z, PTypeStructure.(iistr).vfoptions]=ExogShockSetup_InfHorz(PTypeStructure.(iistr).n_z,PTypeStructure.(iistr).z_grid,PTypeStructure.(iistr).pi_z,PTypeStructure.(iistr).Parameters,PTypeStructure.(iistr).vfoptions,3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@
heteroagentparamsvecindex=0:1:length(GEpricesvec);
[GEpricesvec,penalty]=ParameterConstraints_TransformParamsToOriginal(GEpricesvec,heteroagentparamsvecindex,GEPriceParamNames,heteroagentoptions);

if heteroagentoptions.verbose>0
GEpricesvec_tminus1=zeros(nGEprices,1);
AggVars_tminus1=NaN(length(AggVarNames),1);

for pp=1:nGEprices
GEpricesvec_tminus1(pp)=Parameters.(GEPriceParamNames{pp});
end
GEpricesvec_delta=GEpricesvec-GEpricesvec_tminus1;
for aa=1:length(AggVarNames)
if isfield(Parameters,AggVarNames{aa})
AggVars_tminus1(aa)=Parameters.(AggVarNames{aa});
end
end
if heteroagentoptions.useintermediateEqns==1
intEqnnames=fieldnames(heteroagentoptions.intermediateEqns);
intermediateEqns_tminus1=zeros(length(intEqnnames),1);
for aa=1:length(intEqnnames)
if isfield(Parameters,intEqnnames{aa})
intEqns_tminus1(aa)=Parameters.(intEqnnames{aa});
end
end
end
% We don't do anything special for CustomModelStats, which are not as easily done as others above.
end

if heteroagentoptions.verbose==2
fprintf(' \n')
fprintf('Current GE prices: \n')
Expand Down Expand Up @@ -60,6 +85,10 @@
jj=PTypeStructure.(iistr).WhichFnsForCurrentPType(kk);
if jj>0
AggVars(kk)=AggVars(kk)+PTypeStructure.(iistr).PTypeWeight*AggVars_ii(jj);

% Put updated AggVars into subsequent PTypeStructure Parameters, so they can be used for subsequent PType evaluations
warning("check AggVar parameter insertion here")
PTypeStructure.(iistr).Parameters.(PTypeStructure.(iistr).FnsToEvaluate{kk})=AggVars_ii(jj);
end
end

Expand All @@ -71,12 +100,13 @@
end



%% Put GE parameters and AggVars in structure, so they can be used for intermediateEqns and GeneralEqmEqns
% already did the basic GE params
% for pp=1:nGEprices
% Parameters.(GEPriceParamNames{pp})=GEprices(pp);
% end

% We pushed AggVars down into the PTypeStructure parameters; this puts them into the unified Parameter structure
for aa=1:length(AggVarNames)
Parameters.(AggVarNames{aa})=AggVars(aa);
end
Expand Down
Loading