pypdevsbbl.generic.queues.html 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>pypdevsbbl.generic.queues module &#8212; Python(P)DEVS-BBL documentation</title>
  8. <link rel="stylesheet" href="_static/nature.css" type="text/css" />
  9. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  10. <link rel="stylesheet" type="text/css" href="_static/custom.css" />
  11. <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
  12. <script type="text/javascript" src="_static/jquery.js"></script>
  13. <script type="text/javascript" src="_static/underscore.js"></script>
  14. <script type="text/javascript" src="_static/doctools.js"></script>
  15. <script type="text/javascript" src="_static/language_data.js"></script>
  16. <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  17. <link rel="index" title="Index" href="genindex.html" />
  18. <link rel="search" title="Search" href="search.html" />
  19. <link rel="next" title="pypdevsbbl.generic.routing module" href="pypdevsbbl.generic.routing.html" />
  20. <link rel="prev" title="pypdevsbbl.generic.math module" href="pypdevsbbl.generic.math.html" />
  21. </head><body>
  22. <div class="related" role="navigation" aria-label="related navigation">
  23. <h3>Navigation</h3>
  24. <ul>
  25. <li class="right" style="margin-right: 10px">
  26. <a href="genindex.html" title="General Index"
  27. accesskey="I">index</a></li>
  28. <li class="right" >
  29. <a href="py-modindex.html" title="Python Module Index"
  30. >modules</a> |</li>
  31. <li class="right" >
  32. <a href="pypdevsbbl.generic.routing.html" title="pypdevsbbl.generic.routing module"
  33. accesskey="N">next</a> |</li>
  34. <li class="right" >
  35. <a href="pypdevsbbl.generic.math.html" title="pypdevsbbl.generic.math module"
  36. accesskey="P">previous</a> |</li>
  37. <li class="nav-item nav-item-0"><a href="index.html">Python(P)DEVS-BBL documentation</a> &#187;</li>
  38. <li class="nav-item nav-item-1"><a href="pypdevsbbl.html" >pypdevsbbl package</a> &#187;</li>
  39. <li class="nav-item nav-item-2"><a href="pypdevsbbl.generic.html" accesskey="U">pypdevsbbl.generic package</a> &#187;</li>
  40. </ul>
  41. </div>
  42. <div class="document">
  43. <div class="documentwrapper">
  44. <div class="bodywrapper">
  45. <div class="body" role="main">
  46. <div class="section" id="module-pypdevsbbl.generic.queues">
  47. <span id="pypdevsbbl-generic-queues-module"></span><h1>pypdevsbbl.generic.queues module<a class="headerlink" href="#module-pypdevsbbl.generic.queues" title="Permalink to this headline">¶</a></h1>
  48. <p>PythonPDEVS Queue for storing items that are waiting to be processed.</p>
  49. <dl class="class">
  50. <dt id="pypdevsbbl.generic.queues.SimpleQueue">
  51. <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.queues.</code><code class="descname">SimpleQueue</code><span class="sig-paren">(</span><em>name: str</em>, <em>fc=&lt;function &lt;lambda&gt;&gt;</em>, <em>K=inf</em>, <em>dr=inf</em>, <em>contents=()</em>, <em>req_am=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#SimpleQueue"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.SimpleQueue" title="Permalink to this definition">¶</a></dt>
  52. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
  53. <p>Queue with reneging that allows items to wait for storage.</p>
  54. <p>Items can only be dequeued when a requestdequeue input is obtained. This
  55. makes it so the queue don’t have to handle the complexities concerning
  56. automatic dequeueing. See the <a class="reference internal" href="#pypdevsbbl.generic.queues.Queue" title="pypdevsbbl.generic.queues.Queue"><code class="xref py py-class docutils literal notranslate"><span class="pre">Queue</span></code></a> for more details on automatic
  57. dequeueing.</p>
  58. <p>Reneging will happen automatically if needs be. The requestrenege will
  59. renege the last item in the queue.</p>
  60. <p>The enqueue will send the outputs to the overflow output if capacity &gt;= K.</p>
  61. <div class="admonition note">
  62. <p class="first admonition-title">Note</p>
  63. <p class="last">We will be using a maxheap in this queue.</p>
  64. </div>
  65. <div align="center" class="align-center"><img alt="../paper/images/blocks/queue/simple-queue.svg" src="../paper/images/blocks/queue/simple-queue.svg" /></div>
  66. <table class="docutils field-list" frame="void" rules="none">
  67. <col class="field-name" />
  68. <col class="field-body" />
  69. <tbody valign="top">
  70. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  71. <li><strong>name</strong> (<em>str</em>) – The name of the Queue.</li>
  72. <li><strong>fc</strong> (<em>def</em>) – Queueing Discipline. I.e. the priority assigning
  73. function. Takes the current time, the value and a
  74. unique index as arguments. Defaults to
  75. <a class="reference internal" href="pypdevsbbl.extra.queues.html#pypdevsbbl.extra.queues.FIFO" title="pypdevsbbl.extra.queues.FIFO"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pypdevsbbl.extra.queues.FIFO()</span></code></a>.</li>
  76. <li><strong>K</strong> (<em>int</em>) – The maximal capacity of the Queue.
  77. Defaults to INFINITY (= no maximal capacity).</li>
  78. <li><strong>dr</strong> (<em>numeric</em>) – Standard reneging time delay. Cannot be negative.
  79. Defaults to INFINITY (= no reneging).</li>
  80. <li><strong>contents</strong> (<em>iter</em>) – A list of contents to be inserted into the queue on
  81. startup. Defaults to an empty tuple.</li>
  82. <li><strong>req_am</strong> (<em>bool</em>) – When <code class="docutils literal notranslate"><span class="pre">True</span></code>, the message in a dequeue/renege
  83. request indicates the amount that should be released.
  84. When <code class="docutils literal notranslate"><span class="pre">False</span></code>, no matter which message arrives on
  85. these ports, only a single item is released. Defaults
  86. to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</li>
  87. </ul>
  88. </td>
  89. </tr>
  90. <tr class="field-even field"><th class="field-name">State:</th><td class="field-body"><ul class="first simple">
  91. <li><strong>queue</strong> (<em>heap</em>) – The internal heap for this priority queue.</li>
  92. <li><strong>dr</strong> (<em>numeric</em>) – The renege time delay.</li>
  93. <li><strong>T</strong> (<em>numeric</em>) – Current absolute time.</li>
  94. <li><strong>rd</strong> (<em>bool</em>) – If a dequeue operation was requested.</li>
  95. <li><strong>rr</strong> (<em>bool</em>) – If a renege operation was requested.</li>
  96. <li><strong>ovf</strong> (<em>any</em>) – The overflowing items.</li>
  97. </ul>
  98. </td>
  99. </tr>
  100. <tr class="field-odd field"><th class="field-name">Input Ports:</th><td class="field-body"><ul class="first simple">
  101. <li><strong>enqueue</strong> (<em>any</em>) – Obtains values and queues them.</li>
  102. <li><strong>dr</strong> (<em>numeric</em>) – A new minimal time in the system value. Cannot be
  103. negative.</li>
  104. <li><strong>requestdequeue</strong> – Indicates that items must dequeue. When <code class="xref py py-attr docutils literal notranslate"><span class="pre">req_am</span></code>
  105. is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it expects a natural number. Otherwise,
  106. any arriving value is accepted and a single item will
  107. be dequeued.</li>
  108. <li><strong>requestrenege</strong> – Indicates that the last item in the queue must depart on
  109. the <cite>renege</cite> port. When <code class="xref py py-attr docutils literal notranslate"><span class="pre">req_am</span></code> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it
  110. expects a natural number. Otherwise, any arriving value is
  111. accepted and a single item will be reneged.</li>
  112. </ul>
  113. </td>
  114. </tr>
  115. <tr class="field-even field"><th class="field-name">Output Ports:</th><td class="field-body"><ul class="first last simple">
  116. <li><strong>dequeue</strong> (<em>any</em>) – Outputs the next item if it exists.</li>
  117. <li><strong>renege</strong> (<em>any</em>) – Outputs reneged items.</li>
  118. <li><strong>overflow</strong> (<em>any</em>) – Outputs overflowing items.</li>
  119. </ul>
  120. </td>
  121. </tr>
  122. </tbody>
  123. </table>
  124. <dl class="method">
  125. <dt id="pypdevsbbl.generic.queues.SimpleQueue.minRen">
  126. <code class="descname">minRen</code><span class="sig-paren">(</span><em>init=inf</em>, <em>it=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#SimpleQueue.minRen"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.SimpleQueue.minRen" title="Permalink to this definition">¶</a></dt>
  127. <dd><p>Obtain the item that has a minimal reneging time.</p>
  128. <p>Also compare it to the given item.</p>
  129. <table class="docutils field-list" frame="void" rules="none">
  130. <col class="field-name" />
  131. <col class="field-body" />
  132. <tbody valign="top">
  133. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  134. <li><strong>init</strong> (<em>numeric</em>) – The initial value to compare it to.</li>
  135. <li><strong>it</strong> (<em>any</em>) – The item that is linked to the <code class="docutils literal notranslate"><span class="pre">init</span></code>
  136. value.</li>
  137. </ul>
  138. </td>
  139. </tr>
  140. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Tuple in the shape of <code class="docutils literal notranslate"><span class="pre">(time,</span> <span class="pre">item)</span></code> where <code class="docutils literal notranslate"><span class="pre">time</span></code> is
  141. the time delay until next renege and <code class="docutils literal notranslate"><span class="pre">item</span></code> the item that
  142. must be reneged.</p>
  143. </td>
  144. </tr>
  145. </tbody>
  146. </table>
  147. </dd></dl>
  148. <dl class="method">
  149. <dt id="pypdevsbbl.generic.queues.SimpleQueue.maxRen">
  150. <code class="descname">maxRen</code><span class="sig-paren">(</span><em>init=-inf</em>, <em>it=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#SimpleQueue.maxRen"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.SimpleQueue.maxRen" title="Permalink to this definition">¶</a></dt>
  151. <dd><p>Obtain the item that has a maximal reneging time.</p>
  152. <p>Also compare it to the given item.</p>
  153. <table class="docutils field-list" frame="void" rules="none">
  154. <col class="field-name" />
  155. <col class="field-body" />
  156. <tbody valign="top">
  157. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  158. <li><strong>init</strong> (<em>numeric</em>) – The initial value to compare it to.</li>
  159. <li><strong>it</strong> (<em>any</em>) – The item that is linked to the <code class="docutils literal notranslate"><span class="pre">init</span></code>
  160. value.</li>
  161. </ul>
  162. </td>
  163. </tr>
  164. <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Tuple in the shape of <code class="docutils literal notranslate"><span class="pre">(time,</span> <span class="pre">item)</span></code> where <code class="docutils literal notranslate"><span class="pre">time</span></code> is
  165. the time delay until the last renege and <code class="docutils literal notranslate"><span class="pre">item</span></code> the item
  166. that must be reneged last.</p>
  167. </td>
  168. </tr>
  169. </tbody>
  170. </table>
  171. </dd></dl>
  172. <dl class="method">
  173. <dt id="pypdevsbbl.generic.queues.SimpleQueue.timeAdvance">
  174. <code class="descname">timeAdvance</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#SimpleQueue.timeAdvance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.SimpleQueue.timeAdvance" title="Permalink to this definition">¶</a></dt>
  175. <dd></dd></dl>
  176. <dl class="method">
  177. <dt id="pypdevsbbl.generic.queues.SimpleQueue.intTransition">
  178. <code class="descname">intTransition</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#SimpleQueue.intTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.SimpleQueue.intTransition" title="Permalink to this definition">¶</a></dt>
  179. <dd></dd></dl>
  180. <dl class="method">
  181. <dt id="pypdevsbbl.generic.queues.SimpleQueue.extTransition">
  182. <code class="descname">extTransition</code><span class="sig-paren">(</span><em>inputs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#SimpleQueue.extTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.SimpleQueue.extTransition" title="Permalink to this definition">¶</a></dt>
  183. <dd></dd></dl>
  184. <dl class="method">
  185. <dt id="pypdevsbbl.generic.queues.SimpleQueue.outputFnc">
  186. <code class="descname">outputFnc</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#SimpleQueue.outputFnc"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.SimpleQueue.outputFnc" title="Permalink to this definition">¶</a></dt>
  187. <dd></dd></dl>
  188. </dd></dl>
  189. <dl class="class">
  190. <dt id="pypdevsbbl.generic.queues.QueueTracker">
  191. <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.queues.</code><code class="descname">QueueTracker</code><span class="sig-paren">(</span><em>name: str</em>, <em>dt=inf</em>, <em>size=0</em>, <em>value=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#QueueTracker"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.QueueTracker" title="Permalink to this definition">¶</a></dt>
  192. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
  193. <p>Helper block for the <a class="reference internal" href="#pypdevsbbl.generic.queues.SimpleQueue" title="pypdevsbbl.generic.queues.SimpleQueue"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleQueue</span></code></a> to be linked in the <a class="reference internal" href="#pypdevsbbl.generic.queues.Queue" title="pypdevsbbl.generic.queues.Queue"><code class="xref py py-class docutils literal notranslate"><span class="pre">Queue</span></code></a>.</p>
  194. <p>Instead of using a <code class="xref py py-class docutils literal notranslate"><span class="pre">ConstantGenerator</span></code>, this block will be used to
  195. periodically request dequeues. It also keeps track of the current queue
  196. size, meaning that, whenever the queue is empty, it can pause until the
  197. next input.</p>
  198. <div align="center" class="align-center"><img alt="../paper/images/blocks/queue/queue-tracker.svg" src="../paper/images/blocks/queue/queue-tracker.svg" /></div>
  199. <table class="docutils field-list" frame="void" rules="none">
  200. <col class="field-name" />
  201. <col class="field-body" />
  202. <tbody valign="top">
  203. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  204. <li><strong>name</strong> (<em>str</em>) – The name for the block.</li>
  205. <li><strong>dt</strong> (<em>numeric</em>) – Standard time delay between messages.
  206. Defaults to INFINITY. Cannot be zero or negative.</li>
  207. <li><strong>size</strong> (<em>int</em>) – The queue size to start from. Must be positive or
  208. zero. Defaults to 0.</li>
  209. <li><strong>value</strong> (<em>any</em>) – The value to output instead of the queue size.
  210. When <code class="docutils literal notranslate"><span class="pre">None</span></code>, the queue size is used. Defaults to
  211. <code class="docutils literal notranslate"><span class="pre">None</span></code>.</li>
  212. </ul>
  213. </td>
  214. </tr>
  215. <tr class="field-even field"><th class="field-name">State:</th><td class="field-body"><ul class="first simple">
  216. <li><strong>dt</strong> (<em>numeric</em>) – The time delay between messages.</li>
  217. <li><strong>el</strong> (<em>numeric</em>) – The elapsed time since the last event.</li>
  218. <li><strong>size</strong> (<em>int</em>) – The current queue size.</li>
  219. </ul>
  220. </td>
  221. </tr>
  222. <tr class="field-odd field"><th class="field-name">Input Ports:</th><td class="field-body"><ul class="first simple">
  223. <li><strong>dt</strong> (<em>numeric</em>) – Updates the time delay.</li>
  224. <li><strong>enter</strong> (<em>any</em>) – An item entered the queue.</li>
  225. <li><strong>leave</strong> (<em>any</em>) – An item left the queue.</li>
  226. </ul>
  227. </td>
  228. </tr>
  229. <tr class="field-even field"><th class="field-name">Output Ports:</th><td class="field-body"><p class="first last"><strong>size</strong> (<em>int</em>) – The queue size or a predefined value.</p>
  230. </td>
  231. </tr>
  232. </tbody>
  233. </table>
  234. <dl class="method">
  235. <dt id="pypdevsbbl.generic.queues.QueueTracker.extTransition">
  236. <code class="descname">extTransition</code><span class="sig-paren">(</span><em>inputs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#QueueTracker.extTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.QueueTracker.extTransition" title="Permalink to this definition">¶</a></dt>
  237. <dd></dd></dl>
  238. <dl class="method">
  239. <dt id="pypdevsbbl.generic.queues.QueueTracker.intTransition">
  240. <code class="descname">intTransition</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#QueueTracker.intTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.QueueTracker.intTransition" title="Permalink to this definition">¶</a></dt>
  241. <dd></dd></dl>
  242. <dl class="method">
  243. <dt id="pypdevsbbl.generic.queues.QueueTracker.timeAdvance">
  244. <code class="descname">timeAdvance</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#QueueTracker.timeAdvance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.QueueTracker.timeAdvance" title="Permalink to this definition">¶</a></dt>
  245. <dd></dd></dl>
  246. <dl class="method">
  247. <dt id="pypdevsbbl.generic.queues.QueueTracker.outputFnc">
  248. <code class="descname">outputFnc</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#QueueTracker.outputFnc"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.QueueTracker.outputFnc" title="Permalink to this definition">¶</a></dt>
  249. <dd></dd></dl>
  250. </dd></dl>
  251. <dl class="class">
  252. <dt id="pypdevsbbl.generic.queues.Queue">
  253. <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.queues.</code><code class="descname">Queue</code><span class="sig-paren">(</span><em>name: str</em>, <em>fc=&lt;function &lt;lambda&gt;&gt;</em>, <em>K=inf</em>, <em>dd=inf</em>, <em>dr=inf</em>, <em>contents=()</em>, <em>req_am=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Queue"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Queue" title="Permalink to this definition">¶</a></dt>
  254. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.CoupledDEVS</span></code></p>
  255. <p>Queue with reneging that allows items to wait for storage.</p>
  256. <p>This queue will be a wrapper around the <a class="reference internal" href="#pypdevsbbl.generic.queues.SimpleQueue" title="pypdevsbbl.generic.queues.SimpleQueue"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleQueue</span></code></a> and
  257. allows for automatic dequeueing by continuously sending messages
  258. to the <cite>requestdequeue</cite> input.</p>
  259. <p>The names of the internal <a class="reference internal" href="#pypdevsbbl.generic.queues.SimpleQueue" title="pypdevsbbl.generic.queues.SimpleQueue"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleQueue</span></code></a> and <a class="reference internal" href="#pypdevsbbl.generic.queues.QueueTracker" title="pypdevsbbl.generic.queues.QueueTracker"><code class="xref py py-class docutils literal notranslate"><span class="pre">QueueTracker</span></code></a>
  260. will be made up of this Queue’s name, appended with <code class="docutils literal notranslate"><span class="pre">-queue</span></code> and
  261. <code class="docutils literal notranslate"><span class="pre">-tracker</span></code> respectively.</p>
  262. <div class="admonition note">
  263. <p class="first admonition-title">Note</p>
  264. <p class="last">If you don’t want to use automatic dequeueing, it’s more
  265. efficient to make use of the <a class="reference internal" href="#pypdevsbbl.generic.queues.SimpleQueue" title="pypdevsbbl.generic.queues.SimpleQueue"><code class="xref py py-class docutils literal notranslate"><span class="pre">SimpleQueue</span></code></a> instead.</p>
  266. </div>
  267. <div class="admonition note">
  268. <p class="first admonition-title">Note</p>
  269. <p class="last">We will be using a maxheap in this queue.</p>
  270. </div>
  271. <div align="center" class="align-center"><img alt="../paper/images/blocks/queue/queue.svg" src="../paper/images/blocks/queue/queue.svg" /></div>
  272. <table class="docutils field-list" frame="void" rules="none">
  273. <col class="field-name" />
  274. <col class="field-body" />
  275. <tbody valign="top">
  276. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  277. <li><strong>name</strong> (<em>str</em>) – The name of the Queue.</li>
  278. <li><strong>fc</strong> (<em>def</em>) – Queueing Discipline. I.e. the priority assigning function.
  279. Takes the current time, the value and a unique index as
  280. arguments. Defaults to <a class="reference internal" href="pypdevsbbl.extra.queues.html#pypdevsbbl.extra.queues.FIFO" title="pypdevsbbl.extra.queues.FIFO"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pypdevsbbl.extra.queues.FIFO()</span></code></a>.</li>
  281. <li><strong>K</strong> (<em>int</em>) – The maximal capacity of the Queue.
  282. Defaults to INFINITY (= no maximal capacity).</li>
  283. <li><strong>dd</strong> (<em>numeric</em>) – Standard dequeueing time delay. Cannot be zero or negative.
  284. Defaults to INFINITY (= no automatic dequeueing).</li>
  285. <li><strong>dr</strong> (<em>numeric</em>) – Standard reneging time delay. Cannot be negative.
  286. Defaults to INFINITY (= no reneging).</li>
  287. <li><strong>contents</strong> (<em>iter</em>) – A list of contents to be inserted into the queue on startup.
  288. Defaults to an empty tuple.</li>
  289. <li><strong>req_am</strong> (<em>bool</em>) – When <code class="docutils literal notranslate"><span class="pre">True</span></code>, the message in a dequeue/renege request
  290. indicates the amount that should be released. When <code class="docutils literal notranslate"><span class="pre">False</span></code>,
  291. no matter which message arrives on these ports, only a single
  292. item is released. Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</li>
  293. </ul>
  294. </td>
  295. </tr>
  296. <tr class="field-even field"><th class="field-name">Input Ports:</th><td class="field-body"><ul class="first simple">
  297. <li><strong>enqueue</strong> (<em>any</em>) – Obtains values and queues them.</li>
  298. <li><strong>dd</strong> (<em>numeric</em>) – A new minimal time until dequeue. Cannot be zero or negative.</li>
  299. <li><strong>dr</strong> (<em>numeric</em>) – A new minimal time in the system value. Cannot be negative.</li>
  300. <li><strong>requestdequeue</strong> – Indicates that items must dequeue. When <code class="xref py py-attr docutils literal notranslate"><span class="pre">req_am</span></code> is
  301. <code class="docutils literal notranslate"><span class="pre">True</span></code>, it expects a natural number. Otherwise, any arriving
  302. value is accepted and a single item will be dequeued.</li>
  303. <li><strong>requestrenege</strong> – Indicates that the last item in the queue must depart on the
  304. <cite>renege</cite> port. When <code class="xref py py-attr docutils literal notranslate"><span class="pre">req_am</span></code> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, it expects a
  305. natural number. Otherwise, any arriving value is accepted and
  306. a single item will be reneged.</li>
  307. </ul>
  308. </td>
  309. </tr>
  310. <tr class="field-odd field"><th class="field-name">Output Ports:</th><td class="field-body"><ul class="first last simple">
  311. <li><strong>dequeue</strong> (<em>any</em>) – Outputs the next item if it exists.</li>
  312. <li><strong>renege</strong> (<em>any</em>) – Outputs reneged items.</li>
  313. <li><strong>overflow</strong> (<em>any</em>) – Outputs overflowing items.</li>
  314. <li><strong>count</strong> (<em>int</em>) – Current queue size.</li>
  315. </ul>
  316. </td>
  317. </tr>
  318. </tbody>
  319. </table>
  320. </dd></dl>
  321. <dl class="class">
  322. <dt id="pypdevsbbl.generic.queues.Retain">
  323. <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.queues.</code><code class="descname">Retain</code><span class="sig-paren">(</span><em>name: str</em>, <em>ind: bool = True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Retain"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Retain" title="Permalink to this definition">¶</a></dt>
  324. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
  325. <p>Retains an item until the next arrival or next time instance.</p>
  326. <dl class="docutils">
  327. <dt>There are two modes:</dt>
  328. <dd><ul class="first last simple">
  329. <li><em>individual</em>: Will only output the previous item.</li>
  330. <li><em>collection</em>: Will collect all arrived items in the same time
  331. instance and will output a list of all these items.</li>
  332. </ul>
  333. </dd>
  334. </dl>
  335. <div align="center" class="align-center"><img alt="../paper/images/blocks/queue/retain.svg" src="../paper/images/blocks/queue/retain.svg" /></div>
  336. <table class="docutils field-list" frame="void" rules="none">
  337. <col class="field-name" />
  338. <col class="field-body" />
  339. <tbody valign="top">
  340. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
  341. <li><strong>name</strong> (<em>str</em>) – The name of the block.</li>
  342. <li><strong>ind</strong> (<em>bool</em>) – When true, this block uses the “individual” mode.
  343. Otherwise, the “collection” mode is used.</li>
  344. </ul>
  345. </td>
  346. </tr>
  347. <tr class="field-even field"><th class="field-name">State:</th><td class="field-body"><ul class="first simple">
  348. <li><strong>old</strong> (<em>any</em>) – The previous item (or a list thereof).</li>
  349. <li><strong>cur</strong> (<em>any</em>) – The current item.</li>
  350. </ul>
  351. </td>
  352. </tr>
  353. <tr class="field-odd field"><th class="field-name">Input Ports:</th><td class="field-body"><p class="first"><strong>input</strong> (<em>any</em>) – An item that needs to be remembered.</p>
  354. </td>
  355. </tr>
  356. <tr class="field-even field"><th class="field-name">Output Ports:</th><td class="field-body"><ul class="first last simple">
  357. <li><strong>previous</strong> (<em>any</em>) – The previous item (or a list thereof).</li>
  358. <li><strong>current</strong> (<em>any</em>) – The current item.</li>
  359. </ul>
  360. </td>
  361. </tr>
  362. </tbody>
  363. </table>
  364. <dl class="method">
  365. <dt id="pypdevsbbl.generic.queues.Retain.extTransition">
  366. <code class="descname">extTransition</code><span class="sig-paren">(</span><em>inputs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Retain.extTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Retain.extTransition" title="Permalink to this definition">¶</a></dt>
  367. <dd></dd></dl>
  368. <dl class="method">
  369. <dt id="pypdevsbbl.generic.queues.Retain.intTransition">
  370. <code class="descname">intTransition</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Retain.intTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Retain.intTransition" title="Permalink to this definition">¶</a></dt>
  371. <dd></dd></dl>
  372. <dl class="method">
  373. <dt id="pypdevsbbl.generic.queues.Retain.timeAdvance">
  374. <code class="descname">timeAdvance</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Retain.timeAdvance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Retain.timeAdvance" title="Permalink to this definition">¶</a></dt>
  375. <dd></dd></dl>
  376. <dl class="method">
  377. <dt id="pypdevsbbl.generic.queues.Retain.outputFnc">
  378. <code class="descname">outputFnc</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Retain.outputFnc"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Retain.outputFnc" title="Permalink to this definition">¶</a></dt>
  379. <dd></dd></dl>
  380. </dd></dl>
  381. <dl class="class">
  382. <dt id="pypdevsbbl.generic.queues.Advance">
  383. <em class="property">class </em><code class="descclassname">pypdevsbbl.generic.queues.</code><code class="descname">Advance</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Advance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Advance" title="Permalink to this definition">¶</a></dt>
  384. <dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevs.DEVS.AtomicDEVS</span></code></p>
  385. <p>Reneging queue where each item holds their own delay.</p>
  386. <p>This block is inspired by the <code class="docutils literal notranslate"><span class="pre">ADVANCE</span></code> block from GPSS.</p>
  387. <div class="admonition note">
  388. <p class="first admonition-title">Note</p>
  389. <p class="last">The input and the delay must arrive at exactly the same time.
  390. When in doubt, use the <a class="reference internal" href="pypdevsbbl.generic.routing.html#pypdevsbbl.generic.routing.Sync" title="pypdevsbbl.generic.routing.Sync"><code class="xref py py-class docutils literal notranslate"><span class="pre">pypdevsbbl.generic.routing.Sync</span></code></a>
  391. block to ensure this happens.</p>
  392. </div>
  393. <div class="admonition warning">
  394. <p class="first admonition-title">Warning</p>
  395. <p class="last">The items traveling through must be unique!</p>
  396. </div>
  397. <div class="admonition warning">
  398. <p class="first admonition-title">Warning</p>
  399. <p class="last">When using pausing, it is pertinent that the items traveling
  400. through the block are hashable.</p>
  401. </div>
  402. <div align="center" class="align-center"><img alt="../paper/images/blocks/queue/advance.svg" src="../paper/images/blocks/queue/advance.svg" /></div>
  403. <table class="docutils field-list" frame="void" rules="none">
  404. <col class="field-name" />
  405. <col class="field-body" />
  406. <tbody valign="top">
  407. <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>name</strong> (<em>str</em>) – The name of the block.</p>
  408. </td>
  409. </tr>
  410. <tr class="field-even field"><th class="field-name">State:</th><td class="field-body"><ul class="first simple">
  411. <li><strong>items</strong> (<em>dict</em>) – All the scheduled items in the “queue”, with
  412. their expected delay.</li>
  413. <li><strong>least</strong> (<em>tuple</em>) – The item to leave the block first, in the form
  414. of <code class="docutils literal notranslate"><span class="pre">(item,</span> <span class="pre">time)</span></code>.</li>
  415. <li><strong>paused</strong> (<em>set</em>) – Set of items that are currently paused. Note
  416. that the items must be hashable.</li>
  417. </ul>
  418. </td>
  419. </tr>
  420. <tr class="field-odd field"><th class="field-name">Input Ports:</th><td class="field-body"><ul class="first simple">
  421. <li><strong>input</strong> (<em>any</em>) – The item to schedule. Must arrive at the same
  422. time as the <cite>delay</cite> input.</li>
  423. <li><strong>delay</strong> (<em>numeric</em>) – The delay of the item. Must arrive at the same
  424. time as the <cite>input</cite> message.</li>
  425. <li><strong>pause</strong> (<em>list</em>) – A list of tuples <code class="docutils literal notranslate"><span class="pre">(item,</span> <span class="pre">bool)</span></code> indicative of
  426. whether or not the item must pause.</li>
  427. </ul>
  428. </td>
  429. </tr>
  430. <tr class="field-even field"><th class="field-name">Output Ports:</th><td class="field-body"><p class="first last"><strong>output</strong> (<em>any</em>) – The item, at the pre-scheduled delay.</p>
  431. </td>
  432. </tr>
  433. </tbody>
  434. </table>
  435. <dl class="method">
  436. <dt id="pypdevsbbl.generic.queues.Advance.least">
  437. <code class="descname">least</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Advance.least"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Advance.least" title="Permalink to this definition">¶</a></dt>
  438. <dd></dd></dl>
  439. <dl class="method">
  440. <dt id="pypdevsbbl.generic.queues.Advance.timeAdvance">
  441. <code class="descname">timeAdvance</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Advance.timeAdvance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Advance.timeAdvance" title="Permalink to this definition">¶</a></dt>
  442. <dd></dd></dl>
  443. <dl class="method">
  444. <dt id="pypdevsbbl.generic.queues.Advance.outputFnc">
  445. <code class="descname">outputFnc</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Advance.outputFnc"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Advance.outputFnc" title="Permalink to this definition">¶</a></dt>
  446. <dd></dd></dl>
  447. <dl class="method">
  448. <dt id="pypdevsbbl.generic.queues.Advance.intTransition">
  449. <code class="descname">intTransition</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Advance.intTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Advance.intTransition" title="Permalink to this definition">¶</a></dt>
  450. <dd></dd></dl>
  451. <dl class="method">
  452. <dt id="pypdevsbbl.generic.queues.Advance.extTransition">
  453. <code class="descname">extTransition</code><span class="sig-paren">(</span><em>inputs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pypdevsbbl/generic/queues.html#Advance.extTransition"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pypdevsbbl.generic.queues.Advance.extTransition" title="Permalink to this definition">¶</a></dt>
  454. <dd></dd></dl>
  455. </dd></dl>
  456. </div>
  457. </div>
  458. </div>
  459. </div>
  460. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  461. <div class="sphinxsidebarwrapper">
  462. <h4>Previous topic</h4>
  463. <p class="topless"><a href="pypdevsbbl.generic.math.html"
  464. title="previous chapter">pypdevsbbl.generic.math module</a></p>
  465. <h4>Next topic</h4>
  466. <p class="topless"><a href="pypdevsbbl.generic.routing.html"
  467. title="next chapter">pypdevsbbl.generic.routing module</a></p>
  468. <div id="searchbox" style="display: none" role="search">
  469. <h3>Quick search</h3>
  470. <div class="searchformwrapper">
  471. <form class="search" action="search.html" method="get">
  472. <input type="text" name="q" />
  473. <input type="submit" value="Go" />
  474. <input type="hidden" name="check_keywords" value="yes" />
  475. <input type="hidden" name="area" value="default" />
  476. </form>
  477. </div>
  478. </div>
  479. <script type="text/javascript">$('#searchbox').show(0);</script>
  480. </div>
  481. </div>
  482. <div class="clearer"></div>
  483. </div>
  484. <div class="related" role="navigation" aria-label="related navigation">
  485. <h3>Navigation</h3>
  486. <ul>
  487. <li class="right" style="margin-right: 10px">
  488. <a href="genindex.html" title="General Index"
  489. >index</a></li>
  490. <li class="right" >
  491. <a href="py-modindex.html" title="Python Module Index"
  492. >modules</a> |</li>
  493. <li class="right" >
  494. <a href="pypdevsbbl.generic.routing.html" title="pypdevsbbl.generic.routing module"
  495. >next</a> |</li>
  496. <li class="right" >
  497. <a href="pypdevsbbl.generic.math.html" title="pypdevsbbl.generic.math module"
  498. >previous</a> |</li>
  499. <li class="nav-item nav-item-0"><a href="index.html">Python(P)DEVS-BBL documentation</a> &#187;</li>
  500. <li class="nav-item nav-item-1"><a href="pypdevsbbl.html" >pypdevsbbl package</a> &#187;</li>
  501. <li class="nav-item nav-item-2"><a href="pypdevsbbl.generic.html" >pypdevsbbl.generic package</a> &#187;</li>
  502. </ul>
  503. </div>
  504. <div class="footer" role="contentinfo">
  505. &#169; Copyright 2020, Randy Paredis.
  506. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.5.
  507. </div>
  508. </body>
  509. </html>