Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Dynare.jl
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Fabian Greimel
Dynare.jl
Commits
05e3ad78
Commit
05e3ad78
authored
7 years ago
by
Stéphane Adjemian
Browse files
Options
Downloads
Patches
Plain Diff
Added basic linesearch learning over newton iterations.
Reduces significantly the number of iterations.
parent
16edf443
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/DynareSolvers.jl
+23
-4
23 additions, 4 deletions
src/DynareSolvers.jl
with
23 additions
and
4 deletions
src/DynareSolvers.jl
+
23
−
4
View file @
05e3ad78
...
...
@@ -179,9 +179,10 @@ function trustregion(f!::Function, j!::Function, x0::Vector{Float64}, factor::Fl
catch
error
(
"The Jacobian of the system of nonlinear equations cannot be evaluated on the initial guess!"
)
end
# Initialize counters
ncsucc
=
zero
(
Int
)
nslow1
=
zero
(
Int
)
# Initialize counters.
ncsucc
,
nslow1
=
zero
(
Int
),
zero
(
Int
)
# Initialize scale parameter.
scale
,
scale0
=
one
(
Float64
),
one
(
Float64
)
# Newton iterations
while
iter
<=
maxiter
&&
info
==
0
# Compute columns norm for the Jacobian matrix.
...
...
@@ -224,7 +225,7 @@ function trustregion(f!::Function, j!::Function, x0::Vector{Float64}, factor::Fl
if
iter
==
1
δ
=
min
(
δ
,
pnorm
)
end
fwrong
,
jwrong
,
s
cale
=
true
,
true
,
one
(
Float64
)
fwrong
,
jwrong
,
s
iter
=
true
,
true
,
0
while
(
fwrong
||
jwrong
)
&&
scale
>.
0005
# Move along the direction p. Set a candidate value for x and predicted improvement for f.
@inbounds
for
i
=
1
:
n
...
...
@@ -242,6 +243,7 @@ function trustregion(f!::Function, j!::Function, x0::Vector{Float64}, factor::Fl
# If evaluation of the residuals returns an error, then keep the same
# direction but reduce the step length.
scale
*=
.
5
siter
+=
1
continue
end
fnorm1
=
norm
(
wa
.
fval1
)
...
...
@@ -337,6 +339,7 @@ function trustregion(f!::Function, j!::Function, x0::Vector{Float64}, factor::Fl
wa
.
fval
[
i
]
=
wa
.
fval0
[
i
]
end
scale
*=
.
5
siter
+=
1
jwrong
=
true
end
if
fwrong
||
jwrong
...
...
@@ -345,6 +348,22 @@ function trustregion(f!::Function, j!::Function, x0::Vector{Float64}, factor::Fl
return
info
end
end
# Update the value of the scale parameter.
if
siter
>
0
# Something went wrong when evaluating the nonlinear equations or the
# jacobian matrix, and the scale parameter had to be reduced. The scale
# parameter is updated with its average across newton iterations (first
# while-loop). This avoids to use the default value of the scale
# parameter (1.0) in the following iteration and reduces the number of
# iterations. The average value of the scale parameter is recursively
# computed.
scale
=
((
iter
-
1
)
*
scale0
+
scale
)
/
iter
else
# Increase the value of the scale parameter by 5 percent if the previous
# step provided by the dogleg routine did not cause any trouble...
scale
=
min
(
scale0
*
1.05
,
1.0
)
end
scale0
=
scale
@label
mainloop
end
if
info
==
0
&&
iter
>
maxiter
...
...
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