{"data":{"markdownRemark":{"html":"<h2 id=\"introduction\"><a href=\"#introduction\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Introduction</h2>\n<p>The toolkit exposes a new <code class=\"language-text\">Facility</code> agent class that you are free to extend. This class is the main agent class that can be used to represent all different kinds of facilities. </p>\n<p>A sample model has been provided in the <a href=\":version/supply_chain_toolkit/supply_toolkit_overview\">Supply Chain Toolkit Overview</a> that gives a specific usage example for reference.</p>\n<p>The <code class=\"language-text\">Facility</code> agent contains abstract functions in the super class that must be implemented in your extended class.</p>\n<h2 id=\"facility-class\"><a href=\"#facility-class\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Facility class</h2>\n<p>When you create a new <code class=\"language-text\">Facility</code> agent you will need to implement the following methods.</p>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"> <span class=\"token annotation punctuation\">@Override</span>\n<span class=\"token keyword\">protected</span> <span class=\"token keyword\">void</span> <span class=\"token function\">processOutboundLoadingBay</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n    \n<span class=\"token punctuation\">}</span>\n\n<span class=\"token annotation punctuation\">@Override</span>\n<span class=\"token keyword\">protected</span> <span class=\"token keyword\">void</span> <span class=\"token function\">departTransport</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n\n<span class=\"token punctuation\">}</span>\n\n<span class=\"token annotation punctuation\">@Override</span>\n<span class=\"token keyword\">protected</span> <span class=\"token keyword\">void</span> <span class=\"token function\">receiveInboundTransport</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">{</span>\n    \n<span class=\"token punctuation\">}</span>\n\n<span class=\"token annotation punctuation\">@Override</span>\n<span class=\"token keyword\">protected</span> <span class=\"token keyword\">void</span> <span class=\"token function\">processInboundLoadingBay</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">{</span>\n\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>These methods provide the basic functionality required to handle the sending and receiving of <code class=\"language-text\">TransportMessage</code> messages carrying units / products between facility agents. They must be called from an <code class=\"language-text\">Action</code> and can be ignored if other mechanisms for departing transport are desired.</p>\n<p>The <code class=\"language-text\">receiveInboundTransport()</code> method also has a function in the super class for receiving <code class=\"language-text\">TransportMessage</code> messages automatically.</p>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token annotation punctuation\">@Override</span>\n<span class=\"token keyword\">protected</span> <span class=\"token keyword\">void</span> <span class=\"token function\">receiveInboundTransport</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">super</span><span class=\"token punctuation\">.</span><span class=\"token function\">receiveInboundTransport</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>When calling <code class=\"language-text\">departTransport()</code>, you can add your custom logic for determining how you will depart trucks and by calling the <code class=\"language-text\">receiveInboundTransport()</code> function in the super class immediately afterwards in the run sequence, the <code class=\"language-text\">TransportMessage</code> messages will be placed in the <code class=\"language-text\">LoadingBay.TransportQueue</code>.</p>\n<p>An example from the sample model use case can be found below:</p>\n<div class=\"gatsby-highlight\" data-language=\"java\"><pre class=\"language-java\"><code class=\"language-java\"><span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> Action<span class=\"token generics function\"><span class=\"token punctuation\">&lt;</span>FacilityTypeA<span class=\"token punctuation\">></span></span> departOutboundTransport <span class=\"token operator\">=</span>\n            Action<span class=\"token punctuation\">.</span><span class=\"token function\">create</span><span class=\"token punctuation\">(</span>FacilityTypeA<span class=\"token punctuation\">.</span><span class=\"token keyword\">class</span><span class=\"token punctuation\">,</span> FacilityTypeA<span class=\"token operator\">:</span><span class=\"token operator\">:</span>departTransport<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code></pre></div>\n<h2 id=\"loading-bays\"><a href=\"#loading-bays\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Loading Bays</h2>\n<p>As many <code class=\"language-text\">LoadingBay</code> classes as desired can be added to your <code class=\"language-text\">Facility</code> classes. They can be either initialized during the <code class=\"language-text\">setup()</code> phase, it could be done during an <code class=\"language-text\">firstStep()</code> run sequence, or new ones could be added during the simulation.</p>\n<p>More on the <code class=\"language-text\">LoadingBay</code> class can be found in the <a href=\":version/supply_chain_toolkit/loading_bay\">Loading Bay</a> docs.</p>\n<h2 id=\"multithreaded-processing\"><a href=\"#multithreaded-processing\" aria-hidden=\"true\" class=\"anchor\"><svg aria-hidden=\"true\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Multithreaded Processing</h2>\n<p>A common challenge when simulating supply chains with massive throughput is the simulation time required for dealing with processing and filtering through millions, even 100s of millions of units travelling through facilities.</p>\n<p>One way to handle this and speed up these operations is by using <code class=\"language-text\">ParallelStreams</code>, <code class=\"language-text\">ConcurrentList</code>, and <code class=\"language-text\">ConcurrentHashmap</code>.</p>\n<p>By using these structure it's possible to parallelize the operations across massive lists and maps while not running in to concurrent modification exceptions.</p>\n<p>More information can be found in the <code class=\"language-text\">java.util.Concurrent</code> &#x26; <code class=\"language-text\">java.util.Collection</code> libraries linked below:</p>\n<ol>\n<li><a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/package-summary.html\">Java Concurrent</a></li>\n<li><a href=\"https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html#parallelStream--\">Java Parallel Streams</a></li>\n</ol>","headings":[{"value":"Introduction","depth":2},{"value":"Facility class","depth":2},{"value":"Loading Bays","depth":2},{"value":"Multithreaded Processing","depth":2}],"frontmatter":{"title":"Facility Agent","toc":null,"experimental":false}},"site":{"siteMetadata":{"title":"Simudyne Docs","latestVersion":"2.6"}}},"pageContext":{"absolutePath":"/home/vsts/work/1/s/content/2.6/docs/supply_chain_toolkit/facility.md","versioned":false,"version":"2.6","kind":"docs","pagePath":"/supply_chain_toolkit/facility","chronology":{"prev":{"name":"Supply Chain Toolkit Overview","path":"/supply_chain_toolkit/supply_toolkit_overview"},"next":{"name":"Transport Message","path":"/supply_chain_toolkit/transport_message"}},"lastUpdated":"2026-04-21T13:56:54.866Z"}}