Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dynare
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Johannes Pfeifer
dynare
Commits
2015b792
Unverified
Commit
2015b792
authored
May 25, 2020
by
Sébastien Villemot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
solve_{one_boundary,two_boundaries}: convert some input arguments to logical type
parent
6f0196be
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
30 deletions
+25
-30
matlab/dynare_solve_block_or_bytecode.m
matlab/dynare_solve_block_or_bytecode.m
+2
-2
matlab/solve_one_boundary.m
matlab/solve_one_boundary.m
+19
-23
matlab/solve_two_boundaries.m
matlab/solve_two_boundaries.m
+4
-5
No files found.
matlab/dynare_solve_block_or_bytecode.m
View file @
2015b792
...
...
@@ -37,9 +37,9 @@ if options.block && ~options.bytecode
else
n
=
length
(
M
.
block_structure_stat
.
block
(
b
)
.
variable
);
[
ss
,
check
]
=
solve_one_boundary
([
M
.
fname
'.block.static_'
int2str
(
b
)],
ss
,
exo
,
...
params
,
[],
M
.
block_structure_stat
.
block
(
b
)
.
variable
,
n
,
1
,
0
,
b
,
0
,
options
.
simul
.
maxit
,
...
params
,
[],
M
.
block_structure_stat
.
block
(
b
)
.
variable
,
n
,
1
,
false
,
b
,
0
,
options
.
simul
.
maxit
,
...
options
.
solve_tolf
,
...
options
.
slowc
,
0
,
options
.
solve_algo
,
1
,
0
,
0
,
M
,
options
);
options
.
slowc
,
0
,
options
.
solve_algo
,
true
,
false
,
false
,
M
,
options
);
if
check
info
=
1
;
return
...
...
matlab/solve_one_boundary.m
View file @
2015b792
function
[
y
,
info
]
=
solve_one_boundary
(
fname
,
y
,
x
,
params
,
steady_state
,
...
y_index_eq
,
nze
,
periods
,
is_linear
,
Block_Num
,
y_kmin
,
maxit_
,
solve_tolf
,
lambda
,
cutoff
,
stack_solve_algo
,
forward_back
ward
,
is_dynamic
,
verbose
,
M
,
options
,
oo
)
y_index_eq
,
nze
,
periods
,
is_linear
,
Block_Num
,
y_kmin
,
maxit_
,
solve_tolf
,
lambda
,
cutoff
,
stack_solve_algo
,
is_for
ward
,
is_dynamic
,
verbose
,
M
,
options
,
oo
)
% Computes the deterministic simulation of a block of equation containing
% lead or lag variables
%
...
...
@@ -15,8 +15,7 @@ function [y, info] = solve_one_boundary(fname, y, x, params, steady_state, ...
% nze [integer] number of non-zero elements in the
% jacobian matrix
% periods [integer] number of simulation periods
% is_linear [integer] if is_linear=1 the block is linear
% if is_linear=0 the block is not linear
% is_linear [logical] whether the block is linear
% Block_Num [integer] block number
% y_kmin [integer] maximum number of lag in the model
% maxit_ [integer] maximum number of iteration in Newton
...
...
@@ -31,18 +30,15 @@ function [y, info] = solve_one_boundary(fname, y, x, params, steady_state, ...
% - 2 GMRES
% - 3 BicGStab
% - 4 Optimal path length
%
forward_backward [integer] The block has to be solve
forward
%
(1) or backward (0)
% is_dynamic [
integer] (1) The block belong to the dynamic
%
is_forward [logical] Whether the block has to be solved
forward
%
If false, the block is solved backward
% is_dynamic [
logical] If true, the block belongs to the dynamic file
% file and the oo_.deterministic_simulation field has to be uptated
%
(0) The block belong
to the static
% file and th
oo_.deteerminstic
%
If false, the block belongs
to the static
% file and th
e oo_.detereministic_simulation
% field remains unchanged
% verbose [integer] (0) iterations are not printed
% (1) iterations are printed
% indirect_call [integer] (0) direct call to the fname
% (1) indirect call via the
% local_fname wrapper
% verbose [logical] Whether iterations are to be printed
%
% OUTPUTS
% y [matrix] All endogenous variables of the model
% info [integer] >=0 no error
...
...
@@ -55,7 +51,7 @@ function [y, info] = solve_one_boundary(fname, y, x, params, steady_state, ...
% none.
%
% Copyright (C) 1996-20
18
Dynare Team
% Copyright (C) 1996-20
20
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -80,7 +76,7 @@ correcting_factor=0.01;
ilu_setup
.
droptol
=
1e-10
;
max_resa
=
1e100
;
reduced
=
0
;
if
forward_back
ward
if
is_for
ward
incr
=
1
;
start
=
y_kmin
+
1
;
finish
=
periods
+
y_kmin
;
...
...
@@ -105,7 +101,7 @@ for it_=start:incr:finish
else
max_res
=
max
(
max
(
abs
(
r
)));
end
if
verbose
==
1
if
verbose
disp
([
'iteration : '
int2str
(
iter
+
1
)
' => '
num2str
(
max_res
)
' time = '
int2str
(
it_
)])
if
is_dynamic
disp
([
M
.
endo_names
{
y_index_eq
}
num2str
([
y
(
it_
,
y_index_eq
)
'
r
g1
])])
...
...
@@ -230,7 +226,7 @@ for it_=start:incr:finish
info
=
-
Block_Num
*
10
;
end
elseif
(
~
is_dynamic
&&
options
.
solve_algo
==
2
)
||
(
is_dynamic
&&
stack_solve_algo
==
4
)
if
verbose
==
1
&&
~
is_dynamic
if
verbose
&&
~
is_dynamic
disp
(
'steady: LU + lnsrch1'
)
end
lambda
=
1
;
...
...
@@ -260,7 +256,7 @@ for it_=start:incr:finish
y
=
ya
'
;
end
elseif
~
is_dynamic
&&
options
.
solve_algo
==
3
if
verbose
==
1
if
verbose
disp
(
'steady: csolve'
)
end
[
yn
,
info
]
=
csolve
(
@
local_fname
,
y
(
y_index_eq
),
@
...
...
...
@@ -268,7 +264,7 @@ for it_=start:incr:finish
dx
=
ya
-
yn
;
y
(
y_index_eq
)
=
yn
;
elseif
(
stack_solve_algo
==
1
&&
is_dynamic
)
||
(
stack_solve_algo
==
0
&&
is_dynamic
)
||
(
~
is_dynamic
&&
(
options
.
solve_algo
==
1
||
options
.
solve_algo
==
6
))
if
verbose
==
1
&&
~
is_dynamic
if
verbose
&&
~
is_dynamic
disp
(
'steady: Sparse LU '
)
end
dx
=
g1
\
r
;
...
...
@@ -280,7 +276,7 @@ for it_=start:incr:finish
end
elseif
(
stack_solve_algo
==
2
&&
is_dynamic
)
||
(
options
.
solve_algo
==
7
&&
~
is_dynamic
)
flag1
=
1
;
if
verbose
==
1
&&
~
is_dynamic
if
verbose
&&
~
is_dynamic
disp
(
'steady: GMRES '
)
end
while
flag1
>
0
...
...
@@ -309,7 +305,7 @@ for it_=start:incr:finish
end
elseif
(
stack_solve_algo
==
3
&&
is_dynamic
)
||
(
options
.
solve_algo
==
8
&&
~
is_dynamic
)
flag1
=
1
;
if
verbose
==
1
&&
~
is_dynamic
if
verbose
&&
~
is_dynamic
disp
(
'steady: BiCGStab'
)
end
while
flag1
>
0
...
...
@@ -377,7 +373,7 @@ for it_=start:incr:finish
fprintf
(
'Error in simul: Convergence not achieved in block %d, at time %d, after %d iterations.\n Increase "options_.simul.maxit" or set "cutoff=0" in model options.\n'
,
Block_Num
,
it_
,
iter
);
end
end
if
(
is_dynamic
)
if
is_dynamic
oo_
.
deterministic_simulation
.
status
=
0
;
oo_
.
deterministic_simulation
.
error
=
max_res
;
oo_
.
deterministic_simulation
.
iterations
=
iter
;
...
...
@@ -407,4 +403,4 @@ y(y_index_eq) = yl;
[
err
,
y
,
G
]
=
feval
(
fname
,
y
,
x
,
params
,
steady_state
,
0
);
if
(
is_csolve
)
G
=
full
(
G
);
end
\ No newline at end of file
end
matlab/solve_two_boundaries.m
View file @
2015b792
...
...
@@ -16,8 +16,7 @@ function [y, oo]= solve_two_boundaries(fname, y, x, params, steady_state, y_inde
% periods [integer] number of simulation periods
% y_kmin_l [integer] maximum number of lag in the block
% y_kmax_l [integer] maximum number of lead in the block
% is_linear [integer] if is_linear=1 the block is linear
% if is_linear=0 the block is not linear
% is_linear [logical] Whether the block is linear
% Block_Num [integer] block number
% y_kmin [integer] maximum number of lag in the model
% maxit_ [integer] maximum number of iteration in Newton
...
...
@@ -46,7 +45,7 @@ function [y, oo]= solve_two_boundaries(fname, y, x, params, steady_state, y_inde
% none.
%
% Copyright (C) 1996-20
18
Dynare Team
% Copyright (C) 1996-20
20
Dynare Team
%
% This file is part of Dynare.
%
...
...
@@ -95,7 +94,7 @@ while ~(cvg==1 || iter>maxit_)
end
if
~
isreal
(
max_res
)
||
isnan
(
max_res
)
cvg
=
0
;
elseif
(
is_linear
&&
iter
>
0
)
elseif
is_linear
&&
iter
>
0
cvg
=
1
;
else
cvg
=
(
max_res
<
solve_tolf
);
...
...
@@ -337,4 +336,4 @@ oo.deterministic_simulation.error = max_res;
oo
.
deterministic_simulation
.
iterations
=
iter
;
oo
.
deterministic_simulation
.
block
(
Block_Num
)
.
status
=
1
;
% Convergency obtained.
oo
.
deterministic_simulation
.
block
(
Block_Num
)
.
error
=
max_res
;
oo
.
deterministic_simulation
.
block
(
Block_Num
)
.
iterations
=
iter
;
\ No newline at end of file
oo
.
deterministic_simulation
.
block
(
Block_Num
)
.
iterations
=
iter
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment