-
Notifications
You must be signed in to change notification settings - Fork 0
/
dike_model_optimization.py
54 lines (38 loc) · 1.89 KB
/
dike_model_optimization.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from __future__ import (unicode_literals, print_function, absolute_import,
division)
from ema_workbench import (Model, MultiprocessingEvaluator,
ScalarOutcome, IntegerParameter, optimize, Scenario)
from ema_workbench.em_framework.optimization import EpsilonProgress
from ema_workbench.util import ema_logging
from problem_formulation import get_model_for_problem_formulation
import matplotlib.pyplot as plt
import seaborn as sns
if __name__ == '__main__':
ema_logging.log_to_stderr(ema_logging.INFO)
model, steps = get_model_for_problem_formulation(2)
reference_values = {'Bmax': 175, 'Brate': 1.5, 'pfail': 0.5,
'discount rate 0': 3.5, 'discount rate 1': 3.5,
'discount rate 2': 3.5,
'ID flood wave shape': 4}
scen1 = {}
for key in model.uncertainties:
name_split = key.name.split('_')
if len(name_split) == 1:
scen1.update({key.name: reference_values[key.name]})
else:
scen1.update({key.name: reference_values[name_split[1]]})
ref_scenario = Scenario('reference', **scen1)
convergence_metrics = [EpsilonProgress()]
espilon = [1e3] * len(model.outcomes)
nfe = 200 # proof of principle only, way to low for actual use
with MultiprocessingEvaluator(model) as evaluator:
results, convergence = evaluator.optimize(nfe=nfe, searchover='levers',
epsilons=espilon,
convergence=convergence_metrics,
reference=ref_scenario)
fig, (ax1, ax2) = plt.subplots(ncols=2, sharex=True)
fig, ax1 = plt.subplots(ncols=1)
ax1.plot(convergence.epsilon_progress)
ax1.set_xlabel('nr. of generations')
ax1.set_ylabel('$\epsilon$ progress')
sns.despine()