You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
parser.add_argument( 'location', type=str, help='Required: Directory in which the scripts (in tsv format) are all located. OR: File in which each line is the filename of a scripts.tsv file, followed by weight to assign for that file.')
112
122
parser.add_argument( '-n', '--numProcesses', type=int, help='Optional: Number of processes to spawn', default=2 )
113
123
parser.add_argument( '-m', '--model', type=str, help='Optional: Composite model definition file. First searched in directory "location", then in current directory.', default="FindSim_compositeModel_1.g" )
114
-
parser.add_argument( '-p', '--parameter_sweep', nargs='*', default=[], help='Does a parameter sweep in range 0.5-2x of each object.field pair.' )
115
-
parser.add_argument( '-f', '--file', type=str, help='Optional: File name for output of parameter sweep', default="" )
124
+
parser.add_argument( '-p', '--parameter_optimize', nargs='*', default=[], help='Does a parameter optimization for each specified object.field pair.' )
125
+
parser.add_argument( '-ps', '--presettle', nargs=3, default=[], help='Arguments: tsv_file, model_file, settle_time. Obtains values of all concentrations after a specified settle-time, so that all calculations for the optimization runs can be initialized to this presettled value. The tsv_file is to specify which subset of the model_file to use. This option is most useful in costly multiscale models.' )
126
+
parser.add_argument( '-f', '--file', type=str, help='Optional: File name for output of parameter optimization', default=""
127
+
)
116
128
args=parser.parse_args()
117
129
location=args.location
118
130
iflocation[-1] !='/':
@@ -130,13 +142,14 @@ def main():
130
142
pool=Pool( processes=args.numProcesses )
131
143
132
144
results= {}
133
-
foriinargs.parameter_sweep:
145
+
foriinargs.parameter_optimize:
134
146
print( "{}".format( i ) )
135
147
spl=i.split( '.' )
136
148
assert( len(spl) ==2 )
137
149
obj, field=spl
138
-
ev=EvalFunc( i, fnames, weights, pool, modelFile )
139
-
results[i] =optimize.minimize_scalar( ev.doEval )
150
+
ev=EvalFunc( i, fnames, weights, pool, modelFile, args.presettle )
print( "Error: Scale {} out of range".format( scale ) )
550
+
assert( False )
551
+
#assert( scale >= 0.0 and scale <= 100.0 )
549
552
ifparams[1] =='Kd':
550
553
ifnotobj.isA[ "ReacBase" ]:
551
554
raiseSimError( "scaleParam: can only assign Kd to a Reac, was: '{}'".format( obj.className ) )
@@ -1435,11 +1438,19 @@ def main():
1435
1438
parser.add_argument( '-hs', '--hide_subplots', action="store_true", help='Hide subplot output of simulation. By default the graphs include dotted lines to indicate individual quantities (e.g., states of a molecule) that are being summed to give a total response. This flag turns off just those dotted lines, while leaving the main plot intact.' )
1436
1439
parser.add_argument( '-o', '--optimize_elec', action="store_true", help='Optimize electrical computation. By default the electrical computation runs for the entire duration of the simulation. With this flag the system turns off the electrical engine except during the times when electrical stimuli are being given. This can be *much* faster.' )
parser.add_argument( '-settle_time', '--settle_time', type=float, default=0, help='Run model for specified settle time and return dict of {path,conc}.' )
parser=argparse.ArgumentParser( description='Wrapper script to run a lot of FindSim evaluations in parallel.' )
126
-
126
+
parser=argparse.ArgumentParser( description='Script to run a multi-parameter optimization in which each function evaluation is the weighted mean of a set of FindSim evaluations. These evaluations may be run in parallel. The optimiser uses the BGFR method with bounds. Since we are doing relative scaling the bounds are between 0.03 and 30 for Kd, tau and Km, and between 0 and 30 for other parameters' )
127
127
parser.add_argument( 'location', type=str, help='Required: Directory in which the scripts (in tsv format) are all located. OR: File in which each line is the filename of a scripts.tsv file, followed by weight to assign for that file.')
128
128
parser.add_argument( '-n', '--numProcesses', type=int, help='Optional: Number of processes to spawn', default=2 )
129
+
parser.add_argument( '-t', '--tolerance', type=float, help='Optional: Tolerance criterion for completion of minimization', default=1e-4 )
129
130
parser.add_argument( '-m', '--model', type=str, help='Optional: Composite model definition file. First searched in directory "location", then in current directory.', default="FindSim_compositeModel_1.g" )
130
-
parser.add_argument( '-p', '--parameters', nargs='*', default=[], help='Parameter to vary. Each is defined as an object.field pair. The object is defined as a unique MOOSE name, typically name or parent/name. The field is separated from the object by a period. The field may be concInit for molecules, Kf, Kb, Kd or tau for reactions, and Km or Kcat for enzymes. One can specify more than one parameter for a given reaction or enzyme. It is advisable to use Kd and tau for reactions unless you have a unidirectional reaction.' )
131
+
parser.add_argument( '-p', '--parameters', nargs='*', default=[], help='Parameter to vary. Each is defined as an object.field pair. The object is defined as a unique MOOSE name, typically name or parent/name. The field is separated from the object by a period. The field may be concInit for molecules, Kf, Kb, Kd or tau for reactions, and Km or kcat for enzymes. One can specify more than one parameter for a given reaction or enzyme. It is advisable to use Kd and tau for reactions unless you have a unidirectional reaction.' )
131
132
parser.add_argument( '-f', '--file', type=str, help='Optional: File name for output of parameter minimization', default="" )
132
133
args=parser.parse_args()
134
+
133
135
location=args.location
134
136
iflocation[-1] !='/':
135
137
location+='/'
@@ -146,32 +148,92 @@ def main():
146
148
pool=Pool( processes=args.numProcesses )
147
149
148
150
params= []
151
+
bounds= []
149
152
foriinargs.parameters:
150
153
print( "{}".format( i ) )
151
154
spl=i.split( '.' )
152
155
assert( len(spl) ==2 )
153
156
params.append( i )
157
+
ifspl[1] =='Kd'orspl[1] =='tau'orspl[1] =='Km':
158
+
bounds.append( (0.03,30) )
159
+
else:
160
+
bounds.append( (0.0, 30 ) ) # Concs, Kfs and Kbs can be zero.
154
161
ev=EvalFunc( params, fnames, weights, pool, modelFile )
0 commit comments