Beispiel #1
0
        private void Recalculate()
        {
            if (!testing)
            {
                return;
            }
            G = new Graph();
            CapacitatedVehicleRoutingProblem problem = CapacitatedVehicleRoutingProblem.FromFile("Benchmarks/A-n53-k7.vrp");
            var nodes = problem.NodeProvider.GetNodes();

            for (int i = 0; i < nodes.Count; i++)
            {
                TspLibNet.Graph.Nodes.Node2D node = (TspLibNet.Graph.Nodes.Node2D)nodes[i];
                double  demand = problem.DemandProvider.GetDemand(nodes[i]);
                Vertice v      = new Vertice();
                v.X      = node.X;
                v.Y      = node.Y;
                v.Demand = demand;
                G.Vertices.Add(v);
            }
            G.RecalculateVertices();
            solution = G.FindDVRPSolution();
            double usage = G.CalculateUsage(solution);

            textBox1.Text = usage.ToString();
        }
Beispiel #2
0
        private static void RunCalculation(string file, string timeStamp)
        {
            TspFile tspfile = TspFile.Load(file);
            CapacitatedVehicleRoutingProblem problem = CapacitatedVehicleRoutingProblem.FromFile(file);
            Graph Graph = new Graph(_maxDemand: tspfile.Capacity);
            var   nodes = problem.NodeProvider.GetNodes();

            for (int i = 0; i < nodes.Count; i++)
            {
                TspLibNet.Graph.Nodes.Node2D node = (TspLibNet.Graph.Nodes.Node2D)nodes[i];
                double  demand = problem.DemandProvider.GetDemand(nodes[i]);
                Vertice v      = new Vertice();
                v.X      = node.X;
                v.Y      = node.Y;
                v.Demand = demand;
                Graph.Vertices.Add(v);
            }
            Graph.RecalculateVertices();
            var maxDistance = Graph.Edges.SelectMany(x => x).Max(x => x.Weigth) * 200;

            Graph.maxDistance = maxDistance;
            var    solution  = Graph.FindDVRPSolution();
            double usage     = Graph.CalculateUsage(solution);
            string paramsCSV = file + "," + Graph.GetParamsCSV() + ",\"" + tspfile.Comment + "\"," + usage + "\n";

            System.IO.File.AppendAllText(@"Benchmarks" + timeStamp + ".csv", paramsCSV);
        }