![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
#include <line/lang/lqn/lqn_builder.h>
Public Member Functions | |
| std::size_t | processor (const std::string &name, double mult, SchedStrategy sched, double repl=1.0) |
| Add a processor. | |
| std::size_t | task (const std::string &name, double mult, SchedStrategy sched, const std::string &on_processor, double repl=1.0) |
| Add a task on a processor. | |
| void | think_time (const std::string &task_name, const Distrib< T > &d) |
| Set a task's think time. | |
| std::size_t | cache_task (const std::string &name, double mult, SchedStrategy sched, const std::string &on_processor, std::size_t nitems, const std::vector< int > &itemcap, ReplacementStrategy replacestrat, double repl=1.0) |
| A CacheTask: a task whose entries are looked up in a cache of nitems. | |
| void | setup_time (const std::string &task_name, const Distrib< T > &setup, const Distrib< T > &delayoff) |
| A SetupTask: a server that powers down when idle and pays to restart. | |
| std::size_t | item_entry (const std::string &name, const std::string &on_task, std::size_t cardinality, const std::vector< T > &popularity) |
| An ItemEntry: the entry a cache read enters, over cardinality items. | |
| std::size_t | entry (const std::string &name, const std::string &on_task) |
| Add an entry on a task. | |
| void | open_arrival (const std::string &entry_name, const Distrib< T > &d) |
| An open arrival stream at an entry. | |
| std::size_t | activity (const std::string &name, const Distrib< T > &hostdem, const std::string &on_task) |
| Add an activity on a task, with its host demand. | |
| void | bound_to (const std::string &act, const std::string &entry_name) |
| Bind an activity to an entry: it is the entry's first activity. | |
| void | sync_call (const std::string &act, const std::string &dest_entry, const T &mean) |
| A synchronous call from an activity to an entry of another task. | |
| void | async_call (const std::string &act, const std::string &dest_entry, const T &mean) |
| An asynchronous call from an activity to an entry of another task. | |
| void | sync_call_round_robin (const std::string &act, const std::vector< std::string > &dest_entries, const T &mean) |
| ONE synchronous call per invocation, its destination CYCLING over the targets in the order given (synchCallRoundRobin). | |
| void | sync_call_jsq (const std::string &act, const std::vector< std::string > &dest_entries, const T &mean) |
| As above, with the least loaded target taking the call (synchCallJSQ). | |
| void | forward (const std::string &src_entry, const std::string &dest_entry, const T &prob) |
| Forwarding: whenever src_entry is invoked, with probability prob the request is handed onward to dest_entry instead of src_entry replying – lqn_finalize (shared with the .lqnx reader, see lqn_reader.h) turns this into a CallType::FWD call and SolverLN's lqn_fwd_rendezvous rewrite (lqn_helpers.h) flattens it into a caller-side pseudo rendezvous. | |
| void | replies_to (const std::string &act, const std::string &entry_name) |
| Mark an activity as the one that replies to an entry. | |
| void | act_think_time (const std::string &act, const Distrib< T > &d) |
| An activity think time, in series with the host demand. | |
| void | serial (const std::string &pre, const std::string &post) |
| pre -> post, a plain sequence. | |
| void | and_fork (const std::string &pre, const std::vector< std::string > &posts) |
| pre -> every post, concurrently. | |
| void | and_join (const std::vector< std::string > &pres, const std::string &post, std::size_t quorum=0) |
| all pres (or quorum of them) -> post. | |
| void | or_fork (const std::string &pre, const std::vector< std::string > &posts, const std::vector< T > &probs) |
| pre -> one of the posts, with the given branch probabilities. | |
| void | cache_access (const std::string &pre, const std::string &hit, const std::string &miss) |
| ActivityPrecedence.CacheAccess(pre, {hit, miss}). | |
| void | or_join (const std::vector< std::string > &pres, const std::string &post) |
| any of the pres -> post. | |
| void | loop (const std::string &pre, const std::vector< std::string > &body, const std::string &end, const T &count) |
| pre -> body, repeated count times in expectation, then -> end. | |
| void | add_constraint (const std::string &elem, const std::vector< std::string > &operands, const std::vector< T > &coeffs, const T &cap) |
| elem.addConstraint(operands, coeffs, cap): sum(coeffs . | |
| void | set_constraint (const std::string &elem, const Matrix< T > &A, const std::vector< T > &b) |
| The positional form, elem.setConstraint(A, b). | |
| void | set_load_dependence (const std::string &elem, const std::vector< T > &alpha) |
| elem.setLoadDependence(alpha): alpha(n) scales the rate of the layer station of ELEM when it holds n jobs in total, on top of the multiplicity. | |
| void | set_class_dependence (const std::string &elem, const CdScaling< T > &beta, const std::vector< T > &peak) |
| elem.setClassDependence(beta, peak): the product-form handle, whose argument is the per-OPERAND population of ELEM – task j of a processor, entry j of a task, in declaration order. | |
| void | set_joint_dependence (const std::string &elem, const CdScaling< T > &eta, const std::vector< T > &peak) |
| elem.setJointDependence(eta, peak): the non-product-form handle, read at the whole per-operand vector, so solvers treat it as an approximation. | |
| void | add_server_type (const std::string &elem, const std::string &pool, double count, const std::vector< std::string > &compatible, const T &rate) |
| elem.addServerType(ServerType(pool, count, compatible)): one pool of COUNT identical servers, each running at RATE, eligible for the operands named in COMPATIBLE. | |
| LqnStruct< T > | build () const |
| Flatten into the struct SolverLN consumes. | |
| const LqnModel< T > & | model () const |
Definition at line 46 of file lqn_builder.h.
|
inline |
An activity think time, in series with the host demand.
Definition at line 242 of file lqn_builder.h.
|
inline |
Add an activity on a task, with its host demand.
Definition at line 175 of file lqn_builder.h.
References line::lqn::Distrib< T >::immediate().
Referenced by line::io::build_lqn_from_json(), and line::io::qn2lqn().
|
inline |
elem.addConstraint(operands, coeffs, cap): sum(coeffs .
elem is a task (whose operands are its entries) or a host (whose operands are its tasks). Port of LayeredNetworkElement.addConstraint; the operands stay NAMED until build(), because their column order is the task's entriesof / the host's tasksof and neither exists yet.
Definition at line 355 of file lqn_builder.h.
References line::InputError::InputError().
|
inline |
elem.addServerType(ServerType(pool, count, compatible)): one pool of COUNT identical servers, each running at RATE, eligible for the operands named in COMPATIBLE.
The operands are resolved by name against the element's own operand list at build() time, so a pool may name a task or an entry that is declared later. Pools accumulate; SolverLN lowers the whole declaration to the activated-server rate.
Definition at line 461 of file lqn_builder.h.
References line::InputError::InputError().
|
inline |
pre -> every post, concurrently.
Definition at line 259 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json(), and line::io::qn2lqn().
|
inline |
all pres (or quorum of them) -> post.
Definition at line 269 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json(), and line::io::qn2lqn().
|
inline |
An asynchronous call from an activity to an entry of another task.
Definition at line 198 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json().
|
inline |
Bind an activity to an entry: it is the entry's first activity.
Definition at line 188 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json(), and line::io::qn2lqn().
|
inline |
Flatten into the struct SolverLN consumes.
Definition at line 480 of file lqn_builder.h.
References line::lqn::lqn_finalize().
Referenced by line::io::build_lqn_from_json(), and line::io::qn2lqn().
|
inline |
ActivityPrecedence.CacheAccess(pre, {hit, miss}).
pre reads the cache; the job leaves it on the HIT branch or the MISS branch. POST_CACHE lands on the two successors, not on pre – that is how getStruct.m records a post type, and what SolverLN keys on.
Definition at line 304 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json().
|
inline |
A CacheTask: a task whose entries are looked up in a cache of nitems.
itemcap is the capacity of each cache list, so a plain single-level cache passes one value. The task itself is an ordinary server in its own layer; the Cache NODE appears in its HOST's layer, which is where buildLayersRecursive puts it (iscachelayer is a host-layer test).
Definition at line 94 of file lqn_builder.h.
References line::InputError::InputError(), and task().
Referenced by line::io::build_lqn_from_json().
|
inline |
Add an entry on a task.
Definition at line 159 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json(), item_entry(), and line::io::qn2lqn().
|
inline |
Forwarding: whenever src_entry is invoked, with probability prob the request is handed onward to dest_entry instead of src_entry replying – lqn_finalize (shared with the .lqnx reader, see lqn_reader.h) turns this into a CallType::FWD call and SolverLN's lqn_fwd_rendezvous rewrite (lqn_helpers.h) flattens it into a caller-side pseudo rendezvous.
Definition at line 230 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json().
|
inline |
An ItemEntry: the entry a cache read enters, over cardinality items.
popularity is the pmf of the read over those items. The reference takes a discrete Distribution (a Zipf, typically) and reads only its pmf; this port has no discrete-distribution type, so the pmf is given directly.
Definition at line 145 of file lqn_builder.h.
References entry(), and line::InputError::InputError().
Referenced by line::io::build_lqn_from_json().
|
inline |
pre -> body, repeated count times in expectation, then -> end.
The body list is the loop body in order; end is the activity the loop exits to. This is MATLAB's ActivityPrecedence.Loop(pre, body, count), whose postacts vector is body followed by end.
Definition at line 333 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json().
|
inline |
Definition at line 482 of file lqn_builder.h.
Referenced by line::io::qn2lqn().
|
inline |
An open arrival stream at an entry.
Definition at line 168 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json().
|
inline |
pre -> one of the posts, with the given branch probabilities.
Definition at line 284 of file lqn_builder.h.
References line::InputError::InputError().
Referenced by line::io::build_lqn_from_json(), and line::io::qn2lqn().
|
inline |
any of the pres -> post.
Definition at line 315 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json().
|
inline |
Add a processor.
mult may be infinite; INF scheduling forces it so.
Definition at line 49 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json(), and line::io::qn2lqn().
|
inline |
Mark an activity as the one that replies to an entry.
Definition at line 237 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json(), and line::io::qn2lqn().
|
inline |
pre -> post, a plain sequence.
Definition at line 249 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json(), and line::io::qn2lqn().
|
inline |
elem.setClassDependence(beta, peak): the product-form handle, whose argument is the per-OPERAND population of ELEM – task j of a processor, entry j of a task, in declaration order.
Definition at line 416 of file lqn_builder.h.
|
inline |
The positional form, elem.setConstraint(A, b).
Only the column COUNT is checked, at build() time, as the reference does: the columns are the element's entries or tasks in declaration order.
Definition at line 379 of file lqn_builder.h.
References line::InputError::InputError(), and line::Matrix< T >::rows().
|
inline |
elem.setJointDependence(eta, peak): the non-product-form handle, read at the whole per-operand vector, so solvers treat it as an approximation.
Definition at line 435 of file lqn_builder.h.
|
inline |
elem.setLoadDependence(alpha): alpha(n) scales the rate of the layer station of ELEM when it holds n jobs in total, on top of the multiplicity.
Definition at line 400 of file lqn_builder.h.
References line::InputError::InputError().
|
inline |
A SetupTask: a server that powers down when idle and pays to restart.
setup is charged to the first arrival that finds the server off; delayoff is the idle timer that has to expire before it goes off, so a long delay-off makes the setup rare. Both are ordinary Task properties in the reference (Task.setSetupTime/setDelayOffTime), so this is a plain task with the two times attached rather than a distinct kind.
Definition at line 124 of file lqn_builder.h.
References line::lang::Distrib< T >::disabled, and line::InputError::InputError().
Referenced by line::io::build_lqn_from_json().
|
inline |
A synchronous call from an activity to an entry of another task.
Definition at line 193 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json(), and line::io::qn2lqn().
|
inline |
As above, with the least loaded target taking the call (synchCallJSQ).
Definition at line 218 of file lqn_builder.h.
References line::lang::JSQ.
|
inline |
ONE synchronous call per invocation, its destination CYCLING over the targets in the order given (synchCallRoundRobin).
The members are ordinary sync calls of mean mean/n, so the aggregate call rate is mean either way; what round robin removes is the variance of the branching, which is what smooths the target queues. Needs at least two targets – a group of one is not a dispatch decision.
Definition at line 211 of file lqn_builder.h.
References line::lang::RROBIN.
|
inline |
Add a task on a processor.
Definition at line 61 of file lqn_builder.h.
References line::lqn::Distrib< T >::immediate().
Referenced by line::io::build_lqn_from_json(), cache_task(), and line::io::qn2lqn().
|
inline |
Set a task's think time.
Accepted on ANY task, not only a reference one. That is what the MATLAB API allows and what the .lqnx writer cannot express; refusing it here to match the file format would make the builder strictly weaker than the reference for no gain.
Definition at line 82 of file lqn_builder.h.
Referenced by line::io::build_lqn_from_json().