pyadjoint-ad 2023.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. pyadjoint-ad-2023.0.0/LICENSE +165 -0
  2. pyadjoint-ad-2023.0.0/PKG-INFO +84 -0
  3. pyadjoint-ad-2023.0.0/README.md +40 -0
  4. pyadjoint-ad-2023.0.0/firedrake_adjoint/__init__.py +12 -0
  5. pyadjoint-ad-2023.0.0/numpy_adjoint/__init__.py +18 -0
  6. pyadjoint-ad-2023.0.0/numpy_adjoint/array.py +56 -0
  7. pyadjoint-ad-2023.0.0/pyadjoint/__init__.py +25 -0
  8. pyadjoint-ad-2023.0.0/pyadjoint/adjfloat.py +510 -0
  9. pyadjoint-ad-2023.0.0/pyadjoint/block.py +417 -0
  10. pyadjoint-ad-2023.0.0/pyadjoint/block_variable.py +81 -0
  11. pyadjoint-ad-2023.0.0/pyadjoint/control.py +117 -0
  12. pyadjoint-ad-2023.0.0/pyadjoint/drivers.py +93 -0
  13. pyadjoint-ad-2023.0.0/pyadjoint/enlisting.py +12 -0
  14. pyadjoint-ad-2023.0.0/pyadjoint/ipopt.py +13 -0
  15. pyadjoint-ad-2023.0.0/pyadjoint/optimization/__init__.py +9 -0
  16. pyadjoint-ad-2023.0.0/pyadjoint/optimization/constraints.py +138 -0
  17. pyadjoint-ad-2023.0.0/pyadjoint/optimization/ipopt_solver.py +203 -0
  18. pyadjoint-ad-2023.0.0/pyadjoint/optimization/moola_problem.py +117 -0
  19. pyadjoint-ad-2023.0.0/pyadjoint/optimization/optimization.py +290 -0
  20. pyadjoint-ad-2023.0.0/pyadjoint/optimization/optimization_problem.py +95 -0
  21. pyadjoint-ad-2023.0.0/pyadjoint/optimization/optimization_solver.py +20 -0
  22. pyadjoint-ad-2023.0.0/pyadjoint/optimization/rol_solver.py +258 -0
  23. pyadjoint-ad-2023.0.0/pyadjoint/overloaded_function.py +56 -0
  24. pyadjoint-ad-2023.0.0/pyadjoint/overloaded_type.py +374 -0
  25. pyadjoint-ad-2023.0.0/pyadjoint/placeholder.py +51 -0
  26. pyadjoint-ad-2023.0.0/pyadjoint/reduced_functional.py +244 -0
  27. pyadjoint-ad-2023.0.0/pyadjoint/reduced_functional_numpy.py +132 -0
  28. pyadjoint-ad-2023.0.0/pyadjoint/tape.py +635 -0
  29. pyadjoint-ad-2023.0.0/pyadjoint/verification.py +152 -0
  30. pyadjoint-ad-2023.0.0/pyadjoint_ad.egg-info/PKG-INFO +84 -0
  31. pyadjoint-ad-2023.0.0/pyadjoint_ad.egg-info/SOURCES.txt +35 -0
  32. pyadjoint-ad-2023.0.0/pyadjoint_ad.egg-info/dependency_links.txt +1 -0
  33. pyadjoint-ad-2023.0.0/pyadjoint_ad.egg-info/requires.txt +39 -0
  34. pyadjoint-ad-2023.0.0/pyadjoint_ad.egg-info/top_level.txt +3 -0
  35. pyadjoint-ad-2023.0.0/setup.cfg +20 -0
  36. pyadjoint-ad-2023.0.0/setup.py +29 -0
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
@@ -0,0 +1,84 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyadjoint-ad
3
+ Version: 2023.0.0
4
+ Summary: High-level automatic differentiation library.
5
+ Home-page: https://github.com/dolfin-adjoint/pyadjoint
6
+ Author: Jørgen Dokken
7
+ Author-email: dokken@simula.no
8
+ License: LGPL-3.0
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: scipy>=1.0
12
+ Provides-Extra: moola
13
+ Requires-Dist: moola>=0.1.6; extra == "moola"
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest>=3.10; extra == "test"
16
+ Requires-Dist: flake8; extra == "test"
17
+ Requires-Dist: coverage; extra == "test"
18
+ Provides-Extra: visualisation
19
+ Requires-Dist: tensorflow; extra == "visualisation"
20
+ Requires-Dist: protobuf; extra == "visualisation"
21
+ Requires-Dist: networkx; extra == "visualisation"
22
+ Requires-Dist: pygraphviz; extra == "visualisation"
23
+ Provides-Extra: meshing
24
+ Requires-Dist: pygmsh; extra == "meshing"
25
+ Requires-Dist: meshio; extra == "meshing"
26
+ Provides-Extra: doc
27
+ Requires-Dist: sphinx; extra == "doc"
28
+ Requires-Dist: sphinx-autobuild; extra == "doc"
29
+ Requires-Dist: sphinxcontrib-bibtex; extra == "doc"
30
+ Provides-Extra: all
31
+ Requires-Dist: moola>=0.1.6; extra == "all"
32
+ Requires-Dist: pytest>=3.10; extra == "all"
33
+ Requires-Dist: flake8; extra == "all"
34
+ Requires-Dist: coverage; extra == "all"
35
+ Requires-Dist: tensorflow; extra == "all"
36
+ Requires-Dist: protobuf; extra == "all"
37
+ Requires-Dist: networkx; extra == "all"
38
+ Requires-Dist: pygraphviz; extra == "all"
39
+ Requires-Dist: pygmsh; extra == "all"
40
+ Requires-Dist: meshio; extra == "all"
41
+ Requires-Dist: sphinx; extra == "all"
42
+ Requires-Dist: sphinx-autobuild; extra == "all"
43
+ Requires-Dist: sphinxcontrib-bibtex; extra == "all"
44
+
45
+ # The algorithmic differentation tool pyadjoint
46
+
47
+ The full documentation is available [here](https://pyadjoint.org)
48
+
49
+ Circle CI status: [![CircleCI](https://circleci.com/gh/dolfin-adjoint/pyadjoint.svg?style=svg)](https://circleci.com/gh/dolfin-adjoint/pyadjoint)
50
+
51
+
52
+ # Contributing
53
+
54
+ We love pull requests from everyone.
55
+
56
+ Fork, then clone the repository at https://github.com/dolfin-adjoint/pyadjoint
57
+
58
+ Make sure the tests pass:
59
+
60
+ py.test tests/pyadjoint
61
+
62
+ Make your change. Add tests for your change. Make the tests pass:
63
+
64
+ py.test tests/pyadjoint
65
+
66
+ Push to your fork and [submit a pull request][pr].
67
+
68
+ [pr]: https://github.com/dolfin-adjoint/pyadjoint/pulls
69
+
70
+ At this point you're waiting on us. We may suggest
71
+ some changes or improvements or alternatives.
72
+
73
+ Some things that will increase the chance that your pull request is accepted:
74
+
75
+ * Write tests.
76
+ * Add Python docstrings that follow the [Google Style][style].
77
+ * Write good commit and pull request message.
78
+
79
+ [style]: http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
80
+
81
+ # Licence
82
+ This software is licensed under the [GNU LGPL v3][license].
83
+
84
+ [license]: https://github.com/dolfin-adjoint/pyadjoint/raw/master/LICENSE
@@ -0,0 +1,40 @@
1
+ # The algorithmic differentation tool pyadjoint
2
+
3
+ The full documentation is available [here](https://pyadjoint.org)
4
+
5
+ Circle CI status: [![CircleCI](https://circleci.com/gh/dolfin-adjoint/pyadjoint.svg?style=svg)](https://circleci.com/gh/dolfin-adjoint/pyadjoint)
6
+
7
+
8
+ # Contributing
9
+
10
+ We love pull requests from everyone.
11
+
12
+ Fork, then clone the repository at https://github.com/dolfin-adjoint/pyadjoint
13
+
14
+ Make sure the tests pass:
15
+
16
+ py.test tests/pyadjoint
17
+
18
+ Make your change. Add tests for your change. Make the tests pass:
19
+
20
+ py.test tests/pyadjoint
21
+
22
+ Push to your fork and [submit a pull request][pr].
23
+
24
+ [pr]: https://github.com/dolfin-adjoint/pyadjoint/pulls
25
+
26
+ At this point you're waiting on us. We may suggest
27
+ some changes or improvements or alternatives.
28
+
29
+ Some things that will increase the chance that your pull request is accepted:
30
+
31
+ * Write tests.
32
+ * Add Python docstrings that follow the [Google Style][style].
33
+ * Write good commit and pull request message.
34
+
35
+ [style]: http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
36
+
37
+ # Licence
38
+ This software is licensed under the [GNU LGPL v3][license].
39
+
40
+ [license]: https://github.com/dolfin-adjoint/pyadjoint/raw/master/LICENSE
@@ -0,0 +1,12 @@
1
+ # flake8: noqa
2
+
3
+ import warnings
4
+
5
+ from firedrake.adjoint import *
6
+
7
+ continue_annotation()
8
+
9
+ warnings.warn("""The firedrake_adjoint module is deprecated.
10
+
11
+ Instead, use the firedrake.adjoint module and explicitly start taping
12
+ by calling continue_annotation().""", FutureWarning)
@@ -0,0 +1,18 @@
1
+ # flake8: noqa
2
+
3
+ import pyadjoint
4
+ __version__ = pyadjoint.__version__
5
+ __author__ = 'Sebastian Kenji Mitusch'
6
+ __credits__ = []
7
+ __license__ = 'LGPL-3'
8
+ __maintainer__ = 'Sebastian Kenji Mitusch'
9
+ __email__ = 'sebastkm@simula.no'
10
+
11
+
12
+ from .array import ndarray
13
+
14
+ # Use pyadjoint AdjFloat for numpy.float64.
15
+ import numpy
16
+ from pyadjoint.overloaded_type import register_overloaded_type
17
+ from pyadjoint.adjfloat import AdjFloat
18
+ register_overloaded_type(AdjFloat, numpy.float64)
@@ -0,0 +1,56 @@
1
+ import numpy
2
+ from pyadjoint.overloaded_type import OverloadedType, register_overloaded_type, create_overloaded_object
3
+ from pyadjoint.tape import get_working_tape, stop_annotating, annotate_tape
4
+ from pyadjoint.block import Block
5
+
6
+
7
+ @register_overloaded_type
8
+ class ndarray(OverloadedType, numpy.ndarray):
9
+ def __init__(self, *args, **kwargs):
10
+ pass
11
+
12
+ @classmethod
13
+ def _ad_init_object(cls, obj):
14
+ return cls(obj.shape, numpy.float_, buffer=obj)
15
+
16
+ def _ad_create_checkpoint(self):
17
+ return self.copy()
18
+
19
+ def _ad_restore_at_checkpoint(self, checkpoint):
20
+ return checkpoint
21
+
22
+ def __getitem__(self, item):
23
+ annotate = annotate_tape()
24
+ if annotate:
25
+ block = NumpyArraySliceBlock(self, item)
26
+ tape = get_working_tape()
27
+ tape.add_block(block)
28
+
29
+ with stop_annotating():
30
+ out = numpy.ndarray.__getitem__(self, item)
31
+
32
+ if annotate:
33
+ out = create_overloaded_object(out)
34
+ block.add_output(out.create_block_variable())
35
+ return out
36
+
37
+ def _ad_convert_type(self, value, options={}):
38
+ return value
39
+
40
+ def __array_finalize__(self, obj):
41
+ OverloadedType.__init__(self)
42
+
43
+
44
+ class NumpyArraySliceBlock(Block):
45
+ def __init__(self, array, item):
46
+ super().__init__()
47
+ self.add_dependency(array)
48
+ self.item = item
49
+
50
+ def evaluate_adj_component(self, inputs, adj_inputs, block_variable, idx, prepared=None):
51
+ adj_output = numpy.zeros(inputs[0].shape)
52
+ adj_output[self.item] = adj_inputs[0]
53
+ return adj_output
54
+
55
+ def recompute_component(self, inputs, block_variable, idx, prepared):
56
+ return inputs[0][self.item]
@@ -0,0 +1,25 @@
1
+ # flake8: noqa
2
+
3
+ __version__ = '2019.1.2'
4
+ __author__ = 'Sebastian Kenji Mitusch'
5
+ __credits__ = []
6
+ __license__ = 'LGPL-3'
7
+ __maintainer__ = 'Sebastian Kenji Mitusch'
8
+ __email__ = 'sebastkm@math.uio.no'
9
+
10
+ from .block import Block
11
+ from .tape import (Tape,
12
+ set_working_tape, get_working_tape, no_annotations,
13
+ annotate_tape, stop_annotating, pause_annotation, continue_annotation)
14
+ from .adjfloat import AdjFloat
15
+ from .reduced_functional import ReducedFunctional
16
+ from .drivers import compute_gradient, compute_hessian, solve_adjoint
17
+ from .verification import taylor_test, taylor_to_dict
18
+ from .overloaded_type import OverloadedType, create_overloaded_object
19
+ from .control import Control
20
+ from .optimization.optimization import minimize, maximize, print_optimization_methods
21
+ from .optimization.optimization_problem import MinimizationProblem
22
+ from .optimization.ipopt_solver import IPOPTSolver
23
+ from .optimization.rol_solver import ROLSolver
24
+ from .optimization.constraints import InequalityConstraint, EqualityConstraint
25
+ from .optimization.moola_problem import MoolaOptimizationProblem