Order of parameters in parameter scan


120
views
0
7 months ago by
I am confused about what is the order in the which the parameters are chosen from the list of parameter scan. Are all parameters varied at the same time randomly or is there a sequence for the variation. I have 8 parameters to be varied and I chose 5 values for each. If I am thinking right, I should get 0 , 1 , 2, 3 ,4 and 5 directories in the output folder. However, how would I be able to know the results correspond to which values of parameters ?
Community: CompuCell3D

1 Answer


3
7 months ago by
The parameter scan task exhaustively enumerates all possible combination of your parameters. 8 parameters with 5 values each is equivalent to an 8-digit base 5 number so there are 5^8=390,625 simulations. If it takes 10 minutes per simulation, then it will take 2,712 days to do them all. As you can see, parameter scanning can rapidly spin up into an intractable number of simulations.

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;

A1B1C1
A2B1C1
A1B2C1
A2B2C1
A1B1C2
A2B1C2
A1B2C2
A2B2C2
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.

Similar posts:
Search »