-
Notifications
You must be signed in to change notification settings - Fork 125
/
propti_sense.py
67 lines (54 loc) · 2.13 KB
/
propti_sense.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
#!/usr/bin/env python3
import numpy as np
import propti as pr
import pickle
import propti as pr
import logging
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("root_dir", type=str,
help="optimisation root directory")
cmdl_args = parser.parse_args()
setups = None # type: pr.SimulationSetupSet
ops = None # type: pr.ParameterSet
optimiser = None # type: pr.OptimiserProperties
in_file = open('propti.pickle.init', 'rb')
ver, setups, ops, optimiser = pickle.load(in_file)
in_file.close()
# Check if everything is in order
if ops is None:
logging.critical("optimisation parameter are not defined")
if setups is None:
logging.critical("simulation setups are not defined")
if optimiser is None:
logging.critical("optimiser properties are not defined")
# Optimiser to perform FAST sensitivity analysis.
# Use the same data from optimiser for sensitivity analysis
num_subproc = optimiser.num_subprocesses
mpi_bool = optimiser.mpi
backup = optimiser.backup_every
# Compute number of repetitions required
k = len(ops) # total number of optimization params
(M, d) = 3, 2 # M = inference factor, d = freq. step <spotpy defaults>
rep = (1 + 4*(M**2)*(1+(k-2)*d))*k
sensitivity = pr.OptimiserProperties('fast',
repetitions=rep,
backup_every=backup,
db_name="propti_sensitivity_db",
db_type="csv",
num_subprocesses=num_subproc,
mpi=mpi_bool)
print(ver, setups, ops, sensitivity)
'''
Not writing any data to pickle file since there is only
one method to analyse sensitivity. It makes sense to Wiki this instead.
'''
# Write sensitivity pickle file
# out_file = open('propti_sensitivity.pickle.init', 'wb')
# pickle.dump((setups, ops, optimiser), out_file)
# out_file.close()
# Run optimization.
# Output of run_optimisation will be None.
# What are some good parameters that can be printed ?
res = pr.run_optimisation(ops, setups, sensitivity)
# print(res) # output of res is None.