parent
bcce997112
commit
850d1dcc95
|
@ -1,14 +1,16 @@
|
||||||
function ast = handle_constant_eqs(ast)
|
function [ast, ds] = handle_constant_eqs(ast, ds)
|
||||||
%function ast = handle_constant_eqs(ast)
|
%function [ast, ds] = handle_constant_eqs(ast, ds)
|
||||||
%
|
%
|
||||||
% Code to handle equations of type `X = 0;` in AST. Returns equation(s)
|
% Code to handle equations of type `X = 0;` in AST. Returns equation(s)
|
||||||
% removed from AST.
|
% removed from AST and ds.X == 0.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% ast [cell array] JSON representation of abstract syntax tree
|
% ast [cell array] JSON representation of abstract syntax tree
|
||||||
|
% ds [dseries] data to be updated
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% ast [cell array] updated JSON representation of abstract syntax tree
|
% ast [cell array] updated JSON representation of abstract syntax tree
|
||||||
|
% ds [dseries] data to be updated
|
||||||
%
|
%
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% none
|
% none
|
||||||
|
@ -30,7 +32,7 @@ function ast = handle_constant_eqs(ast)
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
if nargin ~= 1
|
if nargin ~= 2
|
||||||
error('Incorrect number of arguments to function')
|
error('Incorrect number of arguments to function')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,12 +40,18 @@ if isempty(ast) || ~iscell(ast)
|
||||||
error('ast must be a cell')
|
error('ast must be a cell')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if isempty(ds) || ~isdseries(ds)
|
||||||
|
error('ds must be a nonempty dseries')
|
||||||
|
end
|
||||||
|
|
||||||
for i = length(ast):-1:1
|
for i = length(ast):-1:1
|
||||||
assert(strcmp(ast{i}.AST.node_type, 'BinaryOpNode') && strcmp(ast{i}.AST.op, '='), 'Expecting equation');
|
assert(strcmp(ast{i}.AST.node_type, 'BinaryOpNode') && strcmp(ast{i}.AST.op, '='), 'Expecting equation');
|
||||||
if strcmp(ast{i}.AST.arg2.node_type, 'NumConstNode')
|
if strcmp(ast{i}.AST.arg2.node_type, 'NumConstNode')
|
||||||
if ~strcmp(ast{i}.AST.arg1.node_type, 'VariableNode')
|
if ~strcmp(ast{i}.AST.arg1.node_type, 'VariableNode')
|
||||||
error('At the moment only handling Variable Nodes on LHS')
|
error('At the moment only handling Variable Nodes on LHS')
|
||||||
end
|
end
|
||||||
|
ds.(ast{i}.AST.arg1.name) = ...
|
||||||
|
dseries(ast{i}.AST.arg2.value*ones(ds.nobs, 1), ds.firstdate, ast{i}.AST.arg1.name);
|
||||||
ast = ast([1:i-1, i+1:end]);
|
ast = ast([1:i-1, i+1:end]);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -59,7 +59,8 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
%% Get Equation(s)
|
%% Get Equation(s)
|
||||||
ast = handle_constant_eqs(get_ast(eqtags));
|
ast = get_ast(eqtags);
|
||||||
|
[ast, ds] = handle_constant_eqs(ast, ds);
|
||||||
neqs = length(ast);
|
neqs = length(ast);
|
||||||
|
|
||||||
%% Find parameters and variable names in equations and setup estimation matrices
|
%% Find parameters and variable names in equations and setup estimation matrices
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 1e071ca499c30b4e112d1ee032181f27057ef46c
|
Subproject commit c5fc2e38c1361aef5820f91a4b1d0375e97f3af9
|
Loading…
Reference in New Issue