5#ifndef LINE_LANG_QN_NODES_H
6#define LINE_LANG_QN_NODES_H
74 operator std::size_t()
const {
return idx_; }
150 :
Station(m, m.add_queue(nm, sched), nm) {}
185 for (std::size_t k = 0; k < classes.size(); ++k)
207 :
Node(m, m.add_class_switch(nm), nm) {
220 :
Node(m, m.add_fork(nm, tasks_per_link), nm) {}
227 :
Node(m, m.add_join(nm, fork_node), nm) {}
238 :
Node(m, m.add_cache(nm, par), nm) {}
241 const std::vector<std::size_t>& hit_classes) {
266 :
Station(m, m.add_place(nm, sched), nm) {}
309 :
Node(m, m.add_transition(nm, par), nm) {}
335 std::size_t mode,
const std::function<
double(
const std::vector<double>&)>& g) {
352 const std::function<
double(
double)>& h) {
361 const std::function<
double(
const std::vector<double>&)>& phi,
362 const std::vector<Place>& read = std::vector<Place>()) {
363 std::vector<std::size_t> rd;
364 for (
const Place& p : read) rd.push_back(p.get_index());
392 operator std::size_t()
const {
return idx_; }
409 :
JobClass(m, m.add_closed_class(nm, njobs, refstat_node, prio), nm) {}
416 :
JobClass(m, m.add_open_class(nm, prio), nm) {}
423 std::size_t refstat_node,
int prio = 0)
424 :
JobClass(m, m.add_self_looping_class(nm, njobs, refstat_node, prio), nm) {}
432 const Place& place,
double tokens) {
437 const Place& place,
double tokens) {
442 const Node& dest,
double tokens) {
452 const std::vector<std::size_t>& nodes) {
453 for (std::size_t k = 0; k + 1 < nodes.size(); ++k) P.set(r, s, nodes[k], nodes[k + 1], 1.0);
464 if (nodes.size() > 1) P.set(r, r, nodes.back(), nodes.front(), 1.0);
void set_miss_class(std::size_t cls, std::size_t miss)
setMissClass(jobclass, missclass).
Cache(NetworkModel &m, const std::string &nm, const qn::CacheParam< double > &par)
void set_read(std::size_t cls, const lang::Distrib< double > &d)
setRead(jobclass, Zipf(s, n)) or setRead(jobclass, DiscreteSampler(p)).
void set_hit_class(std::size_t cls, std::size_t hit)
setHitClass(jobclass, hitclass).
void set_read(std::size_t cls, const std::vector< double > &pmf)
setRead(jobclass, popularity): a pmf over the item ranks 1..nitems.
void set_item_read_classes(const std::vector< std::size_t > &read_classes, const std::vector< std::size_t > &hit_classes)
setItemReadClasses(read_classes, hit_classes), one entry per item.
void set_class_switching_matrix(const Matrix< double > &C)
setClassSwitchingMatrix(C).
ClassSwitch(NetworkModel &m, const std::string &nm, const Matrix< double > &C)
ClosedClass(NetworkModel &m, const std::string &nm, double njobs, std::size_t refstat_node, int prio=0)
Delay(NetworkModel &m, const std::string &nm)
Fork(NetworkModel &m, const std::string &nm, double tasks_per_link=1.0)
A job class: the index it was given, and the model that owns it.
void set_completes(bool flag)
completes = flag: whether passing the reference station completes the chain's cycle.
JobClass(NetworkModel &m, std::size_t idx, const std::string &nm)
const std::string & get_name() const
getName().
std::size_t get_index() const
get_index(): the 1-based class index.
void set_strategy(lang::JoinStrategy strategy, double quorum=0.0)
setStrategy(strategy, quorum).
Join(NetworkModel &m, const std::string &nm, std::size_t fork_node)
A node of the model: the index it was given, and the model that owns it.
Node(NetworkModel &m, std::size_t idx, const std::string &nm)
void set_routing(std::size_t cls, lang::RoutingStrategy rs)
setRouting(class, strategy).
NetworkModel & model() const
The model this node belongs to.
std::size_t get_index() const
get_index(): the 1-based node index the builder assigned.
void set_routing_weights(std::size_t cls, const std::map< std::size_t, double > &weights)
setRoutingWeight(class, weights): the WRROBIN share per destination.
const std::string & get_name() const
getName().
OpenClass(NetworkModel &m, const std::string &nm, int prio=0)
Place(model, name): a Petri-net place.
void set_departure_discipline(std::size_t cls, lang::DepartureDiscipline rule)
setDepartureDiscipline(class, rule): how a served token leaves the depository.
void set_fluid_capacity(double cap)
setFluidCapacity(B): the level ceiling, Inf when unbounded.
void set_fluid_level(double level)
setFluidLevel(x0): the initial level.
double get_fluid_level() const
getFluidLevel().
void set_initial_marking(const std::vector< double > &tokens)
setInitialMarking(tokens).
Place(NetworkModel &m, const std::string &nm)
bool is_fluid() const
isFluid().
Place(NetworkModel &m, const std::string &nm, lang::SchedStrategy sched)
Place(model, name, schedStrategy): a place with an EMBEDDED QUEUE.
double get_fluid_capacity() const
getFluidCapacity().
void set_fluid(bool flag=true)
setFluid(flag): a FLUID place of an FSPN, holding one real level instead of tokens.
Queue(NetworkModel &m, const std::string &nm, lang::SchedStrategy sched=lang::SchedStrategy::FCFS)
Router(NetworkModel &m, const std::string &nm)
SelfLoopingClass(NetworkModel &m, const std::string &nm, double njobs, std::size_t refstat_node, int prio=0)
Sink(NetworkModel &m, const std::string &nm)
void set_arrival_batch(std::size_t cls, const Dist &d)
setArrivalBatch(class, batchSizeDist).
void set_arrival(std::size_t cls, const Dist &d)
setArrival(class, distribution).
void set_marked_arrival(const Dist &d, const std::vector< std::size_t > &classes)
setMarkedArrival(process, classes): bind a MARKED arrival process, one class per mark.
Source(NetworkModel &m, const std::string &nm)
void add_server_type(const qn::Station< double >::ServerType &stype)
addServerType(type): one pool of a heterogeneous station.
void set_breakdown(const Dist &failure, const Dist &repair)
setBreakdown(failure, repair).
void set_polling_type(lang::PollingType rule, int par=0)
setPollingType(type, k).
Station(NetworkModel &m, std::size_t idx, const std::string &nm)
void set_switchover(std::size_t from_cls, std::size_t to_cls, const Dist &so)
setSwitchover(fromClass, toClass, distribution).
void set_capacity(double k)
setCapacity(k), the K of Kendall's notation.
void set_service(std::size_t cls, const Dist &d)
setService(class, distribution).
void set_sched_param(std::size_t cls, double weight)
setSchedParam(class, weight): the DPS/GPS share.
void set_class_capacity(std::size_t cls, double k)
setClassCapacity(class, k).
std::size_t get_station_index() const
getStationIndex(): the 1-based station index, distinct from the node one.
void set_drop_rule(std::size_t cls, lang::DropStrategy rule)
setDropRule(class, rule).
void set_number_of_servers(double n)
setNumberOfServers(n).
void set_load_dependence(const std::vector< double > &alpha)
setLoadDependence(alpha).
void set_switchover(std::size_t cls, const Dist &so)
setSwitchover(class, distribution).
void set_firing_weights(std::size_t mode, double w)
setFiringWeights(mode, weight): the share among simultaneously enabled modes.
void set_fluid_rate(std::size_t mode, const Place &place, double rate)
setFluidRate(mode, place, rate): flow per running server into (> 0) or out of (< 0) a fluid place.
void set_fluid_flow_dependence(std::size_t mode, const Place &place, const std::function< double(const std::vector< double > &)> &phi, const std::vector< Place > &read=std::vector< Place >())
setFluidFlowDependence(mode, place, phi[, readPlaces]): the flow on the fluid place becomes k * rate ...
void set_fluid_impulse(std::size_t mode, const Place &place, double delta)
setFluidImpulse(mode, place, delta): the level jump on every firing of the mode.
void set_fluid_rate_dependence(std::size_t mode, const Place &place, const std::function< double(double)> &h)
setFluidRateDependence(mode, place, h): h(level) scales the firing rate of a timed Exp mode.
Transition(NetworkModel &m, const std::string &nm)
void set_number_of_servers(std::size_t mode, double n)
setNumberOfServers(mode, n); GlobalConstants::MaxInt is infinite.
void set_firing_rate_dependence(std::size_t mode, const std::function< double(const std::vector< double > &)> &g)
setFiringRateDependence(mode, g): g(marking) scales the firing rate.
void set_firing_outcome(std::size_t mode, const JobClass &cls, const Node &dest, double tokens)
setFiringOutcome(mode, class, node, tokens); the node may be a Sink.
bool has_fluid_arcs() const
hasFluidArcs().
void set_timing_strategy(std::size_t mode, lang::TimingStrategy ts)
setTimingStrategy(mode, strategy): TIMED or IMMEDIATE.
void set_inhibiting_conditions(std::size_t mode, const JobClass &cls, const Place &place, double tokens)
setInhibitingConditions(mode, class, place, tokens); absent means never.
void set_fluid_guard(std::size_t mode, const Place &place, const std::string &op, double threshold)
setFluidGuard(mode, place, op, threshold): op ">=" or "<="; an empty op removes the guard.
void set_firing_priorities(std::size_t mode, double prio)
setFiringPriorities(mode, priority).
std::size_t add_mode(const std::string &nm)
addMode(name): the new mode's 1-based index.
void set_distribution(std::size_t mode, const Dist &d)
setDistribution(mode, dist): the mode's firing law.
void set_enabling_conditions(std::size_t mode, const JobClass &cls, const Place &place, double tokens)
setEnablingConditions(mode, class, place, tokens).
Transition(NetworkModel &m, const std::string &nm, const qn::TransitionParam< double > &par)
The all-at-once form, for a caller that already holds a finished block.
A queueing network under construction.
void set_drop_rule(std::size_t node, std::size_t cls, DropStrategy rule)
station.setDropRule(class, rule).
void set_departure_discipline(std::size_t node, std::size_t cls, lang::DepartureDiscipline rule)
Place.setDepartureDiscipline(class, rule).
void set_load_dependence(std::size_t node, const std::vector< T > &alpha)
station.setLoadDependence(alpha): the rate multiplier at population 1, 2, ... The vector is indexed f...
void set_mode_fluid_impulse(std::size_t node, std::size_t mode, std::size_t place, double delta)
Transition.setFluidImpulse(mode, place, delta): every firing of the mode moves the level of the fluid...
void set_class_capacity(std::size_t node, std::size_t cls, double k)
station.setChainCapacity(class, k).
void set_enabling_conditions(std::size_t node, std::size_t mode, std::size_t cls, std::size_t place, const T &tokens)
Transition.setEnablingConditions(mode, class, place, tokens): how many class-r tokens the mode needs ...
void set_arrival_batch(std::size_t node, std::size_t cls, const Distrib< T > &dist)
Source.setArrivalBatch(class, dist): the batch-size law released at each arrival epoch.
double get_fluid_level(std::size_t node)
void set_cache_read(std::size_t cache_node, std::size_t r, const std::vector< T > &pmf)
Cache.setRead(jobclass, popularity): class r (1-based) reads the cache, drawing items from the pmf pm...
void set_mode_timing(std::size_t node, std::size_t mode, lang::TimingStrategy ts)
Transition.setTimingStrategy(mode, strategy): TIMED or IMMEDIATE.
void set_firing_weight(std::size_t node, std::size_t mode, const T &w)
Transition.setFiringWeights(mode, weight): the share among tied modes.
void set_cache_miss_class(std::size_t cache_node, std::size_t r, std::size_t m)
Cache.setMissClass(jobclass, missclass): a class-r read that misses leaves as class m.
void set_mode_fluid_dependence(std::size_t node, std::size_t mode, std::size_t place, const std::function< double(double)> &h)
Transition.setFluidRateDependence(mode, place, h): the firing rate of a TIMED, exponential mode is mu...
void set_mode_distribution(std::size_t node, std::size_t mode, const Distrib< T > &d)
Transition.setDistribution(mode, dist): the mode's firing law.
bool is_place_fluid(std::size_t node)
Place.isFluid(), getFluidCapacity() and getFluidLevel().
void set_initial_marking(std::size_t node, const std::vector< T > &tokens)
Place.setState(marking): the initial token count of the place, per class.
void set_mode_fluid_rate(std::size_t node, std::size_t mode, std::size_t place, double rate)
Transition.setFluidRate(mode, place, rate): the FSPN flow of a TIMED mode into (rate > 0) or out of (...
void set_inhibiting_conditions(std::size_t node, std::size_t mode, std::size_t cls, std::size_t place, const T &tokens)
Transition.setInhibitingConditions(mode, class, place, tokens): the class-r count at place that BLOCK...
void set_number_of_servers(std::size_t node, double n)
queue.setNumberOfServers(n).
bool has_fluid_arcs(std::size_t node) const
Transition.hasFluidArcs(): any mode declares a flow, guard, impulse or fluid rate dependence.
void set_mode_firing_dependence(std::size_t node, std::size_t mode, const std::function< T(const std::vector< T > &)> &g)
Transition.setFiringRateDependence(mode, g): g(marking) scales the rate.
void set_class_completes(std::size_t cls, bool flag)
jobclass.completes = flag: whether a passage through the reference station counts as a completion.
void set_class_switch_matrix(std::size_t node, const Matrix< T > &C)
Install the switching matrix of a ClassSwitch created without one.
void set_routing(std::size_t node, std::size_t cls, RoutingStrategy rs)
node.setRouting(class, strategy).
void set_join_strategy(std::size_t node, lang::JoinStrategy strategy, double quorum=0.0)
Join.setStrategy(...): STD waits for every sibling, PARTIAL for a quorum.
void set_fluid_capacity(std::size_t node, double cap)
Place.setFluidCapacity(B): the level ceiling of a fluid place, Inf when unbounded.
std::size_t add_mode(std::size_t node, const std::string &nm)
Transition.addMode(name): a new firing mode, returning its 1-based index.
void set_marked_classes(std::size_t node, const std::vector< std::size_t > &classes)
Source.markedClasses: the 1-based class carried by each mark of an MMAP.
void set_sched_param(std::size_t node, std::size_t cls, const T &weight)
The DPS / GPS weight of a class at a station.
void set_firing_priority(std::size_t node, std::size_t mode, double prio)
Transition.setFiringPriorities(mode, priority).
void set_fluid_level(std::size_t node, double level)
Place.setFluidLevel(x0): the initial level of a fluid place.
void set_routing_weights(std::size_t node, std::size_t cls, const std::map< std::size_t, double > &weights)
The per-destination weights of a WRROBIN dispatcher, per (node, class).
void set_mode_fluid_flow_dependence(std::size_t node, std::size_t mode, std::size_t place, const std::function< double(const std::vector< double > &)> &phi, const std::vector< std::size_t > &read=std::vector< std::size_t >())
Transition.setFluidFlowDependence(mode, place, phi, readPlaces): the flow of the mode into or out of ...
void set_capacity(std::size_t node, double k)
station.setCapacity(k), the K of Kendall's notation.
void set_switchover(std::size_t node, std::size_t cls, const Distrib< T > &so)
Queue.setSwitchover(jobclass, distrib): the switchover time of a class.
void set_cache_hit_class(std::size_t cache_node, std::size_t r, std::size_t h)
Cache.setHitClass(jobclass, hitclass): a class-r read that hits leaves as class h.
void set_place_fluid(std::size_t node, bool fluid)
Place.setFluid(flag): the place holds one real level in [0, fluid capacity] instead of tokens,...
void add_server_type(std::size_t node, const typename Station< T >::ServerType &stype)
Queue.addServerType(...): one heterogeneous server pool of the station.
void set_service(std::size_t node, std::size_t cls, const Distrib< T > &d)
station.setService(class, dist).
void set_breakdown(std::size_t node, const Distrib< T > &failure, const Distrib< T > &repair, const std::vector< Distrib< T > > &down_service=std::vector< Distrib< T > >())
Queue.setBreakdown(failure, repair, downService): the server alternates up and down on the two clocks...
void set_item_read_classes(std::size_t cache_node, const std::vector< std::size_t > &read_classes, const std::vector< std::size_t > &hit_classes)
Cache.setItemReadClasses(readClasses, hitClasses): declare that read_classes[i] is the request stream...
void set_mode_servers(std::size_t node, std::size_t mode, double n)
Transition.setNumberOfServers(mode, n); GlobalConstants::MaxInt is infinite.
void set_firing_outcome(std::size_t node, std::size_t mode, std::size_t cls, std::size_t dest, const T &tokens)
Transition.setFiringOutcome(mode, class, node, tokens): the class-r tokens the firing deposits.
std::size_t station_index(std::size_t node) const
void set_arrival(std::size_t node, std::size_t cls, const Distrib< T > &d)
source.setArrival(class, dist): the same table, at the Source.
void set_mode_fluid_guard(std::size_t node, std::size_t mode, std::size_t place, const std::string &op, double threshold)
Transition.setFluidGuard(mode, place, op, threshold): the mode is enabled only while the level of the...
double get_fluid_capacity(std::size_t node)
void set_polling_type(std::size_t node, lang::PollingType rule, int par=0)
Queue.setPollingType(rule, par): the polling discipline of a POLLING station, identical across all cl...
The routing matrix a model script fills in, MATLAB's P cell array.
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
DropStrategy
Blocking and loss rules, with the values of MATLAB DropStrategy.
TimingStrategy
SPN transition timing, with the values of MATLAB TimingStrategy.
JoinStrategy
Join rules, with the values of MATLAB JoinStrategy.
RoutingStrategy
Routing strategies, with the values of MATLAB RoutingStrategy.
DepartureDiscipline
When a Place releases a served token, MATLAB DepartureDiscipline.
PollingType
Polling service disciplines, with the values of MATLAB PollingType.
Conservation laws of a layered queueing network, enumerated from its structure.
lang::Distrib< double > Dist
qn::Network< double > NetworkModel
void cyclic_routing(Routing &P, std::size_t r, const std::vector< std::size_t > &nodes)
The same chain closed into a cycle, which is how a closed model circulates.
qn::RoutingMatrix< double > Routing
void serial_routing(Routing &P, std::size_t r, std::size_t s, const std::vector< std::size_t > &nodes)
Network.serialRouting(nodes) for one class pair: 1 -> 2 -> ... -> n.
The Network constructor API: Queue, Delay, Source, Sink, Router, ClassSwitch, Cache,...
The parameters of a Cache node, MATLAB's sn.nodeparam{ind} for a Cache.
A heterogeneous server pool: count servers that serve only compatible classes, each with its own serv...
The parameters of a Transition node: MATLAB sn.nodeparam{ind} for an SPN transition,...