Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
ca8a91eb
Commit
ca8a91eb
authored
May 27, 2020
by
Philipp Arras
Browse files
Add simplify for constant input
parent
b3ea2e41
Pipeline
#75629
canceled with stages
in 1 minute and 18 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty6/minimization/energy_adapter.py
View file @
ca8a91eb
...
...
@@ -11,12 +11,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-20
19
Max-Planck-Society
# Copyright(C) 2013-20
20
Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from
..linearization
import
Linearization
from
..minimization.energy
import
Energy
from
..sugar
import
makeDomain
class
EnergyAdapter
(
Energy
):
...
...
@@ -40,10 +41,20 @@ class EnergyAdapter(Energy):
additional resources. Default: False.
"""
def
__init__
(
self
,
position
,
op
,
constants
=
[],
want_metric
=
False
):
def
__init__
(
self
,
position
,
op
,
constants
=
[],
want_metric
=
False
,
_op4eval
=
None
):
super
(
EnergyAdapter
,
self
).
__init__
(
position
)
self
.
_op
=
op
self
.
_constants
=
constants
if
self
.
_op4eval
is
None
:
if
len
(
constants
)
>
0
:
dom
=
{
kk
:
vv
for
kk
,
vv
in
position
.
domain
.
items
()
if
kk
in
constants
}
dom
=
makeDomain
(
dom
)
cstpos
=
position
.
extract
(
dom
)
_
,
self
.
_op4eval
=
op
.
simplify_for_constant_input
(
cstpos
)
else
:
self
.
_op4eval
=
op
self
.
_want_metric
=
want_metric
lin
=
Linearization
.
make_partial_var
(
position
,
constants
,
want_metric
)
tmp
=
self
.
_op
(
lin
)
...
...
@@ -53,7 +64,7 @@ class EnergyAdapter(Energy):
def
at
(
self
,
position
):
return
EnergyAdapter
(
position
,
self
.
_op
,
self
.
_constants
,
self
.
_want_metric
)
self
.
_want_metric
,
self
.
_op4eval
)
@
property
def
value
(
self
):
...
...
Write
Preview
Supports
Markdown
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