Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-gfe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Sander, Oliver
dune-gfe
Commits
c4f47443
Commit
c4f47443
authored
13 years ago
by
Oliver Sander
Committed by
sander@FU-BERLIN.DE
13 years ago
Browse files
Options
Downloads
Patches
Plain Diff
implement a simple quasi-Newton method
[[Imported from SVN: r8261]]
parent
e5c3375a
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
dune/gfe/riemanniantrsolver.cc
+29
-7
29 additions, 7 deletions
dune/gfe/riemanniantrsolver.cc
with
29 additions
and
7 deletions
dune/gfe/riemanniantrsolver.cc
+
29
−
7
View file @
c4f47443
...
...
@@ -213,6 +213,8 @@ void RiemannianTrustRegionSolver<GridType,TargetSpace>::solve()
// /////////////////////////////////////////////////////
double
oldEnergy
=
assembler_
->
computeEnergy
(
x_
);
bool
quasiNewtonMethod
=
false
;
bool
recomputeHessian
=
true
;
for
(
int
i
=
0
;
i
<
maxTrustRegionSteps_
;
i
++
)
{
...
...
@@ -237,12 +239,16 @@ void RiemannianTrustRegionSolver<GridType,TargetSpace>::solve()
assembler_
->
assembleGradient
(
x_
,
rhs
);
std
::
cout
<<
"gradient assembly took "
<<
gradientTimer
.
elapsed
()
<<
" sec."
<<
std
::
endl
;
gradientTimer
.
reset
();
assembler_
->
assembleMatrix
(
x_
,
*
hessianMatrix_
,
i
==
0
// assemble occupation pattern only for the first call
);
std
::
cout
<<
"hessian assembly took "
<<
gradientTimer
.
elapsed
()
<<
" sec."
<<
std
::
endl
;
if
(
recomputeHessian
)
{
assembler_
->
assembleMatrix
(
x_
,
*
hessianMatrix_
,
i
==
0
// assemble occupation pattern only for the first call
);
std
::
cout
<<
"hessian assembly took "
<<
gradientTimer
.
elapsed
()
<<
" sec."
<<
std
::
endl
;
}
else
std
::
cout
<<
"Reuse previous Hessian"
<<
std
::
endl
;
// The right hand side is the _negative_ gradient
rhs
*=
-
1
;
...
...
@@ -447,6 +453,9 @@ void RiemannianTrustRegionSolver<GridType,TargetSpace>::solve()
// current energy becomes 'oldEnergy' for the next iteration
oldEnergy
=
energy
;
if
(
quasiNewtonMethod
)
recomputeHessian
=
false
;
}
else
if
(
(
oldEnergy
-
energy
)
/
modelDecrease
>
0.01
||
std
::
abs
(
oldEnergy
-
energy
)
<
1e-12
)
{
// successful iteration
...
...
@@ -455,9 +464,22 @@ void RiemannianTrustRegionSolver<GridType,TargetSpace>::solve()
// current energy becomes 'oldEnergy' for the next iteration
oldEnergy
=
energy
;
if
(
quasiNewtonMethod
)
recomputeHessian
=
false
;
}
else
{
// unsuccessful iteration
trustRegion
.
scale
(
0.5
);
// If quasi Newton method and we have used an old matrix:
// Try again with the actual Newton matrix
if
(
not
recomputeHessian
&&
quasiNewtonMethod
)
{
recomputeHessian
=
true
;
}
else
{
// Decrease the trust-region radius
trustRegion
.
scale
(
0.5
);
}
if
(
this
->
verbosity_
==
NumProc
::
FULL
)
std
::
cout
<<
"Unsuccessful iteration!"
<<
std
::
endl
;
}
...
...
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