The value a quantity takes in one particular scenario:
Arguments
- x
A random expression (see
is_random()).- prob
A number above 0 and at most 1. It cannot depend on a decision.
Details
scenario_max(x)is the largest value ofxamong the scenarios. Minimizing it makes the worst scenario as good as possible.scenario_min(x)is the smallest. Maximizing it does the same for a quantity where large is good, such as a profit.scenario_quantile(x, prob)is the value that the shareprobof the scenarios stays at or below. Withn_scenariosscenarios it is theceiling(prob * n_scenarios)-th smallest value, which is whatquantile(x, prob, type = 1)returns for a sample.scenario_quantile(x, 1)isscenario_max(x). For a cost it is also known as the value at risk;cvar()at the same level is the average of the values above it.
These are different from max(), min() and quantile(). max(a, b)
compares two expressions within each scenario, and the result is still
random. scenario_max(x) compares the values of one expression across
the scenarios, and the result is a single number.
A single scenario decides the largest or smallest value, so it changes
more from one sample of scenarios to the next than an average does, and a
larger sample usually contains a more extreme scenario. Check a solution
found with these on new scenarios, with resample().
Examples
m <- model()
stock <- num_var(m, "stock", lower = 0, upper = 200)
demand <- rand_var(m, "demand", normal(100, 15))
set_scenarios(m, 512, seed = 42)
cost <- 3 * stock + 10 * max(demand - stock, 0)
minimize(m, scenario_max(cost)) # the cost of the worst scenario
add(m, scenario_quantile(cost, 0.95) <= 500) # at most 500 in 95% of scenarios