tvboptim 0.3.1__tar.gz → 0.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.
- {tvboptim-0.3.1/src/tvboptim.egg-info → tvboptim-0.4.0}/PKG-INFO +5 -3
- {tvboptim-0.3.1 → tvboptim-0.4.0}/pyproject.toml +5 -3
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/execution.py +6 -3
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/__init__.py +2 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/core/bunch.py +12 -2
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/core/network.py +60 -10
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/coupling/__init__.py +3 -0
- tvboptim-0.4.0/src/tvboptim/experimental/network_dynamics/coupling/base.py +1319 -0
- tvboptim-0.4.0/src/tvboptim/experimental/network_dynamics/coupling/kuramoto.py +159 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/coupling/linear.py +44 -56
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/coupling/subspace.py +60 -15
- tvboptim-0.4.0/src/tvboptim/experimental/network_dynamics/coupling/transport.py +65 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/coupling/tvb.py +8 -16
- tvboptim-0.4.0/src/tvboptim/experimental/network_dynamics/graph/__init__.py +26 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/graph/base.py +428 -29
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/graph/sparse.py +338 -231
- tvboptim-0.4.0/src/tvboptim/experimental/network_dynamics/graph/topology.py +159 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/solve.py +26 -5
- tvboptim-0.4.0/src/tvboptim/experimental/network_dynamics/solvers/base.py +31 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/solvers/native.py +31 -9
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/utils/history.py +6 -3
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/types/parameter.py +48 -20
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/types/spaces.py +67 -0
- tvboptim-0.4.0/src/tvboptim/utils/caching.py +159 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/utils/utils.py +27 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0/src/tvboptim.egg-info}/PKG-INFO +5 -3
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim.egg-info/SOURCES.txt +3 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim.egg-info/requires.txt +2 -2
- tvboptim-0.3.1/src/tvboptim/experimental/network_dynamics/coupling/base.py +0 -1057
- tvboptim-0.3.1/src/tvboptim/experimental/network_dynamics/graph/__init__.py +0 -14
- tvboptim-0.3.1/src/tvboptim/experimental/network_dynamics/solvers/base.py +0 -12
- tvboptim-0.3.1/src/tvboptim/utils/caching.py +0 -82
- {tvboptim-0.3.1 → tvboptim-0.4.0}/LICENSE +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/README.md +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/setup.cfg +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/analysis/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/analysis/identifiability.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/data/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/data/connectivity/dTOR/data.npz +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/data/connectivity/dk_average/data.npz +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/data/functional/dk_average/data.npz +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/data/loaders.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/data/plotting/dk_average/aparc+aseg-mni_09c.nii.gz +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/data/plotting/dk_average/fs_default.txt +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/data/plotting/dk_average/fs_default_freesurfer_idx.csv +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/analysis/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/analysis/adiabatic_scan.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/analysis/lyapunov.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/core/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/base.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/lorenz.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/coombes_byrne.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/epileptor.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/generic_2d_oscillator.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/jansen_rit.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/kuramoto.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/larter_breakspear.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/linear.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/montbrio_pazo_roxin.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/sup_hopf.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wilson_cowan.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wong_wang.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/dynamics/tvb/wong_wang_exc_inh.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/external_input/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/external_input/base.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/external_input/data.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/external_input/parametric.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/graph/utils.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/noise/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/noise/base.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/noise/gaussian.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/result.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/solvers/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/solvers/diffrax.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/utils/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/utils/printer.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/observations/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/observations/observation.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/observations/tvb_monitors/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/observations/tvb_monitors/bold.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/observations/tvb_monitors/downsampling.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/optim/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/optim/callbacks.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/optim/optax.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/tvbo/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/tvbo/prepare_experiment.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/types/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/types/stateutils.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/utils/__init__.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim.egg-info/dependency_links.txt +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim.egg-info/top_level.txt +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/tests/test_execution.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/tests/test_identifiability.py +0 -0
- {tvboptim-0.3.1 → tvboptim-0.4.0}/tests/test_optax_optimizer_toy.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tvboptim
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Optimization tools for The Virtual Brain
|
|
5
5
|
Author-email: Marius Pille <marius.pille@bih-charite.de>
|
|
6
6
|
License-Expression: EUPL-1.2
|
|
@@ -14,6 +14,8 @@ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
19
|
Classifier: Operating System :: OS Independent
|
|
18
20
|
Requires-Python: >=3.11
|
|
19
21
|
Description-Content-Type: text/markdown
|
|
@@ -23,11 +25,11 @@ Requires-Dist: optimistix
|
|
|
23
25
|
Requires-Dist: matplotlib
|
|
24
26
|
Requires-Dist: numpy
|
|
25
27
|
Requires-Dist: pandas
|
|
26
|
-
Requires-Dist: jax
|
|
28
|
+
Requires-Dist: jax
|
|
27
29
|
Requires-Dist: equinox
|
|
28
30
|
Requires-Dist: dill
|
|
29
31
|
Requires-Dist: tqdm
|
|
30
|
-
Requires-Dist: numpyro>=0.
|
|
32
|
+
Requires-Dist: numpyro>=0.21.0
|
|
31
33
|
Requires-Dist: diffrax
|
|
32
34
|
Requires-Dist: plum-dispatch
|
|
33
35
|
Provides-Extra: dev
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tvboptim"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "Optimization tools for The Virtual Brain"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -21,6 +21,8 @@ classifiers = [
|
|
|
21
21
|
"Programming Language :: Python :: 3",
|
|
22
22
|
"Programming Language :: Python :: 3.11",
|
|
23
23
|
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Programming Language :: Python :: 3.14",
|
|
24
26
|
"Operating System :: OS Independent",
|
|
25
27
|
]
|
|
26
28
|
requires-python = ">=3.11"
|
|
@@ -30,11 +32,11 @@ dependencies = [
|
|
|
30
32
|
"matplotlib",
|
|
31
33
|
"numpy",
|
|
32
34
|
"pandas",
|
|
33
|
-
"jax
|
|
35
|
+
"jax",
|
|
34
36
|
"equinox",
|
|
35
37
|
"dill",
|
|
36
38
|
"tqdm",
|
|
37
|
-
"numpyro>=0.
|
|
39
|
+
"numpyro>=0.21.0",
|
|
38
40
|
"diffrax",
|
|
39
41
|
"plum-dispatch",
|
|
40
42
|
]
|
|
@@ -224,13 +224,16 @@ class ParallelExecution(Execution):
|
|
|
224
224
|
self.n_pmap = n_pmap
|
|
225
225
|
self.args = args
|
|
226
226
|
self.kwargs = kwargs
|
|
227
|
-
diff_state, static_state = space.
|
|
227
|
+
diff_state, axis_tree_def, static_state = space._collect_mapping_inputs(
|
|
228
|
+
n_pmap=n_pmap
|
|
229
|
+
)
|
|
228
230
|
|
|
229
231
|
self.diff_state = diff_state
|
|
230
232
|
|
|
231
233
|
# kwargs args probably go directly into model
|
|
232
|
-
def _model(
|
|
233
|
-
|
|
234
|
+
def _model(axis_values):
|
|
235
|
+
axis_state = jax.tree.unflatten(axis_tree_def, axis_values)
|
|
236
|
+
state = combine_state(axis_state, static_state)
|
|
234
237
|
return model(state, *self.args, **self.kwargs)
|
|
235
238
|
|
|
236
239
|
def map_model(d):
|
|
@@ -8,6 +8,7 @@ from .graph import (
|
|
|
8
8
|
DelayGraph,
|
|
9
9
|
DenseDelayGraph,
|
|
10
10
|
DenseGraph,
|
|
11
|
+
DenseLengthGraph,
|
|
11
12
|
Graph,
|
|
12
13
|
SparseDelayGraph,
|
|
13
14
|
SparseGraph,
|
|
@@ -22,6 +23,7 @@ __all__ = [
|
|
|
22
23
|
"SparseDelayGraph",
|
|
23
24
|
"DenseGraph",
|
|
24
25
|
"DenseDelayGraph",
|
|
26
|
+
"DenseLengthGraph",
|
|
25
27
|
"solve",
|
|
26
28
|
"prepare",
|
|
27
29
|
"Network",
|
|
@@ -46,8 +46,18 @@ class Bunch(dict):
|
|
|
46
46
|
return f"{self.__class__.__name__}({items})"
|
|
47
47
|
|
|
48
48
|
def copy(self) -> "Bunch":
|
|
49
|
-
"""
|
|
50
|
-
|
|
49
|
+
"""Structurally copy this Bunch and any nested PyTree containers.
|
|
50
|
+
|
|
51
|
+
Rebuilds every container (nested Bunch, graph object, ...) so
|
|
52
|
+
mutating the copy -- including plain attribute assignment like
|
|
53
|
+
`cfg.graph.delays = x` -- does not leak back into the original.
|
|
54
|
+
Leaves (arrays, scalars, PRNG keys) are immutable in JAX, so
|
|
55
|
+
sharing them is safe and avoids duplicating large arrays (graph
|
|
56
|
+
weights, history buffers, pre-sampled noise tensors). Same
|
|
57
|
+
operation as solve.py's `_snapshot`, exposed here as `.copy()` so
|
|
58
|
+
it works for ad-hoc config mutation outside prepare().
|
|
59
|
+
"""
|
|
60
|
+
return jax.tree.map(lambda x: x, self)
|
|
51
61
|
|
|
52
62
|
|
|
53
63
|
# Register Bunch as a JAX PyTree with named keys so that
|
{tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/core/network.py
RENAMED
|
@@ -11,7 +11,8 @@ import jax.numpy as jnp
|
|
|
11
11
|
|
|
12
12
|
from ..coupling.base import AbstractCoupling
|
|
13
13
|
from ..dynamics.base import AbstractDynamics
|
|
14
|
-
from ..graph.base import AbstractGraph
|
|
14
|
+
from ..graph.base import AbstractGraph, delay_steps_bound, effective_max_delay
|
|
15
|
+
from ..graph.topology import prepare_graph_topology, validate_graph_topology
|
|
15
16
|
from ..noise.base import AbstractNoise
|
|
16
17
|
from ..result import NativeSolution
|
|
17
18
|
from .bunch import Bunch
|
|
@@ -100,8 +101,12 @@ class Network:
|
|
|
100
101
|
|
|
101
102
|
self.externals = self._normalize_external_inputs(external_input or {}, dynamics)
|
|
102
103
|
|
|
103
|
-
# Extract max_delay from graph (0.0 for non-DelayGraph)
|
|
104
|
-
|
|
104
|
+
# Extract max_delay from graph (0.0 for non-DelayGraph). Prefers a
|
|
105
|
+
# declared max_delay_bound over the actual max(delays), matching the
|
|
106
|
+
# coupling's own buffer sizing (coupling/base.py prepare()), so
|
|
107
|
+
# history is padded to the same length delays may be raised to
|
|
108
|
+
# within the bound during a sweep.
|
|
109
|
+
self.max_delay = effective_max_delay(graph)
|
|
105
110
|
|
|
106
111
|
# Resolve noise state indices if noise provided
|
|
107
112
|
if self.noise is not None:
|
|
@@ -318,7 +323,16 @@ class Network:
|
|
|
318
323
|
variable_names=state_names,
|
|
319
324
|
)
|
|
320
325
|
|
|
321
|
-
def prepare(
|
|
326
|
+
def prepare(
|
|
327
|
+
self,
|
|
328
|
+
dt: float,
|
|
329
|
+
t0: float,
|
|
330
|
+
t1: float,
|
|
331
|
+
*,
|
|
332
|
+
stage_time_centroid: float = 0.0,
|
|
333
|
+
recompute_coupling_per_stage: bool = False,
|
|
334
|
+
_prepared_topology=None,
|
|
335
|
+
) -> tuple[Bunch, Bunch]:
|
|
322
336
|
"""Prepare all couplings for simulation.
|
|
323
337
|
|
|
324
338
|
Calls prepare() on each coupling to get coupling_data and coupling_state.
|
|
@@ -327,6 +341,20 @@ class Network:
|
|
|
327
341
|
dt: Integration timestep
|
|
328
342
|
t0: Simulation start time
|
|
329
343
|
t1: Simulation end time
|
|
344
|
+
stage_time_centroid: The solver's ``sum_i b_i * c_i`` (see
|
|
345
|
+
AbstractSolver). DelayedCoupling.precompute() reads it to undo
|
|
346
|
+
the delay bias introduced by freezing the coupling across
|
|
347
|
+
solver stages. The default 0.0 means "step-start evaluation",
|
|
348
|
+
i.e. no shift.
|
|
349
|
+
recompute_coupling_per_stage: The solver's flag of the same name.
|
|
350
|
+
DelayedCoupling.precompute() needs it to decide whether the
|
|
351
|
+
stage-time shift is safe to apply (it is not, on its own, for a
|
|
352
|
+
coupling that also reads a frozen local state).
|
|
353
|
+
|
|
354
|
+
Both are written into every coupling_data *after* coupling.prepare()
|
|
355
|
+
returns, rather than passed down into it, so that couplings overriding
|
|
356
|
+
prepare() with the historical (network, dt, t0, t1) signature keep
|
|
357
|
+
working unchanged.
|
|
330
358
|
|
|
331
359
|
Returns:
|
|
332
360
|
coupling_data_dict: Bunch {name: coupling_data_bunch}
|
|
@@ -336,9 +364,17 @@ class Network:
|
|
|
336
364
|
"""
|
|
337
365
|
coupling_data_dict = Bunch()
|
|
338
366
|
coupling_state_dict = Bunch()
|
|
367
|
+
prepared_topology = (
|
|
368
|
+
prepare_graph_topology(self.graph)
|
|
369
|
+
if _prepared_topology is None
|
|
370
|
+
else _prepared_topology
|
|
371
|
+
)
|
|
339
372
|
|
|
340
373
|
for name, coupling in self.coupling.items():
|
|
341
374
|
data, state = coupling.prepare(self, dt, t0, t1)
|
|
375
|
+
data._prepared_topology = prepared_topology
|
|
376
|
+
data.stage_time_centroid = stage_time_centroid
|
|
377
|
+
data.recompute_coupling_per_stage = recompute_coupling_per_stage
|
|
342
378
|
coupling_data_dict[name] = data
|
|
343
379
|
coupling_state_dict[name] = state
|
|
344
380
|
|
|
@@ -380,16 +416,27 @@ class Network:
|
|
|
380
416
|
Args:
|
|
381
417
|
t: Current time
|
|
382
418
|
state: Current network state [n_states, n_nodes]
|
|
383
|
-
coupling_data_dict:
|
|
419
|
+
coupling_data_dict: Coupling data from prepare()
|
|
384
420
|
coupling_state_dict: Current coupling internal states
|
|
385
421
|
|
|
386
422
|
Returns:
|
|
387
423
|
coupling_inputs: Bunch {name: array[n_dims, n_nodes]}
|
|
388
424
|
Named coupling inputs ready for dynamics.dynamics()
|
|
389
425
|
Missing couplings automatically filled with zeros
|
|
426
|
+
|
|
427
|
+
Note:
|
|
428
|
+
Runs precompute() per call, as solve.py does once per forward pass.
|
|
429
|
+
compute() must never see raw prepare() output: DelayedCoupling only
|
|
430
|
+
resolves its delay read indices in precompute().
|
|
390
431
|
"""
|
|
391
432
|
coupling_inputs = Bunch()
|
|
392
433
|
|
|
434
|
+
if coupling_data_dict:
|
|
435
|
+
first_data = next(iter(coupling_data_dict.values()))
|
|
436
|
+
state = validate_graph_topology(
|
|
437
|
+
first_data._prepared_topology, self.graph, state
|
|
438
|
+
)
|
|
439
|
+
|
|
393
440
|
for name, n_dims in self.dynamics.COUPLING_INPUTS.items():
|
|
394
441
|
if name not in self.coupling:
|
|
395
442
|
# Missing coupling - use zeros
|
|
@@ -397,7 +444,9 @@ class Network:
|
|
|
397
444
|
else:
|
|
398
445
|
# Compute coupling
|
|
399
446
|
coupling = self.coupling[name]
|
|
400
|
-
data =
|
|
447
|
+
data = coupling.precompute(
|
|
448
|
+
coupling_data_dict[name], coupling.params, self.graph
|
|
449
|
+
)
|
|
401
450
|
state_data = coupling_state_dict[name]
|
|
402
451
|
coupling_inputs[name] = coupling.compute(
|
|
403
452
|
t, state, data, state_data, coupling.params, self.graph
|
|
@@ -552,11 +601,12 @@ class Network:
|
|
|
552
601
|
Returns:
|
|
553
602
|
None if no delays (max_delay == 0.0)
|
|
554
603
|
Otherwise history buffer [n_steps, n_states, n_nodes]
|
|
555
|
-
where n_steps =
|
|
604
|
+
where n_steps = delay_steps_bound(max_delay, dt) + 1
|
|
556
605
|
"""
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
606
|
+
# Covering [t0 - max_delay, t0] takes one row per step plus the t0
|
|
607
|
+
# endpoint. Must match extract_history_window() and the read indices
|
|
608
|
+
# DelayedCoupling.prepare() derives from the same bound.
|
|
609
|
+
n_steps = delay_steps_bound(self.max_delay, dt) + 1
|
|
560
610
|
return jnp.broadcast_to(
|
|
561
611
|
self.initial_state[None, :, :],
|
|
562
612
|
(n_steps, self.initial_state.shape[0], self.initial_state.shape[1]),
|
{tvboptim-0.3.1 → tvboptim-0.4.0}/src/tvboptim/experimental/network_dynamics/coupling/__init__.py
RENAMED
|
@@ -6,6 +6,7 @@ from .base import (
|
|
|
6
6
|
DelayedCoupling,
|
|
7
7
|
InstantaneousCoupling,
|
|
8
8
|
)
|
|
9
|
+
from .kuramoto import DelayedKuramotoCoupling, KuramotoCoupling
|
|
9
10
|
from .linear import (
|
|
10
11
|
DelayedDifferenceCoupling,
|
|
11
12
|
DelayedLinearCoupling,
|
|
@@ -29,4 +30,6 @@ __all__ = [
|
|
|
29
30
|
"DelayedDifferenceCoupling",
|
|
30
31
|
"FastLinearCoupling",
|
|
31
32
|
"SubspaceCoupling",
|
|
33
|
+
"KuramotoCoupling",
|
|
34
|
+
"DelayedKuramotoCoupling",
|
|
32
35
|
]
|