LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line::lqn::LqnBuilder< T > Class Template Reference

#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 host (const std::string &name, double mult, SchedStrategy sched, double repl=1.0)
 Host, the other name MATLAB, the JAR and python give a processor: the same element.
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 cache_retrieval (const std::string &task_name, bool on=true)
 CacheTask.setRetrieval(true): concurrent misses of one item coalesce on a single fetch.
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 record_call_group (const std::string &act, const std::vector< std::string > &dest_entries, lang::RoutingStrategy rs)
 Records the grouping of sync calls the activity ALREADY declares (recordCallGroup).
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 activity_phase (const std::string &act, int phase)
 Activity phase: 1 before the entry replies, 2 after it (the second phase).
void act_think_time (const std::string &act, const Distrib< T > &d)
 An activity think time, in series with the host demand.
void task_priority (const std::string &task_name, int priority)
 Task.setPriority, on the lqns scale the .lqnx priority attribute carries: a LARGER value is served first and the default 0 is the lowest.
void entry_type (const std::string &entry_name, const std::string &type)
 Entry.setType: PH1PH2 (the default) or NONE; carried for the code generators only.
void call_order (const std::string &act, const std::string &order)
 Activity.setCallOrder: STOCHASTIC or DETERMINISTIC, any other value reading as STOCHASTIC.
void host_class (const std::string &proc_name, bool is_host=true)
 Declare a processor as a Host rather than a Processor: the same element to every solver.
void speed_factor (const std::string &proc_name, double speed)
 Processor::setSpeedFactor: the processor serves its activities' demands speed times faster.
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

Detailed Description

template<class T>
class line::lqn::LqnBuilder< T >

Definition at line 46 of file lqn_builder.h.

Member Function Documentation

◆ act_think_time()

template<class T>
void line::lqn::LqnBuilder< T >::act_think_time ( const std::string & act,
const Distrib< T > & d )
inline

An activity think time, in series with the host demand.

Definition at line 277 of file lqn_builder.h.

◆ activity()

template<class T>
std::size_t line::lqn::LqnBuilder< T >::activity ( const std::string & name,
const Distrib< T > & hostdem,
const std::string & on_task )
inline

Add an activity on a task, with its host demand.

Definition at line 188 of file lqn_builder.h.

References line::lqn::Distrib< T >::immediate().

Referenced by line::gen::LayeredNetworkGenerator< T >::generate(), and line::io::qn2lqn().

◆ activity_phase()

template<class T>
void line::lqn::LqnBuilder< T >::activity_phase ( const std::string & act,
int phase )
inline

Activity phase: 1 before the entry replies, 2 after it (the second phase).

Definition at line 272 of file lqn_builder.h.

◆ add_constraint()

template<class T>
void line::lqn::LqnBuilder< T >::add_constraint ( const std::string & elem,
const std::vector< std::string > & operands,
const std::vector< T > & coeffs,
const T & cap )
inline

elem.addConstraint(operands, coeffs, cap): sum(coeffs .

  • n(operands)) <= cap.

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 425 of file lqn_builder.h.

References line::InputError::InputError().

◆ add_server_type()

template<class T>
void line::lqn::LqnBuilder< T >::add_server_type ( const std::string & elem,
const std::string & pool,
double count,
const std::vector< std::string > & compatible,
const T & rate )
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 531 of file lqn_builder.h.

References line::InputError::InputError().

◆ and_fork()

template<class T>
void line::lqn::LqnBuilder< T >::and_fork ( const std::string & pre,
const std::vector< std::string > & posts )
inline

pre -> every post, concurrently.

Definition at line 329 of file lqn_builder.h.

Referenced by line::io::qn2lqn().

◆ and_join()

template<class T>
void line::lqn::LqnBuilder< T >::and_join ( const std::vector< std::string > & pres,
const std::string & post,
std::size_t quorum = 0 )
inline

all pres (or quorum of them) -> post.

Definition at line 339 of file lqn_builder.h.

Referenced by line::io::qn2lqn().

◆ async_call()

template<class T>
void line::lqn::LqnBuilder< T >::async_call ( const std::string & act,
const std::string & dest_entry,
const T & mean )
inline

An asynchronous call from an activity to an entry of another task.

Definition at line 211 of file lqn_builder.h.

◆ bound_to()

template<class T>
void line::lqn::LqnBuilder< T >::bound_to ( const std::string & act,
const std::string & entry_name )
inline

Bind an activity to an entry: it is the entry's first activity.

Definition at line 201 of file lqn_builder.h.

Referenced by line::gen::LayeredNetworkGenerator< T >::generate(), and line::io::qn2lqn().

◆ build()

template<class T>
LqnStruct< T > line::lqn::LqnBuilder< T >::build ( ) const
inline

Flatten into the struct SolverLN consumes.

Definition at line 550 of file lqn_builder.h.

References line::lqn::lqn_finalize().

Referenced by line::io::qn2lqn(), and run_generate().

◆ cache_access()

template<class T>
void line::lqn::LqnBuilder< T >::cache_access ( const std::string & pre,
const std::string & hit,
const std::string & miss )
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 374 of file lqn_builder.h.

◆ cache_retrieval()

template<class T>
void line::lqn::LqnBuilder< T >::cache_retrieval ( const std::string & task_name,
bool on = true )
inline

CacheTask.setRetrieval(true): concurrent misses of one item coalesce on a single fetch.

Definition at line 121 of file lqn_builder.h.

References line::InputError::InputError().

◆ cache_task()

template<class T>
std::size_t line::lqn::LqnBuilder< 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 )
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 99 of file lqn_builder.h.

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

◆ call_order()

template<class T>
void line::lqn::LqnBuilder< T >::call_order ( const std::string & act,
const std::string & order )
inline

Activity.setCallOrder: STOCHASTIC or DETERMINISTIC, any other value reading as STOCHASTIC.

Definition at line 300 of file lqn_builder.h.

◆ entry()

template<class T>
std::size_t line::lqn::LqnBuilder< T >::entry ( const std::string & name,
const std::string & on_task )
inline

Add an entry on a task.

Definition at line 172 of file lqn_builder.h.

Referenced by line::gen::LayeredNetworkGenerator< T >::generate(), item_entry(), and line::io::qn2lqn().

◆ entry_type()

template<class T>
void line::lqn::LqnBuilder< T >::entry_type ( const std::string & entry_name,
const std::string & type )
inline

Entry.setType: PH1PH2 (the default) or NONE; carried for the code generators only.

Definition at line 295 of file lqn_builder.h.

◆ forward()

template<class T>
void line::lqn::LqnBuilder< T >::forward ( const std::string & src_entry,
const std::string & dest_entry,
const T & prob )
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 257 of file lqn_builder.h.

◆ host()

template<class T>
std::size_t line::lqn::LqnBuilder< T >::host ( const std::string & name,
double mult,
SchedStrategy sched,
double repl = 1.0 )
inline

Host, the other name MATLAB, the JAR and python give a processor: the same element.

Definition at line 61 of file lqn_builder.h.

References processor().

◆ host_class()

template<class T>
void line::lqn::LqnBuilder< T >::host_class ( const std::string & proc_name,
bool is_host = true )
inline

Declare a processor as a Host rather than a Processor: the same element to every solver.

Definition at line 305 of file lqn_builder.h.

◆ item_entry()

template<class T>
std::size_t line::lqn::LqnBuilder< T >::item_entry ( const std::string & name,
const std::string & on_task,
std::size_t cardinality,
const std::vector< T > & popularity )
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 158 of file lqn_builder.h.

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

◆ loop()

template<class T>
void line::lqn::LqnBuilder< T >::loop ( const std::string & pre,
const std::vector< std::string > & body,
const std::string & end,
const T & count )
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 403 of file lqn_builder.h.

◆ model()

template<class T>
const LqnModel< T > & line::lqn::LqnBuilder< T >::model ( ) const
inline

◆ open_arrival()

template<class T>
void line::lqn::LqnBuilder< T >::open_arrival ( const std::string & entry_name,
const Distrib< T > & d )
inline

An open arrival stream at an entry.

Definition at line 181 of file lqn_builder.h.

◆ or_fork()

template<class T>
void line::lqn::LqnBuilder< T >::or_fork ( const std::string & pre,
const std::vector< std::string > & posts,
const std::vector< T > & probs )
inline

pre -> one of the posts, with the given branch probabilities.

Definition at line 354 of file lqn_builder.h.

References line::InputError::InputError().

Referenced by line::io::qn2lqn().

◆ or_join()

template<class T>
void line::lqn::LqnBuilder< T >::or_join ( const std::vector< std::string > & pres,
const std::string & post )
inline

any of the pres -> post.

Definition at line 385 of file lqn_builder.h.

Referenced by line::io::qn2lqn().

◆ processor()

template<class T>
std::size_t line::lqn::LqnBuilder< T >::processor ( const std::string & name,
double mult,
SchedStrategy sched,
double repl = 1.0 )
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::gen::LayeredNetworkGenerator< T >::generate(), host(), and line::io::qn2lqn().

◆ record_call_group()

template<class T>
void line::lqn::LqnBuilder< T >::record_call_group ( const std::string & act,
const std::vector< std::string > & dest_entries,
lang::RoutingStrategy rs )
inline

Records the grouping of sync calls the activity ALREADY declares (recordCallGroup).

The model.json reader has read the members back as ordinary sync calls, so it records the grouping alone; issuing them again would double the call rate.

Definition at line 242 of file lqn_builder.h.

References line::InputError::InputError().

◆ replies_to()

template<class T>
void line::lqn::LqnBuilder< T >::replies_to ( const std::string & act,
const std::string & entry_name )
inline

Mark an activity as the one that replies to an entry.

Definition at line 264 of file lqn_builder.h.

References line::InputError::InputError().

Referenced by line::gen::LayeredNetworkGenerator< T >::generate(), and line::io::qn2lqn().

◆ serial()

template<class T>
void line::lqn::LqnBuilder< T >::serial ( const std::string & pre,
const std::string & post )
inline

pre -> post, a plain sequence.

Definition at line 319 of file lqn_builder.h.

Referenced by line::io::qn2lqn().

◆ set_class_dependence()

template<class T>
void line::lqn::LqnBuilder< T >::set_class_dependence ( const std::string & elem,
const CdScaling< T > & beta,
const std::vector< T > & peak )
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 486 of file lqn_builder.h.

◆ set_constraint()

template<class T>
void line::lqn::LqnBuilder< T >::set_constraint ( const std::string & elem,
const Matrix< T > & A,
const std::vector< T > & b )
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 449 of file lqn_builder.h.

References line::InputError::InputError(), and line::Matrix< T >::rows().

◆ set_joint_dependence()

template<class T>
void line::lqn::LqnBuilder< T >::set_joint_dependence ( const std::string & elem,
const CdScaling< T > & eta,
const std::vector< T > & peak )
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 505 of file lqn_builder.h.

◆ set_load_dependence()

template<class T>
void line::lqn::LqnBuilder< T >::set_load_dependence ( const std::string & elem,
const std::vector< T > & alpha )
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 470 of file lqn_builder.h.

References line::InputError::InputError().

◆ setup_time()

template<class T>
void line::lqn::LqnBuilder< T >::setup_time ( const std::string & task_name,
const Distrib< T > & setup,
const Distrib< T > & delayoff )
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 137 of file lqn_builder.h.

References line::lang::Distrib< T >::disabled, and line::InputError::InputError().

◆ speed_factor()

template<class T>
void line::lqn::LqnBuilder< T >::speed_factor ( const std::string & proc_name,
double speed )
inline

Processor::setSpeedFactor: the processor serves its activities' demands speed times faster.

Definition at line 310 of file lqn_builder.h.

References line::InputError::InputError().

◆ sync_call()

template<class T>
void line::lqn::LqnBuilder< T >::sync_call ( const std::string & act,
const std::string & dest_entry,
const T & mean )
inline

A synchronous call from an activity to an entry of another task.

Definition at line 206 of file lqn_builder.h.

Referenced by line::io::qn2lqn().

◆ sync_call_jsq()

template<class T>
void line::lqn::LqnBuilder< T >::sync_call_jsq ( const std::string & act,
const std::vector< std::string > & dest_entries,
const T & mean )
inline

As above, with the least loaded target taking the call (synchCallJSQ).

Definition at line 231 of file lqn_builder.h.

References line::lang::JSQ.

◆ sync_call_round_robin()

template<class T>
void line::lqn::LqnBuilder< T >::sync_call_round_robin ( const std::string & act,
const std::vector< std::string > & dest_entries,
const T & mean )
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 224 of file lqn_builder.h.

References line::lang::RROBIN.

◆ task()

template<class T>
std::size_t line::lqn::LqnBuilder< T >::task ( const std::string & name,
double mult,
SchedStrategy sched,
const std::string & on_processor,
double repl = 1.0 )
inline

Add a task on a processor.

Definition at line 66 of file lqn_builder.h.

References line::lqn::Distrib< T >::immediate().

Referenced by cache_task(), line::gen::LayeredNetworkGenerator< T >::generate(), and line::io::qn2lqn().

◆ task_priority()

template<class T>
void line::lqn::LqnBuilder< T >::task_priority ( const std::string & task_name,
int priority )
inline

Task.setPriority, on the lqns scale the .lqnx priority attribute carries: a LARGER value is served first and the default 0 is the lowest.

Read only under the priority disciplines (HOL, 'pri' and the other *PRIO ones), where a host serves the demand of the task with the largest value first and a task serves the request of the CALLER with the largest value first. SolverLN maps it to a class priority max - prio (ln_host_task_priorities).

Definition at line 290 of file lqn_builder.h.

◆ think_time()

template<class T>
void line::lqn::LqnBuilder< T >::think_time ( const std::string & task_name,
const Distrib< T > & d )
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 87 of file lqn_builder.h.


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