@Override
	public void run() {
		
		
		
		/////////////////////////////////////////////
		// iterations 0 to max-1
		
		setToleranceAsFraction(initialToleranceFraction);
		bom.resetSummary();
		
		int numIts = 0;
		while (numIts < maxIts) {
			
			if (numIts > 0) {
				// update parameters based on previous results
				bom.updateModelParametersWithGoodResults();
				
				// reduce tolerance
				reduceToleranceByFactor(tolfactor);
			}
			
			// choose parameters for this batch of models
			bom.setup();
			
			// reset results summary statistics for this iteration
			bom.resetSummary();
			
			// run one batch of models
			bom.run();
			
			// harvest good models
			bom.summariseGoodModels();
			
			if (verbose) {
				System.out.println("Iteration "+numIts);
				printSummaryOfResults();
				System.out.println();
				
				/*
				System.out.println("All Result Statistics");
				for (SummaryResultStatistic stat : bom.summariseAllModelResultStatistics()) {
					System.out.println(stat.toString());
				}
				
				System.out.println("All Parameter Estimates");
				for (SummaryResultStatistic stat : bom.summariseAllModelParameterEstimates()) {
					System.out.println(stat.toString());
				}
				*/
			}
			
			if ((rootname != null) && (numIts==0))  {
				outputFile = new TraceFileWriter( path + rootname + ext );
				String header = "#"+this.getClass().getSimpleName()+" seed="+Distributions.getSeed();
				outputFile.writeHeader(header);
			
				String[] colNames = ModelSingleLineOutput.composeValuesHeader("Iteration", "ModelNumber", bom.getModels()[0], bom.getTargetStats());
				outputFile.writeColumnNames(colNames);
			}
			
			// this is not very efficient since the "closeTo" has already been calculated
			if ( outputFile != null ) {
				for (int j = 0; j < bom.getModels().length; j++ ) {
					Model m = bom.getModels()[j];
					outputFile.writeRow(ModelSingleLineOutput.composeValuesLine(numIts, j, m, bom.getTargetStats()));
				}
			}
			
			numIts++;
		}
		
		if (outputFile != null) {
			outputFile.closeFile();
		}
		
	}