<!-- Yes, this website is "inspired" by scikit-learn website. Thank you -->
<htmlxmlns="http://www.w3.org/1999/xhtml">
<HTML>
<head>
<TITLE>
JSON Single Server Example
</TITLE>
</head>
<BODY>
<H1>JSON Single Server Example</H1>
<P>This example provides the same model as in <ahref="server.html">ManPy Single Server Example</a>,
but now the model is built in JSON and passed to ManPy as an argument.</P>
<P>The full JSON input of the model is given in \dream\simulation\Examples\SingleServerModelInput.json.
Under node we have the simulation objects that correspond to Figure 2. For example, the Exit is defined as:</P>
<pre><code>
"E1": {
"_class": "Dream.Exit",
"name": "Exit"
}
</code></pre>
<P>Every entry in node describes one object and the key (e.g. “E1”) is the id of
the ManPy object that should be unique (no two nodes with the same id). The value is a JSON object that contains all the attributes.
For E1 we have only two:</P>
<ul>
<li>class points to the ManPy class of the object. “Dream” is used as a convention to point to dream\simulation where generic ManPy components are. Nonetheless, an absolute path can also be used, e.g. dream.simulation.Exit.Exit (since Exit class is in dream\simulation\Exit.py) </li>
<li>name: contains the name of the object.</li>
</ul>
<P>In other elements we may have to input more parameters. For example in Queue we have the capacity:</P>
<pre><code>
"Q1": {
"_class": "Dream.Queue",
"capacity": 1,
"name": "Queue"
}
</code></pre>
<P>For the Machine we need to define the processing time. This is given below:</P>
<pre><code>
"M1": {
"_class": "Dream.Machine",
"name": "Machine",
"processingTime": {
"Fixed": {
"mean": 0.25
}
}
}
</code></pre>
<P>Note that the distribution is defined similarly to the style of when defining distributions using ManPy through Python
(see <ahref="server.html">ManPy Single Server Example</a>).</P>
<P>Similarly we define the inter-arrival time for the source:P>
<pre><code>
"S1": {
"_class": "Dream.Source",
"name": "Source",
"entity": "Dream.Part",
"interArrivalTime": {
"Fixed": {
"mean": 0.5
}
}
}
</code></pre>
<P>Under edge the connections between the object in the style of arrows are defined. Below we give example of an edge:</P>
<pre><code>
"2": {
"_class": "Dream.Edge",
"source": "Q1",
"destination": M1
}
</code></pre>
<P>Again, the key of the object is the id of the edge that should be unique (no two edges with the same id).
_class defines the class of the node. The default value is Dream.Edge.
source defines the object that the edge starts from and destination the object that it points to. </P>
<P>Finally, generic information about the model is defined in general:</P>
<pre><code>
"general": {
"maxSimTime": 1440,
"numberOfReplications": 1,
"trace": "No"
}
</code></pre>
<P>The above definition dictates that we have one replication of 1440 time units. No trace will be returned.</P>
<P>Passing this JSON to dream\simulation\LineGenerationJSON.py,
the ManPy model is run and the result is returned.
The full result is in \dream\simulation\Examples\SingleServerModelReuslt.json.</P>
<P>In the elementList we can see results that all simulation components return. For the Exit for example it is:</P>
<pre><code>
{
"_class": "Dream.Exit",
"id": "E1",
"family": "Exit",
"results": {
"throughput": [
2880
],
"takt_time": [
0.49991319444444443
],
"lifespan": [
0.25
]
}
}
</code></pre>
<P>Note the family attribute. This can help if external software wants to group object types (
e.g. Exit and ExitJobShop) and process the results they return similarly.</P>
<P>All results like throughput are given in a list so that if we have many replications the results of all runs are returned.</P>
<P>Some objects can output specific stats only if the user sets a flag on. So for the Queue we can set gatherWipStat to 1 like below:</P>