Remove duplicate assignments for parameters.
parent
4386116c91
commit
8b197bf71c
|
@ -166,7 +166,7 @@ xlist = xlist(1:xnum,:);
|
||||||
xlist = xlist(idx,:);
|
xlist = xlist(idx,:);
|
||||||
|
|
||||||
% Get parameter values.
|
% Get parameter values.
|
||||||
calibration = '';
|
pArray = cell(0, 3);
|
||||||
for i=1:length(varargin)
|
for i=1:length(varargin)
|
||||||
fid = fopen(sprintf('%s/parameter-values.inc', varargin{i}));
|
fid = fopen(sprintf('%s/parameter-values.inc', varargin{i}));
|
||||||
if fid<0
|
if fid<0
|
||||||
|
@ -176,12 +176,51 @@ for i=1:length(varargin)
|
||||||
end
|
end
|
||||||
cline = fgetl(fid);
|
cline = fgetl(fid);
|
||||||
while ischar(cline)
|
while ischar(cline)
|
||||||
calibration = sprintf('%s\n%s', calibration, cline);
|
tmp = textscan(cline, '%s = %f', 'Delimiter', {';','=',' '});
|
||||||
|
pArray(end+1,1) = tmp{1};
|
||||||
|
pArray{end,2} = tmp{2};
|
||||||
|
pArray{end,3} = varargin{i};
|
||||||
cline = fgetl(fid);
|
cline = fgetl(fid);
|
||||||
end
|
end
|
||||||
fclose(fid);
|
fclose(fid);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if rows(pArray)>1
|
||||||
|
irow = 2;
|
||||||
|
while irow<=rows(pArray)
|
||||||
|
ispreviouslydefined = strcmpi(pArray{irow,1}, pArray(1:irow-1,1));
|
||||||
|
if any(ispreviouslydefined)
|
||||||
|
if isnan(pArray{ispreviouslydefined,2})
|
||||||
|
if ~isnan(pArray{irow,2})
|
||||||
|
% Remove first assignment (with NaN)
|
||||||
|
pArray(ispreviouslydefined,:) = [];
|
||||||
|
else
|
||||||
|
% Remove second assignment (both assigments are NaNs)
|
||||||
|
pArray(irow,:) = [];
|
||||||
|
end
|
||||||
|
elseif isnan(pArray{irow,2})
|
||||||
|
% New assigment is NaN but not the previous one.
|
||||||
|
pArray(irow,:) = [];
|
||||||
|
else
|
||||||
|
% Check that the values are identical in both assignments.
|
||||||
|
if abs(pArray{ispreviouslydefined,2}-pArray{irow,2})>1e-10
|
||||||
|
error('More than one assigment for parameter %s with different values (see cherrypicked files in %s and %s).', pArray{irow,1}, pArray{irow,3}, pArray{ispreviouslydefined,3});
|
||||||
|
else
|
||||||
|
% Remove last assignement (duplicate).
|
||||||
|
pArray(irow,:) = [];
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
irow = irow+1;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
calibration = '';
|
||||||
|
for i=1:rows(pArray)
|
||||||
|
calibration = sprintf('%s%s = %f;\n', calibration, pArray{i,1}, pArray{i,2});
|
||||||
|
end
|
||||||
|
|
||||||
% Move the endogenous variables which are not LHS of an equation
|
% Move the endogenous variables which are not LHS of an equation
|
||||||
% into the set of exogenous variables.
|
% into the set of exogenous variables.
|
||||||
[~, i1] = intersect(elist(:,1), eqlist(:,1));
|
[~, i1] = intersect(elist(:,1), eqlist(:,1));
|
||||||
|
|
|
@ -4,4 +4,5 @@ c3 = -.3;
|
||||||
d3 = -.4;
|
d3 = -.4;
|
||||||
e3 = -.5;
|
e3 = -.5;
|
||||||
f3 = -.6;
|
f3 = -.6;
|
||||||
g3 = -.7;
|
g3 = -.7;
|
||||||
|
g1 = .7;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
parameters a3 b3 c3 d3 e3 f3 g3;
|
parameters a3 b3 c3 d3 e3 f3 g3 g1;
|
||||||
|
|
Loading…
Reference in New Issue