private static ISolver LocalSearchNewStopConditions() { GreedyFastHeuristic randomSolver = new GreedyFastHeuristic() { MaxOverfillUnits = 0, }; CompoundSolver compundSolver = new CompoundSolver() { MaxLoops = 7, DiagnosticMessages = true, }; LocalSearch solver = new LocalSearch() { ScoringFunction = new Scorer(), DiagnosticMessages = true, PropagateRandomSeed = true, NumberOfNoGoodActionsToStop = 10, TimeLimit = new TimeSpan(0, 1, 0), BestFactoryAdjustmentParam = 0.2, NeighberhoodAdjustmentParam = 0.2, ImprovementOverNarrowNeighb = 2, Description = "local_search_new_stop_condition_1", }; solver.InitialSolvers.Add(randomSolver); solver.InitialSolvers.Add(compundSolver); return(solver); }
public void GreedyFastHeuristicSolveDay3ChannelInstance() { var file = Properties.Resources.day_DS_D_DH_inst; var reader = new InstanceJsonSerializer { Reader = new StreamReader(new MemoryStream(file), Encoding.UTF8) }; Instance instance = reader.DeserializeInstance(); GreedyFastHeuristic solver = new GreedyFastHeuristic() { Instance = instance, Seed = 10, ScoringFunction = new Scorer(), MaxOverfillUnits = 1, }; solver.Solve(); InstanceJsonSerializer serializer = new InstanceJsonSerializer() { Path = @"results\day_DS_D_DH_sol_greedyfastheur.json" }; serializer.SerializeSolution(solver.Solution, SolutionSerializationMode.DebugTaskData); var taskStats = solver.Solution.AdOrdersScores; solver.ScoringFunction.AssesSolution(solver.Solution); Assert.IsTrue(taskStats.Values.Sum(d => d.SelfIncompatibilityConflictsProportion) == 0); Assert.IsTrue(taskStats.Values.Sum(d => d.SelfSpacingConflictsProportion) == 0); Assert.IsTrue(taskStats.Values.Sum(d => d.OwnerConflictsProportion) == 0); Assert.IsTrue(taskStats.Values.Sum(d => d.BreakTypeConflictsProportion) == 0); }
private static ISolver InsertionStartEndingDeleteConfiguration() { GreedyFastHeuristic randomSolver = new GreedyFastHeuristic(); ViewsHeuristic insertionHeuristic = new ViewsHeuristic() { MaxBreakExtensionUnits = 40, MaxLoops = 6, MaxInsertedPerBreak = 5, }; BeginingsHeuristic beginingsHeuristic = new BeginingsHeuristic() { MaxLoops = 6, MaxBreakExtensionUnits = 999, }; EndingsHeuristic endingHeuristic = new EndingsHeuristic() { MaxLoops = 6, MaxBreakExtensionUnits = 999, }; FreeSpaceHeuristic freeSpaceHeuristic = new FreeSpaceHeuristic() { ScoringFunction = new Scorer(), MaxLoops = 6, PropagateRandomSeed = true, Seed = 10, DiagnosticMessages = true, Description = "views_starts_ends_trim_heuristic", }; freeSpaceHeuristic.InitialSolvers.Add(randomSolver); freeSpaceHeuristic.InitialSolvers.Add(insertionHeuristic); freeSpaceHeuristic.InitialSolvers.Add(beginingsHeuristic); freeSpaceHeuristic.InitialSolvers.Add(endingHeuristic); return(freeSpaceHeuristic); }
private static ISolver SimulatedAnnealingGenerator() { GreedyFastHeuristic randomSolver = new GreedyFastHeuristic() { MaxOverfillUnits = 0, DiagnosticMessages = true, }; CompoundSolver compundSolver = new CompoundSolver() { MaxLoops = 7, DiagnosticMessages = true, }; SimulatedAnnealing simulatedAnnealing = new SimulatedAnnealing() { DiagnosticMessages = true, ScoringFunction = new Scorer(), StepsAnalyzedWithoutImprovementToStop = 200, NumberOfLoopsWithoutActionsToStop = 1, PropagateRandomSeed = true, Seed = 100, Description = "SimulatedAnnealing", IntegrityLossMultiplier = 1000.0, }; simulatedAnnealing.InitialSolvers.Add(randomSolver); simulatedAnnealing.InitialSolvers.Add(compundSolver); return(simulatedAnnealing); }
private static ISolver LocalSearchEvolutionaryInitial() { GreedyFastHeuristic randomSolver = new GreedyFastHeuristic() { MaxOverfillUnits = 0, }; CompoundSolver compundSolver = new CompoundSolver() { MaxLoops = 3, }; LocalSearch solver = new LocalSearch() { PropagateRandomSeed = true, NumberOfNoGoodActionsToStop = 7, BestFactoryAdjustmentParam = 0.1, NeighberhoodAdjustmentParam = 0.1, ImprovementOverNarrowNeighb = 1.5, TimeLimit = new TimeSpan(0, 5, 0), DiagnosticMessages = true, ReportTimeouts = true, }; solver.MoveFactories = new List <ITransformationFactory> { new InsertFactory() { MildlyRandomOrder = true, PositionsCountLimit = 3, MaxTasksChecked = 1, MaxBreaksChecked = 1, IgnoreBreaksWhenUnitOverfillAbove = 60, IgnoreCompletedTasks = true, IgnoreTasksWithCompletedViews = false, AlwaysReturnStartsAndEnds = true, }, new RandomDeleteFactory() { MovesReturned = 20, RampUpSpeed = 3.0, }, new RandomInsertFactory() { MovesReturned = 20, RampUpSpeed = 3.0, }, new RandomSwapFactory() { MovesReturned = 40, RampUpSpeed = 4.0, }, }; solver.InitialSolvers.Add(randomSolver); solver.InitialSolvers.Add(compundSolver); return(solver); }
private static ISolver LocalSearchNewStopConditions2() { GreedyFastHeuristic randomSolver = new GreedyFastHeuristic() { MaxOverfillUnits = 0, DiagnosticMessages = true, }; CompoundSolver compundSolver = new CompoundSolver() { MaxLoops = 7, DiagnosticMessages = true, }; LocalSearch solver = new LocalSearch() { ScoringFunction = new Scorer(), DiagnosticMessages = true, PropagateRandomSeed = true, NumberOfNoGoodActionsToStop = 15, BestFactoryAdjustmentParam = 0.2, NeighberhoodAdjustmentParam = 0.2, ImprovementOverNarrowNeighb = 2, TimeLimit = new TimeSpan(0, 5, 0), Description = "local_search_new_stop_condition_15rs4", }; solver.MoveFactories = new List <ITransformationFactory> { new InsertFactory() { MildlyRandomOrder = true, PositionsCountLimit = 4, MaxTasksChecked = 3, MaxBreaksChecked = 3, IgnoreBreaksWhenUnitOverfillAbove = 60, IgnoreCompletedTasks = true, IgnoreTasksWithCompletedViews = false, AlwaysReturnStartsAndEnds = true, }, new RandomDeleteFactory() { MovesReturned = 20, }, new RandomInsertFactory() { MovesReturned = 30, }, new RandomSwapFactory() { MovesReturned = 30, }, }; solver.InitialSolvers.Add(randomSolver); solver.InitialSolvers.Add(compundSolver); return(solver); }
private static ISolver FastRandomGreedyConfig() { GreedyFastHeuristic randomSolver = new GreedyFastHeuristic() { MaxOverfillUnits = -10, ScoringFunction = new Scorer(), PropagateRandomSeed = true, Seed = 10, Description = "heuristic_fast_random", }; return(randomSolver); }
private ISolver CompundNoIncom() { GreedyFastHeuristic randomSolver = new GreedyFastHeuristic() { }; CompoundSolver compundSolver = new CompoundSolver() { ScoringFunction = new Scorer(), MaxLoops = 10, PropagateRandomSeed = true, TimeLimit = new TimeSpan(0, 15, 0), Description = "compund_no_incom", }; compundSolver.InitialSolvers.Add(randomSolver); return(compundSolver); }
private ISolver InitialGood() { GreedyFastHeuristic randomSolver = new GreedyFastHeuristic() { MaxOverfillUnits = 0, }; CompoundSolver compundSolver = new CompoundSolver() { Description = "experiment_initial_new", DiagnosticMessages = true, ScoringFunction = new Scorer(), TimeLimit = new TimeSpan(0, 5, 0), }; compundSolver.InitialSolvers.Add(randomSolver); return(compundSolver); }
public void StartsHeuristicSolveDay3ChannelInstance() { var file = Properties.Resources.day_DS_D_DH_inst; var reader = new InstanceJsonSerializer { Reader = new StreamReader(new MemoryStream(file), Encoding.UTF8) }; Instance instance = reader.DeserializeInstance(); GreedyFastHeuristic fastRandomHeur = new GreedyFastHeuristic() { Seed = 10, MaxOverfillUnits = 1, }; BeginingsHeuristic solver = new BeginingsHeuristic() { Seed = 10, ScoringFunction = new Scorer(), Instance = instance, PropagateRandomSeed = true, MaxBreakExtensionUnits = 30, }; solver.InitialSolvers.Add(fastRandomHeur); solver.Solve(); InstanceJsonSerializer serializer = new InstanceJsonSerializer() { Path = @"results\day_DS_D_DH_sol_startsheur.json" }; serializer.SerializeSolution(solver.Solution, SolutionSerializationMode.DebugTaskData); var taskStats = solver.Solution.AdOrdersScores; Assert.IsTrue(taskStats.Values.Sum(d => d.SelfIncompatibilityConflictsProportion) == 0); Assert.IsTrue(taskStats.Values.Sum(d => d.SelfSpacingConflictsProportion) == 0); Assert.IsTrue(taskStats.Values.Sum(d => d.OwnerConflictsProportion) == 0); Assert.IsTrue(taskStats.Values.Sum(d => d.BreakTypeConflictsProportion) == 0); }