Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
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
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
Stéphane Adjemian
dynare
Commits
90a8abf5
Verified
Commit
90a8abf5
authored
1 year ago
by
Sébastien Villemot
Browse files
Options
Downloads
Patches
Plain Diff
solve1.m: misc cleanups
parent
771627ea
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
matlab/optimization/solve1.m
+4
-16
4 additions, 16 deletions
matlab/optimization/solve1.m
with
4 additions
and
16 deletions
matlab/optimization/solve1.m
+
4
−
16
View file @
90a8abf5
...
@@ -9,7 +9,7 @@ function [x, errorflag, errorcode] = solve1(func, x, j1, j2, jacobian_flag, gste
...
@@ -9,7 +9,7 @@ function [x, errorflag, errorcode] = solve1(func, x, j1, j2, jacobian_flag, gste
% j2: unknown variables index
% j2: unknown variables index
% jacobian_flag=true: jacobian given by the 'func' function
% jacobian_flag=true: jacobian given by the 'func' function
% jacobian_flag=false: jacobian obtained numerically
% jacobian_flag=false: jacobian obtained numerically
% gstep increment multiplier in numer
c
ial derivative
% gstep increment multiplier in numeri
c
al derivative
% computation
% computation
% tolf tolerance for residuals
% tolf tolerance for residuals
% tolx tolerance for solution variation
% tolx tolerance for solution variation
...
@@ -20,12 +20,9 @@ function [x, errorflag, errorcode] = solve1(func, x, j1, j2, jacobian_flag, gste
...
@@ -20,12 +20,9 @@ function [x, errorflag, errorcode] = solve1(func, x, j1, j2, jacobian_flag, gste
%
%
% OUTPUTS
% OUTPUTS
% x: results
% x: results
% errorflag=1: the model can not be solved
% errorflag=true: the model can not be solved
%
% SPECIAL REQUIREMENTS
% none
% Copyright © 2001-202
2
Dynare Team
% Copyright © 2001-202
4
Dynare Team
%
%
% This file is part of Dynare.
% This file is part of Dynare.
%
%
...
@@ -45,8 +42,6 @@ function [x, errorflag, errorcode] = solve1(func, x, j1, j2, jacobian_flag, gste
...
@@ -45,8 +42,6 @@ function [x, errorflag, errorcode] = solve1(func, x, j1, j2, jacobian_flag, gste
nn
=
length
(
j1
);
nn
=
length
(
j1
);
g
=
zeros
(
nn
,
1
)
;
g
=
zeros
(
nn
,
1
)
;
tolmin
=
tolx
;
stpmx
=
100
;
stpmx
=
100
;
errorflag
=
false
;
errorflag
=
false
;
...
@@ -91,7 +86,6 @@ if max(abs(fvec))<tolf*tolf
...
@@ -91,7 +86,6 @@ if max(abs(fvec))<tolf*tolf
end
end
stpmax
=
stpmx
*
max
([
sqrt
(
x
'*
x
);
nn
])
;
stpmax
=
stpmx
*
max
([
sqrt
(
x
'*
x
);
nn
])
;
first_time
=
1
;
if
~
jacobian_flag
if
~
jacobian_flag
fjac
=
zeros
(
nn
,
nn
);
fjac
=
zeros
(
nn
,
nn
);
end
end
...
@@ -155,7 +149,7 @@ for its = 1:maxit
...
@@ -155,7 +149,7 @@ for its = 1:maxit
if
lnsearchflag
if
lnsearchflag
errorflag
=
true
;
errorflag
=
true
;
den
=
max
([
f
;
0.5
*
nn
])
;
den
=
max
([
f
;
0.5
*
nn
])
;
if
max
(
abs
(
g
)
.*
max
([
abs
(
x
(
j2
)
') ones(1,nn)])'
)/
den
<
tol
min
if
max
(
abs
(
g
)
.*
max
([
abs
(
x
(
j2
)
') ones(1,nn)])'
)/
den
<
tol
x
if
max
(
abs
(
x
(
j2
)
-
xold
(
j2
))
.
/
max
([
abs
(
x
(
j2
)
') ones(1,nn)])'
)
<
tolx
if
max
(
abs
(
x
(
j2
)
-
xold
(
j2
))
.
/
max
([
abs
(
x
(
j2
)
') ones(1,nn)])'
)
<
tolx
errorcode
=
3
;
errorcode
=
3
;
if
nargout
<
3
if
nargout
<
3
...
@@ -189,9 +183,3 @@ if nargout<3
...
@@ -189,9 +183,3 @@ if nargout<3
skipline
()
skipline
()
disp
(
'SOLVE: maxit has been reached'
)
disp
(
'SOLVE: maxit has been reached'
)
end
end
% 01/14/01 MJ lnsearch is now a separate function
% 01/16/01 MJ added varargin to function evaluation
% 04/13/01 MJ added test f < tolf !!
% 05/11/01 MJ changed tests for 'check' so as to remove 'continue' which is
% an instruction which appears only in version 6
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