示例#1
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
        }