Skip to contents

The service draws n_scenarios scenarios, each a possible outcome of the model's random variables. More scenarios describe the uncertainty more accurately, and take longer to solve. A model whose scenarios are never set is solved over a single scenario, unless an empirical() sample sets the number by its length.

Usage

set_scenarios(m, n_scenarios, seed = NULL)

Arguments

m

A model().

n_scenarios

How many scenarios to draw, at least 1.

seed

The seed for the draws, at least 1. Left NULL, the model keeps its current seed.

Value

The model, invisibly.

Details

The number of scenarios and the seed belong to the model, so solving the same model again uses the same scenarios, and two solves of it can be compared. The scenarios are drawn by the service, so R's set.seed() has no effect on them.

The service limits the number of scenarios. A model above the limit is refused when it is solved, with a message that states the limit.

Examples

m <- model()
demand <- rand_var(m, "demand", normal(100, 15))
set_scenarios(m, 512, seed = 42)