Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynare
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marco Ratto
dynare
Commits
a1e0c35c
Commit
a1e0c35c
authored
2 years ago
by
Marco Ratto
Browse files
Options
Downloads
Patches
Plain Diff
bug fix when max_check_ahead_periods interacts with curb_retrench
parent
2f236048
Branches
exceptions
No related tags found
No related merge requests found
Pipeline
#7660
passed
2 years ago
Stage: build
Stage: test
Stage: pkg
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
matlab/+occbin/solve_one_constraint.m
+9
-4
9 additions, 4 deletions
matlab/+occbin/solve_one_constraint.m
matlab/+occbin/solve_two_constraints.m
+8
-4
8 additions, 4 deletions
matlab/+occbin/solve_two_constraints.m
with
17 additions
and
8 deletions
matlab/+occbin/solve_one_constraint.m
+
9
−
4
View file @
a1e0c35c
...
...
@@ -194,8 +194,10 @@ for shock_period = 1:n_shocks_periods
if
~
isinf
(
opts_simul_
.
max_check_ahead_periods
)
&&
opts_simul_
.
max_check_ahead_periods
<
length
(
binding_indicator
)
end_periods
=
opts_simul_
.
max_check_ahead_periods
;
last_indicator
=
false
(
length
(
binding_indicator
)
-
end_periods
,
1
);
else
end_periods
=
length
(
binding_indicator
);
last_indicator
=
false
(
0
);
end
% check if changes to the hypothesis of the duration for each
% regime
...
...
@@ -211,18 +213,21 @@ for shock_period = 1:n_shocks_periods
max_err
(
iter
)
=
0
;
end
% if max_check_ahead_periods<inf, enforce unconstrained regime for period larger than max_check_ahead_periods
binding_constraint_new
=
[
binding
.
constraint_1
(
1
:
end_periods
);
last_indicator
];
relaxed_constraint_new
=
[
relax
.
constraint_1
(
1
:
end_periods
);
not
(
last_indicator
)];
if
curb_retrench
% apply Gauss-Seidel idea of slowing down the change in the guess
% for the constraint -- only relax one
% period at a time starting from the last
% one when each of the constraints is true.
retrench
=
false
(
numel
(
binding_indicator
),
1
);
max_relax_constraint_1
=
find
(
relax
.
constraint_1
&
binding_indicator
,
1
,
'last'
);
if
~
isempty
(
max_relax_constraint_1
)
&&
find
(
relax
.
constraint_1
,
1
,
'last'
)
>=
find
(
binding_indicator
,
1
,
'last'
)
max_relax_constraint_1
=
find
(
relax
.
constraint_1
(
1
:
end_periods
)
&
binding_indicator
(
1
:
end_periods
)
,
1
,
'last'
);
if
~
isempty
(
max_relax_constraint_1
)
&&
find
(
relax
.
constraint_1
(
1
:
end_periods
)
,
1
,
'last'
)
>=
find
(
binding_indicator
(
1
:
end_periods
)
,
1
,
'last'
)
retrench
(
max_relax_constraint_1
)
=
true
;
end
binding_indicator
=
(
binding_indicator
|
binding
.
constraint_
1
)
&
~
retrench
;
binding_indicator
=
(
binding_indicator
|
binding
_
constraint_
new
)
&
~
retrench
;
else
binding_indicator
=
(
binding_indicator
|
binding
.
constraint_
1
)
&
~
(
binding_indicator
&
relax
.
constraint_
1
);
binding_indicator
=
(
binding_indicator
|
binding
_
constraint_
new
)
&
~
(
binding_indicator
&
relax
ed_
constraint_
new
);
end
if
iter
>
1
&&
regime_change_this_iteration
&&
~
nperiods_endogenously_increased
...
...
This diff is collapsed.
Click to expand it.
matlab/+occbin/solve_two_constraints.m
+
8
−
4
View file @
a1e0c35c
...
...
@@ -216,8 +216,10 @@ for shock_period = 1:n_shocks_periods
if
~
isinf
(
opts_simul_
.
max_check_ahead_periods
)
&&
opts_simul_
.
max_check_ahead_periods
<
length
(
binding_indicator
)
end_periods
=
opts_simul_
.
max_check_ahead_periods
;
last_indicator
=
false
(
length
(
binding_indicator
)
-
end_periods
,
1
);
else
end_periods
=
length
(
binding_indicator
);
last_indicator
=
false
(
0
);
end
binding_constraint_new
=
[
binding
.
constraint_1
(
1
:
end_periods
);
binding
.
constraint_2
(
1
:
end_periods
)];
relaxed_constraint_new
=
[
relax
.
constraint_1
(
1
:
end_periods
);
relax
.
constraint_2
(
1
:
end_periods
)];
...
...
@@ -237,17 +239,19 @@ for shock_period = 1:n_shocks_periods
max_err
(
iter
)
=
0
;
end
binding_constraint_new
=
[
binding
.
constraint_1
(
1
:
end_periods
);
last_indicator
;
binding
.
constraint_2
(
1
:
end_periods
);
last_indicator
];
relaxed_constraint_new
=
[
relax
.
constraint_1
(
1
:
end_periods
);
not
(
last_indicator
);
relax
.
constraint_2
(
1
:
end_periods
);
not
(
last_indicator
)];
if
curb_retrench
% apply Gauss-Seidel idea of slowing down the change in the guess
% for the constraint -- only relax one
% period at a time starting from the last
% one when each of the constraints is true.
retrench
=
false
(
numel
(
binding_indicator
),
1
);
max_relax_constraint_1
=
find
(
relax
.
constraint_1
&
binding_indicator
(
:
,
1
),
1
,
'last'
);
if
~
isempty
(
max_relax_constraint_1
)
&&
find
(
relax
.
constraint_1
,
1
,
'last'
)
>=
find
(
binding_indicator
(
:
,
1
),
1
,
'last'
)
max_relax_constraint_1
=
find
(
relax
.
constraint_1
(
1
:
end_periods
)
&
binding_indicator
(
1
:
end_periods
,
1
),
1
,
'last'
);
if
~
isempty
(
max_relax_constraint_1
)
&&
find
(
relax
.
constraint_1
(
1
:
end_periods
)
,
1
,
'last'
)
>=
find
(
binding_indicator
(
1
:
end_periods
,
1
),
1
,
'last'
)
retrench
(
max_relax_constraint_1
)
=
true
;
end
max_relax_constraint_2
=
find
(
relax
.
constraint_2
&
binding_indicator
(
:
,
2
),
1
,
'last'
);
if
~
isempty
(
max_relax_constraint_2
)
&&
find
(
relax
.
constraint_2
,
1
,
'last'
)
>=
find
(
binding_indicator
(
:
,
2
),
1
,
'last'
)
max_relax_constraint_2
=
find
(
relax
.
constraint_2
(
1
:
end_periods
)
&
binding_indicator
(
1
:
end_periods
,
2
),
1
,
'last'
);
if
~
isempty
(
max_relax_constraint_2
)
&&
find
(
relax
.
constraint_2
(
1
:
end_periods
)
,
1
,
'last'
)
>=
find
(
binding_indicator
(
1
:
end_periods
,
2
),
1
,
'last'
)
retrench
(
max_relax_constraint_2
+
nperiods_0
+
1
)
=
true
;
end
binding_indicator
=
(
binding_indicator
(:)
|
binding_constraint_new
)
&
~
retrench
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment