/api/simulations/model-sampler

Last updated on 16th July 2024

POST

Creates and runs a model sampler simulation and returns the object with its various attributes.

Request

Example request body

curl -X POST \
  http://localhost:8080/api/simulations/model-sampler \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
  "modelName": "Simple Credit Card",
  "outputPath":"/tmp/sampler",
  "modelSampler": {
      "dimensions": {
        "interest":[0.01,0.02,0.03],
        "spending":{
          "min":100,
          "max":500
          }
      },
      "seeds":[123456, 987645],
      "nbSamples":3,
      "nbTicks":5
  }
}'

Windows user File

Characters need to be escaped when using model sampler in windows on cmd.

'{"name": "Game of Life"}' must become '{\"name\": \"Game of Life\"}'

Body Schema

Parameter Type Required Description
modelName string true Name of model to run a model sampler for
outputPath String true Where to output the model sampler data.
modelSampler object true Parameters of the model sampler
>dimensions object true The dimensions that will be used for parameters sampling. The name should correspond the model inner parameters.
>seeds array The seeds used for the runs. The size of the array determine the number of runs.
>mcCount Integer The number of Monte-Carlo run per sample.
>nbTicks Integer true How long to run each simulation of the model sampler for
>nbSamples Long true The number of samples to create from the dimensions values.

The parameters mcCount and seeds both represents the number of run per sample. However, mcCount offer no control over the seeds generation. The seeds will be generated using an internal prng. If you wish to control the specific seeds used, then provide the SDK with the seeds parameter.

Only one should be provided. If both are provided but mcCount does not match seeds' size, an error will be thrown.

Example request body with inline definition for the model sampler

{
  "modelName": "Simple Credit Card",
  "outputPath":"/tmp/sampler",
  "modelSampler": {
      "dimensions": {
        "interest":[0.01,0.02,0.03],
        "spending":{
          "min":100,
          "max":500
        }
      },
      "seeds":[123456, 987645],
      "nbSamples":3,
      "nbTicks":5
  }
}

Example of a request body with model sampler definition from input

{
  "modelName": "Simple Credit Card",
  "outputPath":"/tmp/sampler",
  "modelSampler": "path/to/input.json"
}

The content of input.json should be the same as the one given in the inline definition.

Dimensions input format

The input for a dimension can either be:

  • An array of values
  • A range which the model sampler tool will sample from