Order of parameters in parameter scan
5 weeks ago by
5 weeks ago by
The order of simulation is the same as outlined in the scan xml file. If you have 3 parameters (A,B,C) and are doing 2 values (1,2) each, the sequence (top to bottom in the xml file) will be;
And there are 2^3=8 total simulations.
CC3D doesn’t do anything in particular to help you tract the results. All the output files are created, and each set is in its own numbered directory. You can examine each of the directories and see what values were used and what the results are but that isn’t very easy.
A better approach is to add code to your model to log all the simulation results into a single output file. You would log the parameters used for a particular run along with one or more results. Can you define a few numeric metrics for a simulation? Perhaps the number of cells at the end of the run, or the number of cells that died during the run. Or, if you are fitting experimental data, a residual error or chi-squared type metric describing how well the particular run reproduced the experimental data. To actually log that data, and preferable to have all the simulation log into the same file, you can add code to a “finish” block of one of your steppables to write the file at the end of the run. Below is sample code to give you an idea how to do it.
def finish(self): # part of one of your python steppables # Finish Function gets called after the last MCS # # Write a small summary of parameter scanning to a file. # Since we want all the simulaltions writing to the same file we # need it in an obvious and unambigous place. Here we assume we can just write # to the Windows’ root directory of c:\ # Buld up a tab-delimited stirng with the scan paramters actually used in this run plus # some measures of the simulation’s results # myParam1,myParam2, ... are the variables being scanned and are probably global # myOutput are the result of some calculation, the number of cells, whatever you want to log outLine = str(myParam1)+"\t"+str(myParam2)+"\t" outLine += str(myParam3)+"\t"+str(myParam4)+"\t" outLine += str(myOutput1)+"\t"+str(myOutput1) # add as many items as you need outline += "\n" # need a trailing line break! #open a file for append, write the string and close the file logfile = open(“C:\\ParmaterScan_log”,'a+') # the ‘a+’ means create if it doesn’t exist, logfile.write(outLine) # append to it otherwise logfile.close()
I’ll leave it to the reader to figure out how to include on the output line the simulation number, that is, the name (which is a number) of the directly where the output corresponding to this particular line in the logfile is stored. You might be able to use the Twedit++ shortcut to get the name of the output directory and just include that on the log file line.
CC3D Python – Python Utilities – Get Full Path of Current File
Please login to add an answer/comment or follow this question.