gamspy 1.18.3__py3-none-any.whl → 1.19.0__py3-none-any.whl
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.
- gamspy/__init__.py +86 -98
- gamspy/__main__.py +6 -6
- gamspy/_algebra/__init__.py +13 -13
- gamspy/_algebra/condition.py +290 -194
- gamspy/_algebra/domain.py +103 -93
- gamspy/_algebra/expression.py +820 -799
- gamspy/_algebra/number.py +79 -70
- gamspy/_algebra/operable.py +185 -185
- gamspy/_algebra/operation.py +948 -845
- gamspy/_backend/backend.py +313 -311
- gamspy/_backend/engine.py +960 -960
- gamspy/_backend/local.py +124 -124
- gamspy/_backend/neos.py +567 -567
- gamspy/_cli/__init__.py +1 -1
- gamspy/_cli/cli.py +64 -64
- gamspy/_cli/gdx.py +377 -377
- gamspy/_cli/install.py +375 -372
- gamspy/_cli/list.py +94 -94
- gamspy/_cli/mps2gms.py +128 -128
- gamspy/_cli/probe.py +52 -52
- gamspy/_cli/retrieve.py +79 -79
- gamspy/_cli/run.py +158 -158
- gamspy/_cli/show.py +246 -255
- gamspy/_cli/uninstall.py +165 -165
- gamspy/_cli/util.py +94 -94
- gamspy/_communication.py +215 -215
- gamspy/_config.py +132 -132
- gamspy/_container.py +1694 -1452
- gamspy/_convert.py +720 -720
- gamspy/_database.py +271 -271
- gamspy/_extrinsic.py +181 -181
- gamspy/_miro.py +356 -352
- gamspy/_model.py +1803 -1615
- gamspy/_model_instance.py +701 -701
- gamspy/_options.py +780 -700
- gamspy/_serialization.py +156 -144
- gamspy/_symbols/__init__.py +17 -17
- gamspy/_symbols/alias.py +305 -299
- gamspy/_symbols/equation.py +1407 -1298
- gamspy/_symbols/implicits/__init__.py +11 -11
- gamspy/_symbols/implicits/implicit_equation.py +186 -186
- gamspy/_symbols/implicits/implicit_parameter.py +272 -272
- gamspy/_symbols/implicits/implicit_set.py +124 -124
- gamspy/_symbols/implicits/implicit_symbol.py +315 -315
- gamspy/_symbols/implicits/implicit_variable.py +255 -255
- gamspy/_symbols/parameter.py +648 -609
- gamspy/_symbols/set.py +985 -923
- gamspy/_symbols/symbol.py +395 -386
- gamspy/_symbols/universe_alias.py +182 -182
- gamspy/_symbols/variable.py +1101 -1017
- gamspy/_types.py +7 -7
- gamspy/_validation.py +735 -735
- gamspy/_workspace.py +72 -72
- gamspy/exceptions.py +128 -128
- gamspy/formulations/__init__.py +46 -46
- gamspy/formulations/ml/__init__.py +11 -11
- gamspy/formulations/ml/decision_tree_struct.py +80 -80
- gamspy/formulations/ml/gradient_boosting.py +203 -203
- gamspy/formulations/ml/random_forest.py +187 -187
- gamspy/formulations/ml/regression_tree.py +533 -533
- gamspy/formulations/nn/__init__.py +19 -19
- gamspy/formulations/nn/avgpool2d.py +232 -232
- gamspy/formulations/nn/conv1d.py +533 -533
- gamspy/formulations/nn/conv2d.py +529 -529
- gamspy/formulations/nn/linear.py +341 -341
- gamspy/formulations/nn/maxpool2d.py +88 -88
- gamspy/formulations/nn/minpool2d.py +88 -88
- gamspy/formulations/nn/mpool2d.py +245 -245
- gamspy/formulations/nn/torch_sequential.py +278 -278
- gamspy/formulations/piecewise.py +682 -682
- gamspy/formulations/result.py +119 -119
- gamspy/formulations/shape.py +188 -188
- gamspy/formulations/utils.py +173 -173
- gamspy/math/__init__.py +215 -215
- gamspy/math/activation.py +783 -767
- gamspy/math/log_power.py +435 -435
- gamspy/math/matrix.py +534 -534
- gamspy/math/misc.py +1709 -1625
- gamspy/math/probability.py +170 -170
- gamspy/math/trigonometric.py +232 -232
- gamspy/utils.py +810 -791
- gamspy/version.py +5 -5
- {gamspy-1.18.3.dist-info → gamspy-1.19.0.dist-info}/METADATA +90 -121
- gamspy-1.19.0.dist-info/RECORD +90 -0
- {gamspy-1.18.3.dist-info → gamspy-1.19.0.dist-info}/WHEEL +1 -1
- {gamspy-1.18.3.dist-info → gamspy-1.19.0.dist-info}/licenses/LICENSE +22 -22
- gamspy-1.18.3.dist-info/RECORD +0 -90
- {gamspy-1.18.3.dist-info → gamspy-1.19.0.dist-info}/entry_points.txt +0 -0
- {gamspy-1.18.3.dist-info → gamspy-1.19.0.dist-info}/top_level.txt +0 -0
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
4
|
-
|
|
5
|
-
from gamspy.formulations.nn.mpool2d import _MPool2d
|
|
6
|
-
|
|
7
|
-
if TYPE_CHECKING:
|
|
8
|
-
import gamspy as gp
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MaxPool2d(_MPool2d):
|
|
12
|
-
"""
|
|
13
|
-
Formulation generator for 2D Max Pooling in GAMS.
|
|
14
|
-
|
|
15
|
-
Parameters
|
|
16
|
-
----------
|
|
17
|
-
container : Container
|
|
18
|
-
Container that will contain the new variable and equations.
|
|
19
|
-
kernel_size : int | tuple[int, int]
|
|
20
|
-
Filter size
|
|
21
|
-
stride : int | tuple[int, int] | None
|
|
22
|
-
Stride in the max pooling, it is equal to kernel_size if not provided
|
|
23
|
-
padding : int | tuple[int, int]
|
|
24
|
-
Amount of padding to be added to input, by default 0
|
|
25
|
-
name_prefix : str | None
|
|
26
|
-
Prefix for generated GAMSPy symbols, by default None which means
|
|
27
|
-
random prefix. Using the same name_prefix in different formulations causes name
|
|
28
|
-
conflicts. Do not use the same name_prefix again.
|
|
29
|
-
|
|
30
|
-
Examples
|
|
31
|
-
--------
|
|
32
|
-
>>> import gamspy as gp
|
|
33
|
-
>>> from gamspy.math import dim
|
|
34
|
-
>>> m = gp.Container()
|
|
35
|
-
>>> # 2x2 max pooling
|
|
36
|
-
>>> mp1 = gp.formulations.MaxPool2d(m, (2, 2))
|
|
37
|
-
>>> inp = gp.Variable(m, domain=dim((10, 1, 24, 24)))
|
|
38
|
-
>>> out, eqs = mp1(inp)
|
|
39
|
-
>>> type(out)
|
|
40
|
-
<class 'gamspy._symbols.variable.Variable'>
|
|
41
|
-
>>> [len(x) for x in out.domain]
|
|
42
|
-
[10, 1, 12, 12]
|
|
43
|
-
|
|
44
|
-
"""
|
|
45
|
-
|
|
46
|
-
def __init__(
|
|
47
|
-
self,
|
|
48
|
-
container: gp.Container,
|
|
49
|
-
kernel_size: int | tuple[int, int],
|
|
50
|
-
stride: int | None = None,
|
|
51
|
-
padding: int = 0,
|
|
52
|
-
name_prefix: str | None = None,
|
|
53
|
-
):
|
|
54
|
-
super().__init__("max", container, kernel_size, stride, padding, name_prefix)
|
|
55
|
-
|
|
56
|
-
def __call__(
|
|
57
|
-
self,
|
|
58
|
-
input: gp.Parameter | gp.Variable,
|
|
59
|
-
big_m: int = 1000,
|
|
60
|
-
propagate_bounds: bool = True,
|
|
61
|
-
) -> tuple[gp.Variable, list[gp.Equation]]:
|
|
62
|
-
"""
|
|
63
|
-
Forward pass your input, generate output and equations required for
|
|
64
|
-
calculating the max pooling. Returns the output variable and the list
|
|
65
|
-
of equations required for the max pooling formulation. if propagate_bounds
|
|
66
|
-
is True, it will also set the bounds for the output variable based on the input.
|
|
67
|
-
It will also compute the big M value required for the pooling operation
|
|
68
|
-
using the bounds.
|
|
69
|
-
|
|
70
|
-
Parameters
|
|
71
|
-
----------
|
|
72
|
-
input : gp.Parameter | gp.Variable
|
|
73
|
-
input to the max pooling 2d layer, must be in shape
|
|
74
|
-
(batch x in_channels x height x width)
|
|
75
|
-
big_m: int
|
|
76
|
-
Big M value that is required for the pooling operation.
|
|
77
|
-
Default value: 1000.
|
|
78
|
-
propagate_bounds: bool
|
|
79
|
-
If True, it will set the bounds for the output variable
|
|
80
|
-
based on the input.
|
|
81
|
-
Default value: True
|
|
82
|
-
|
|
83
|
-
Returns
|
|
84
|
-
-------
|
|
85
|
-
tuple[gp.Variable, list[gp.Equation]]
|
|
86
|
-
|
|
87
|
-
"""
|
|
88
|
-
return super().__call__(input, big_m, propagate_bounds)
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from gamspy.formulations.nn.mpool2d import _MPool2d
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
import gamspy as gp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MaxPool2d(_MPool2d):
|
|
12
|
+
"""
|
|
13
|
+
Formulation generator for 2D Max Pooling in GAMS.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
container : Container
|
|
18
|
+
Container that will contain the new variable and equations.
|
|
19
|
+
kernel_size : int | tuple[int, int]
|
|
20
|
+
Filter size
|
|
21
|
+
stride : int | tuple[int, int] | None
|
|
22
|
+
Stride in the max pooling, it is equal to kernel_size if not provided
|
|
23
|
+
padding : int | tuple[int, int]
|
|
24
|
+
Amount of padding to be added to input, by default 0
|
|
25
|
+
name_prefix : str | None
|
|
26
|
+
Prefix for generated GAMSPy symbols, by default None which means
|
|
27
|
+
random prefix. Using the same name_prefix in different formulations causes name
|
|
28
|
+
conflicts. Do not use the same name_prefix again.
|
|
29
|
+
|
|
30
|
+
Examples
|
|
31
|
+
--------
|
|
32
|
+
>>> import gamspy as gp
|
|
33
|
+
>>> from gamspy.math import dim
|
|
34
|
+
>>> m = gp.Container()
|
|
35
|
+
>>> # 2x2 max pooling
|
|
36
|
+
>>> mp1 = gp.formulations.MaxPool2d(m, (2, 2))
|
|
37
|
+
>>> inp = gp.Variable(m, domain=dim((10, 1, 24, 24)))
|
|
38
|
+
>>> out, eqs = mp1(inp)
|
|
39
|
+
>>> type(out)
|
|
40
|
+
<class 'gamspy._symbols.variable.Variable'>
|
|
41
|
+
>>> [len(x) for x in out.domain]
|
|
42
|
+
[10, 1, 12, 12]
|
|
43
|
+
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
def __init__(
|
|
47
|
+
self,
|
|
48
|
+
container: gp.Container,
|
|
49
|
+
kernel_size: int | tuple[int, int],
|
|
50
|
+
stride: int | None = None,
|
|
51
|
+
padding: int = 0,
|
|
52
|
+
name_prefix: str | None = None,
|
|
53
|
+
):
|
|
54
|
+
super().__init__("max", container, kernel_size, stride, padding, name_prefix)
|
|
55
|
+
|
|
56
|
+
def __call__(
|
|
57
|
+
self,
|
|
58
|
+
input: gp.Parameter | gp.Variable,
|
|
59
|
+
big_m: int = 1000,
|
|
60
|
+
propagate_bounds: bool = True,
|
|
61
|
+
) -> tuple[gp.Variable, list[gp.Equation]]:
|
|
62
|
+
"""
|
|
63
|
+
Forward pass your input, generate output and equations required for
|
|
64
|
+
calculating the max pooling. Returns the output variable and the list
|
|
65
|
+
of equations required for the max pooling formulation. if propagate_bounds
|
|
66
|
+
is True, it will also set the bounds for the output variable based on the input.
|
|
67
|
+
It will also compute the big M value required for the pooling operation
|
|
68
|
+
using the bounds.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
input : gp.Parameter | gp.Variable
|
|
73
|
+
input to the max pooling 2d layer, must be in shape
|
|
74
|
+
(batch x in_channels x height x width)
|
|
75
|
+
big_m: int
|
|
76
|
+
Big M value that is required for the pooling operation.
|
|
77
|
+
Default value: 1000.
|
|
78
|
+
propagate_bounds: bool
|
|
79
|
+
If True, it will set the bounds for the output variable
|
|
80
|
+
based on the input.
|
|
81
|
+
Default value: True
|
|
82
|
+
|
|
83
|
+
Returns
|
|
84
|
+
-------
|
|
85
|
+
tuple[gp.Variable, list[gp.Equation]]
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
return super().__call__(input, big_m, propagate_bounds)
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from typing import TYPE_CHECKING
|
|
4
|
-
|
|
5
|
-
from gamspy.formulations.nn.mpool2d import _MPool2d
|
|
6
|
-
|
|
7
|
-
if TYPE_CHECKING:
|
|
8
|
-
import gamspy as gp
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class MinPool2d(_MPool2d):
|
|
12
|
-
"""
|
|
13
|
-
Formulation generator for 2D Min Pooling in GAMS.
|
|
14
|
-
|
|
15
|
-
Parameters
|
|
16
|
-
----------
|
|
17
|
-
container : Container
|
|
18
|
-
Container that will contain the new variable and equations.
|
|
19
|
-
kernel_size : int | tuple[int, int]
|
|
20
|
-
Filter size
|
|
21
|
-
stride : int | tuple[int, int] | None
|
|
22
|
-
Stride in the min pooling, it is equal to kernel_size if not provided
|
|
23
|
-
padding : int | tuple[int, int]
|
|
24
|
-
Amount of padding to be added to input, by default 0
|
|
25
|
-
name_prefix : str | None
|
|
26
|
-
Prefix for generated GAMSPy symbols, by default None which means
|
|
27
|
-
random prefix. Using the same name_prefix in different formulations causes name
|
|
28
|
-
conflicts. Do not use the same name_prefix again.
|
|
29
|
-
|
|
30
|
-
Examples
|
|
31
|
-
--------
|
|
32
|
-
>>> import gamspy as gp
|
|
33
|
-
>>> from gamspy.math import dim
|
|
34
|
-
>>> m = gp.Container()
|
|
35
|
-
>>> # 2x2 min pooling
|
|
36
|
-
>>> mp1 = gp.formulations.MinPool2d(m, (2, 2))
|
|
37
|
-
>>> inp = gp.Variable(m, domain=dim((10, 1, 24, 24)))
|
|
38
|
-
>>> out, eqs = mp1(inp)
|
|
39
|
-
>>> type(out)
|
|
40
|
-
<class 'gamspy._symbols.variable.Variable'>
|
|
41
|
-
>>> [len(x) for x in out.domain]
|
|
42
|
-
[10, 1, 12, 12]
|
|
43
|
-
|
|
44
|
-
"""
|
|
45
|
-
|
|
46
|
-
def __init__(
|
|
47
|
-
self,
|
|
48
|
-
container: gp.Container,
|
|
49
|
-
kernel_size: int | tuple[int, int],
|
|
50
|
-
stride: int | None = None,
|
|
51
|
-
padding: int = 0,
|
|
52
|
-
name_prefix: str | None = None,
|
|
53
|
-
):
|
|
54
|
-
super().__init__("min", container, kernel_size, stride, padding, name_prefix)
|
|
55
|
-
|
|
56
|
-
def __call__(
|
|
57
|
-
self,
|
|
58
|
-
input: gp.Parameter | gp.Variable,
|
|
59
|
-
big_m: int = 1000,
|
|
60
|
-
propagate_bounds: bool = True,
|
|
61
|
-
) -> tuple[gp.Variable, list[gp.Equation]]:
|
|
62
|
-
"""
|
|
63
|
-
Forward pass your input, generate output and equations required for
|
|
64
|
-
calculating the min pooling. Returns the output variable and the list
|
|
65
|
-
of equations required for the min pooling formulation. if propagate_bounds
|
|
66
|
-
is True, it will also set the bounds for the output variable based on the input.
|
|
67
|
-
It will also compute the big M value required for the pooling operation
|
|
68
|
-
using the bounds.
|
|
69
|
-
|
|
70
|
-
Parameters
|
|
71
|
-
----------
|
|
72
|
-
input : gp.Parameter | gp.Variable
|
|
73
|
-
input to the min pooling 2d layer, must be in shape
|
|
74
|
-
(batch x in_channels x height x width)
|
|
75
|
-
big_m: int
|
|
76
|
-
Big M value that is required for the pooling operation.
|
|
77
|
-
Default value: 1000.
|
|
78
|
-
propagate_bounds: bool
|
|
79
|
-
If True, it will set the bounds for the output variable
|
|
80
|
-
based on the input.
|
|
81
|
-
Default value: True
|
|
82
|
-
|
|
83
|
-
Returns
|
|
84
|
-
-------
|
|
85
|
-
tuple[gp.Variable, list[gp.Equation]]
|
|
86
|
-
|
|
87
|
-
"""
|
|
88
|
-
return super().__call__(input, big_m, propagate_bounds)
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from gamspy.formulations.nn.mpool2d import _MPool2d
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
import gamspy as gp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MinPool2d(_MPool2d):
|
|
12
|
+
"""
|
|
13
|
+
Formulation generator for 2D Min Pooling in GAMS.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
container : Container
|
|
18
|
+
Container that will contain the new variable and equations.
|
|
19
|
+
kernel_size : int | tuple[int, int]
|
|
20
|
+
Filter size
|
|
21
|
+
stride : int | tuple[int, int] | None
|
|
22
|
+
Stride in the min pooling, it is equal to kernel_size if not provided
|
|
23
|
+
padding : int | tuple[int, int]
|
|
24
|
+
Amount of padding to be added to input, by default 0
|
|
25
|
+
name_prefix : str | None
|
|
26
|
+
Prefix for generated GAMSPy symbols, by default None which means
|
|
27
|
+
random prefix. Using the same name_prefix in different formulations causes name
|
|
28
|
+
conflicts. Do not use the same name_prefix again.
|
|
29
|
+
|
|
30
|
+
Examples
|
|
31
|
+
--------
|
|
32
|
+
>>> import gamspy as gp
|
|
33
|
+
>>> from gamspy.math import dim
|
|
34
|
+
>>> m = gp.Container()
|
|
35
|
+
>>> # 2x2 min pooling
|
|
36
|
+
>>> mp1 = gp.formulations.MinPool2d(m, (2, 2))
|
|
37
|
+
>>> inp = gp.Variable(m, domain=dim((10, 1, 24, 24)))
|
|
38
|
+
>>> out, eqs = mp1(inp)
|
|
39
|
+
>>> type(out)
|
|
40
|
+
<class 'gamspy._symbols.variable.Variable'>
|
|
41
|
+
>>> [len(x) for x in out.domain]
|
|
42
|
+
[10, 1, 12, 12]
|
|
43
|
+
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
def __init__(
|
|
47
|
+
self,
|
|
48
|
+
container: gp.Container,
|
|
49
|
+
kernel_size: int | tuple[int, int],
|
|
50
|
+
stride: int | None = None,
|
|
51
|
+
padding: int = 0,
|
|
52
|
+
name_prefix: str | None = None,
|
|
53
|
+
):
|
|
54
|
+
super().__init__("min", container, kernel_size, stride, padding, name_prefix)
|
|
55
|
+
|
|
56
|
+
def __call__(
|
|
57
|
+
self,
|
|
58
|
+
input: gp.Parameter | gp.Variable,
|
|
59
|
+
big_m: int = 1000,
|
|
60
|
+
propagate_bounds: bool = True,
|
|
61
|
+
) -> tuple[gp.Variable, list[gp.Equation]]:
|
|
62
|
+
"""
|
|
63
|
+
Forward pass your input, generate output and equations required for
|
|
64
|
+
calculating the min pooling. Returns the output variable and the list
|
|
65
|
+
of equations required for the min pooling formulation. if propagate_bounds
|
|
66
|
+
is True, it will also set the bounds for the output variable based on the input.
|
|
67
|
+
It will also compute the big M value required for the pooling operation
|
|
68
|
+
using the bounds.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
input : gp.Parameter | gp.Variable
|
|
73
|
+
input to the min pooling 2d layer, must be in shape
|
|
74
|
+
(batch x in_channels x height x width)
|
|
75
|
+
big_m: int
|
|
76
|
+
Big M value that is required for the pooling operation.
|
|
77
|
+
Default value: 1000.
|
|
78
|
+
propagate_bounds: bool
|
|
79
|
+
If True, it will set the bounds for the output variable
|
|
80
|
+
based on the input.
|
|
81
|
+
Default value: True
|
|
82
|
+
|
|
83
|
+
Returns
|
|
84
|
+
-------
|
|
85
|
+
tuple[gp.Variable, list[gp.Equation]]
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
return super().__call__(input, big_m, propagate_bounds)
|