quaquel / EMAworkbench

workbench for performing exploratory modeling and analysis
BSD 3-Clause "New" or "Revised" License
128 stars 90 forks source link

Return useful error when sampling multiple policies with no levers defined, or multiple scenarios with no uncertainties defined #290

Closed EwoutH closed 1 year ago

EwoutH commented 1 year ago

The code below will now give an error

raise EMAError(ema_workbench.util.ema_exceptions.EMAError: some fatal error has occurred while running the experiments, not all runs have completed. expected 100, got 0

when the code below is ran.

model = Model("simpleModel", function=some_model)  # instantiate the model

# specify uncertainties
model.uncertainties = [
    RealParameter("x1", 0.1, 10),
    RealParameter("x2", -0.01, 0.01),
    RealParameter("x3", -0.01, 0.01),
]
# specify outcomes
model.outcomes = [ScalarOutcome("y")]

with SequentialEvaluator(model) as evaluator:
    results = evaluator.perform_experiments(scenarios=100, policies=1)

This error comes from the definition of policies=1 while no levers are defined. For clarity, this error message should be refined to return a useful error when sampling one or multiple policies with no levers defined, or one or multiple scenarios with no uncertainties defined.