Skip to content

Commit 3f0424c

Browse files
Update of StabilityMeasuresAccumulator (#184)
* Make possible that nls parameters are functions * Check epsilon distance minimum before saving ct * Corrected median conv time/pace and optimized critical shocks * notes on how to simplify code * Comprehensive refactoring to record only needed information Has been tested to show that the results did not change * Small fix for PR tests * Adjusted saving of ics and corrected expected test values * More type parametrization * Fix of max amplification * Handle Inf values in plotting of continuation curves * Updated docs * add some dummy entries to bib for now * use `distace` * Continuation with variable distance parameter * Bump version * fix name specification * add instructions how to extent the accumulator --------- Co-authored-by: Datseris <[email protected]>
1 parent e8ce5b5 commit 3f0424c

File tree

9 files changed

+324
-235
lines changed

9 files changed

+324
-235
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v1.29
2+
3+
- Keyword `metric` of `StabilityMeasuresAccumulator` is no longer used as it was incorrect.
4+
- New keyword `distance` for `StabilityMeasuresAccumulator`.
5+
- Source code of `StabilityMeasuresAccumulator` has been drastically simplified, and instructions for how to extent its functionality were added.
6+
17
# v1.28
28

39
- `extract_attractors` will now automatically name the dimensions of the attractors for MTK-derived systems.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name = "Attractors"
22
uuid = "f3fd9213-ca85-4dba-9dfd-7fc91308fec7"
33
authors = ["George Datseris <[email protected]>", "Kalel Rossi", "Alexandre Wagemakers"]
44
repo = "https://github.com/JuliaDynamics/Attractors.jl.git"
5-
version = "1.28.0"
5+
version = "1.29.0"
66

77

88
[deps]

docs/refs.bib

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,12 @@ @article{Krakovska2024ResilienceDynamicalSystems
296296
}
297297

298298
@article{Morr2025,
299-
title = {To be published},
300-
author = {Andreas Morr, George Datseris},
301-
journal = {},
302-
volume = {},
303-
number = {},
304-
pages = {},
299+
title = {Numerically Estimating Resilience Measures in Dynamical Systems},
300+
author = {Andreas Morr and Christian Kuehn and George Datseris},
301+
journal = {to be published},
302+
volume = {1},
303+
number = {1},
304+
pages = {1},
305305
year = {2025},
306306
}
307307

ext/plotting.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ function Attractors.plot_continuation_curves!(ax, continuation_info, prange = 1:
301301
)
302302

303303
series = continuation_series(continuation_info, NaN, ukeys)
304+
for (k, v) in series
305+
v[isinf.(v)] .= NaN
306+
end
307+
304308
for k in ukeys
305309
scatterlines!(ax, prange, series[k];
306310
color = colors[k], label = "$(labels[k])", marker = markers[k],

src/continuation/continuation_stability_measures.jl

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ continuation steps.
108108
109109
- `ε = nothing`: given to [`AttractorsViaProximity`](@ref).
110110
- `proximity_mapper_options = NamedTuple()`: extra keywords for `AttractorsViaProximity`.
111-
- `metric, finite_time, weighting_distribution`: given to [`StabilityMeasuresAccumulator`](@ref).
111+
- `distance, finite_time, weighting_distribution`: given to [`StabilityMeasuresAccumulator`](@ref).
112112
- `samples_per_parameter = 1000`: how many samples to use when estimating stability measures
113113
via [`StabilityMeasuresAccumulator`](@ref). Ignored when `ics` is not a function.
114114
"""
@@ -121,7 +121,7 @@ function stability_measures_along_continuation(
121121
weighting_distribution = EverywhereUniform(),
122122
finite_time = 1.0,
123123
samples_per_parameter = 1000,
124-
metric = Euclidean(),
124+
distance = Centroid(),
125125
proximity_mapper_options = NamedTuple(),
126126
show_progress=true
127127
)
@@ -130,16 +130,41 @@ function stability_measures_along_continuation(
130130
)
131131
measures_cont = []
132132
for (i, p) in enumerate(pcurve)
133-
ε_ = ε isa AbstractVector ? ε[i] : ε # if its a vector, get i-th entry
134-
weighting_distribution_ = weighting_distribution isa AbstractVector ?
135-
weighting_distribution[i] : weighting_distribution
136-
finite_time_ = finite_time isa AbstractVector ? finite_time[i] : finite_time
137133
set_parameters!(ds, p)
138134
attractors = attractors_cont[i]
135+
if ε isa AbstractVector
136+
ε_ = ε[i]
137+
elseif ε isa Function
138+
ε_ = ε(p, attractors)
139+
else
140+
ε_ = ε
141+
end
142+
if weighting_distribution isa AbstractVector
143+
wd = weighting_distribution[i]
144+
elseif weighting_distribution isa Function
145+
wd = weighting_distribution(p, attractors)
146+
else
147+
wd = weighting_distribution
148+
end
149+
if finite_time isa AbstractVector
150+
ft = finite_time[i]
151+
elseif finite_time isa Function
152+
ft = finite_time(p, attractors)
153+
else
154+
ft = finite_time
155+
end
156+
if distance isa AbstractVector
157+
d = distance[i]
158+
elseif distance isa Function
159+
d = distance(p, attractors)
160+
else
161+
d = distance
162+
end
163+
139164
accumulator = StabilityMeasuresAccumulator(
140165
AttractorsViaProximity(ds, attractors; ε = ε_, proximity_mapper_options...);
141-
weighting_distribution = weighting_distribution_, finite_time = finite_time_,
142-
metric = metric
166+
weighting_distribution=wd, finite_time=ft,
167+
distance=d
143168
)
144169
N = ics isa Function ? samples_per_parameter : length(ics)
145170
for i 1:N

src/mapping/attractor_mapping_proximity.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ function AttractorsViaProximity(ds::DynamicalSystem, attractors::Dict;
6969
if !(valtype(attractors) <: AbstractStateSpaceSet)
7070
error("The input attractors must be a dictionary with values of `StateSpaceSet`s.")
7171
end
72+
if isempty(attractors)
73+
error("The input attractors cannot be an empty dictionary.")
74+
end
7275
if dimension(ds) dimension(first(attractors)[2])
7376
error("Dimension of the dynamical system and candidate attractors must match.")
7477
end

0 commit comments

Comments
 (0)