Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warning and dtype issue in flu_example.py #235

Merged
merged 1 commit into from
Apr 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions ema_workbench/examples/flu_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
"""
import matplotlib.pyplot as plt
import numpy as np
from numpy import sin, min
from scipy import exp
from numpy import sin, min, exp

from ema_workbench import Model, RealParameter, TimeSeriesOutcome, perform_experiments, ema_logging
from ema_workbench import MultiprocessingEvaluator
from ema_workbench import MultiprocessingEvaluator, SequentialEvaluator
from ema_workbench.analysis import lines, Density

# =============================================================================
Expand Down Expand Up @@ -137,7 +136,7 @@ def flu_model(

# --End of Initialization--

Max_infected = 0
Max_infected = 0.0

for time in range(int(INITIAL_TIME / TIME_STEP), int(FINAL_TIME / TIME_STEP)):
runTime.append(runTime[-1] + TIME_STEP)
Expand Down Expand Up @@ -285,20 +284,22 @@ def flu_model(

normal_immune_population_fraction_region_2 = switch_immunity_cap * min(
(
sin((time * TIME_STEP / 2) + 1.5)
* additional_seasonal_immune_population_fraction_R2
/ 2
)
+ (
(
(2 * permanent_immune_population_fraction_R2)
+ additional_seasonal_immune_population_fraction_R2
sin((time * TIME_STEP / 2) + 1.5)
* additional_seasonal_immune_population_fraction_R2
/ 2
)
/ 2
),
(
permanent_immune_population_fraction_R1
+ additional_seasonal_immune_population_fraction_R1
+ (
(
(2 * permanent_immune_population_fraction_R2)
+ additional_seasonal_immune_population_fraction_R2
)
/ 2
),
(
permanent_immune_population_fraction_R1
+ additional_seasonal_immune_population_fraction_R1
),
),
) + (
(1 - switch_immunity_cap)
Expand Down Expand Up @@ -451,9 +452,11 @@ def flu_model(

nr_experiments = 500

with MultiprocessingEvaluator(model) as evaluator:
with SequentialEvaluator(model) as evaluator:
results = perform_experiments(model, nr_experiments, evaluator=evaluator)

print("laat")

lines(
results,
outcomes_to_show="deceased_population_region_1",
Expand Down