コード例 #1
0
        /// <summary>
        /// Calculates solution to the given problem.
        /// </summary>
        /// <param name="problem"></param>
        /// <param name="min"></param>
        /// <param name="max"></param>
        /// <returns></returns>
        public static int[][] Calculate(OsmSharp.Math.VRP.Core.IProblemWeights problem,
                                        Second min, Second max)
        {
            Problem        local_problem = new LocalProblem(problem, min, max);
            SolverSettings settings      = new SolverSettings(1000, 10, 0, 10, 20, 30);

            return(Facade.Calculate(local_problem, settings, 50));
        }
コード例 #2
0
ファイル: GuidedVNS.cs プロジェクト: yousoftvn/OsmSharp
        /// <summary>
        /// Apply some improvements within one route.
        /// </summary>
        /// <param name="problem"></param>
        /// <param name="route"></param>
        /// <param name="currentWeight"></param>
        private double ImproveIntraRoute(OsmSharp.Math.VRP.Core.IProblemWeights problem, IRoute route,
                                         double currentWeight)
        {
            bool   improvement = true;
            double newWeight   = currentWeight;

            while (improvement)
            { // keep trying while there are still improvements.
                improvement = false;

                // loop over all improvement operations.
                foreach (IImprovement improvementOperation in _intraImprovements)
                { // try the current improvement operations.
                    double difference;
                    if (improvementOperation.Improve(problem, route, out difference))
                    { // there was an improvement.
                        OsmSharp.Logging.Log.TraceEvent("OsmSharp.Routing.VRP.WithDepot.MaxTime.VNS.GuidedVNS", TraceEventType.Information,
                                                        "Intra-improvement found {0} {1}->{2}",
                                                        improvementOperation.Name, newWeight, newWeight + difference);

                        // check if the route is valid.
                        if (!route.IsValid())
                        {
                            throw new Exception();
                        }

                        // update the weight.
                        newWeight = newWeight + difference;

                        improvement = true;

                        break;
                    }
                }
            }
            return(newWeight);
        }
コード例 #3
0
 public LocalProblem(OsmSharp.Math.VRP.Core.IProblemWeights problem,
                     Second min, Second max)
     : base(problem.Size, min, max)
 {
     _problem = problem;
 }