|
4 | 4 | "cell_type": "code",
|
5 | 5 | "execution_count": 1,
|
6 | 6 | "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": {}, |
20 | 36 | "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" |
23 | 38 | ]
|
24 | 39 | },
|
25 | 40 | {
|
26 | 41 | "cell_type": "code",
|
27 |
| - "execution_count": null, |
| 42 | + "execution_count": 2, |
28 | 43 | "metadata": {},
|
29 | 44 | "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 | + ] |
31 | 113 | },
|
32 | 114 | {
|
33 | 115 | "cell_type": "code",
|
|
0 commit comments