private ScatterSearch CreateScatterSearchVRPSample() {
      #region Problem Configuration
      var provider = new SolomonInstanceProvider();
      var instance = provider.GetDataDescriptors().Single(x => x.Name == "C101");
      VehicleRoutingProblem vrpProblem = new VehicleRoutingProblem();
      vrpProblem.Load(provider.LoadData(instance));
      #endregion

      #region Algorithm Configuration
      ScatterSearch ss = new ScatterSearch();
      ss.Engine = new SequentialEngine.SequentialEngine();
      ss.Name = "Scatter Search - VRP";
      ss.Description = "A scatter search algorithm which solves the \"C101\" vehicle routing problem (imported from Solomon)";
      ss.Problem = vrpProblem;

      var improver = ss.Problem.Operators.OfType<VRPIntraRouteImprovementOperator>().First();
      improver.ImprovementAttemptsParameter.Value.Value = 15;
      improver.SampleSizeParameter.Value.Value = 10;
      ss.Improver = improver;

      var pathRelinker = ss.Problem.Operators.OfType<VRPPathRelinker>().First();
      pathRelinker.IterationsParameter.Value.Value = 25;
      ss.PathRelinker = pathRelinker;

      var similarityCalculator = ss.SimilarityCalculatorParameter.ValidValues.OfType<VRPSimilarityCalculator>().First();
      ss.SimilarityCalculator = similarityCalculator;

      ss.MaximumIterations.Value = 2;
      ss.PopulationSize.Value = 20;
      ss.ReferenceSetSize.Value = 10;
      ss.Seed.Value = 0;
      return ss;
      #endregion
    }
Ejemplo n.º 2
0
        private GeneticAlgorithm CreateGaVrpSample()
        {
            GeneticAlgorithm ga = new GeneticAlgorithm();

            #region Problem Configuration
            VehicleRoutingProblem vrpProblem = new VehicleRoutingProblem();

            SolomonFormatInstanceProvider instanceProvider = new SolomonInstanceProvider();
            CVRPTWData data = instanceProvider.Import(@"Test Resources\C101.txt", @"Test Resources\C101.opt.txt") as CVRPTWData;
            vrpProblem.Load(data);
            vrpProblem.Name        = "C101 VRP (imported from Solomon)";
            vrpProblem.Description = "Represents a Vehicle Routing Problem.";
            CVRPTWProblemInstance instance = vrpProblem.ProblemInstance as CVRPTWProblemInstance;
            instance.DistanceFactor.Value   = 1;
            instance.FleetUsageFactor.Value = 100;
            instance.OverloadPenalty.Value  = 100;
            instance.TardinessPenalty.Value = 100;
            instance.TimeFactor.Value       = 0;
            vrpProblem.MaximizationParameter.Value.Value = false;
            instance.UseDistanceMatrix.Value             = true;
            instance.Vehicles.Value = 25;
            #endregion
            #region Algorithm Configuration
            ga.Name        = "Genetic Algorithm - VRP";
            ga.Description = "A genetic algorithm which solves the \"C101\" vehicle routing problem (imported from Solomon)";
            ga.Problem     = vrpProblem;
            SamplesUtils.ConfigureGeneticAlgorithmParameters <TournamentSelector, MultiVRPSolutionCrossover, MultiVRPSolutionManipulator>(
                ga, 100, 1, 1000, 0.05, 3);

            var xOver = (MultiVRPSolutionCrossover)ga.Crossover;
            foreach (var op in xOver.Operators)
            {
                xOver.Operators.SetItemCheckedState(op, false);
            }
            xOver.Operators.SetItemCheckedState(xOver.Operators
                                                .OfType <PotvinRouteBasedCrossover>()
                                                .Single(), true);
            xOver.Operators.SetItemCheckedState(xOver.Operators
                                                .OfType <PotvinSequenceBasedCrossover>()
                                                .Single(), true);

            var manipulator = (MultiVRPSolutionManipulator)ga.Mutator;
            foreach (var op in manipulator.Operators)
            {
                manipulator.Operators.SetItemCheckedState(op, false);
            }
            manipulator.Operators.SetItemCheckedState(manipulator.Operators
                                                      .OfType <PotvinOneLevelExchangeMainpulator>()
                                                      .Single(), true);
            manipulator.Operators.SetItemCheckedState(manipulator.Operators
                                                      .OfType <PotvinTwoLevelExchangeManipulator>()
                                                      .Single(), true);
            #endregion

            return(ga);
        }
Ejemplo n.º 3
0
    private GeneticAlgorithm CreateGaVrpSample() {
      GeneticAlgorithm ga = new GeneticAlgorithm();

      #region Problem Configuration
      VehicleRoutingProblem vrpProblem = new VehicleRoutingProblem();

      SolomonFormatInstanceProvider instanceProvider = new SolomonInstanceProvider();
      CVRPTWData data = instanceProvider.Import(@"Test Resources\C101.txt", @"Test Resources\C101.opt.txt") as CVRPTWData;
      vrpProblem.Load(data);
      vrpProblem.Name = "C101 VRP (imported from Solomon)";
      vrpProblem.Description = "Represents a Vehicle Routing Problem.";
      CVRPTWProblemInstance instance = vrpProblem.ProblemInstance as CVRPTWProblemInstance;
      instance.DistanceFactor.Value = 1;
      instance.FleetUsageFactor.Value = 100;
      instance.OverloadPenalty.Value = 100;
      instance.TardinessPenalty.Value = 100;
      instance.TimeFactor.Value = 0;
      vrpProblem.MaximizationParameter.Value.Value = false;
      instance.UseDistanceMatrix.Value = true;
      instance.Vehicles.Value = 25;
      #endregion
      #region Algorithm Configuration
      ga.Name = "Genetic Algorithm - VRP";
      ga.Description = "A genetic algorithm which solves the \"C101\" vehicle routing problem (imported from Solomon)";
      ga.Problem = vrpProblem;
      SamplesUtils.ConfigureGeneticAlgorithmParameters<TournamentSelector, MultiVRPSolutionCrossover, MultiVRPSolutionManipulator>(
        ga, 100, 1, 1000, 0.05, 3);

      var xOver = (MultiVRPSolutionCrossover)ga.Crossover;
      foreach (var op in xOver.Operators) {
        xOver.Operators.SetItemCheckedState(op, false);
      }
      xOver.Operators.SetItemCheckedState(xOver.Operators
        .OfType<PotvinRouteBasedCrossover>()
        .Single(), true);
      xOver.Operators.SetItemCheckedState(xOver.Operators
        .OfType<PotvinSequenceBasedCrossover>()
        .Single(), true);

      var manipulator = (MultiVRPSolutionManipulator)ga.Mutator;
      foreach (var op in manipulator.Operators) {
        manipulator.Operators.SetItemCheckedState(op, false);
      }
      manipulator.Operators.SetItemCheckedState(manipulator.Operators
        .OfType<PotvinOneLevelExchangeMainpulator>()
        .Single(), true);
      manipulator.Operators.SetItemCheckedState(manipulator.Operators
        .OfType<PotvinTwoLevelExchangeManipulator>()
        .Single(), true);
      #endregion

      return ga;
    }
Ejemplo n.º 4
0
        private TabuSearch CreateTabuSearchVrpSample()
        {
            TabuSearch ts = new TabuSearch();

            #region Problem Configuration
            var provider = new AugeratInstanceProvider();
            var instance = provider.GetDataDescriptors().Where(x => x.Name == "A-n62-k8").Single();
            VehicleRoutingProblem vrpProblem = new VehicleRoutingProblem();
            vrpProblem.Load(provider.LoadData(instance));
            #endregion
            #region Algorithm Configuration
            ts.Name        = "Tabu Search - VRP";
            ts.Description = "A tabu search algorithm that solves the \"A-n62-k8\" VRP (imported from Augerat)";
            ts.Problem     = vrpProblem;

            ts.MaximumIterations.Value = 200;
            // move generator has to be set first
            var moveGenerator = ts.MoveGeneratorParameter.ValidValues
                                .OfType <PotvinCustomerRelocationExhaustiveMoveGenerator>()
                                .Single();
            ts.MoveGenerator = moveGenerator;
            var moveEvaluator = ts.MoveEvaluatorParameter.ValidValues
                                .OfType <PotvinCustomerRelocationMoveEvaluator>()
                                .Single();
            ts.MoveEvaluator = moveEvaluator;
            var moveMaker = ts.MoveMakerParameter.ValidValues
                            .OfType <PotvinCustomerRelocationMoveMaker>()
                            .Single();
            ts.MoveMaker             = moveMaker;
            ts.SampleSize.Value      = 1000;
            ts.Seed.Value            = 0;
            ts.SetSeedRandomly.Value = true;

            var tabuChecker = ts.TabuCheckerParameter.ValidValues
                              .OfType <PotvinCustomerRelocationMoveTabuCriterion>()
                              .Single();
            tabuChecker.UseAspirationCriterion.Value = false;
            ts.TabuChecker = tabuChecker;

            var tabuMaker = ts.TabuMakerParameter.ValidValues
                            .OfType <PotvinCustomerRelocationMoveTabuMaker>()
                            .Single();
            ts.TabuMaker        = tabuMaker;
            ts.TabuTenure.Value = 6;

            #endregion
            ts.Engine = new ParallelEngine.ParallelEngine();
            return(ts);
        }
    private TabuSearch CreateTabuSearchVrpSample() {
      TabuSearch ts = new TabuSearch();
      #region Problem Configuration
      var provider = new AugeratInstanceProvider();
      var instance = provider.GetDataDescriptors().Where(x => x.Name == "A-n62-k8").Single();
      VehicleRoutingProblem vrpProblem = new VehicleRoutingProblem();
      vrpProblem.Load(provider.LoadData(instance));
      #endregion
      #region Algorithm Configuration
      ts.Name = "Tabu Search - VRP";
      ts.Description = "A tabu search algorithm that solves the \"A-n62-k8\" VRP (imported from Augerat)";
      ts.Problem = vrpProblem;

      ts.MaximumIterations.Value = 200;
      // move generator has to be set first
      var moveGenerator = ts.MoveGeneratorParameter.ValidValues
        .OfType<PotvinCustomerRelocationExhaustiveMoveGenerator>()
        .Single();
      ts.MoveGenerator = moveGenerator;
      var moveEvaluator = ts.MoveEvaluatorParameter.ValidValues
        .OfType<PotvinCustomerRelocationMoveEvaluator>()
        .Single();
      ts.MoveEvaluator = moveEvaluator;
      var moveMaker = ts.MoveMakerParameter.ValidValues
        .OfType<PotvinCustomerRelocationMoveMaker>()
        .Single();
      ts.MoveMaker = moveMaker;
      ts.SampleSize.Value = 1000;
      ts.Seed.Value = 0;
      ts.SetSeedRandomly.Value = true;

      var tabuChecker = ts.TabuCheckerParameter.ValidValues
        .OfType<PotvinCustomerRelocationMoveTabuCriterion>()
        .Single();
      tabuChecker.UseAspirationCriterion.Value = false;
      ts.TabuChecker = tabuChecker;

      var tabuMaker = ts.TabuMakerParameter.ValidValues
        .OfType<PotvinCustomerRelocationMoveTabuMaker>()
        .Single();
      ts.TabuMaker = tabuMaker;
      ts.TabuTenure.Value = 6;

      #endregion
      ts.Engine = new ParallelEngine.ParallelEngine();
      return ts;
    }
Ejemplo n.º 6
0
        private ScatterSearch CreateScatterSearchVRPSample()
        {
            #region Problem Configuration
            var provider = new SolomonInstanceProvider();
            var instance = provider.GetDataDescriptors().Single(x => x.Name == "C101");
            VehicleRoutingProblem vrpProblem = new VehicleRoutingProblem();
            vrpProblem.Load(provider.LoadData(instance));
            #endregion

            #region Algorithm Configuration
            ScatterSearch ss = new ScatterSearch();
            ss.Engine      = new SequentialEngine.SequentialEngine();
            ss.Name        = "Scatter Search - VRP";
            ss.Description = "A scatter search algorithm which solves the \"C101\" vehicle routing problem (imported from Solomon)";
            ss.Problem     = vrpProblem;

            var improver = ss.Problem.Operators.OfType <VRPIntraRouteImprovementOperator>().First();
            improver.ImprovementAttemptsParameter.Value.Value = 15;
            improver.SampleSizeParameter.Value.Value          = 10;
            ss.Improver = improver;

            var pathRelinker = ss.Problem.Operators.OfType <VRPPathRelinker>().First();
            pathRelinker.IterationsParameter.Value.Value = 25;
            ss.PathRelinker = pathRelinker;

            var similarityCalculator = ss.SimilarityCalculatorParameter.ValidValues.OfType <VRPSimilarityCalculator>().First();
            ss.SimilarityCalculator = similarityCalculator;

            ss.MaximumIterations.Value = 2;
            ss.PopulationSize.Value    = 20;
            ss.ReferenceSetSize.Value  = 10;
            ss.Seed.Value = 0;
            return(ss);

            #endregion
        }