-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparameters.py
135 lines (111 loc) · 4.57 KB
/
parameters.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import importlib.util
import logging
import os
import sys
import numpy as np
import pandas as pd
import scipy.stats as stats
logger = logging.getLogger(__name__)
# What to run in main
# 'BAYES_OPT' | 'EXPERIMENT_3' | 'PRECOMPUTE' | 'MULTI_OBJECTIVE_BAYES_OPT'
main_func = 'EXPERIMENT_3'
seed = 0xBE_BAD_BAE
# Naive weights
penalty_weights = None
# Experiment 3 timing
simulation_time = {'warm_up': 7 * 6 * 4,
'horizon': 7 * 6 * 5,
'cool_down': 0}
# Anticpation for usability
anticipation = [True, False, False]
# No anticipation
# anticipation = False
# Anticipation and forecasting
# anticipation = [True, True, True]
pop_phen_configs = dict()
# Experiment 3
dummy_demand = dict()
# For precompute
# dummy_demand = dict(excess_supply=0)
inventory = {
'appointments': stats.randint(33, 34),
'units_per_appointment': stats.randint(10, 11),
'stock': stats.randint(3500, 3501),
'starting_inventory': 30_000 - 3500,
'scd_requests_ratio': 330 / 3500,
'initial_age_dist': 'data/inventory/initial_age_distribution.tsv',
}
rules = ['Extended']
replications = 1
cpus = 1
exp2 = None
stock_measurement = {
'watched_antigens': np.array([114688, 114688, 114688, 114688, 114688, 114688, 114688, 114688, 31744, 128, 64, 192, 31936]),
'watched_phenotypes': np.array([0, 16384, 32768, 49152, 65536, 81920, 98304, 114688, 21504, 0, 0, 0, 21504]),
'watched_phenotypes_names': ['O-', 'O+', 'B-', 'B+', 'A-', 'A+', 'AB-', 'AB+', 'R0', 'Fya-', 'Fyb-', 'Fya-_Fyb-', 'R0_Fya-_Fyb-'],
}
forecasting = {
'units_days': 1,
'requests_days': 3,
'units_shows': 1, # Fraction of forecasted units that actually show up
'requests_shows': 1 # Fraction of forecasted requests that actually show up
}
pre_compute_folder = 'out/experiments/exp3/precompute/20230711-14-53/' # Where to save precomputed data or read from
ab_datafile = 'data/antibody_frequencies/bayes_alloAb_frequencies.tsv'
bayes_opt = {
'init_points_count': 5,
'num_iterations': 5,
'replications': replications,
'num_objectives': 3,
'iteration_chunks': 5,
'gp_mean': None,
'variable_names': ['immunogenicity', 'usability', 'substitutions', 'fifo', 'young_blood'],
# For fixed variables use a dictionary with the variable name as key and the value as value
# 'fixed_variables': {'young_blood': 0.0},
'objective_name': ['alloimmunisations'],
# Options for objective names: 'alloimmunisations', 'scd_shortages', 'O_level',
# 'O_neg_level', 'O_pos_level', 'O_level',
# 'D_subs_num_patients', 'ABO_subs_num_patients', 'ABOD_subs_num_patients'
'objective_names': ['alloimmunisations', 'scd_shortages', 'O_level'],
'objective_directions': ['MIN', 'MIN', 'MAX'],
'normalized_kernel': True,
}
solver = 'maxflow' # 'pot' or 'ortools' or ('maxflow' or 'ortools-maxflow)
constraints = {
'max_age': 35, # Shelf life
'max_young_blood': 14,
'yb_constraint': True,
'substitution_weight_equal': True
}
computation_times = False
## The following code block is used to import parameters from a file passed as a command line argument
## It should only be used in the main parameter file
## Which is at `BSCSimulator/experiments/parameters.py`
## It should not be used in any other file,
## as it will cause a recursion loop and error
if len(sys.argv) > 1:
try:
print(f'Parameter file passed: {sys.argv[1]}')
pfile_path = os.path.realpath(os.path.expanduser(sys.argv[1]))
pfile = os.path.split(pfile_path)[1]
spec = importlib.util.spec_from_file_location(pfile[:-3], pfile_path)
imported_param = importlib.util.module_from_spec(spec)
spec.loader.exec_module(imported_param)
globals().update(imported_param.__dict__)
except IndexError as e:
logger.exception('No parameter file passed. Using default parameters.')
print('No parameter file passed. Using default parameters.')
except FileNotFoundError as e:
logger.exception(
f'Parameter file {pfile} not found. Using default parameters.')
print(f'Parameter file {pfile} not found. Using default parameters.')
except ImportError as e:
logger.exception(
f'Parameter file {pfile} is not a valid python file. Using default parameters.')
print(
f'Parameter file {pfile} is not a valid python file. Using default parameters.')
except Exception as e:
logger.exception(
f'Error while importing parameter file {pfile}. Using default parameters.')
print(
f'Error while importing parameter file {pfile}. Using default parameters.')