LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
wfn_transition.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2026, QORE Lab, Imperial College London
3 * All rights reserved.
4 */
5#ifndef LINE_API_WFN_WFN_TRANSITION_H
6#define LINE_API_WFN_WFN_TRANSITION_H
7
8/**
9 * @file
10 * @ingroup api_wfn
11 * A transition (task) of a WorkflowNet.
12 *
13 * A timed transition fires after its firing-time law; an immediate one fires in
14 * zero time, and among the enabled immediate transitions only those of the
15 * highest priority fire, chosen in proportion to their weights.
16 *
17 * MATLAB twin: matlab/src/api/wfn/WFNTransition.m
18 */
19
20#include <cstddef>
21#include <limits>
22#include <string>
23
25#include "line/util/error.h"
26
27namespace line {
28namespace wfn {
29
30class WorkflowNet;
31
32class WFNTransition {
33public:
34 const std::string& name() const { return name_; }
35 /** 0-based position in `WorkflowNet::transitions()`. */
36 std::size_t index() const { return index_; }
37 const lang::Distrib<double>& distribution() const { return distribution_; }
38 lang::TimingStrategy timing() const { return timing_; }
39 /** Concurrent firings allowed; infinite unless the task limits its own concurrency. */
40 double servers() const { return servers_; }
41 double priority() const { return priority_; }
42 double weight() const { return weight_; }
43 /** 0-based index into `WorkflowNet::resources()`, or -1 when the task holds none. */
44 long resource() const { return resource_; }
45
46 bool is_timed() const { return timing_ == lang::TimingStrategy::TIMED; }
47 bool is_immediate() const { return timing_ == lang::TimingStrategy::IMMEDIATE; }
48
49 /** `setDistribution(d)`. */
50 void set_distribution(const lang::Distrib<double>& d) { distribution_ = d; }
51 /** `setTiming(t)`. */
54 throw InputError(ErrorKind("Argument"),
55 "Timing must be TimingStrategy.TIMED or TimingStrategy.IMMEDIATE.");
56 timing_ = timing;
57 }
58 /** `setServers(n)`. */
59 void set_servers(double servers) {
60 if (!(servers >= 1))
61 throw InputError(ErrorKind("Argument"), "Number of servers must be at least 1.");
62 servers_ = servers;
63 }
64 /** `setPriority(p)`. */
65 void set_priority(double priority) {
66 if (!(priority > 0)) throw InputError(ErrorKind("Argument"), "Priority must be positive.");
67 priority_ = priority;
68 }
69 /** `setWeight(w)`. */
70 void set_weight(double weight) {
71 if (!(weight > 0)) throw InputError(ErrorKind("Argument"), "Weight must be positive.");
72 weight_ = weight;
73 }
74
75private:
76 friend class WorkflowNet;
77 WFNTransition(const std::string& name, std::size_t index, const lang::Distrib<double>& d,
78 lang::TimingStrategy timing, double servers, double priority, double weight)
79 : name_(name), index_(index), distribution_(d), timing_(timing), servers_(servers),
80 priority_(priority), weight_(weight) {}
81
82 std::string name_;
83 std::size_t index_;
84 lang::Distrib<double> distribution_;
86 double servers_ = std::numeric_limits<double>::infinity();
87 double priority_ = 1.0;
88 double weight_ = 1.0;
89 long resource_ = -1;
90};
91
92} // namespace wfn
93} // namespace line
94
95#endif // LINE_API_WFN_WFN_TRANSITION_H
InputError(const std::string &what)
Definition error.h:105
void set_servers(double servers)
setServers(n).
std::size_t index() const
0-based position in WorkflowNet::transitions().
lang::TimingStrategy timing() const
long resource() const
0-based index into WorkflowNet::resources(), or -1 when the task holds none.
void set_distribution(const lang::Distrib< double > &d)
setDistribution(d).
const std::string & name() const
double servers() const
Concurrent firings allowed; infinite unless the task limits its own concurrency.
void set_weight(double weight)
setWeight(w).
void set_priority(double priority)
setPriority(p).
void set_timing(lang::TimingStrategy timing)
setTiming(t).
const lang::Distrib< double > & distribution() const
The exception types the port throws.
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
TimingStrategy
SPN transition timing, with the values of MATLAB TimingStrategy.
Definition lang_types.h:368
@ IMMEDIATE
fires with zero delay, resolved by weight and priority
Definition lang_types.h:370
@ TIMED
fires after its firing distribution elapses
Definition lang_types.h:369
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:52
ErrorKind(std::string n)
Definition error.h:39