Package org.oristool.models.stpn
Class TransientSolution<R,S>
java.lang.Object
org.oristool.models.stpn.TransientSolution<R,S>
- Type Parameters:
R
- type of initial states (such as regenerations)S
- type of reachable states (such as markings)
Transient probabilities from many initial states.
-
Constructor Summary
ConstructorDescriptionTransientSolution
(BigDecimal timeBound, BigDecimal timeStep, List<R> regenerations, List<S> columnStates, R initialRegeneration) Prepares a new instance and allocates the vector of probabilities. -
Method Summary
Modifier and TypeMethodDescriptionstatic <R> TransientSolution<R,
MarkingCondition> computeAggregateSolution
(TransientSolution<R, Marking> solution, String markingConditions) Aggregates the marking probabilities based on a predicate.static <R> TransientSolution<R,
MarkingCondition> computeAggregateSolution
(TransientSolution<R, Marking> solution, R initialRegeneration, MarkingCondition... markingConditions) Aggregates the marking probabilities based on a predicate.Computes the derivative of each time series.Computes the integral of each time series.static <R> TransientSolution<R,
RewardRate> computeRewards
(boolean cumulative, TransientSolution<R, Marking> solution, String rewardRates) Computes rewards from a transient solution (only for the first initial state).static <R> TransientSolution<R,
RewardRate> computeRewards
(boolean cumulative, TransientSolution<R, Marking> solution, RewardRate... rewardRates) Computes rewards from a transient solution (only for the first initial state).static <S> TransientSolution<S,
S> Prepares a new instance from a given array.Returns the first initial state of the analysis.int
double[][][]
getStep()
boolean
isClose
(TransientSolution<String, String> other, double epsilon) <U,
T> double jsDistance
(TransientSolution<T, U> other, int i, int j, int u, int v) Computes the Jensen-Shannon distance between the time series of state (i,j) for this solution, and (u,v) for the other.static double
klDivergence
(double px, double py) Computes the Kullback-Leibler divergence on the input probability values.<T,
U> double klDivergence
(TransientSolution<T, U> other, int i, int j, int u, int v) Computes the Kullback-Leibler divergence between the time series of state (i,j) for this solution, and (u,v) for the other.static TransientSolution<String,
String> static TransientSolution<String,
String> static RewardRate[]
rewardRates
(String rewardRates) Creates reward evaluators from a string of expressions separated by semicolon.boolean
sumsToOne
(double epsilon) toString()
void
void
-
Constructor Details
-
TransientSolution
public TransientSolution(BigDecimal timeBound, BigDecimal timeStep, List<R> regenerations, List<S> columnStates, R initialRegeneration) Prepares a new instance and allocates the vector of probabilities.- Parameters:
timeBound
- time bound for of the time seriestimeStep
- time stepregenerations
- initial statescolumnStates
- reachable statesinitialRegeneration
- first initial state
-
-
Method Details
-
fromArray
public static <S> TransientSolution<S,S> fromArray(double[][] probs, double step, Map<S, Integer> statePos, S initialState) Prepares a new instance from a given array.- Type Parameters:
S
- type of reachable states (such as markings)- Parameters:
probs
- array of transient probabilities for each time/statestep
- time step between solutions in the arraystatePos
- mapping from states to positioninitialState
- initial state of the analysis- Returns:
- a new transient solution backed by the input parameters
-
toString
-
writeCSV
-
writeCSV
-
readCSV
-
readCSV
-
getInitialRegeneration
Returns the first initial state of the analysis.- Returns:
- first initial state
-
getTimeLimit
-
getStep
-
getSamplesNumber
public int getSamplesNumber() -
getRegenerations
-
getColumnStates
-
getSolution
public double[][][] getSolution() -
computeIntegralSolution
Computes the integral of each time series.- Returns:
- a transient solution with cumulative values
-
computeDerivativeSolution
Computes the derivative of each time series.- Returns:
- a transient solution with finite differences
-
klDivergence
public static double klDivergence(double px, double py) Computes the Kullback-Leibler divergence on the input probability values.- Parameters:
px
- probability value according to PDF Xpy
- probability value according to PDF Y- Returns:
- KL divergence
-
klDivergence
Computes the Kullback-Leibler divergence between the time series of state (i,j) for this solution, and (u,v) for the other.- Parameters:
other
- another solutioni
- initial regeneration of this solutionj
- state of this solution solution (over time should give a PDF)u
- initial regeneration of the other solutionv
- state of the other solution solution (over time should give a PDF)- Returns:
- KL divergence
-
jsDistance
Computes the Jensen-Shannon distance between the time series of state (i,j) for this solution, and (u,v) for the other.- Parameters:
other
- another solutioni
- initial regeneration of this solutionj
- state of this solution solution (over time should give a PDF)u
- initial regeneration of the other solutionv
- state of the other solution solution (over time should give a PDF)- Returns:
- JS distance
-
computeAggregateSolution
public static <R> TransientSolution<R,MarkingCondition> computeAggregateSolution(TransientSolution<R, Marking> solution, String markingConditions) Aggregates the marking probabilities based on a predicate.- Type Parameters:
R
- type of initial states (such as regenerations)- Parameters:
solution
- input solutionmarkingConditions
- string of marking conditions separated by comma- Returns:
- transient probabilities for each marking condition
-
computeAggregateSolution
public static <R> TransientSolution<R,MarkingCondition> computeAggregateSolution(TransientSolution<R, Marking> solution, R initialRegeneration, MarkingCondition... markingConditions) Aggregates the marking probabilities based on a predicate.- Type Parameters:
R
- type of initial states (such as regenerations)- Parameters:
solution
- input solutioninitialRegeneration
- first initial statemarkingConditions
- marking conditions- Returns:
- transient probabilities for each marking condition
-
rewardRates
Creates reward evaluators from a string of expressions separated by semicolon.- Parameters:
rewardRates
- list of rewards separated by semicolon- Returns:
- reward rate evaluators
-
computeRewards
public static <R> TransientSolution<R,RewardRate> computeRewards(boolean cumulative, TransientSolution<R, Marking> solution, String rewardRates) Computes rewards from a transient solution (only for the first initial state).- Type Parameters:
R
- type of initial states (such as regenerations)- Parameters:
cumulative
- whether to compute cumulative rewardssolution
- input transient solutionrewardRates
- list of rewards separated by semicolon- Returns:
- transient rewards for each reward expression
-
computeRewards
public static <R> TransientSolution<R,RewardRate> computeRewards(boolean cumulative, TransientSolution<R, Marking> solution, RewardRate... rewardRates) Computes rewards from a transient solution (only for the first initial state).- Type Parameters:
R
- type of initial states (such as regenerations)- Parameters:
cumulative
- whether to compute cumulative rewardssolution
- input transient solutionrewardRates
- list of rewards separated by semicolon- Returns:
- transient rewards for each reward expression
-
isClose
-
sumsToOne
public boolean sumsToOne(double epsilon)
-