Sensitivity Analysis Experiment

This experiment helps you to explore how sensitive are the simulation results to changes of the model parameters. The experiment runs the model multiple times varying one of the parameters and shows how the simulation output depends on it. For a single value type of output the chart “output vs parameter” is displayed. If the simulation output is a dataset (e.g. dynamics of a certain process in time), a series of curves is shown on one chart for comparison.

AnyLogic supports multicore processors. When you start sensitivity analysis experiment, AnyLogic automatically detects the number of available cores and runs several iterations in parallel on different processor cores. Thereby performance is multiply increased and the experiment is performed significantly quicker than on processor with a single core.

Creating a sensitivity analysis experiment

To create a sensitivity analysis experiment
  1. In the Projects view, right-click (Mac OS: Ctrl+click) the model item and choose New >  Experiment from the popup menu. The New Experiment dialog box is displayed.
  1. Choose  Sensitivity Analysis option in the Experiment Type list.
  2. Type the experiment name in the Name edit box.
  3. Choose the top-level agent of the experiment from the Top-level agent drop-down list.
  4. If you want to apply model time settings from another experiment, leave the Copy model time settings from check box selected and choose the experiment in the drop-down list to the right.
  5. Click Next to go to the next page of the wizard.
  6. Here you choose the parameter you wish to vary and the way it is varied. The parameter you want to vary is selected in the Varied parameter drop-down list. Below this control you choose the way this parameter will be varied. 
  7. If you set your parameters to be Freeform varied, you should specify any stochastic expression evaluating the parameter value in the Expression field. It can be either a fixed value, or an expression evaluating the actual parameter value.In the Expression field of the use index to refer the iteration number (0,1,2,…).
  8. Otherwise, if you set your parameters to be Varied in range, you should define Min, Max and Step values for the varied parameter.
  9. Click Next to go to the Charts page of the wizard. Here you specify the charts that will display the simulation output. Each chart is defined in a separate row of the table: you should define Title, Type and Expression for each chart. Available types of charts are: dataset charts for datasets and scalar XY charts for scalar values of the varied parameter. You can use root in Expression.
  10. Click Finish.



Name – The name of the experiment.
 Since AnyLogic generates Java class for each experiment, please follow Java naming guidelines and start the name with an uppercase letter. 

Ignore – If selected, the experiment is excluded from the model.

Top-level agent – Using the drop-down list, choose the top-level agent type for the experiment. The agent of this type will play a role of a root for the hierarchical tree of agents in your model.

Maximum available memory – The maximum size of Java heap allocated for the model.

Create default UI – The button creates the default UI for the experiment. 
 Please do not press this button since it will delete the experiment UI created by the wizard and will create the default UI for optimization experiment that may not correspond to your task.


Varied in range – If selected, you should explicitly define the range of values for each parameter you want to vary. Namely, you define minimum and maximum values for a parameter and also the step this parameter will increase its value to reach the maximum.

Freeform – If selected, model is run for the fixed number of iterations you specify and the parameter values are calculated according to the expressions you define. Using the index keyword in the parameter value expression you can refer to the current model run number. Thus this mode also allows defining dependencies between the parameter value and other parameters and/or the number of the current model run.

Parameters – Here the user defines the set of varied parameters. The table lists all the parameters of the top level agent. To make a parameter a decision variable, click in the Type field and choose range there. If it is a numeric parameter, then specify the range for the parameter. Enter the parameter’s lower bound in the Min field, the parameter’s upper bound in the Max field, and specify the increment value in the Step field. 

Model time

Stop – Defines, whether the model will Stop at specified timeStop at specified date, or it will Never stop. In the first two cases, the stop time is specified using the Stop time/Stop date controls.

Start time – The initial time for the simulation time horizon.

Start date – The initial calendar date for the simulation time horizon.

Stop time – The final time for the simulation time horizon (the number of model time units for model to run before it will be stopped).

Stop date – The initial calendar date for the simulation time horizon.

Additional experiment stop conditions  – Here you can define any number of additional experiment stop conditions. When any of these conditions will become true, experiment will be stopped. Condition can include checks of dataset mean confidence, variable values, etc. The top-level agent of the experiment can be accessed here as root, so if you want e.g. to stop the experiment when the variable plainVar of the experiment's top-level agent steps over the threshold, type here, say, root.plainVar>11. To make the condition active, select the checkbox in the corresponding row of the table.


Random number generator –  Here you specify, whether you want to initialize random number generator for this model randomly or with some fixed seed. This makes sense for stochastic models. Stochastic models require a random seed value for the pseudorandom number generator. In this case model runs cannot be reproduced since the model random number generator is initialized with different values for each model run. Specifying the fixed seed value, you initialize the model random number generator with the same value for each model run, thus the model runs are reproducible. Moreover, here you can substitute AnyLogic default RNG with your own RNG.

Random seed (unique simulation runs) – If selected, the seed value of the random number generator is random. In this case random number generator is initialized with the same value for each model run, and the model runs are unique (non-reproducible).

Fixed seed (reproducible simulation runs) – If selected, the seed value of the random number generator is fixed (specify it in the Seed value field). In this case random number generator is initialized with the same value for each model run, and the model runs are reproducible.

Custom generator (subclass of Random) – If for any reason you are not satisfied with the quality of the default random number generator Random, you can substitute it with your own one. Just prepare your custom RNG (it should be a subclass of the Java class Random, e.g. MyRandom), choose this particular option and type the expression returning an instance of your RNG in the field on the right, for example: new MyRandom() or new MyRandom( 1234 ) You can find more information here.

Selection mode for simultaneous events – Here you can choose the order of execution for simultaneous events (that occur at the same moment of model time). Choose from:


Use replications – if selected, the OptQuest Engine will run several replications per one simulation.

Fixed number of replications – if selected, fixed number of replications will be run per each simulation.  

Replications per iteration – [enabled if Fixed number of replications is set] the fixed number of replications, which will be run per each simulation. 

Varying number of replications (stop replications after minimum replications, when confidence level is reached) – if selected, varying number of replications will be run per each simulation. When running a varying number of replications, you will specify minimum and maximum number of replications to be run. The OptQuest Engine will always run the minimum number of replications for a solution. OptQuest then determines if more replications are needed. The OptQuest Engines stops evaluating a solution when one of the following occurs:

Minimum replications  – [enabled if Varying number of replications is set] – the minimum number of replications the OptQuest Engine will always run per one simulation.

Maximum replications  – [enabled if Varying number of replications is set] – the maximum number of replications the OptQuest Engine can run per one simulation.

Confidence level  – [enabled if Varying number of replications is set] – the confidence level to be evaluated for the objective.

Error percent  – [enabled if Varying number of replications is set] –  the percent of the objective for which the confidence level is determined.


Window properties define the appearance of the model window, that will be shown, when the user starts the experiment. Note that the size of the experiment window is defined using the model frame and applies to all experiments and agent types of the model

Title – The title of the model window.

Enable zoom and panning – If selected, the user will be allowed to pan and zoom the model window.

Enable developer panel – Select/clear the checkbox to enable/disable the developer panel in the model window.

Show developer panel on start – [Enabled only if the Enable developer panel checkbox is selected] If selected, the developer panel will be shown by default in the model window every time you run the experiment.

Java actions

Initial experiment setup – The code executed on experiment setup.

Before each experiment run – The code executed before each simulation run.

Before simulation run – The code executed before simulation run. This code is run on setup of the model. At this moment the top-level agent of the model is already created, but the model is not started yet. You may perform here some actions with elements of the top-level agent, e.g assign actual parameter values here.

After simulation run – The code executed after simulation run. This code is executed when simulation engine finishes the model execution (Engine.finished() function is called). This code is not executed when you stop your model by clicking the Terminate execution button.

After iteration – The code executed after iteration run.

After experiment – The code executed after experiment run.

Advanced Java

Imports sectionimport statements needed for correct compilation of the experiment class' code. When Java code is generated, these statements are inserted before definition of the Java class.

Additional class code – Arbitrary member variables, nested classes, constants and methods are defined here. This code will be inserted into the experiment class definition. You can access these class data members anywhere within this experiment. 

Java machine arguments – Specify here Java machine arguments you want to apply on launching your model. You can find the detailed information on possible arguments at Java Sun Microsystems web site:

Command-line arguments – Here you can specify command line arguments you want to pass to your model. You can get the values of passed argument values in the experiment's Additional class code using the method String[] getCommandLineArguments()


Allow parallel evaluations – If the option is selected and the processor has several cores, AnyLogic will run several experiment iterations in parallel on different processor cores. Thereby performance is multiply increased and the experiment is performed significantly quicker. This feature is made controllable because in some rare cases parallel evaluations may affect the optimizer strategy so that more iterations are required to find the optimal solution.
Do not use static variables, collections, table functions and custom distributions (check that their advanced option Static is deselected), if you turn on parallel evaluations here.

Load top-level agent from snapshot – If selected, the experiment will load the model state from the snapshot file specified in the control to the right. The experiment will be started from the time when the model state was saved.