{"data":{"markdownRemark":{"html":"<h1 id=\"post\"><a href=\"#post\" 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>POST</h1>\n<p>Creates and runs a model sampler simulation and returns the object with its various attributes.</p>\n<h2 id=\"request\"><a href=\"#request\" 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>Request</h2>\n<p class=\"code-header\">Example request body</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">curl</span> -X POST \\\n  http://localhost:8080/api/simulations/model-sampler \\\n  -H <span class=\"token string\">'Cache-Control: no-cache'</span> \\\n  -H <span class=\"token string\">'Content-Type: application/json'</span> \\\n  -d <span class=\"token string\">'{\n  \"modelName\": \"Simple Credit Card\",\n  \"outputPath\":\"/tmp/sampler\",\n  \"modelSampler\": {\n      \"dimensions\": {\n        \"interest\":[0.01,0.02,0.03],\n        \"spending\":{\n          \"min\":100,\n          \"max\":500\n          }\n      },\n      \"seeds\":[123456, 987645],\n      \"nbSamples\":3,\n      \"nbTicks\":5\n  }\n}'</span></code></pre></div>\n<div class=\"ui segment warning message\">\n<h4>Windows user File</h4>\n Characters need to be escaped when using model sampler in windows on cmd.\n<p> <code class=\"language-text\">&#39;{&quot;name&quot;: &quot;Game of Life&quot;}&#39;</code> must become <code class=\"language-text\">&#39;{\\&quot;name\\&quot;: \\&quot;Game of Life\\&quot;}&#39;</code></p>\n</div>\n<h3 id=\"body-schema\"><a href=\"#body-schema\" 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>Body Schema</h3>\n<table class=\"ui basic table\">\n<thead>\n<tr>\n<th>Parameter</th>\n<th>Type</th>\n<th>Required</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>modelName</td>\n<td>string</td>\n<td>true</td>\n<td>Name of model to run a model sampler for</td>\n</tr>\n<tr>\n<td>outputPath</td>\n<td>String</td>\n<td>true</td>\n<td>Where to output the model sampler data.</td>\n</tr>\n<tr>\n<td>modelSampler</td>\n<td>object</td>\n<td>true</td>\n<td>Parameters of the model sampler</td>\n</tr>\n<tr>\n<td>>dimensions</td>\n<td>object</td>\n<td>true</td>\n<td>The dimensions that will be used for parameters sampling. The name should correspond the model inner parameters.</td>\n</tr>\n<tr>\n<td>>seeds</td>\n<td>array</td>\n<td></td>\n<td>The seeds used for the runs. The size of the array determine the number of runs.</td>\n</tr>\n<tr>\n<td>>mcCount</td>\n<td>Integer</td>\n<td></td>\n<td>The number of Monte-Carlo run per sample.</td>\n</tr>\n<tr>\n<td>>nbTicks</td>\n<td>Integer</td>\n<td>true</td>\n<td>How long to run each simulation of the model sampler for</td>\n</tr>\n<tr>\n<td>>nbSamples</td>\n<td>Long</td>\n<td>true</td>\n<td>The number of samples to create from the dimensions values.</td>\n</tr>\n</tbody>\n</table>\n<div class=\"ui segment info message\">\n<p>The parameters <strong>mcCount</strong> and <strong>seeds</strong> both represents the number of run per sample. However, <strong>mcCount</strong> offer no control over the seeds generation.\nThe seeds will be generated using an internal prng. If you wish to control the specific seeds used, then provide the SDK with the <strong>seeds</strong> parameter. </p>\n<p>Only one should be provided. If both are provided but <strong>mcCount</strong> does not match <strong>seeds</strong>' size, an error will be thrown.</p>\n</div>\n<p class=\"code-header\">Example request body with inline definition for the model sampler </p>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property\">\"modelName\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Simple Credit Card\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"outputPath\"</span><span class=\"token operator\">:</span><span class=\"token string\">\"/tmp/sampler\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"modelSampler\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token property\">\"dimensions\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n        <span class=\"token property\">\"interest\"</span><span class=\"token operator\">:</span><span class=\"token punctuation\">[</span><span class=\"token number\">0.01</span><span class=\"token punctuation\">,</span><span class=\"token number\">0.02</span><span class=\"token punctuation\">,</span><span class=\"token number\">0.03</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\n        <span class=\"token property\">\"spending\"</span><span class=\"token operator\">:</span><span class=\"token punctuation\">{</span>\n          <span class=\"token property\">\"min\"</span><span class=\"token operator\">:</span><span class=\"token number\">100</span><span class=\"token punctuation\">,</span>\n          <span class=\"token property\">\"max\"</span><span class=\"token operator\">:</span><span class=\"token number\">500</span>\n        <span class=\"token punctuation\">}</span>\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"seeds\"</span><span class=\"token operator\">:</span><span class=\"token punctuation\">[</span><span class=\"token number\">123456</span><span class=\"token punctuation\">,</span> <span class=\"token number\">987645</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"nbSamples\"</span><span class=\"token operator\">:</span><span class=\"token number\">3</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"nbTicks\"</span><span class=\"token operator\">:</span><span class=\"token number\">5</span>\n  <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p class=\"code-header\">Example of a request body with model sampler definition from input</p>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property\">\"modelName\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Simple Credit Card\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"outputPath\"</span><span class=\"token operator\">:</span><span class=\"token string\">\"/tmp/sampler\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"modelSampler\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"path/to/input.json\"</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>The content of <code class=\"language-text\">input.json</code> should be the same as the one given in the inline definition.</p>\n<h3 id=\"dimensions-input-format\"><a href=\"#dimensions-input-format\" 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>Dimensions input format</h3>\n<p>\nThe input for a dimension can either be:\n<ul>\n<li>An array of values </li>\n<li>A range which the model sampler tool will sample from</li>\n</ul>\n</div>\n<p>When using bounded range, the current method for parameters sampling will be a Latin Hypercube Sampler.</p>\n<p>When using arrays of values as inputs, the parameters sets will be built in an iterative manner. As an example, with the following inputs:</p>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n    <span class=\"token property\">\"interest\"</span><span class=\"token operator\">:</span><span class=\"token punctuation\">[</span><span class=\"token number\">0.01</span><span class=\"token punctuation\">,</span><span class=\"token number\">0.02</span><span class=\"token punctuation\">,</span><span class=\"token number\">0.03</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"spending\"</span><span class=\"token operator\">:</span><span class=\"token punctuation\">[</span><span class=\"token number\">100</span><span class=\"token punctuation\">,</span><span class=\"token number\">200</span><span class=\"token punctuation\">,</span><span class=\"token number\">300</span><span class=\"token punctuation\">]</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<p>The resulting parameters sets for the model would be:</p>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n    <span class=\"token property\">\"1\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token property\">\"interest\"</span><span class=\"token operator\">:</span> <span class=\"token number\">0.1</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"spending\"</span><span class=\"token operator\">:</span> <span class=\"token number\">100</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"2\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token property\">\"interest\"</span><span class=\"token operator\">:</span> <span class=\"token number\">0.2</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"spending\"</span><span class=\"token operator\">:</span> <span class=\"token number\">200</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n    <span class=\"token property\">\"3\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token property\">\"interest\"</span><span class=\"token operator\">:</span> <span class=\"token number\">0.3</span><span class=\"token punctuation\">,</span>\n      <span class=\"token property\">\"spending\"</span><span class=\"token operator\">:</span> <span class=\"token number\">300</span>\n    <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n</p>\n<div class=\"ui segment warning message\">\nWhen working with Spark multi-run, the model sampler file should be on HDFS. Consequentely the path should start with: \"hdfs://[...]\".\n</div>\n<h2 id=\"response\"><a href=\"#response\" 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>Response</h2>\n<table class=\"ui basic table\">\n<thead>\n<tr>\n<th>Status</th>\n<th>Meaning</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>200</td>\n<td><a href=\"https://tools.ietf.org/html/rfc7231#section-6.3.1\">OK</a></td>\n<td>Successfully created. The session ID is returned in a cookie named <code>simudyneSessionID</code>. You need to include this cookie in subsequent get requests.</td>\n</tr>\n<tr>\n<td>404</td>\n<td><a href=\"https://tools.ietf.org/html/rfc7231#section-6.5.4\">Not Found</a></td>\n<td>Simulation not found.</td>\n</tr>\n</tbody>\n</table>\n<h3 id=\"response-schema\"><a href=\"#response-schema\" 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>Response Schema</h3>\n<p>Status Code <strong>200</strong></p>\n<table class=\"ui basic table\">\n<thead>\n<tr>\n<th>Name</th>\n<th>Type</th>\n<th>Required</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>id</td>\n<td>string(uuid)</td>\n<td>true</td>\n<td></td>\n</tr>\n<tr>\n<td>name</td>\n<td>string</td>\n<td>true</td>\n<td></td>\n</tr>\n<tr>\n<td>description</td>\n<td>string</td>\n<td>true</td>\n<td></td>\n</tr>\n<tr>\n<td>public</td>\n<td>boolean</td>\n<td>true</td>\n<td></td>\n</tr>\n<tr>\n<td>session</td>\n<td>string(uuid)</td>\n<td>true</td>\n<td>simudyneSessionID cookie</td>\n</tr>\n<tr>\n<td>kind</td>\n<td>string</td>\n<td>true</td>\n<td></td>\n</tr>\n</tbody>\n</table>\n<p class=\"code-header\">Example 200 response body</p>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n  <span class=\"token property\">\"id\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"d7558ad9-3405-4a4c-972a-531a87fdcd27\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Game of Life\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"description\"</span><span class=\"token operator\">:</span>\n    <span class=\"token string\">\"The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970.\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"public\"</span><span class=\"token operator\">:</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"session\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"760b2d3e-20b2-42e6-9655-58e662e79e73\"</span><span class=\"token punctuation\">,</span>\n  <span class=\"token property\">\"kind\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"pojo\"</span>\n<span class=\"token punctuation\">}</span></code></pre></div>\n<br> \n<p>Status Code <strong>404</strong></p>\n<table class=\"ui basic table\">\n<thead>\n<tr>\n<th>Name</th>\n<th>Type</th>\n<th>Required</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>message</td>\n<td>string</td>\n<td>true</td>\n</tr>\n</tbody>\n</table>\n<p class=\"code-header\">Example 404 response body</p>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre class=\"language-json\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\n    <span class=\"token property\">\"message\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"SimulationRegistry: Could not find requested simulation default.\"</span>\n<span class=\"token punctuation\">}</span></code></pre></div>","headings":[{"value":"POST","depth":1},{"value":"Request","depth":2},{"value":"Body Schema","depth":3},{"value":"Dimensions input format","depth":3},{"value":"Response","depth":2},{"value":"Response Schema","depth":3}],"frontmatter":{"title":"/api/simulations/model-sampler","toc":null,"experimental":null}},"site":{"siteMetadata":{"title":"Simudyne Docs","latestVersion":"2.6"}}},"pageContext":{"absolutePath":"/home/vsts/work/1/s/content/2.2/rest_api/model_sampler/api_simulations_model-sampler.md","versioned":true,"version":"2.2","kind":"rest_api","pagePath":"/rest_api/model_sampler/api_simulations_model-sampler","chronology":{"prev":{"name":"Model sampler Rest API","path":"/rest_api/model_sampler"},"next":{"name":"/api/simulations/model-sampler/{id}","path":"/rest_api/model_sampler/api_simulations_model-sampler_id"}},"lastUpdated":"2026-04-21T13:56:54.839Z"}}