From 4d0f996adcbf3499ba59578e503f67183bcbee29 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Thu, 4 Jan 2024 15:34:30 +0000 Subject: [PATCH] build based on a7e0efb --- dev/.documenter-siteinfo.json | 2 +- dev/api/index.html | 8 +-- dev/assets/Manifest.toml | 2 +- dev/complete_sii/index.html | 2 +- dev/index.html | 6 +-- dev/simple_sii_sys/index.html | 2 +- dev/solution_wrappers/index.html | 2 +- dev/usage/{eb2d1a29.svg => 3fb8e17d.svg} | 64 ++++++++++++------------ dev/usage/index.html | 4 +- 9 files changed, 46 insertions(+), 46 deletions(-) rename dev/usage/{eb2d1a29.svg => 3fb8e17d.svg} (98%) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index bcc1a43d..fd753de2 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-01-04T15:33:17","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-01-04T15:34:25","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/api/index.html b/dev/api/index.html index bac2d9b4..8ff18e15 100644 --- a/dev/api/index.html +++ b/dev/api/index.html @@ -3,7 +3,7 @@ function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-90474609-3', {'page_path': location.pathname + location.search + location.hash}); -

Interface Functions

Mandatory methods

SymbolicIndexingInterface.symbolic_containerFunction
symbolic_container(p)

Using p, return an object that implements the symbolic indexing interface. In case p itself implements the interface, p can be returned as-is. All symbolic indexing interface methods fall back to calling the same method on symbolic_container(p), so this may be used for trivial implementations of the interface that forward all calls to another object.

source
SymbolicIndexingInterface.variable_symbolsFunction
variable_symbols(sys, [i])

Return a vector of the symbolic variables being solved for in the system sys. If constant_structure(sys) == false this accepts an additional parameter indicating the current time index. The returned vector should not be mutated.

For types that implement Base.getindex with symbolic indices using this interface, the shorthand sys[solvedvariables] can be used as shorthand for sys[variable_symbols(sys)]. See: solvedvariables.

source
SymbolicIndexingInterface.all_variable_symbolsFunction
all_variable_symbols(sys)

Return a vector of variable symbols in the system, including observed quantities.

For types that implement Base.getindex with symbolic indices using this interface, The shorthand sys[allvariables] can be used as shorthand for sys[all_variable_symbols(sys)]. See: allvariables.

source

Optional Methods

Observed equation handling

SymbolicIndexingInterface.observedFunction
observed(sys, sym, [states])

Return the observed function of the given sym in sys. The returned function should have the signature (u, p) -> [values...] where u and p is the current state and parameter vector, respectively. If istimedependent(sys) == true, the function should accept the current time t as its third parameter. If constant_structure(sys) == false, accept a third parameter, which can either be a vector of symbols indicating the order of states or a time index, which identifies the order of states. This function does not need to be defined if is_observed always returns false. Thus, it is mandatory to always check is_observed before using this function.

See also: is_time_dependent, constant_structure

source

Parameter indexing

SymbolicIndexingInterface.set_parameter!Function
set_parameter!(sys, val, idx)

Set the parameter at index idx to val for system sys. This defaults to modifying parameter_values(sys). If any additional bookkeeping needs to be performed or the default implementation does not work for a particular type, this method needs to be defined to enable the proper functioning of setp.

See: parameter_values

source
SymbolicIndexingInterface.getpFunction
getp(sys, p)

Return a function that takes an integrator or solution of sys, and returns the value of the parameter p. Note that p can be a direct numerical index or a symbolic value. Requires that the integrator or solution implement parameter_values. This function typically does not need to be implemented, and has a default implementation relying on parameter_values.

source
SymbolicIndexingInterface.setpFunction
setp(sys, p)

Return a function that takes an integrator of sys and a value, and sets the parameter p to that value. Note that p can be a direct numerical index or a symbolic value. Requires that the integrator implement parameter_values and the returned collection be a mutable reference to the parameter vector in the integrator. In case parameter_values cannot return such a mutable reference, or additional actions need to be performed when updating parameters, set_parameter! must be implemented.

source
SymbolicIndexingInterface.ParameterIndexingProxyType
struct ParameterIndexingProxy

This struct wraps any struct implementing the symbolic indexing interface. It allows getindex and setindex! operations to get/set parameter values. Requires that the wrapped type support getp and setp for getting and setting parameter values respectively.

source

State indexing

SymbolicIndexingInterface.NotTimeseriesType
struct NotTimeseries <: IsTimeseriesTrait end

Trait indicating a type does not contain timeseries data. This affects the behaviour of functions such as state_values and current_time. Note that if a type is NotTimeseries this only implies that it does not store timeseries data. It may still be time-dependent. For example, an ODEProblem only stores the initial state of a system, so it is NotTimeseries, but still time-dependent. This is the default trait variant for all types.

See also: Timeseries, is_timeseries

source
SymbolicIndexingInterface.set_state!Function
set_state!(sys, val, idx)

Set the state at index idx to val for system sys. This defaults to modifying state_values(sys). If any additional bookkeeping needs to be performed or the default implementation does not work for a particular type, this method needs to be defined to enable the proper functioning of setu.

See: state_values

source
SymbolicIndexingInterface.getuFunction
getu(sys, sym)

Return a function that takes an integrator, problem or solution of sys, and returns the value of the symbolic sym. sym can be a direct index into the state vector, a symbolic state, a symbolic expression involving symbolic quantities in the system sys, or an array/tuple of the aforementioned.

At minimum, this requires that the integrator, problem or solution implement state_values. To support symbolic expressions, the integrator or problem must implement observed, parameter_values and current_time.

This function typically does not need to be implemented, and has a default implementation relying on the above functions.

source
SymbolicIndexingInterface.setuFunction
setu(sys, sym)

Return a function that takes an integrator or problem of sys and a value, and sets the the state sym to that value. Note that sym can be a direct numerical index, a symbolic state, or an array/tuple of the aforementioned.

Requires that the integrator implement state_values and the returned collection be a mutable reference to the state vector in the integrator/problem. Alternatively, if this is not possible or additional actions need to be performed when updating state, set_state! can be defined. This function does not work on types for which is_timeseries is Timeseries.

source

Symbolic Trait

SymbolicIndexingInterface.ArraySymbolicType
struct ArraySymbolic <: SymbolicTypeTrait end

Trait indicating type is a symbolic array. Calling collect on a symbolic array must return an AbstractArray containing ScalarSymbolic variables for each element in the array, in the same shape as the represented array. For example, if a is a symbolic array representing a 2x2 matrix, collect(a) must return a 2x2 array of scalar symbolic variables.

See also: ScalarSymbolic, NotSymbolic, symbolic_type

source

Types

SymbolicIndexingInterface.SymbolCacheType
struct SymbolCache{V,P,I}
-function SymbolCache(vars, [params, [indepvars]])

A struct implementing the symbolic indexing interface for the trivial case of having a vector of variables, parameters, and independent variables. This struct does not implement observed, and is_observed returns false for all input symbols. It is considered time dependent if it contains at least one independent variable.

The independent variable may be specified as a single symbolic variable instead of an array containing a single variable if the system has only one independent variable.

source
+

Interface Functions

Mandatory methods

SymbolicIndexingInterface.symbolic_containerFunction
symbolic_container(p)

Using p, return an object that implements the symbolic indexing interface. In case p itself implements the interface, p can be returned as-is. All symbolic indexing interface methods fall back to calling the same method on symbolic_container(p), so this may be used for trivial implementations of the interface that forward all calls to another object.

source
SymbolicIndexingInterface.variable_symbolsFunction
variable_symbols(sys, [i])

Return a vector of the symbolic variables being solved for in the system sys. If constant_structure(sys) == false this accepts an additional parameter indicating the current time index. The returned vector should not be mutated.

For types that implement Base.getindex with symbolic indices using this interface, the shorthand sys[solvedvariables] can be used as shorthand for sys[variable_symbols(sys)]. See: solvedvariables.

source
SymbolicIndexingInterface.all_variable_symbolsFunction
all_variable_symbols(sys)

Return a vector of variable symbols in the system, including observed quantities.

For types that implement Base.getindex with symbolic indices using this interface, The shorthand sys[allvariables] can be used as shorthand for sys[all_variable_symbols(sys)]. See: allvariables.

source

Optional Methods

Observed equation handling

SymbolicIndexingInterface.observedFunction
observed(sys, sym, [states])

Return the observed function of the given sym in sys. The returned function should have the signature (u, p) -> [values...] where u and p is the current state and parameter vector, respectively. If istimedependent(sys) == true, the function should accept the current time t as its third parameter. If constant_structure(sys) == false, accept a third parameter, which can either be a vector of symbols indicating the order of states or a time index, which identifies the order of states. This function does not need to be defined if is_observed always returns false. Thus, it is mandatory to always check is_observed before using this function.

See also: is_time_dependent, constant_structure

source

Parameter indexing

SymbolicIndexingInterface.set_parameter!Function
set_parameter!(sys, val, idx)

Set the parameter at index idx to val for system sys. This defaults to modifying parameter_values(sys). If any additional bookkeeping needs to be performed or the default implementation does not work for a particular type, this method needs to be defined to enable the proper functioning of setp.

See: parameter_values

source
SymbolicIndexingInterface.getpFunction
getp(sys, p)

Return a function that takes an integrator or solution of sys, and returns the value of the parameter p. Note that p can be a direct numerical index or a symbolic value. Requires that the integrator or solution implement parameter_values. This function typically does not need to be implemented, and has a default implementation relying on parameter_values.

source
SymbolicIndexingInterface.setpFunction
setp(sys, p)

Return a function that takes an integrator of sys and a value, and sets the parameter p to that value. Note that p can be a direct numerical index or a symbolic value. Requires that the integrator implement parameter_values and the returned collection be a mutable reference to the parameter vector in the integrator. In case parameter_values cannot return such a mutable reference, or additional actions need to be performed when updating parameters, set_parameter! must be implemented.

source
SymbolicIndexingInterface.ParameterIndexingProxyType
struct ParameterIndexingProxy

This struct wraps any struct implementing the symbolic indexing interface. It allows getindex and setindex! operations to get/set parameter values. Requires that the wrapped type support getp and setp for getting and setting parameter values respectively.

source

State indexing

SymbolicIndexingInterface.NotTimeseriesType
struct NotTimeseries <: IsTimeseriesTrait end

Trait indicating a type does not contain timeseries data. This affects the behaviour of functions such as state_values and current_time. Note that if a type is NotTimeseries this only implies that it does not store timeseries data. It may still be time-dependent. For example, an ODEProblem only stores the initial state of a system, so it is NotTimeseries, but still time-dependent. This is the default trait variant for all types.

See also: Timeseries, is_timeseries

source
SymbolicIndexingInterface.set_state!Function
set_state!(sys, val, idx)

Set the state at index idx to val for system sys. This defaults to modifying state_values(sys). If any additional bookkeeping needs to be performed or the default implementation does not work for a particular type, this method needs to be defined to enable the proper functioning of setu.

See: state_values

source
SymbolicIndexingInterface.getuFunction
getu(sys, sym)

Return a function that takes an integrator, problem or solution of sys, and returns the value of the symbolic sym. sym can be a direct index into the state vector, a symbolic state, a symbolic expression involving symbolic quantities in the system sys, or an array/tuple of the aforementioned.

At minimum, this requires that the integrator, problem or solution implement state_values. To support symbolic expressions, the integrator or problem must implement observed, parameter_values and current_time.

This function typically does not need to be implemented, and has a default implementation relying on the above functions.

source
SymbolicIndexingInterface.setuFunction
setu(sys, sym)

Return a function that takes an integrator or problem of sys and a value, and sets the the state sym to that value. Note that sym can be a direct numerical index, a symbolic state, or an array/tuple of the aforementioned.

Requires that the integrator implement state_values and the returned collection be a mutable reference to the state vector in the integrator/problem. Alternatively, if this is not possible or additional actions need to be performed when updating state, set_state! can be defined. This function does not work on types for which is_timeseries is Timeseries.

source

Symbolic Trait

SymbolicIndexingInterface.ArraySymbolicType
struct ArraySymbolic <: SymbolicTypeTrait end

Trait indicating type is a symbolic array. Calling collect on a symbolic array must return an AbstractArray containing ScalarSymbolic variables for each element in the array, in the same shape as the represented array. For example, if a is a symbolic array representing a 2x2 matrix, collect(a) must return a 2x2 array of scalar symbolic variables.

See also: ScalarSymbolic, NotSymbolic, symbolic_type

source

Types

SymbolicIndexingInterface.SymbolCacheType
struct SymbolCache{V,P,I}
+function SymbolCache(vars, [params, [indepvars]])

A struct implementing the symbolic indexing interface for the trivial case of having a vector of variables, parameters, and independent variables. This struct does not implement observed, and is_observed returns false for all input symbols. It is considered time dependent if it contains at least one independent variable.

The independent variable may be specified as a single symbolic variable instead of an array containing a single variable if the system has only one independent variable.

source
diff --git a/dev/assets/Manifest.toml b/dev/assets/Manifest.toml index e86dd978..8e88f1d3 100644 --- a/dev/assets/Manifest.toml +++ b/dev/assets/Manifest.toml @@ -1719,7 +1719,7 @@ version = "7.2.1+1" [[deps.SymbolicIndexingInterface]] path = "/home/runner/work/SymbolicIndexingInterface.jl/SymbolicIndexingInterface.jl" uuid = "2efcf032-c050-4f8e-a9bb-153293bab1f5" -version = "0.3.2" +version = "0.3.3" [[deps.SymbolicUtils]] deps = ["AbstractTrees", "Bijections", "ChainRulesCore", "Combinatorics", "ConstructionBase", "DataStructures", "DocStringExtensions", "DynamicPolynomials", "IfElse", "LabelledArrays", "LinearAlgebra", "MultivariatePolynomials", "NaNMath", "Setfield", "SparseArrays", "SpecialFunctions", "StaticArrays", "SymbolicIndexingInterface", "TimerOutputs", "Unityper"] diff --git a/dev/complete_sii/index.html b/dev/complete_sii/index.html index 2e8fac58..3721e0da 100644 --- a/dev/complete_sii/index.html +++ b/dev/complete_sii/index.html @@ -181,4 +181,4 @@ MySym(Symbol(sym.name, :_, join(idxs, "_"))) for idxs in Iterators.product(Base.OneTo.(sym.size)...) ] -end

hasname is not required to always be true for symbolic types. For example, Symbolics.Num returns false whenever the wrapped value is a number, or an expression.

+end

hasname is not required to always be true for symbolic types. For example, Symbolics.Num returns false whenever the wrapped value is a number, or an expression.

diff --git a/dev/index.html b/dev/index.html index f96cd964..21d3f261 100644 --- a/dev/index.html +++ b/dev/index.html @@ -9,7 +9,7 @@ [961ee093] ModelingToolkit v8.75.0 [1dea7af3] OrdinaryDiffEq v6.68.0 [91a5bcdd] Plots v1.39.0 - [2efcf032] SymbolicIndexingInterface v0.3.2 `~/work/SymbolicIndexingInterface.jl/SymbolicIndexingInterface.jl`
and using this machine and Julia version.
Julia Version 1.10.0
+  [2efcf032] SymbolicIndexingInterface v0.3.3 `~/work/SymbolicIndexingInterface.jl/SymbolicIndexingInterface.jl`
and using this machine and Julia version.
Julia Version 1.10.0
 Commit 3120989f39b (2023-12-25 18:01 UTC)
 Build Info:
   Official https://julialang.org/ release
@@ -199,7 +199,7 @@
   [4c63d2b9] StatsFuns v1.3.0
   [7792a7ef] StrideArraysCore v0.5.2
   [892a3eda] StringManipulation v0.3.4
-  [2efcf032] SymbolicIndexingInterface v0.3.2 `~/work/SymbolicIndexingInterface.jl/SymbolicIndexingInterface.jl`
+  [2efcf032] SymbolicIndexingInterface v0.3.3 `~/work/SymbolicIndexingInterface.jl/SymbolicIndexingInterface.jl`
   [d1185830] SymbolicUtils v1.5.0
   [0c5d862f] Symbolics v5.15.1
   [3783bdb8] TableTraits v1.0.1
@@ -351,4 +351,4 @@
   [8e850b90] libblastrampoline_jll v5.8.0+1
   [8e850ede] nghttp2_jll v1.52.0+1
   [3f19e933] p7zip_jll v17.4.0+2
-Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`

You can also download the manifest file and the project file.

+Info Packages marked with ⌃ and ⌅ have new versions available. Those with ⌃ may be upgradable, but those with ⌅ are restricted by compatibility constraints from upgrading. To see why use `status --outdated -m`

You can also download the manifest file and the project file.

diff --git a/dev/simple_sii_sys/index.html b/dev/simple_sii_sys/index.html index 88443f75..7ab31860 100644 --- a/dev/simple_sii_sys/index.html +++ b/dev/simple_sii_sys/index.html @@ -107,4 +107,4 @@ 64593.73530179436 77241.71691097679 92180.81843146283 - 100000.0 + 100000.0 diff --git a/dev/solution_wrappers/index.html b/dev/solution_wrappers/index.html index f6822f4d..143eb07a 100644 --- a/dev/solution_wrappers/index.html +++ b/dev/solution_wrappers/index.html @@ -8,4 +8,4 @@ # other properties... end -symbolic_container(sys::MySolutionWrapper) = sys.sol

MySolutionWrapper wraps an AbstractTimeseriesSolution which already implements the interface. Since symbolic_container will return the wrapped solution, all method calls such as is_parameter(sys::MySolutionWrapper, sym) will be forwarded to is_parameter(sys.sol, sym).

In cases where some methods need to function differently than those of the wrapped type, they can be selectively defined. For example, suppose MySolutionWrapper does not support observed quantities. The following method can be defined (in addition to the one above):

is_observed(sys::MySolutionWrapper, sym) = false
+symbolic_container(sys::MySolutionWrapper) = sys.sol

MySolutionWrapper wraps an AbstractTimeseriesSolution which already implements the interface. Since symbolic_container will return the wrapped solution, all method calls such as is_parameter(sys::MySolutionWrapper, sym) will be forwarded to is_parameter(sys.sol, sym).

In cases where some methods need to function differently than those of the wrapped type, they can be selectively defined. For example, suppose MySolutionWrapper does not support observed quantities. The following method can be defined (in addition to the one above):

is_observed(sys::MySolutionWrapper, sym) = false
diff --git a/dev/usage/eb2d1a29.svg b/dev/usage/3fb8e17d.svg similarity index 98% rename from dev/usage/eb2d1a29.svg rename to dev/usage/3fb8e17d.svg index 9f781e0f..5f062287 100644 --- a/dev/usage/eb2d1a29.svg +++ b/dev/usage/3fb8e17d.svg @@ -1,46 +1,46 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/usage/index.html b/dev/usage/index.html index 509e2105..aa25e0da 100644 --- a/dev/usage/index.html +++ b/dev/usage/index.html @@ -142,7 +142,7 @@ -7.739577070649573 -5.727345621871555
sol(1.3, idxs=[:y, :z])
2-element Vector{Float64}:
  -1.6888746814711415
-  3.7011061302491606
plot(sol, idxs=x)
Example block output

If necessary, Symbols can be used to refer to variables. This is only valid for symbolic variables for which hasname returns true. The Symbol used must match the one returned by getname for the variable.

hasname(x)
true
getname(x)
:x
sol[(:x, :w)]
1495-element Vector{Tuple{Float64, Float64}}:
+  3.7011061302491606
plot(sol, idxs=x)
Example block output

If necessary, Symbols can be used to refer to variables. This is only valid for symbolic variables for which hasname returns true. The Symbol used must match the one returned by getname for the variable.

hasname(x)
true
getname(x)
:x
sol[(:x, :w)]
1495-element Vector{Tuple{Float64, Float64}}:
  (1.0, 1.0)
  (1.0002823510089436, 1.001695702996486)
  (1.0030752466310615, 1.0186439140427952)
@@ -213,4 +213,4 @@
 parameter_values(prob)
3-element Vector{Float64}:
  29.0
  11.0
-  2.5
Note

These getters and setters generate high-performance functions for the specific chosen symbols or collection of symbols. Caching the getter/setter function and reusing it on other problem/solution instances can be the key to achieving good performance. Note that this caching is allowed only when the symbolic system is unchanged (it's fine for the numerical values to have changed, but not the underlying equations).

+ 2.5
Note

These getters and setters generate high-performance functions for the specific chosen symbols or collection of symbols. Caching the getter/setter function and reusing it on other problem/solution instances can be the key to achieving good performance. Note that this caching is allowed only when the symbolic system is unchanged (it's fine for the numerical values to have changed, but not the underlying equations).