public static void RunIntroOptimization() { var solutionSpace = new IntervalBranch(0, 3.2); var bb = new SIDBranchAndBound <double>(solutionSpace, FitnessFunctions.ExampleFunction, GuidingParameter.OneOverNthQuantile); var result = bb.BranchAndBound(200, 8, 0.99, false, false); Program.logger.WriteLine("Intro Optimization Results:"); for (int i = 0; i < result.Length; i++) { Program.logger.WriteLine($"{i}: {result[i].ToString()}"); } }
public static void RunEggholderOptimization() { var solutionSpace = new RectangleBranch(-512, 512, -512, 512); // Constraints const int sampleSize = 200; const double confidenceLevel = 0.99; const int numSteps = 6; var bb = new SIDBranchAndBound <Tuple <double, double> >(solutionSpace, x => FitnessFunctions.EggHolder(x.Item1, x.Item2), GuidingParameter.OneOverNthQuantile); var result = bb.BranchAndBound(sampleSize, numSteps, confidenceLevel, false, false); Program.logger.WriteLine($"Eggholder Size {sampleSize} Confidence {confidenceLevel} Optimization Results:"); for (int i = 0; i < result.Length; i++) { Program.logger.WriteLine($"{i}: {result[i].ToString()}"); } }
public static void RunWickedCombOptimization() { var solutionSpace = new IntervalBranch(-0.15, 0.15); // Constraints const double difficulty = 5; const double xSquaredCoefficient = 10; const int sampleSize = 200; const double confidenceLevel = 0.99; const int numSteps = 15; var bb = new SIDBranchAndBound <double>(solutionSpace, x => FitnessFunctions.WickedComb(x, difficulty, xSquaredCoefficient), GuidingParameter.OneOverNthQuantile); var result = bb.BranchAndBound(sampleSize, numSteps, confidenceLevel, false, false); Program.logger.WriteLine($"Wicked Comb (x, {difficulty}, {xSquaredCoefficient}) Size {sampleSize} Confidence {confidenceLevel} Optimization Results:"); for (int i = 0; i < result.Length; i++) { Program.logger.WriteLine($"{i}: {result[i].ToString()}"); } }
public static void RunEMSOptimization() { EMSOptimizationOverhaul.Program.ImportData(3); // Use both years of data //var solutionSpace = new OneDimInterval(start: 2, end: 4, SampleSize: 100, rand: rand); //var solutionSpace = new TwoDimInterval(StartX: -10, EndX: 10, StartY: -10, EndY: 10, SampleSize: 30, rand: rand); var solutionSpace = new PartialEMSPlanBranch( //CurrentPlanFullAmbs: new int[] { 2, 0, 1, 0, 0, 0, 1, 1, 0, 2 }, // CK, Crum, Dun, EL, FtG, KenSub, Lav, Pri, SpV, Wayne FullAmbs: new int[Station.List.Count], PartAmbs: new int[Station.List.Count], TargetAmbulanceCount: 10, rand: Program.rand); var Problem = new SIDBranchAndBound <Tuple <int[], int[]> >(solutionSpace, FitnessFunctions.EMSPlanFitness, GuidingParameter.OneOverNthQuantile); Logging.Log("Problem Initialized"); Branch[] branchSet = Problem.BranchAndBound(sampleSize: 5000, iterations: 9, confidenceLevel: 0.99, cullDuplicates: true, multiThread: true); // Print the set of branches produced by the B&B routine foreach (Branch branch in branchSet) { Program.logger.WriteLine(""); var plan = (PartialEMSPlanBranch)branch; Program.logger.WriteLine("Region: "); for (int i = 0; i < Station.List.Count; i++) { Program.logger.Write($"Station: {Station.List[i].Name} Full: {plan.FullAmbs[i]} Part: {plan.PartAmbs[i]}"); } //Console.WriteLine($"Best score: {branch.BestObservation}"); //bestObserved = Math.Min(bestObserved, branch.BestObservation); } // Do an exhaustive search of the reduced search space to find the set of optima //double bestObserved = double.PositiveInfinity; // ... Program.logger.WriteLine(""); Program.logger.WriteLine($"Best observed in all regions :{Problem.BestElementObserved} fitness: {Problem.BestFitnessObserved}"); }