public static bool RunSubletyExperiment(Excel.Application app, Excel.Workbook wbh, int nboots, double significance, double threshold, UserSimulation.Classification c, Random r, String outfile, long max_duration_in_ms, String logfile, ProgBar pb, bool ignore_parse_errors)
{
pb.setMax(5);
// record intitial state of spreadsheet
var prepdata = Prep.PrepSimulation(app, wbh, pb, ignore_parse_errors);
// init error generator
var eg = new ErrorGenerator();
// get inputs as an array of addresses to facilitate random selection
// DATA INPUTS ONLY
AST.Address[] inputs = prepdata.dag.terminalInputCells();
for (int i = 0; i < 100; i++)
{
// randomly choose a *numeric* input
// TODO: use Fischer-Yates and take values until
// either we have a satisfactory input value or none
// remain
var rnd_addrs = inputs.Shuffle().ToList();
bool num_found = false;
String input_string;
double input_value;
AST.Address rand_addr;
do
{
// randomly choose an address; if there are none left, fail
if (rnd_addrs.Count == 0)
{
return(false);
}
rand_addr = rnd_addrs.First();
rnd_addrs = rnd_addrs.Skip(1).ToList();
// get the value
input_string = prepdata.original_inputs[rand_addr];
// try parsing it
if (Double.TryParse(input_string, out input_value))
{
num_found = true;
}
} while (!num_found);
// perturb it
String erroneous_input = eg.GenerateSubtleErrorString(input_value, c);
// create an error dictionary with this one perturbed value
var errors = new CellDict();
errors.Add(rand_addr, erroneous_input);
// run simulations; simulation code does insertion of errors and restore of originals
RunSimulation(app, wbh, nboots, significance, threshold, c, r, outfile, max_duration_in_ms, logfile, pb, prepdata, errors);
}
return(true);
}