MATE-libraries 1.2.0__tar.gz → 1.4.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.
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/PKG-INFO +2 -2
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/pyproject.toml +2 -2
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/networks/_catalogue.py +1 -1
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/networks/_compiled.py +9 -7
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/networks/_networkx.py +5 -4
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/networks/_organ.py +5 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/networks/_prepare.py +6 -1
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/operators/_selection.py +1 -1
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/operators/_variation.py +21 -8
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/.gitignore +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/COPYING +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/COPYING.LESSER +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/README.md +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/__init__.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/analysis/__init__.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/analysis/__main__.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/analysis/_performance.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/analysis/_read.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/analysis/_replay.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/networks/__init__.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/networks/_graph.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/networks/_opencl.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/networks/_propagate.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/networks/_state.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/networks/_techniques.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/operators/__init__.py +0 -0
- {mate_libraries-1.2.0 → mate_libraries-1.4.0}/src/MATE_libraries/operators/_draws.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: MATE-libraries
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: Libraries of MATE, the Modular Algorithmic Toolkit for Evolution: network library and standard operators library for MATE modules, analysis library for recorded runs
|
|
5
5
|
Project-URL: Homepage, https://gitlab.com/artificial_evolution/mate/mate
|
|
6
6
|
Project-URL: Issues, https://gitlab.com/artificial_evolution/mate/mate/-/issues
|
|
@@ -15,7 +15,7 @@ Classifier: Intended Audience :: Science/Research
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3
|
|
16
16
|
Classifier: Topic :: Scientific/Engineering
|
|
17
17
|
Requires-Python: >=3.14
|
|
18
|
-
Requires-Dist: mate-contract<2,>=1.
|
|
18
|
+
Requires-Dist: mate-contract<2,>=1.3
|
|
19
19
|
Provides-Extra: analysis
|
|
20
20
|
Requires-Dist: matplotlib>=3.9; extra == 'analysis'
|
|
21
21
|
Provides-Extra: opencl
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "MATE-libraries"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.4.0"
|
|
8
8
|
description = "Libraries of MATE, the Modular Algorithmic Toolkit for Evolution: network library and standard operators library for MATE modules, analysis library for recorded runs"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.14"
|
|
@@ -21,7 +21,7 @@ classifiers = [
|
|
|
21
21
|
"Programming Language :: Python :: 3",
|
|
22
22
|
"Topic :: Scientific/Engineering",
|
|
23
23
|
]
|
|
24
|
-
dependencies = ["MATE-contract>=1.
|
|
24
|
+
dependencies = ["MATE-contract>=1.3,<2"]
|
|
25
25
|
|
|
26
26
|
[project.optional-dependencies]
|
|
27
27
|
# The device path of the network library: propagation on an OpenCL device.
|
|
@@ -442,13 +442,15 @@ def compile(
|
|
|
442
442
|
|
|
443
443
|
Notes
|
|
444
444
|
-----
|
|
445
|
-
Rules S1-S1j, N10, N11, S8-S8e, S9, S12 and S15 of the libraries specification. Every
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
445
|
+
Rules S1-S1j, N10, N11, S8-S8e, S9, S12 and S15 of the libraries specification. Every row of
|
|
446
|
+
an organ's ``edges`` is an edge, its level ignored; edges into input nodes are dropped and
|
|
447
|
+
counted. Under ``sink_outputs`` an individual with an edge that leaves an output node is
|
|
448
|
+
refused (kind ``"output_source"``), with or without the analysis. The reserved node
|
|
449
|
+
attributes ``bias`` and ``tau``, when the organ spec declares them, give each node a bias
|
|
450
|
+
added to its aggregated input and a time constant; input nodes ignore both. The technique is
|
|
451
|
+
``dense`` for identical topologies, otherwise the faster of ``padded`` and
|
|
452
|
+
``block_diagonal`` measured on the batch; each individual's results are bit-identical
|
|
453
|
+
whatever the batch and technique.
|
|
452
454
|
"""
|
|
453
455
|
t0 = time.perf_counter()
|
|
454
456
|
_check_device(device)
|
|
@@ -74,7 +74,7 @@ def _value(value: Any, domain: Domain, codes: Mapping[Hashable, int] | None,
|
|
|
74
74
|
"""Convert the value of one node or edge to an array of ``shape`` in the domain's dtype.
|
|
75
75
|
|
|
76
76
|
``codes`` maps the labels of an ``Ordinal`` or ``Categorical`` domain to their codes; it is
|
|
77
|
-
``None`` for a numeric domain.
|
|
77
|
+
``None`` for a numeric domain. ``shape`` ends with the domain's ``element_shape``.
|
|
78
78
|
"""
|
|
79
79
|
if codes is not None:
|
|
80
80
|
if shape == ():
|
|
@@ -108,13 +108,14 @@ def _attribute(name: str, domain: Domain, shape: tuple[int, ...],
|
|
|
108
108
|
codes = None
|
|
109
109
|
if isinstance(domain, (Ordinal, Categorical)):
|
|
110
110
|
codes = {label: code for code, label in enumerate(domain.values)}
|
|
111
|
-
|
|
111
|
+
full = (*shape, *domain.element_shape)
|
|
112
|
+
values = np.zeros((len(data), *full), dtype=domain.dtype)
|
|
112
113
|
for i in np.flatnonzero(present):
|
|
113
114
|
where = f"{names[i]}, attribute '{name}'"
|
|
114
|
-
values[i] = _value(data[i][name], domain, codes,
|
|
115
|
+
values[i] = _value(data[i][name], domain, codes, full, where)
|
|
115
116
|
if present.all():
|
|
116
117
|
return values, None
|
|
117
|
-
mask = present.reshape(-1, *(1,) * len(
|
|
118
|
+
mask = present.reshape(-1, *(1,) * len(full))
|
|
118
119
|
return values, np.broadcast_to(mask, values.shape).copy()
|
|
119
120
|
|
|
120
121
|
|
|
@@ -45,6 +45,11 @@ def recurrent(spec: NetworkSpec) -> bool:
|
|
|
45
45
|
return bool(spec.recurrent)
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
def sink_outputs(spec: NetworkSpec) -> bool:
|
|
49
|
+
"""Whether the organ spec forbids every edge that leaves an output node."""
|
|
50
|
+
return bool(spec.sink_outputs)
|
|
51
|
+
|
|
52
|
+
|
|
48
53
|
def declarations(spec: NetworkSpec) -> dict[str, Declaration]:
|
|
49
54
|
"""Return every node then edge attribute declaration, in declaration order."""
|
|
50
55
|
out: dict[str, Declaration] = {}
|
|
@@ -417,7 +417,7 @@ def _malformed(
|
|
|
417
417
|
if arr is None:
|
|
418
418
|
return f"network: malformed organ: {d.place} attribute '{d.name}' is missing"
|
|
419
419
|
count = n if d.place == "node" else src.size
|
|
420
|
-
expected = (count, *d.shape) # type: ignore[misc]
|
|
420
|
+
expected = (count, *d.shape, *d.domain.element_shape) # type: ignore[misc, union-attr]
|
|
421
421
|
if arr.shape != expected:
|
|
422
422
|
return (
|
|
423
423
|
f"network: malformed organ: {d.place} attribute '{d.name}' has shape "
|
|
@@ -553,6 +553,11 @@ def _prepare_one(
|
|
|
553
553
|
if not recurrent and not acyclic:
|
|
554
554
|
reason = "network: cycle in an organ whose organ spec says recurrent=False"
|
|
555
555
|
return _refused(ps, n, inputs, outputs, reason, "cyclic", **graph)
|
|
556
|
+
if _organ.sink_outputs(ps.spec) and src.size and (
|
|
557
|
+
(src >= ps.n_in) & (src < ps.n_in + ps.n_out)).any():
|
|
558
|
+
reason = ("network: an edge leaves an output node in an organ whose organ spec says "
|
|
559
|
+
"sink_outputs=True")
|
|
560
|
+
return _refused(ps, n, inputs, outputs, reason, "output_source", **graph)
|
|
556
561
|
return PreparedNetwork(
|
|
557
562
|
valid=True,
|
|
558
563
|
invalid=None,
|
|
@@ -5,7 +5,16 @@ from dataclasses import dataclass
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
from numpy.typing import ArrayLike
|
|
7
7
|
|
|
8
|
-
from MATE_contract import
|
|
8
|
+
from MATE_contract import (
|
|
9
|
+
Categorical,
|
|
10
|
+
Domain,
|
|
11
|
+
FieldArray,
|
|
12
|
+
Integer,
|
|
13
|
+
Log,
|
|
14
|
+
Ordinal,
|
|
15
|
+
Real,
|
|
16
|
+
UnitVector,
|
|
17
|
+
)
|
|
9
18
|
|
|
10
19
|
_FIXED_SCALARS = (bool, int, float, complex, np.generic, np.ndarray)
|
|
11
20
|
|
|
@@ -19,7 +28,7 @@ def _open_bound(domain: Domain) -> bool:
|
|
|
19
28
|
|
|
20
29
|
def _check_domain(d: object) -> Domain:
|
|
21
30
|
"""Return ``d`` if it is a domain of the contract family with finite bounds."""
|
|
22
|
-
if type(d) not in (Real, Log, Integer, Ordinal, Categorical):
|
|
31
|
+
if type(d) not in (Real, Log, Integer, Ordinal, Categorical, UnitVector):
|
|
23
32
|
raise TypeError(f"op_for expects a Domain or a bounded FieldArray, got {type(d).__name__}")
|
|
24
33
|
if _open_bound(d): # type: ignore[arg-type]
|
|
25
34
|
raise ValueError(f"op_for: domain {d!r} has an open bound; nothing can be drawn from it")
|
|
@@ -46,8 +55,10 @@ class VariationOperator:
|
|
|
46
55
|
-----
|
|
47
56
|
Rules OV1, OV5, OV6 and OV8 of the libraries specification. Calling the operator returns
|
|
48
57
|
exactly ``domain.nudge(x, rng, scale)``: the library maps a domain to its operator and does
|
|
49
|
-
not define a second transformation.
|
|
50
|
-
|
|
58
|
+
not define a second transformation. It transforms elements, one value of the domain each:
|
|
59
|
+
a scalar, or a whole vector along the trailing ``domain.element_shape`` axes for a
|
|
60
|
+
``UnitVector`` (a step on the sphere, never one component). Frozen, hence picklable, so
|
|
61
|
+
that a method holding operators on ``self`` can be sent to worker processes.
|
|
51
62
|
"""
|
|
52
63
|
|
|
53
64
|
domain: Domain
|
|
@@ -61,12 +72,14 @@ class VariationOperator:
|
|
|
61
72
|
Parameters
|
|
62
73
|
----------
|
|
63
74
|
x : array_like
|
|
64
|
-
Values contained in the domain (codes for ``Ordinal`` and ``Categorical
|
|
75
|
+
Values contained in the domain (codes for ``Ordinal`` and ``Categorical``, vectors
|
|
76
|
+
along the last axis for ``UnitVector``).
|
|
65
77
|
rng : numpy.random.Generator
|
|
66
78
|
The method's generator, from its ``variation`` branch of the seed tree (OV3).
|
|
67
79
|
scale : array_like
|
|
68
|
-
Amplitude chosen by the method, broadcastable to ``x
|
|
69
|
-
Required: the amplitude changes
|
|
80
|
+
Amplitude chosen by the method, one per element: broadcastable to ``x`` without its
|
|
81
|
+
``domain.element_shape`` axes, finite and ``>= 0``. Required: the amplitude changes
|
|
82
|
+
the result (OV6).
|
|
70
83
|
|
|
71
84
|
Returns
|
|
72
85
|
-------
|
|
@@ -88,7 +101,7 @@ def op_for(d: Domain | FieldArray) -> VariationOperator:
|
|
|
88
101
|
----------
|
|
89
102
|
d : Domain or FieldArray
|
|
90
103
|
A domain with finite bounds, or a bounded ``FieldArray`` (its domain's operator,
|
|
91
|
-
applied
|
|
104
|
+
applied element by element, shape unchanged).
|
|
92
105
|
|
|
93
106
|
Returns
|
|
94
107
|
-------
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|