example_python.py

 1"""
 2Created on 20 dec. 2010
 3
 4This file illustrated the use the EMA classes for a contrived example
 5It's main purpose has been to test the parallel processing functionality
 6
 7.. codeauthor:: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl>
 8"""
 9
10from ema_workbench import Model, RealParameter, ScalarOutcome, ema_logging, perform_experiments
11
12
13def some_model(x1=None, x2=None, x3=None):
14    return {"y": x1 * x2 + x3}
15
16
17if __name__ == "__main__":
18    ema_logging.LOG_FORMAT = "[%(name)s/%(levelname)s/%(processName)s] %(message)s"
19    ema_logging.log_to_stderr(ema_logging.INFO)
20
21    model = Model("simpleModel", function=some_model)  # instantiate the model
22
23    # specify uncertainties
24    model.uncertainties = [
25        RealParameter("x1", 0.1, 10),
26        RealParameter("x2", -0.01, 0.01),
27        RealParameter("x3", -0.01, 0.01),
28    ]
29    # specify outcomes
30    model.outcomes = [ScalarOutcome("y")]
31
32    results = perform_experiments(model, 100)