コード例 #1
0
        public void UpdateRoutes(Graph graph, GTSPSolver solver)
        {
            var constrainedSol = solution[agentConstrained];
            int offsetTime     = 0;

            for (int i = 0; i < constrainedSol.Length; i++)
            {
                if (i > 0)
                {
                    offsetTime += constrainedSol[i - 1].Length;
                }
                constrainedSol[i].startTime = offsetTime;
                constrainedSol[i]           = solver.SolveGTSP(graph, constraints[agentConstrained], orders[agentConstrained][i], offsetTime);
            }

            // Calculate solution cost as a sum of costs of tours
            for (int i = 0; i < solution.Length; i++)
            {
                for (int j = 0; j < solution[i].Length; j++)
                {
                    this.cost += solution[i][j].Length;
                }
            }

            // Sum constraints count as a tie breaking heristic for CBS
            int constr = 0;

            for (int i = 0; i < constraints.Length; i++)
            {
                constr += constraints[i].Count;
            }
            this.cost = (cost << 10) + constr;
        }
コード例 #2
0
        protected ConstraintSolver(WarehouseInstance instance)
        {
            this.instance       = instance;
            this.agents         = instance.AgentCount;
            this.nodesVisitors0 = new List <int> [instance.graph.vertices.Count];
            this.nodesVisitors1 = new List <int> [instance.graph.vertices.Count];
            for (int i = 0; i < nodesVisitors0.Length; i++)
            {
                nodesVisitors0[i] = new List <int>();
                nodesVisitors1[i] = new List <int>();
            }

            GTSPSolver.FindMaxValues(instance.orders, out int maxClasses,
                                     out int maxItems, out int maxOrders, out int maxSolverTime);
            solver  = new GTSPSolver(maxClasses, maxItems, maxSolverTime);
            maxTime = maxSolverTime * maxOrders;
        }
コード例 #3
0
        public void CalculateInitRoutes(Graph graph, GTSPSolver solver)
        {
            int offsetTime = 0;

            for (int i = 0; i < solution.Length; i++)
            {
                for (int j = 0; j < solution[i].Length; j++)
                {
                    if (j > 0)
                    {
                        offsetTime += solution[i][j - 1].Length;
                    }
                    solution[i][j] = solver.SolveGTSP(graph, constraints[i], orders[i][j], offsetTime);
                    this.cost     += solution[i][j].Length;
                }
                offsetTime = 0;
            }
        }