/// <summary>
        ///
        /// Assumes g of node was already calculated!
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public uint h(WorldState s)
        {
            int sicEstimate = (int)SumIndividualCosts.h(s, this.instance);

            if (sicEstimate == 0)
            {
                return(0);
            }
            int targetCost = s.g + sicEstimate + this.minAboveSic; // Ariel's idea - using SIC directly here to calc the target

            // CBS gets an explicitly partially solved state - the agents' g may be greater than zero.
            // So the cost CBS is going to calc is not of this node but of the initial problem instance,
            // this is accounted for later too.
            // (Notice node usually has a (possibly very wrong) h set already - copied from the parent)
            return(this.h(s, targetCost, sicEstimate));
        }
Example #2
0
        /// <summary>
        /// Construct with chosen algorithms.
        /// </summary>
        public Run()
        {
            this.watch = Stopwatch.StartNew();

            // Preparing the heuristics:
            heuristics = new List <HeuristicCalculator>();
            var sic = new SumIndividualCosts();

            heuristics.Add(sic);

            var     astar = new ClassicAStar(sic);
            ISolver cbs   = new CBS(astar, astar); // CBS

            // Preparing the solvers:
            solvers = new List <ISolver>();

            solvers.Add(cbs);

            outOfTimeCounters = new int[solvers.Count];
            for (int i = 0; i < outOfTimeCounters.Length; i++)
            {
                outOfTimeCounters[i] = 0;
            }
        }
Example #3
0
        /// <summary>
        /// Determines how many additive pattern databases to build and divides
        /// the agents among them, possibly leaving some agents out.
        /// </summary>
        /// <param name="s">The root of the search tree. This is also expected
        /// to have context parameters such as agents' goal states.</param>
        public void build(ProblemInstance pi, WorldState s)
        {
            Debug.Write("Building database...");

            /**
             * As a simple rule, we'll simply take pairs of agents starting
             * with the first two, then the second two, etc.
             */

            m_vPDBs = new List <PDB>();
            if (s.allAgentsState.Length > 1)
            {
                for (uint i = 0; i < s.allAgentsState.Length - 1; i += 2)
                {
                    /**
                     * Make a list of agents we want to include together in the
                     * next additive pattern database. We specify agents by
                     * their index into the Travor_WorldState.allAgentsState
                     * array.
                     */

                    List <uint> vAgents = new List <uint>();
                    vAgents.Add(i);
                    vAgents.Add(i + 1);

                    /**
                     * Create a new root search node where the state only
                     * includes a subset of the agents of the original search
                     * node. This is done by passing into the state copy
                     * constructor our list of important agents.
                     */

                    WorldState tws = new WorldState(s.allAgentsState, vAgents);

                    /**
                     * Initialize, build, and save the new pattern database.
                     */

                    EnumeratedPDB pdb = new EnumeratedPDB();
                    pdb.init(pi, vAgents);
                    pdb.build();
                    Debug.Write(".");
                    m_vPDBs.Add(pdb);
                }
            }

            /**
             * Create single shortest path pattern database heuristics for the
             * remaining agents if we have any left over.
             */

            if (s.allAgentsState.Length % 2 == 1)
            {
                SumIndividualCosts pdb     = new SumIndividualCosts();
                List <uint>        vAgents = new List <uint>(1);
                vAgents.Add((uint)s.allAgentsState.Length - 1);
                pdb.init(pi, vAgents);
                pdb.build();
                m_vPDBs.Add(pdb);
            }

            /**
             * For informational purposes, we will set the number of agents
             * that aren't included in this set of pattern databases.
             */

            m_vExcludedAgents = new SortedSet <uint>();

            Debug.WriteLine("done.");
        }
Example #4
0
        /// <summary>
        /// Construct with chosen algorithms.
        /// </summary>
        public Run()
        {
            this.watch = Stopwatch.StartNew();

            // Preparing the heuristics:
            heuristics = new List <HeuristicCalculator>();
            var sic = new SumIndividualCosts();

            heuristics.Add(sic);
            var astar                = new ClassicAStar(sic, false, false, 0);  //withNoBias
            var astarWithBias1       = new ClassicAStar(sic, false, false, 1);  //withBias
            var astarWithBias2       = new ClassicAStar(sic, false, false, 2);  //withBias2
            var astarWithBias3       = new ClassicAStar(sic, false, false, 3);  //withBias3
            var astarWithBias4       = new ClassicAStar(sic, false, false, 4);  //withBias 4
            var astarWithBias5       = new ClassicAStar(sic, false, false, 5);  //withBias 5
            var astarWithBias6       = new ClassicAStar(sic, false, false, 6);  //withBias 6
            var astarWithBias7       = new ClassicAStar(sic, false, false, 7);  //withBias 7
            var astarWithDynamicBias = new ClassicAStar(sic, false, false, -1); //withBias -1
            var cbs              = new CBS_LocalConflicts(astar, astar, -1);
            var astar_with_od    = new AStarWithOD(sic);
            var epea             = new AStarWithPartialExpansion(sic);
            var macbsLocal5Epea  = new CBS_LocalConflicts(astar, epea, 5);
            var macbsLocal50Epea = new CBS_LocalConflicts(astar, epea, 50);


            // Preparing the solvers:
            solvers = new List <ISolver>();

            //k-robust 0,1,2, .. , 7

            solvers.Add(new CBS_GlobalConflicts(astar, epea, -1, false, CBS_LocalConflicts.BypassStrategy.BEST_FIT_LOOKAHEAD,
                                                false, CBS_LocalConflicts.ConflictChoice.FIRST, false, false, 1, false, 0, ConstraintPolicy.Range)); // CBS/EPEA* + CARDINAL + BP1

            solvers.Add(new CBS_GlobalConflicts(astarWithBias1, epea, -1, false, CBS_LocalConflicts.BypassStrategy.FIRST_FIT_LOOKAHEAD,
                                                false, CBS_LocalConflicts.ConflictChoice.FIRST, false, false, 1, false, 1, ConstraintPolicy.Range)); // CBS/EPEA* + CARDINAL + BP1

            solvers.Add(new CBS_GlobalConflicts(astarWithBias2, epea, -1, false, CBS_LocalConflicts.BypassStrategy.FIRST_FIT_LOOKAHEAD,
                                                false, CBS_LocalConflicts.ConflictChoice.FIRST, false, false, 1, false, 2, ConstraintPolicy.Range)); // CBS/EPEA* + CARDINAL + BP1

            /*
             * solvers.Add(new CBS_GlobalConflicts(astarWithBias3, epea, -1, false, CBS_LocalConflicts.BypassStrategy.FIRST_FIT_LOOKAHEAD,
             *          false, CBS_LocalConflicts.ConflictChoice.FIRST, false, false, 1, false, 3, ConstraintPolicy.Range)); // CBS/EPEA* + CARDINAL + BP1
             *
             * solvers.Add(new CBS_GlobalConflicts(astarWithBias4, epea, -1, false, CBS_LocalConflicts.BypassStrategy.FIRST_FIT_LOOKAHEAD,
             *          false, CBS_LocalConflicts.ConflictChoice.FIRST, false, false, 1, false, 4, ConstraintPolicy.Range)); // CBS/EPEA* + CARDINAL + BP1
             *
             * solvers.Add(new CBS_GlobalConflicts(astarWithBias5, epea, -1, false, CBS_LocalConflicts.BypassStrategy.FIRST_FIT_LOOKAHEAD,
             *          false, CBS_LocalConflicts.ConflictChoice.FIRST, false, false, 1, false, 5, ConstraintPolicy.Range)); // CBS/EPEA* + CARDINAL + BP1
             *
             * solvers.Add(new CBS_GlobalConflicts(astarWithBias6, epea, -1, false, CBS_LocalConflicts.BypassStrategy.FIRST_FIT_LOOKAHEAD,
             *          false, CBS_LocalConflicts.ConflictChoice.FIRST, false, false, 1, false, 6, ConstraintPolicy.Range)); // CBS/EPEA* + CARDINAL + BP1
             *
             * solvers.Add(new CBS_GlobalConflicts(astarWithBias7, epea, -1, false, CBS_LocalConflicts.BypassStrategy.FIRST_FIT_LOOKAHEAD,
             *          false, CBS_LocalConflicts.ConflictChoice.FIRST, false, false, 1, false, 7, ConstraintPolicy.Range)); // CBS/EPEA* + CARDINAL + BP1
             */
            outOfTimeCounters = new int[solvers.Count];
            for (int i = 0; i < outOfTimeCounters.Length; i++)
            {
                outOfTimeCounters[i] = 0;
            }
        }
        /// <summary>
        /// Computes a heuristic by running a bounded CBS search from the given node.
        /// Assumes g of node was already calculated and h isn't zero.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="targetCost">Stop when the target cost is reached</param>
        /// <param name="sicEstimate">For a debug assertion.</param>
        /// <param name="lowLevelGeneratedCap">The number of low level nodes to generated</param>
        /// <param name="milliCap">The process total millisecond count to stop at</param>
        /// <param name="resume">Whether to resume the last search instead of solving the given node. Assumes the last search was from the same node as the given node.</param>
        /// <returns></returns>
        protected uint h(WorldState s, int targetCost, int sicEstimate = -1, int lowLevelGeneratedCap = -1, int milliCap = int.MaxValue, bool resume = false)
        {
            double start = this.runner.ElapsedMilliseconds();

            ProblemInstance sAsProblemInstance;

            if (resume == false)
            {
                this.cbs.Clear();
                sAsProblemInstance = s.ToProblemInstance(this.instance);
                this.cbs.Setup(sAsProblemInstance,
                               Math.Max(s.makespan,  // This forces must constraints to be upheld when dealing with A*+OD nodes,
                                                     // at the cost of forcing every agent to move when a goal could be found earlier with all must constraints upheld.
                                        s.minDepth), // No point in finding shallower goal nodes
                               this.runner);

                if (this.cbs.openList.Count > 0 && this.cbs.topMost)
                {
                    if (sicEstimate == -1)
                    {
                        sicEstimate = (int)SumIndividualCosts.h(s, this.instance);
                    }
                    Debug.Assert(((CbsNode)this.cbs.openList.Peek()).totalCost - s.g == (int)sicEstimate,
                                 "Total cost of CBS root not same as SIC + g");
                    // Notice we're substracting s.g, not sAsProblemInstance.g.
                    // Must constraints we put may have forced some moves,
                    // and we shouldn't count them as part of the estimate.
                }
            }
            else
            {
                sAsProblemInstance = this.cbs.GetProblemInstance();
            }

            if (lowLevelGeneratedCap == -1)
            {
                // Rough estimate of the branching factor:
                lowLevelGeneratedCap = (int)Math.Pow(Constants.NUM_ALLOWED_DIRECTIONS, this.instance.m_vAgents.Length);
            }

            // Calc the h:
            this.cbs.targetCost           = targetCost;
            this.cbs.milliCap             = milliCap;
            this.cbs.lowLevelGeneratedCap = lowLevelGeneratedCap;

            bool solved = this.cbs.Solve();

            if (solved && this.reportSolution)
            {
                // We're always going to find a proper goal since we respected the node's minDepth
                s.SetSolution(this.cbs.GetSinglePlans());
                s.SetGoalCost(this.cbs.totalCost); // We have to do it explicitly.
                // We can't just change the node's g to g + cbs.totalCost and its h to zero
                // because approaches like BPMX or maximazing PDBs might "fix" the h back.
                // So instead h is bumped to its maximum value when this method returns.
                s.SetSingleCosts(this.cbs.GetSingleCosts());
                this.nodesSolved++;
            }

            double end = this.runner.ElapsedMilliseconds();

            this.totalRuntime += end - start;
            this.nCalls++;

            this.cbs.AccumulateStatistics();
            this.cbs.ClearStatistics();

            if (this.cbs.totalCost < 0) // A timeout is legitimately possible if very little time was left to begin with,
                                        // and a no solution failure may theoretically be possible too.
            {
                return(this.cbs.GetHeuristic().h(s));
            }

            Debug.Assert(this.cbs.totalCost >= s.g, "CBS total cost " + this.cbs.totalCost + " is smaller than starting problem's initial cost " + s.g + "."); // = is allowed since even though this isn't a goal node (otherwise this function won't be called),
                                                                                                                                                               // a non-goal node can have h==0 if a minimum depth is specified, and all agents have reached their
                                                                                                                                                               // goal in this node, but the depth isn't large enough.

            uint cbsEstimate = (uint)(this.cbs.totalCost - s.g);

            // Discounting the moves the agents did before we started solving
            // (This is easier than making a copy of each AgentState just to zero its lastMove.time)

            this.totalImprovement += (int)(cbsEstimate - s.h); // Not computing difference from SIC to not over-count, since a node can be improved twice.
                                                               // Can be negative if the base heuristic was improved by:
                                                               // - Partial expansion
                                                               // - BPMX

            if (validate)
            {
                // Brute-force validation of admissability of estimate:
                var sic = new SumIndividualCosts();
                sic.init(this.instance, this.vAgents);
                var epeastarsic = new AStarWithPartialExpansion(sic);
                epeastarsic.Setup(sAsProblemInstance, s.makespan, runner);
                bool epeastarsicSolved = epeastarsic.Solve();
                if (epeastarsicSolved)
                {
                    Debug.Assert(epeastarsic.totalCost - s.g >= this.cbs.totalCost - s.g, "Inadmissable!!");
                }
            }

            return(cbsEstimate);
        }
Example #6
0
        /// <summary>
        /// Construct with chosen algorithms.
        /// </summary>
        public Run()
        {
            this.watch = Stopwatch.StartNew();

            // Preparing the heuristics:
            heuristics = new List <HeuristicCalculator>();
            var sic = new SumIndividualCosts();

            heuristics.Add(sic);
            var astar           = new ClassicAStar(sic);
            var cbs             = new CBS_LocalConflicts(astar, astar, -1);
            var astar_with_od   = new AStarWithOD(sic);
            var epea            = new AStarWithPartialExpansion(sic);
            var macbsLocal5Epea = new CBS_LocalConflicts(astar, epea, 5);
            //var cbsHeuristicNoSolve1 = new CbsHeuristic(cbs, this, false, 1);
            //var cbsHeuristicNoSolve2 = new CbsHeuristic(cbs, this, false, 2);
            //var cbsHeuristicNoSolve3 = new CbsHeuristic(cbs, this, false, 3);
            //var cbsHeuristicNoSolve4 = new CbsHeuristic(cbs, this, false, 4);
            //var cbsHeuristicNoSolve5 = new CbsHeuristic(cbs, this, false, 5);
            //var cbsHeuristicNoSolve6 = new CbsHeuristic(cbs, this, false, 6);
            //var cbsHeuristicSolve1 = new CbsHeuristic(cbs, this, true, 1);
            //var cbsHeuristicSolve2 = new CbsHeuristic(cbs, this, true, 2);
            //var cbsHeuristicSolve3 = new CbsHeuristic(cbs, this, true, 3);
            //var cbsHeuristicSolve4 = new CbsHeuristic(cbs, this, true, 4);
            //var cbsHeuristicSolve5 = new CbsHeuristic(cbs, this, true, 5);
            //var cbsHeuristicSolve6 = new CbsHeuristic(cbs, this, true, 6);
            //var sicOrCbsh6 = new RandomChoiceOfHeuristic(cbsHeuristicSolve6, sic, 1.0 / 5);

            //var dynamicLazyCbsh = new DyanamicLazyCbsh(cbs, this, true);
            //heuristics.Add(dynamicLazyCbsh);

            var dynamicLazyMacbsLocal5EpeaH = new DyanamicLazyCbsh(macbsLocal5Epea, this, true);

            heuristics.Add(dynamicLazyMacbsLocal5EpeaH);

            // Preparing the solvers:
            solvers = new List <ISolver>();

            solvers.Add(new CBS_LocalConflicts(astar, epea, 5)); // Works and is very fast so is a good choice for cost validation
            //solvers.Add(new CBS_GlobalConflicts(astar, astar, -1)); // Should be identical since no merging is done

            /*
             * //solvers.Add(new CBS_LocalConflicts(epea, epea, -1));
             * //solvers.Add(new CBS_GlobalConflicts(epea, epea, -1)); // Should be identical since no merging is done.
             * //solvers.Add(new CBS_LocalConflicts(epea, epea, 0));
             * solvers.Add(new CBS_LocalConflicts(astar, epea, 0));
             * //solvers.Add(new CBS_GlobalConflicts(epea, epea, 0));
             * //solvers.Add(new CBS_LocalConflicts(epea, epea, 1));
             * //solvers.Add(new CBS_GlobalConflicts(epea, epea, 1));
             * //solvers.Add(new CBS_LocalConflicts(epea, epea, 5));
             * solvers.Add(new CBS_LocalConflicts(astar, epea, 5));
             * //solvers.Add(new CBS_GlobalConflicts(epea, epea, 5));
             * //solvers.Add(new CBS_LocalConflicts(epea, epea, 10));
             * solvers.Add(new CBS_LocalConflicts(astar, epea, 10));
             * //solvers.Add(new CBS_GlobalConflicts(epea, epea, 10));
             * //solvers.Add(new CBS_LocalConflicts(epea, epea, 100));
             * solvers.Add(new CBS_LocalConflicts(astar, epea, 100));
             * //solvers.Add(new CBS_GlobalConflicts(epea, epea, 100));
             * //solvers.Add(new CBS_LocalConflicts(epea, epea, 500));
             * //solvers.Add(new CBS_GlobalConflicts(epea, epea, 500));
             *
             * //solvers.Add(new CBS_LocalConflicts(astar_with_od, astar_with_od, -1));
             * //solvers.Add(new CBS_GlobalConflicts(astar_with_od, astar_with_od, -1)); // Should be identical since no merging is done.
             * //solvers.Add(new CBS_LocalConflicts(astar_with_od, astar_with_od, 0));
             * solvers.Add(new CBS_LocalConflicts(astar, astar_with_od, 0));
             * //solvers.Add(new CBS_GlobalConflicts(astar_with_od, astar_with_od, 0));
             * //solvers.Add(new CBS_LocalConflicts(astar_with_od, astar_with_od, 1));
             * //solvers.Add(new CBS_GlobalConflicts(astar_with_od, astar_with_od, 1));
             * //solvers.Add(new CBS_LocalConflicts(astar_with_od, astar_with_od, 5));
             * solvers.Add(new CBS_LocalConflicts(astar, astar_with_od, 5));
             * //solvers.Add(new CBS_GlobalConflicts(astar_with_od, astar_with_od, 5));
             * //solvers.Add(new CBS_LocalConflicts(astar_with_od, astar_with_od, 10));
             * solvers.Add(new CBS_LocalConflicts(astar, astar_with_od, 10));
             * //solvers.Add(new CBS_GlobalConflicts(astar_with_od, astar_with_od, 10));
             * //solvers.Add(new CBS_LocalConflicts(astar_with_od, astar_with_od, 100));
             * solvers.Add(new CBS_LocalConflicts(astar, astar_with_od, 100));
             * //solvers.Add(new CBS_GlobalConflicts(astar_with_od, astar_with_od, 100));
             * //solvers.Add(new CBS_LocalConflicts(astar_with_od, astar_with_od, 500));
             * //solvers.Add(new CBS_GlobalConflicts(astar_with_od, astar_with_od, 500));
             */
            //solvers.Add(new ClassicAStar(sic)); // Works
            //solvers.Add(new ClassicAStar(cbsHeuristic)); // Works
            //solvers.Add(new AStarWithOD(sic));  // Works
            //solvers.Add(new AStarWithPartialExpansionBasic(sic)); // Works
            //solvers.Add(new AStarWithPartialExpansionBasic(cbsHeuristic));
            solvers.Add(new AStarWithPartialExpansion(sic));     // Works.
            solvers.Add(new CBS_LocalConflicts(astar, epea, 0)); // EPEA*+(S)ID

            //solvers.Add(new ClassicAStar(cbsHeuristicSolve1));
            //solvers.Add(new ClassicAStar(cbsHeuristicSolve2));
            //solvers.Add(new ClassicAStar(cbsHeuristicSolve3));
            //solvers.Add(new ClassicAStar(cbsHeuristicSolve4));
            //solvers.Add(new ClassicAStar(cbsHeuristicSolve5));
            //solvers.Add(new ClassicAStar(cbsHeuristicSolve6));
            //solvers.Add(new ClassicAStar(cbsHeuristicNoSolve1));
            //solvers.Add(new ClassicAStar(cbsHeuristicNoSolve2));
            //solvers.Add(new ClassicAStar(cbsHeuristicNoSolve3));
            //solvers.Add(new ClassicAStar(cbsHeuristicNoSolve4));
            //solvers.Add(new ClassicAStar(cbsHeuristicNoSolve5));
            //solvers.Add(new ClassicAStar(cbsHeuristicNoSolve6));
            //solvers.Add(new ClassicAStar(sicOrCbsh6));

            //solvers.Add(new AStarWithOD(cbsHeuristicSolve1));
            //solvers.Add(new AStarWithOD(cbsHeuristicSolve2));
            //solvers.Add(new AStarWithOD(cbsHeuristicSolve3));
            //solvers.Add(new AStarWithOD(cbsHeuristicSolve4));
            //solvers.Add(new AStarWithOD(cbsHeuristicSolve5));
            //solvers.Add(new AStarWithOD(cbsHeuristicSolve6));
            //solvers.Add(new AStarWithOD(cbsHeuristicNoSolve1));
            //solvers.Add(new AStarWithOD(cbsHeuristicNoSolve2));
            //solvers.Add(new AStarWithOD(cbsHeuristicNoSolve3));
            //solvers.Add(new AStarWithOD(cbsHeuristicNoSolve4));
            //solvers.Add(new AStarWithOD(cbsHeuristicNoSolve5));
            //solvers.Add(new AStarWithOD(cbsHeuristicNoSolve6));
            //solvers.Add(new AStarWithOD(sicOrCbsh6));

            ClassicAStar solver;

            // dynamic not rational lazy A*+OD/CBS/A*/SIC:
            //solver = new AStarWithOD(sic);
            //var dynamicLazyOpenList1 = new DynamicLazyOpenList(solver, dynamicLazyCbsh, this);
            //solver.openList = dynamicLazyOpenList1;
            //solvers.Add(solver);

            // dynamic rational lazy A*+OD/CBS/A*/SIC:
            //solver = new AStarWithOD(sic);
            //var dynamicRationalLazyOpenList1 = new DynamicRationalLazyOpenList(solver, dynamicLazyCbsh, this);
            //solver.openList = dynamicRationalLazyOpenList1;
            //solvers.Add(solver);

            // dynamic rational lazy MA-CBS-local-5/A*+OD/MA-CBS-local-5/EPEA*/SIC:
            //solver = new AStarWithOD(sic);
            //var dynamicRationalLazyOpenList3 = new DynamicRationalLazyOpenList(solver, dynamicLazyMacbsLocal5EpeaH, this);
            //solver.openList = dynamicRationalLazyOpenList3;
            //solvers.Add(new CBS_LocalConflicts(astar, solver, 5));

            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicSolve1));
            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicSolve2));
            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicSolve3));
            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicSolve4));
            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicSolve5));
            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicSolve6));
            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicNoSolve1));
            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicNoSolve2));
            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicNoSolve3));
            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicNoSolve4));
            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicNoSolve5));
            //solvers.Add(new AStarWithPartialExpansion(cbsHeuristicNoSolve6));
            //solvers.Add(new AStarWithPartialExpansion(sicOrCbsh6));

            // dynamic not rational lazy EPEA*/CBS/A*/SIC:
            //solver = new AStarWithPartialExpansion(sic);
            //var dynamicLazyOpenList2 = new DynamicLazyOpenList(solver, dynamicLazyCbsh, this);
            //solver.openList = dynamicLazyOpenList2;
            //solvers.Add(solver);

            // dynamic rational lazy EPEA*/CBS/A*/SIC:
            //solver = new AStarWithPartialExpansion(sic);
            //var dynamicRationalLazyOpenList2 = new DynamicRationalLazyOpenList(solver, dynamicLazyCbsh, this);
            //solver.openList = dynamicRationalLazyOpenList2;
            //solvers.Add(solver);

            // MA-CBS-local-5/dynamic rational lazy EPEA*/MA-CBS-local-5/EPEA*/SIC:
            solver = new AStarWithPartialExpansion(sic);
            var dynamicRationalLazyOpenList4 = new DynamicRationalLazyOpenList(solver, dynamicLazyMacbsLocal5EpeaH, this);

            solver.openList = dynamicRationalLazyOpenList4;
            solvers.Add(new CBS_LocalConflicts(astar, solver, 5));

            // dynamic rational lazy EPEA*/MA-CBS-local-5/EPEA*/SIC + (S)ID:
            solver = new AStarWithPartialExpansion(sic);
            var dynamicRationalLazyOpenList6 = new DynamicRationalLazyOpenList(solver, dynamicLazyMacbsLocal5EpeaH, this);

            solver.openList = dynamicRationalLazyOpenList6;
            solvers.Add(new CBS_LocalConflicts(astar, solver, 0));

            // dynamic rational lazy EPEA*/MA-CBS-local-5/EPEA*/SIC:
            solver = new AStarWithPartialExpansion(sic);
            var dynamicRationalLazyOpenList8 = new DynamicRationalLazyOpenList(solver, dynamicLazyMacbsLocal5EpeaH, this);

            solver.openList = dynamicRationalLazyOpenList8;
            solvers.Add(solver);

            //solvers.Add(new CostTreeSearchSolverNoPruning());
            //solvers.Add(new CostTreeSearchSolverKMatch(2));
            //solvers.Add(new CostTreeSearchSolverOldMatching(2));
            //solvers.Add(new CostTreeSearchSolverRepatedMatch(2));
            //solvers.Add(new CostTreeSearchSolverKMatch(3));
            //solvers.Add(new CostTreeSearchSolverOldMatching(3));
            //solvers.Add(new CostTreeSearchSolverRepatedMatch(3));

            //solvers.Add(new CostTreeSearchNoPruning());
            //solvers.Add(new CostTreeSearchKMatch(2));
            //solvers.Add(new CostTreeSearchOldMatching(2));
            //solvers.Add(new CostTreeSearchRepatedMatch(2));
            //solvers.Add(new CostTreeSearchKMatch(3));
            //solvers.Add(new CostTreeSearchOldMatching(3));
            //solvers.Add(new CostTreeSearchRepatedMatch(3));

            //solvers.Add(new Trevor(new AStarWithPartialExpansion()));
            //solvers.Add(new Trevor(new CBS_GlobalConflicts(new AStarWithPartialExpansion(), 1, 1)));
            //solvers.Add(new Trevor(new CBS_GlobalConflicts(new AStarWithPartialExpansion(), 5, 5)));
            //solvers.Add(new Trevor(new CBS_GlobalConflicts(new AStarWithPartialExpansion(), 10, 10)));
            //solvers.Add(new Trevor(new CBS_GlobalConflicts(new AStarWithPartialExpansion(), 100, 100)));
            //solvers.Add(new Trevor(new CBS_GlobalConflicts(new AStarWithPartialExpansion(), 500, 500)));
            //solvers.Add(new Trevor(new CBS_GlobalConflicts(new ClassicAStar())));

            //solvers.Add(new Trevor(new CBS_GlobalConflicts(new ClassicAStar(), 1, 1)));
            //solvers.Add(new Trevor(new CBS_GlobalConflicts(new ClassicAStar(), 5, 5)));
            //solvers.Add(new Trevor(new CBS_GlobalConflicts(new ClassicAStar(), 10, 10)));
            //solvers.Add(new Trevor(new CBS_GlobalConflicts(new ClassicAStar(), 100, 100)));
            //solvers.Add(new Trevor(new CBS_GlobalConflicts(new ClassicAStar(), 500, 500)));

            //solvers.Add(new Trevor(new AStarWithPartialExpansionBasic()));
            //solvers.Add(new Trevor(new AStarWithPartialExpansion()));
            //solvers.Add(new Trevor(new ClassicAStar()));
            //solvers.Add(new Trevor());

            //solvers.Add(new CBS_IDA(new ClassicAStar())); // Don't run! Uses must conds

            //solvers.Add(new CBS_GlobalConflicts(new ClassicAStar())); // Works

            //solvers.Add(new CBS_NoDD(new ClassicAStar()));
            //solvers.Add(new CBS_NoDDb3(new ClassicAStar()));
            //solvers.Add(new CBS_GlobalConflicts(new ClassicAStar(), 1, 1)); // Run this!

            outOfTimeCounters = new int[solvers.Count];
            for (int i = 0; i < outOfTimeCounters.Length; i++)
            {
                outOfTimeCounters[i] = 0;
            }
        }
        public override void Expand(WorldState nodeP)
        {
            var node = (WorldStateForPartialExpansion)nodeP;

            if (node.isAlreadyExpanded() == false)
            {
                node.calcSingleAgentDeltaFs(instance, this.IsValid);
                expandedFullStates++;
                node.alreadyExpanded = true;
                node.targetDeltaF    = 0;                                                     // Assuming a consistent heuristic (as done in the paper), the min delta F is zero.
                node.remainingDeltaF = node.targetDeltaF;                                     // Just for the hasChildrenForCurrentDeltaF call.
                while (node.hasMoreChildren() && node.hasChildrenForCurrentDeltaF() == false) // DeltaF=0 may not be possible if all agents have obstacles between their location and the goal
                {
                    node.targetDeltaF++;
                    node.remainingDeltaF = node.targetDeltaF;
                }
                if (node.hasMoreChildren() == false) // Node has no possible children at all
                {
                    node.Clear();
                    return;
                }
            }
            //Debug.Print("Expanding node " + node);

            // If this node was already expanded, notice its h was updated, so the deltaF refers to its original H

            base.Expand(node);

            node.targetDeltaF++; // This delta F was exhausted
            node.remainingDeltaF = node.targetDeltaF;

            while (node.hasMoreChildren() && node.hasChildrenForCurrentDeltaF() == false)
            {
                node.targetDeltaF++;
                node.remainingDeltaF = node.targetDeltaF;
            }

            if (node.hasMoreChildren() && node.hasChildrenForCurrentDeltaF() && node.h + node.g + node.targetDeltaF <= this.maxCost)
            {
                // Increment H before re-insertion into open list
                int sicEstimate = (int)SumIndividualCosts.h(node, this.instance); // Re-compute even if the heuristic used is SIC since this may be a second expansion
                if (node.h < sicEstimate + node.targetDeltaF)
                {
                    // Assuming the heuristic used doesn't give a lower estimate than SIC for each and every one of the node's children,
                    // (an ok assumption since SIC is quite basic, no heuristic we use is ever worse than it)
                    // then the current target deltaF is really exhausted, since the deltaG is always correct,
                    // and the deltaH predicted by SIC is less than or equal to the finalDeltaH.
                    // So if the heuristic gives the same estimate as SIC for this node
                    // (and that mainly happens when SIC happens to give a perfect estimate),
                    // we can increment the node's h to SIC+targetDeltaH
                    node.h = sicEstimate + node.targetDeltaF;
                }

                // Re-insert node into open list
                openList.Add(node);
            }
            else
            {
                node.Clear();
            }
        }