Package jline.api.sym
Class SageRestEngine
java.lang.Object
jline.api.sym.SageRestEngine
- All Implemented Interfaces:
SymEngine
SymEngine backed by the line-sage-rest service.
The service is SageMath behind the JSON protocol in sage/server.py.
Every request is a single POST carrying the whole problem, so nothing is
bind-mounted and the client works against a container, a remote host or a
hand-started server alike.
Numeric coefficients are sent as decimal strings and read server side as exact rationals, which is what keeps the solve exact: a double coerced by the CAS would carry the binary rational nearest the decimal instead.
Copyright (c) 2012-2026, Imperial College London All rights reserved.-
Nested Class Summary
Nested classes/interfaces inherited from interface jline.api.sym.SymEngine
SymEngine.CTMCSolution, SymEngine.FluidODEs, SymEngine.Sensitivity -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault per-request timeout, in seconds. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExact 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.intcom.google.gson.JsonObjectinfo()Reads the service identity, used to tell a line-sage-rest server apart from another service listening on the same conventional port.booleanTrue if the engine answers a health probe.name()Name of the backing engine, e.g.setTimeoutSeconds(int seconds) Sets the per-request timeout.Rewrites expressions into a normal form.Symbolic stationary distribution of a CTMC, pi Q = 0 with sum(pi) = 1.
-
Field Details
-
DEFAULT_TIMEOUT_SECONDS
public static final int DEFAULT_TIMEOUT_SECONDSDefault per-request timeout, in seconds.- See Also:
-
-
Constructor Details
-
SageRestEngine
- Parameters:
baseUrl- base URL of the service, e.g. "http://localhost:8080"
-
-
Method Details
-
setTimeoutSeconds
Sets the per-request timeout. The server enforces it too, so a runaway symbolic solve is killed there rather than merely abandoned here.- Parameters:
seconds- timeout in seconds; not positive disables it- Returns:
- this engine
-
getTimeoutSeconds
public int getTimeoutSeconds()- Returns:
- the per-request timeout in seconds
-
getBaseUrl
- Returns:
- the base URL this engine posts to
-
name
Description copied from interface:SymEngineName of the backing engine, e.g. "sage". -
isAvailable
public boolean isAvailable()Description copied from interface:SymEngineTrue if the engine answers a health probe.- Specified by:
isAvailablein interfaceSymEngine
-
info
Reads the service identity, used to tell a line-sage-rest server apart from another service listening on the same conventional port.- Returns:
- the /api/v1/info document
- Throws:
IOException- if the service is unreachable
-
solveCTMC
Description copied from interface:SymEngineSymbolic stationary distribution of a CTMC, pi Q = 0 with sum(pi) = 1.- Specified by:
solveCTMCin interfaceSymEngine- 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
public SymEngine.Sensitivity ctmcSensitivity(String[][] Q, List<String> symbols, String theta, List<String> reward) throws IOException Description copied from interface:SymEngineExact parametric sensitivity of a steady-state reward.- Specified by:
ctmcSensitivityin interfaceSymEngine- 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
-
simplify
Description copied from interface:SymEngineRewrites expressions into a normal form.- Specified by:
simplifyin interfaceSymEngine- 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
Description copied from interface:SymEngineDifferentiates expressions.- Specified by:
diffin interfaceSymEngine- 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
Description copied from interface:SymEngineSubstitutes values for symbols and evaluates.- Specified by:
evalin interfaceSymEngine- 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
public SymEngine.FluidODEs fluidODEs(List<String> rhs, List<String> vars, List<String> want) throws IOException Description copied from interface:SymEngineJacobian, LaTeX form and equilibria of a fluid vector field.- Specified by:
fluidODEsin interfaceSymEngine- 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
-