Skip to content

Commit e9c59e9

Browse files
committed
Finish testing
1 parent 3fd3605 commit e9c59e9

File tree

3 files changed

+114
-18
lines changed

3 files changed

+114
-18
lines changed

simulation/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
from .config import state_base, params_base, experiments_map
1+
from .config import (
2+
state_base,
3+
params_base,
4+
experiments_map,
5+
state_test1,
6+
params_test1,
7+
params_test2,
8+
)
29
from .preprocessing import compute_starting_total_length, check_d_probability
310
from .postprocessing import (
411
post_processing_function,

simulation/config/params.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99

1010
params_test1 = deepcopy(params_base)
1111
params_test1["DUMMY D Probability"] = 1
12+
params_test1["FP DUMMY Length-1 DEF Control Action"] = (
13+
"DUMMY Length-1 DEF D Probability Option"
14+
)
15+
1216

1317
params_test2 = deepcopy(params_base)
1418
params_test2["DUMMY D Probability"] = 0
19+
params_test2["FP DUMMY Length-1 DEF Control Action"] = (
20+
"DUMMY Length-1 DEF D Probability Option"
21+
)

tests/DUMMY Economic Test.ipynb

Lines changed: 99 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,112 @@
44
"cell_type": "code",
55
"execution_count": 1,
66
"metadata": {},
7-
"outputs": [
8-
{
9-
"ename": "AssertionError",
10-
"evalue": "Bring in a test state and test parameter set",
11-
"output_type": "error",
12-
"traceback": [
13-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
14-
"\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)",
15-
"Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28;01mFalse\u001b[39;00m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mBring in a test state and test parameter set\u001b[39m\u001b[38;5;124m\"\u001b[39m\n",
16-
"\u001b[0;31mAssertionError\u001b[0m: Bring in a test state and test parameter set"
17-
]
18-
}
19-
],
7+
"outputs": [],
8+
"source": [
9+
"import sys\n",
10+
"import os\n",
11+
"\n",
12+
"sys.path.append(os.path.abspath('..'))\n",
13+
"\n",
14+
"\n",
15+
"from simulation import (params_test2, params_test1, state_test1, params_base, state_base, compute_starting_total_length, check_d_probability, post_processing_function,\n",
16+
" percent_ending_in_d_metric, average_d_count_metric, plot_length_single_simulation)\n",
17+
"\n",
18+
"#from math_spec_mapping import load_from_json\n",
19+
"\n",
20+
"# For development purposes\n",
21+
"sys.path.append(os.path.abspath('../..'))\n",
22+
"from MSML.src.math_spec_mapping import (load_from_json)\n",
23+
"\n",
24+
"from copy import deepcopy\n",
25+
"from src import math_spec_json\n",
26+
"\n",
27+
"ms = load_from_json(deepcopy(math_spec_json))\n",
28+
"\n",
29+
"blocks = [\"DUMMY Control Wiring\"] * 100\n",
30+
"\n"
31+
]
32+
},
33+
{
34+
"cell_type": "markdown",
35+
"metadata": {},
2036
"source": [
21-
"assert False, \"Bring in a test state and test parameter set that has 100% D and 0% D\"\n",
22-
"assert False, \"Also start time at T=100 and make sure time is appropriately updated\""
37+
"Time will be 200 instead of 100 for the first two experiments because of the test state setting as starting at time = 100"
2338
]
2439
},
2540
{
2641
"cell_type": "code",
27-
"execution_count": null,
42+
"execution_count": 2,
2843
"metadata": {},
2944
"outputs": [],
30-
"source": []
45+
"source": [
46+
"experiment = {\"Name\": \"Test 1\",\n",
47+
" \"Param Modifications\": None,\n",
48+
" \"State Modifications\": None,\n",
49+
" \"Blocks\": blocks}\n",
50+
"\n",
51+
"state, params, msi, df, metrics= ms.run_experiment(experiment,\n",
52+
" params_test1,\n",
53+
" state_test1,\n",
54+
" post_processing_function,\n",
55+
" state_preperation_functions=[compute_starting_total_length],\n",
56+
" parameter_preperation_functions=[check_d_probability],\n",
57+
" metrics_functions=[percent_ending_in_d_metric,\n",
58+
" average_d_count_metric])\n",
59+
"\n",
60+
"assert metrics.to_dict() == {'Percent Ending in D': 1.0, 'Average D Count': 50.5}\n",
61+
"assert state[\"Time\"] == 200"
62+
]
63+
},
64+
{
65+
"cell_type": "code",
66+
"execution_count": 3,
67+
"metadata": {},
68+
"outputs": [],
69+
"source": [
70+
"experiment = {\"Name\": \"Test 2\",\n",
71+
" \"Param Modifications\": None,\n",
72+
" \"State Modifications\": None,\n",
73+
" \"Blocks\": blocks}\n",
74+
"\n",
75+
"state, params, msi, df, metrics= ms.run_experiment(experiment,\n",
76+
" params_test2,\n",
77+
" state_test1,\n",
78+
" post_processing_function,\n",
79+
" state_preperation_functions=[compute_starting_total_length],\n",
80+
" parameter_preperation_functions=[check_d_probability],\n",
81+
" metrics_functions=[percent_ending_in_d_metric,\n",
82+
" average_d_count_metric])\n",
83+
"\n",
84+
"\n",
85+
"assert metrics.to_dict() == {'Percent Ending in D': 0, 'Average D Count': 0}\n",
86+
"assert state[\"Time\"] == 200"
87+
]
88+
},
89+
{
90+
"cell_type": "code",
91+
"execution_count": 6,
92+
"metadata": {},
93+
"outputs": [],
94+
"source": [
95+
"experiment = {\"Name\": \"Baseline\",\n",
96+
" \"Param Modifications\": None,\n",
97+
" \"State Modifications\": None,\n",
98+
" \"Blocks\": blocks}\n",
99+
"\n",
100+
"state, params, msi, df, metrics= ms.run_experiment(experiment,\n",
101+
" params_base,\n",
102+
" state_base,\n",
103+
" post_processing_function,\n",
104+
" state_preperation_functions=[compute_starting_total_length],\n",
105+
" parameter_preperation_functions=[check_d_probability],\n",
106+
" metrics_functions=[percent_ending_in_d_metric,\n",
107+
" average_d_count_metric])\n",
108+
"\n",
109+
"\n",
110+
"assert metrics.to_dict()['Average D Count'] >= 0 and metrics.to_dict()['Average D Count'] <= 50.5\n",
111+
"assert state[\"Time\"] == 100"
112+
]
31113
},
32114
{
33115
"cell_type": "code",

0 commit comments

Comments
 (0)