lmlib.statespace.cost.CostBase#
- class lmlib.statespace.cost.CostBase(label='n/a')#
Bases:
abc.ABC
Abstract baseclass for
CostSegment
andCompositeCost
- Parameters
label (str, optional) – Label of Alssm, default: ‘n/a’
Methods
__init__
([label])eval_alssm_output
(xs, alssm_weights)Evaluation of the ALSSM for multiple state vectors xs.
int : Order of the (stacked) Alssm Model
get_steady_state_W
([method])Returns Steady State Matrix W
trajectories
(xs[, F, thd])Returns the
CompositeCost
's ALSSM's trajectories (=output sequences for a fixed initial states) for multiple initial state vectorsxs
windows
(segment_indices[, thd])Returns for each selected segment its window generated by
CostSegment.windows()
.Attributes
Mapping matrix \(F\), maps models to segments
Set of ALSSM
Label of the Cost Model
Set of Segment
- eval_alssm_output(xs, alssm_weights)#
Evaluation of the ALSSM for multiple state vectors xs.
See:
eval()
- Parameters
xs (array_like of shape=(XS, N [,S]) of floats) – List of state vectors \(x\)
alssm_selection (array_like, shape=(M,) of bool) – Each element enables (
True
, 1) or disables (False
, 0) the m-th ALSSM inCompositeCost.alssms
.
- Returns
s – ALSSM outputs
- Return type
ndarray
of shape=(XS,[J,]L[,S]) of floats
N : ALSSM system order, corresponding to the number of state variables
L : output order / number of signal channels
M : number of ALSSMs
S : number of signal sets
XS : number of state vectors in a listExamples
- get_model_order()#
int : Order of the (stacked) Alssm Model
- get_state_var_indices(label)#
Returns the state indices for a specified label of the stacked internal ALSSM
- Parameters
label (str) – state label
- Returns
out – state indices of the label
- Return type
list of int
- get_steady_state_W(method='closed_form')#
Returns Steady State Matrix W
- Parameters
method (str, optional) – if ‘closed_form’ is used the steady state matrix will be calculated in a close form. This method can be critical, as it can produce badly conditioned matrices internally. if ‘limited_sum’ is used, the steady state matrix will be calculated brute force, with a stop condition on a minimum change.
- Returns
Wss = `class – Steady State Matrix W
- Return type
numpy.ndarray`
- trajectories(xs, F=None, thd=1e-06)#
Returns the
CompositeCost
’s ALSSM’s trajectories (=output sequences for a fixed initial states) for multiple initial state vectorsxs
Evaluates the
CompositeCost
’s ALSSM with the state vectorsxs
over the time indices defined byCompositeCost.segments
. The segment’s interval boundaries limit the evaluation interval (samples outside this interval are set to 0). In particular for segments with infinite interval borders, the threshold optionthds
additionally limits the evaluation boundaries by defining a minimal window height of theCompositeCost.segments
.- Parameters
xs (array_like of shape=(XS, N [,S]) of floats) – List of initial state vectors \(x\)
F (array_like, shape(M, P) of int, shape(M,) of int) – Mapping matrix. If not set to
None
, the given matrix overloads the CompositeCost’s internal mapping matrix as provided by the class constructor forCompositeCost
. IfF
is only ofshape(M,)
, the vector gets enlarged to sizeshape(M, P)
by repeating the vector P-times. (This is a shortcut to select a single ALSSM over all segments.)thds (list of shape(P) of floats, scalar, None, optional) – Per segment threshold limiting the evaluation boundaries by setting a minimum window height of the associated
segments
Scalar to use the same threshold for all available segments.
- Returns
trajectories – Each element in trajectories is a tuple with
range
of length JR: relative index range of trajectory with respect to semgent’s boundariesarray
of shape(JR, L, [S]): trajectory values over reported range.
Dimension S is only present in the output, if dimension S is also present in
xs
(i.e., if multiple signal sets are used)- Return type
list of shape=(XS) of tuples of shape=(P) of tuples
(range, array)
JR : index range length
XS : number of state vectors in a list
N : ALSSM system order, corresponding to the number of state variables
S : number of signal sets
M : number of ALSSMs
P : number of segments
- windows(segment_indices, thd=1e-06)#
Returns for each selected segment its window generated by
CostSegment.windows()
.The segments are selected by
segment_selection
.- Parameters
segment_indices (array_like, shape=(P,) of Boolean) – Enables (
True
, 1) or disables (False
, 0) the evaluation of the p-th Segment inCompositeCost.segments
usingCostSegment.window()
thds (list of shape=(P,) of floats, scalar, optional) – List of per-segment threshold values or scalar to use the same threshold for all segments Evaluation is stopped for window weights below the given threshold. Set list element to
None
to disable the threshold for a segment.
- Returns
Each element is a tuple with
range
of length JR: relative index range of window with respect to segment’s boundaries.array
of shape=(JR) of floats: per-index window weight over the reported index range
- Return type
list of shape=(P) of tuples
(range, array)
JR : index range length
P : number of segments