Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
57a67f20
Commit
57a67f20
authored
Mar 01, 2018
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some tweaks
parent
068e855d
Pipeline
#25586
passed with stage
in 5 minutes and 38 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
nifty4/minimization/nonlinear_cg.py
nifty4/minimization/nonlinear_cg.py
+17
-14
No files found.
nifty4/minimization/nonlinear_cg.py
View file @
57a67f20
...
...
@@ -22,12 +22,11 @@ from .line_search_strong_wolfe import LineSearchStrongWolfe
class
NonlinearCG
(
Minimizer
):
#RL FIXME: referenced equations in docstring seem broken for the version I found.
""" Nonlinear Conjugate Gradient scheme according to Polak-Ribiere.
Algorithm 5.4 from Nocedal & Wright.
Eq. (5.41a) has been replaced by eq. (5.49)
Eq. (5.41a) has been replaced by eq. (5.49)
Parameters
----------
controller : IterationController
...
...
@@ -41,11 +40,13 @@ class NonlinearCG(Minimizer):
2006, Springer-Verlag New York
"""
def
__init__
(
self
,
controller
,
line_searcher
=
LineSearchStrongWolfe
(
c2
=
0.1
),
beta_heuristics
=
'Polak-Ribiere'
):
valid_beta_heuristics
=
[
'Polak-Ribiere'
,
'Fletcher-Reeves'
,
'Polak-Ribiere'
]
def
__init__
(
self
,
controller
,
line_searcher
=
LineSearchStrongWolfe
(
c2
=
0.1
),
beta_heuristics
=
'Polak-Ribiere'
):
valid_beta_heuristics
=
[
'Polak-Ribiere'
,
'Fletcher-Reeves'
,
'Hestenes-Stiefel'
]
if
not
(
beta_heuristics
in
valid_beta_heuristics
):
raise
ValueError
(
"beta heuristics must be either 'Polak-Ribiere', "
\
+
"'Fletcher-Reeves', or 'Hestenes-Stiefel'"
)
raise
ValueError
(
"beta heuristics must be either 'Polak-Ribiere', "
"'Fletcher-Reeves', or 'Hestenes-Stiefel'"
)
self
.
_beta_heuristic
=
beta_heuristics
self
.
_controller
=
controller
self
.
_line_searcher
=
line_searcher
...
...
@@ -69,14 +70,16 @@ class NonlinearCG(Minimizer):
if
status
!=
controller
.
CONTINUE
:
return
energy
,
status
grad_new
=
energy
.
gradient
#print(grad_old.val, grad_new.val, p.val, energy.position.val)
if
self
.
_beta_heuristic
==
'Hestenes-Stiefel'
:
#Eq. (5.45) in Nocedal & Wright.
beta
=
max
(
0.0
,(
grad_new
.
vdot
(
grad_new
-
grad_old
)
/
(
grad_new
-
grad_old
).
vdot
(
p
)).
real
)
elif
self
.
_beta_heuristic
==
'Polak Ribiere'
:
#Eq. (5.43) in Nocedal & Wright. (with (5.44) additionally)
beta
=
max
(
0.0
,(
grad_new
.
vdot
(
grad_new
-
grad_old
)
/
(
grad_old
.
vdot
(
grad_old
))).
real
)
# Eq. (5.45) in Nocedal & Wright.
beta
=
max
(
0.0
,
(
grad_new
.
vdot
(
grad_new
-
grad_old
)
/
(
grad_new
-
grad_old
).
vdot
(
p
)).
real
)
elif
self
.
_beta_heuristic
==
'Polak-Ribiere'
:
# Eq. (5.43) in Nocedal & Wright. (with (5.44) additionally)
beta
=
max
(
0.0
,
(
grad_new
.
vdot
(
grad_new
-
grad_old
)
/
(
grad_old
.
vdot
(
grad_old
))).
real
)
else
:
#Eq. (5.40a) in Nocedal & Wright.
#
Eq. (5.40a) in Nocedal & Wright.
beta
=
(
grad_new
.
vdot
(
grad_new
)
/
(
grad_old
.
vdot
(
grad_old
))).
real
p
=
beta
*
p
-
grad_new
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