Managing state space
NumCME.AbstractStateSpace
— TypeAbstract type for FSP state space. This is the supertype of all concrete FSP state space implementations.
NumCME.StateSpaceSparse
— TypeStateSpaceSparse{NS,NR,IntT<:Integer,SizeT<:Integer} <: AbstractStateSpaceSparse{NS,NR,IntT,SizeT}
Basic Sparse FSP State space.
Fields
stoich_matrix::Matrix{IntT}
Stoichiometry matrix S = [s₁ ... sₘ] of size N x M where N is the number of species, M the number of the reactions.
sink_count::SizeT
Number of sinks.
states::Vector{MVector{NS,IntT}}
Array of CME states included in the subspace.
state2idx::Dict{MVector{NS,IntT},SizeT}
Dictionary of states, containing pairs (x=>i)
for (i,x) in enumerate(states). The implementation must ensure that each state in states
is a key in state2idx
and conversely every key in state2idx
exists in states
.
state_connectivity::Vector{MVector{NR,SizeT}}
List of state connectivity information. state_connectivity[i][k] = j
if xᵢ = xⱼ + sₖ, that is, states[i] = states[j] + stoich_mat[:, k]
. If there is no existing state that can reach xᵢ via reaction k, the implementation must ensure that state_connectivity[i][k] = 0
.
sink_connectivity::Vector{MVector{NR,SizeT}}
Matrix to store reaction events by which the included states transit to outside of the projected state space.
See also
expand!
,deleteat!
NumCME.StateSpaceSparse
— MethodStateSpaceSparse(stoich_mat::Matrix{IntT}, init_state::Vector{IntT}; index_type::Type{<:Integer}=UInt32)
Construct a basic FSP state space with stoichiometry matrix stoich_mat
and a single state init_state
with their integer entries being stored in type IntT <: Integer
. The optional keyword argument index_type
allows for more customization on internal indexing representations.
Examples
```jldoctest julia> S = [[1,0] [-1,0] [0,1] [0,-1]] 2×4 Matrix{Int64}: 1 -1 0 0 0 0 1 -1 julia> x0 = [0,1] julia> StateSpaceSparse(S, states)
NumCME.StateSpaceSparse
— MethodStateSpaceSparse(stoich_mat, states; index_type::Type{<:Integer}=UInt32)
Construct a basic FSP state space with stoichiometry matrix stoich_mat
and initial list of states initstates
with their integer entries being stored in type IntT <: Integer
.
Examples
julia> S = [[1,0] [-1,0] [0,1] [0,-1]]
2×4 Matrix{Int64}:
1 -1 0 0
0 0 1 -1
julia> states = [[0,1], [10, 1], [0, 10]]
3-element Vector{Vector{Int64}}:
[0, 1]
[10, 1]
[0, 10]
julia> StateSpaceSparse(S, states)
Base.deleteat!
— Methoddeleteat!(statespace::StateSpaceSparse, ids::Vector{T}) where {T<:Integer}
Delete states with indices ids
from the state space.
NumCME._addstates!
— MethodHelper function to add a state vector newstate
to the current state space statespace
. If newstate
is already included in statespace
, this function will return without modifying any of the input arguments.
NumCME._is_all_nonnegative
— Method_is_all_nonnegative(x::AbstractVector) -> Bool
Helper function. Returns true
if all elements of a vector is positive. Otherwise returns false
.
NumCME.expand!
— MethodExpand the FSP state space to include all states that are reachable from the existing states in r
or fewer reaction events, where r == num_reachable_steps
. The optional keyword argument index_type
allows for more customization on internal indexing representations.
NumCME.get_sink_count
— Methodget_sink_count(statespace::AbstractStateSpace)
Return number of sinks.
NumCME.get_state_count
— Methodget_state_count(statespace::AbstractStateSpace)
Return number of states.
NumCME.get_statedict
— Methodget_statedict(statespace::StateSpaceSparse)
Return state dictionary.
NumCME.get_states
— Methodget_states(statespace::AbstractStateSpaceSparse)
Return list of states.
NumCME.get_stoich_matrix
— Methodget_stoich_matrix(space::StateSpaceSparse)
Return the stoichiometry matrix.