An expression that contains a random variable has a different value in
each scenario, and is called random. Summarizing it across the scenarios,
for example with expectation(), gives a single number again:
demand - stock is random, expectation(demand - stock) is not, and
neither is 3 * stock.
Details
An objective or a constraint must not be random, and a summary such as
expectation() needs a random expression to summarize. quicopt checks
both rules itself and stops with an error when one is broken, so you need
is_random() only in your own code, for example in a function that
accepts both kinds of expression.