/// <summary>
        /// </summary>
        /// <param name="cbs">The underlying CBS to use</param>
        /// <param name="runner"></param>
        /// <param name="reportSolution">
        /// Whether to store the solution found by CBS in the node.
        /// This should greatly speed up searches.</param>
        /// <param name="minAboveSic">
        /// The minimum increment by which to beat SIC's estimate, if possible.
        /// Larger values would cause each call to the heuristic to take longer, but make it return better estimates.
        /// </param>
        public CbsHeuristic(CBS_LocalConflicts cbs, Run runner, bool reportSolution = false, int minAboveSic = 1, bool validate = false)
        {
            this.cbs    = cbs;
            this.runner = runner;

            this.reportSolution = reportSolution;
            this.minAboveSic    = Math.Max(minAboveSic, 1);

            this.validate = validate;
        }
Пример #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, 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;
            }
        }
 public DyanamicLazyCbsh(CBS_LocalConflicts cbs, Run runner, bool reportSolution = false, bool validate = false)
     : base(cbs, runner, reportSolution, -1, validate)
 {
 }
Пример #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);
            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;
            }
        }