Interface SymEngine
- All Known Implementing Classes:
SageRestEngine
Java has no computer algebra system, so every operation here is delegated
to an external engine; SageRestEngine is the SageMath implementation
and is resolved by SymEngines. Expressions cross the interface as
plain ASCII infix strings, e.g. "2*x1 - 3*x2", which is the format
SolverCTMC.symbolicGeneratorResult.getSymbolicEntry already
produces.
Expression strings are not comparable across codebases: the
symbol numbering x1..xE follows event enumeration order, and printed normal
forms depend on the engine version. Compare by substituting values with
eval(java.util.List<java.lang.String>, java.util.Map<java.lang.String, java.lang.Double>) and comparing numbers.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classStationary distribution together with the measures taken from it.static classSymbolic stationary distribution of a CTMC.static classSymbolic analysis of a fluid vector field.static classOne weighted sum of the stationary distribution, or a ratio of two.static classFirst passage time transform and moments.static classA ratio of two measures, by their index into the weight block.static classExact parametric sensitivity, following Trivedi and Bobbio (2017), Sec. -
Method Summary
Modifier and TypeMethodDescriptionctmcMeasures(String[][] Q, List<String> symbols, String[][] weights, List<String> names, List<SymEngine.RatioSpec> ratios) Stationary distribution and a set of weighted sums of it.ctmcPassage(String[][] S, String[] s0, String[] alpha, String atom, List<String> symbols, String svar, List<String> want, int nmax) First passage time into a target set: the transform and the moments.Exact parametric sensitivity of a steady-state reward.Differentiates expressions.double[]Substitutes values for symbols and evaluates.Jacobian, LaTeX form and equilibria of a fluid vector field.booleanTrue if the engine answers a health probe.name()Name of the backing engine, e.g.Rewrites expressions into a normal form.Symbolic stationary distribution of a CTMC, pi Q = 0 with sum(pi) = 1.
-
Method Details
-
name
String name()Name of the backing engine, e.g. "sage". -
isAvailable
boolean isAvailable()True if the engine answers a health probe. -
solveCTMC
Symbolic stationary distribution of a CTMC, pi Q = 0 with sum(pi) = 1.- Parameters:
Q- generator entries as expression strings, row majorsymbols- the symbols appearing in Q, e.g. x1..xE- Returns:
- the solution, with pi also split over a common denominator
- Throws:
IOException- if the engine is unreachable or rejects the request
-
ctmcSensitivity
SymEngine.Sensitivity ctmcSensitivity(String[][] Q, List<String> symbols, String theta, List<String> reward) throws IOException Exact parametric sensitivity of a steady-state reward.- Parameters:
Q- generator entries as expression strings, row majorsymbols- the symbols appearing in Qtheta- the symbol to differentiate with respect toreward- reward rate per state, or null for the distribution alone- Returns:
- the sensitivity of the distribution and, if a reward is given, of its mean
- Throws:
IOException- if the engine is unreachable or rejects the request
-
ctmcMeasures
SymEngine.CTMCMeasures ctmcMeasures(String[][] Q, List<String> symbols, String[][] weights, List<String> names, List<SymEngine.RatioSpec> ratios) throws IOException Stationary distribution and a set of weighted sums of it.Every mean SolverCTMC reports is a NUMERIC linear functional of pi, so the caller builds one weight vector per measure with no algebra at all and this one round trip returns each
w . pias a rational function: a throughput ispi . depRates, a queue length ispi . stateSpaceAggr, a marginal probability ispi . indicatorand a mean reward ispi . r.- Parameters:
Q- generator entries as expression strings, row majorsymbols- the symbols appearing in Qweights- one row per measure, each of length Q.length; entries are parsed in the same field as Q, so an expression is admissible and not only a numbernames- a name per weight row, or null for w0, w1, ...ratios- ratios of two measures, or null for none- Returns:
- the distribution, the measures and the ratios
- Throws:
IOException- if the engine is unreachable or rejects the request
-
ctmcPassage
SymEngine.Passage ctmcPassage(String[][] S, String[] s0, String[] alpha, String atom, List<String> symbols, String svar, List<String> want, int nmax) throws IOException First passage time into a target set: the transform and the moments.With A the complement of the target, S = Q(A,A) the sub-generator, s0 = -S*1 the exit vector and alpha the initial law restricted to A, following Harrison and Knottenbelt (2002),
L(s) = alpha (sI - S)^-1 s0 + atom Eqs. 1-2 (-S) M(n) = n M(n-1), M(0) = 1 Eq. 3
The MOMENTS come from the recursion, not from differentiating L: it carries no transform symbol, stays in the same fraction field and is
nmaxright solves against one matrix. Differentiating instead would leave the fraction field, and the evaluation at s = 0 can hit 0/0 where a factor of s failed to cancel.- Parameters:
S- the sub-generator on the non-target states, row majors0- the exit vector -S*1alpha- the initial law restricted to the non-target statesatom- the initial mass already inside the target setsymbols- the rate symbols appearing in Ssvar- the transform symbol; adjoined to the field only when a transform is asked for, and required to differ from every rate symbolwant- any of lst, lstall, moments, momallnmax- highest moment order, at least 1- Returns:
- the requested items
- Throws:
IOException- if the engine is unreachable or rejects the request
-
simplify
Rewrites expressions into a normal form.- Parameters:
exprs- the expressionsform- one of simplify, factor, together, cancel, expand, latex- Returns:
- the rewritten expressions, in the input order
- Throws:
IOException- if the engine is unreachable or rejects the request
-
diff
Differentiates expressions.- Parameters:
exprs- the expressionsvariable- the differentiation variableorder- the order of the derivative, at least 1- Returns:
- the derivatives, in the input order
- Throws:
IOException- if the engine is unreachable or rejects the request
-
eval
Substitutes values for symbols and evaluates.- Parameters:
exprs- the expressionsassignment- value of each symbol- Returns:
- the numeric values, NaN where a free symbol remains
- Throws:
IOException- if the engine is unreachable or rejects the request
-
fluidODEs
SymEngine.FluidODEs fluidODEs(List<String> rhs, List<String> vars, List<String> want) throws IOException Jacobian, LaTeX form and equilibria of a fluid vector field.- Parameters:
rhs- the right hand side of dx/dt, one expression per state variablevars- the state variable nameswant- any of jacobian, latex, equilibria- Returns:
- the requested items
- Throws:
IOException- if the engine is unreachable or rejects the request
-