LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line::sym::SageRestEngine Class Reference

Client of the line-sage-rest service. More...

#include <line/api/sym/sage_rest_engine.h>

Inheritance diagram for line::sym::SageRestEngine:
Collaboration diagram for line::sym::SageRestEngine:

Public Member Functions

 SageRestEngine (const std::string &baseUrl)
SageRestEnginesetTimeoutSeconds (int seconds)
 Sets the per-request timeout.
int getTimeoutSeconds () const
const std::string & getBaseUrl () const
std::string name () const override
 Name of the backing engine, e.g.
bool isAvailable () const override
 True if the engine answers a health probe.
bool isUsable () const
 Checks that the service can actually EVALUATE, not merely that it answers.
detail::Json info () const
 Reads the service identity, used to tell a line-sage-rest server apart from another line-*-rest service on the same conventional port.
CtmcSolution solveCTMC (const std::vector< std::vector< std::string > > &Q, const std::vector< std::string > &symbols) override
 Symbolic stationary distribution of a CTMC, pi Q = 0 with sum(pi) = 1.
SymSensitivity ctmcSensitivity (const std::vector< std::vector< std::string > > &Q, const std::vector< std::string > &symbols, const std::string &theta, const std::vector< std::string > &reward) override
 Exact parametric sensitivity of a steady-state reward.
std::vector< std::string > simplify (const std::vector< std::string > &exprs, const std::string &form) override
 Rewrites expressions into a normal form.
std::vector< std::string > diff (const std::vector< std::string > &exprs, const std::string &variable, int order) override
 Differentiates expressions.
std::vector< double > eval (const std::vector< std::string > &exprs, const std::map< std::string, double > &assignment) override
 Substitutes values for symbols and evaluates.
FluidODEs fluidODEs (const std::vector< std::string > &rhs, const std::vector< std::string > &vars, const std::vector< std::string > &want) override
 Jacobian, LaTeX form and equilibria of a fluid vector field.
Public Member Functions inherited from line::sym::SymEngine
virtual ~SymEngine ()

Static Public Attributes

static constexpr int DEFAULT_TIMEOUT_SECONDS = 300
 Default per-request timeout, in seconds.

Detailed Description

Client of the line-sage-rest service.

Definition at line 140 of file sage_rest_engine.h.

Constructor & Destructor Documentation

◆ SageRestEngine()

line::sym::SageRestEngine::SageRestEngine ( const std::string & baseUrl)
inlineexplicit
Parameters
baseUrlbase URL of the service, e.g. "http://localhost:8080"

Definition at line 148 of file sage_rest_engine.h.

References DEFAULT_TIMEOUT_SECONDS, and line::InputError::InputError().

Referenced by setTimeoutSeconds().

Member Function Documentation

◆ ctmcSensitivity()

SymSensitivity line::sym::SageRestEngine::ctmcSensitivity ( const std::vector< std::vector< std::string > > & Q,
const std::vector< std::string > & symbols,
const std::string & theta,
const std::vector< std::string > & reward )
inlineoverridevirtual

Exact parametric sensitivity of a steady-state reward.

Parameters
Qgenerator entries as expression strings, row major
symbolsthe symbols appearing in Q
thetathe symbol to differentiate with respect to
rewardreward rate per state, empty for the distribution alone
Returns
the sensitivity of the distribution and, if a reward is given, of its mean

Implements line::sym::SymEngine.

Definition at line 270 of file sage_rest_engine.h.

References line::sym::SymSensitivity::dpi, line::sym::SymSensitivity::Er, line::sym::SymSensitivity::hasReward, line::sym::SymSensitivity::pi, line::sym::SymSensitivity::S, and line::sym::SymSensitivity::SS.

◆ diff()

std::vector< std::string > line::sym::SageRestEngine::diff ( const std::vector< std::string > & exprs,
const std::string & variable,
int order )
inlineoverridevirtual

Differentiates expressions.

Parameters
exprsthe expressions
variablethe differentiation variable
orderthe order of the derivative, at least 1
Returns
the derivatives, in the input order

Implements line::sym::SymEngine.

Definition at line 299 of file sage_rest_engine.h.

◆ eval()

std::vector< double > line::sym::SageRestEngine::eval ( const std::vector< std::string > & exprs,
const std::map< std::string, double > & assignment )
inlineoverridevirtual

Substitutes values for symbols and evaluates.

Parameters
exprsthe expressions
assignmentvalue of each symbol
Returns
the numeric values, NaN where a free symbol remains

Implements line::sym::SymEngine.

Definition at line 308 of file sage_rest_engine.h.

◆ fluidODEs()

FluidODEs line::sym::SageRestEngine::fluidODEs ( const std::vector< std::string > & rhs,
const std::vector< std::string > & vars,
const std::vector< std::string > & want )
inlineoverridevirtual

Jacobian, LaTeX form and equilibria of a fluid vector field.

Parameters
rhsthe right hand side of dx/dt, one expression per state variable
varsthe state variable names
wantany of jacobian, latex, equilibria
Returns
the requested items

Implements line::sym::SymEngine.

Definition at line 329 of file sage_rest_engine.h.

References line::sym::FluidODEs::equilibria, line::sym::FluidODEs::hasEquilibria, line::sym::FluidODEs::hasJacobian, line::sym::FluidODEs::hasLatex, line::sym::FluidODEs::jacobian, and line::sym::FluidODEs::latex.

◆ getBaseUrl()

const std::string & line::sym::SageRestEngine::getBaseUrl ( ) const
inline
Returns
the base URL this engine posts to

Definition at line 174 of file sage_rest_engine.h.

◆ getTimeoutSeconds()

int line::sym::SageRestEngine::getTimeoutSeconds ( ) const
inline
Returns
the per-request timeout in seconds

Definition at line 171 of file sage_rest_engine.h.

◆ info()

detail::Json line::sym::SageRestEngine::info ( ) const
inline

Reads the service identity, used to tell a line-sage-rest server apart from another line-*-rest service on the same conventional port.

Returns
the /api/v1/info document

Definition at line 250 of file sage_rest_engine.h.

◆ isAvailable()

bool line::sym::SageRestEngine::isAvailable ( ) const
inlineoverridevirtual

True if the engine answers a health probe.

Implements line::sym::SymEngine.

Definition at line 178 of file sage_rest_engine.h.

◆ isUsable()

bool line::sym::SageRestEngine::isUsable ( ) const
inline

Checks that the service can actually EVALUATE, not merely that it answers.

The line-sage-rest image ships a FLINT built for CPUs that have BMI2 and ADX. On an older host the first multi-limb exact operation raises SIGILL, the worker dies mid-request and the call returns no bytes at all; /api/v1/health is pure Python and keeps answering, so it cannot see this. The canary is the weighted-average softmin form, which is what the fluid export actually sends, and is the smallest expression observed to trigger it. Verdicts are cached per URL, so this costs one small request the first time a service is considered and nothing after. See _kb/11-conventions-and-gotchas.md.

Returns
true if the service returned the canary's value

Definition at line 203 of file sage_rest_engine.h.

References line::http::post_json().

◆ name()

std::string line::sym::SageRestEngine::name ( ) const
inlineoverridevirtual

Name of the backing engine, e.g.

"sage".

Implements line::sym::SymEngine.

Definition at line 176 of file sage_rest_engine.h.

◆ setTimeoutSeconds()

SageRestEngine & line::sym::SageRestEngine::setTimeoutSeconds ( int seconds)
inline

Sets the per-request timeout.

Parameters
secondstimeout in seconds; not positive disables it
Returns
this engine

Definition at line 165 of file sage_rest_engine.h.

References SageRestEngine().

Referenced by line::fluid::fluid_jacobian().

◆ simplify()

std::vector< std::string > line::sym::SageRestEngine::simplify ( const std::vector< std::string > & exprs,
const std::string & form )
inlineoverridevirtual

Rewrites expressions into a normal form.

Parameters
exprsthe expressions
formone of simplify, factor, together, cancel, expand, latex
Returns
the rewritten expressions, in the input order

Implements line::sym::SymEngine.

Definition at line 291 of file sage_rest_engine.h.

◆ solveCTMC()

CtmcSolution line::sym::SageRestEngine::solveCTMC ( const std::vector< std::vector< std::string > > & Q,
const std::vector< std::string > & symbols )
inlineoverridevirtual

Symbolic stationary distribution of a CTMC, pi Q = 0 with sum(pi) = 1.

Parameters
Qgenerator entries as expression strings, row major and square
symbolsthe symbols appearing in Q, e.g. x1..xE
Returns
the solution, with pi also split over a common denominator

Implements line::sym::SymEngine.

Definition at line 252 of file sage_rest_engine.h.

References line::sym::CtmcSolution::connComp, line::sym::CtmcSolution::den, line::sym::CtmcSolution::nConnComp, line::sym::CtmcSolution::num, and line::sym::CtmcSolution::pi.

Member Data Documentation

◆ DEFAULT_TIMEOUT_SECONDS

int line::sym::SageRestEngine::DEFAULT_TIMEOUT_SECONDS = 300
staticconstexpr

Default per-request timeout, in seconds.

Definition at line 143 of file sage_rest_engine.h.

Referenced by SageRestEngine().


The documentation for this class was generated from the following file: