/// <summary> /// Prunes the individual agent MDDs and, if possible, matches them to return a non-conflicting configuration of /// paths of the given costs. /// </summary> /// <param name="conflictTable"></param> /// <param name="CBS_CAT"></param> /// <returns> /// null if no solution is found. /// </returns> public override SinglePlan[] Solve(Dictionary <TimedMove, List <int> > conflictTable, Dictionary <TimedMove, List <int> > CBS_CAT) { if (this.Prune()) // Everything was pruned { return(null); } CostTreeSearchSolver.passed++; AStarMDD findSolution = new AStarMDD(allMDDs, runner, conflictTable, CBS_CAT); SinglePlan[] ans = findSolution.Solve(); this.generated = findSolution.generated; this.expanded = findSolution.expanded; this.caViolations = findSolution.conflictAvoidanceViolations; return(ans); }
public override LinkedList <Move>[] Solve(HashSet <TimedMove> conflictTable, HashSet_U <TimedMove> CBS_CAT) { for (int i = 0; i < allMDDs.Length; i++) { if (allMDDs[i].levels == null) { return(null); } } AStarMDD findSolution = new AStarMDD(allMDDs, runner, conflictTable, CBS_CAT); LinkedList <Move>[] ans = findSolution.Solve(); generated = findSolution.generated; expanded = findSolution.expanded; caViolations = findSolution.conflictAvoidanceViolations; return(ans); }
public override SinglePlan[] Solve(Dictionary <TimedMove, List <int> > conflictTable, Dictionary <TimedMove, List <int> > CBS_CAT) { for (int i = 0; i < allMDDs.Length; i++) { if (allMDDs[i].levels == null) { return(null); } } AStarMDD findSolution = new AStarMDD(allMDDs, runner, conflictTable, CBS_CAT); SinglePlan[] ans = findSolution.Solve(); generated = findSolution.generated; expanded = findSolution.expanded; caViolations = findSolution.conflictAvoidanceViolations; return(ans); }
public override LinkedList <Move>[] Solve(HashSet <TimedMove> conflictTable, HashSet_U <TimedMove> CBS_CAT) { int notConflicting = 1; for (int i = allMDDs.Length - 1; i >= 0; i--) { for (int j = i + 1; j < allMDDs.Length; j++) { if (syncSize == 2) { notConflicting = allMDDs[i].sync2GDDs(allMDDs[j]); } else if (syncSize == 3) { notConflicting = allMDDs[i].sync3GDDs(allMDDs[j], j); } //Run.resultsWriterdd.Write(matchCounter + ","); //Run.resultsWriterdd.WriteLine(); if (notConflicting == 0) { return(null); } } } if (allMDDs[0].levels == null) { return(null); } CostTreeSearchSolver.passed++; AStarMDD findSolution = new AStarMDD(allMDDs, runner, conflictTable, CBS_CAT); LinkedList <Move>[] ans = findSolution.Solve(); generated = findSolution.generated; expanded = findSolution.expanded; caViolations = findSolution.conflictAvoidanceViolations; return(ans); }
public override LinkedList <Move>[] Solve(HashSet <TimedMove> conflictTable, HashSet_U <TimedMove> CBS_CAT) { MDD[] match = new MDD[2]; bool Converging = true; int[] changed = new int[allMDDs.Length]; int currentIteration = 0; int conflictStatus = 1; while (Converging) { currentIteration++; Converging = false; for (int i = allMDDs.Length - 1; i >= 0; i--) { for (int j = i + 1; j < allMDDs.Length; j++) { if (changed[i] >= currentIteration - 1 || changed[j] >= currentIteration - 1)//if at least one of the two MDDs was changed during the last iteration { if (syncSize == 2) { conflictStatus = allMDDs[i].sync2GDDs(allMDDs[j]); } else if (syncSize == 3) { conflictStatus = allMDDs[i].sync3GDDs(allMDDs[j], j); } if (conflictStatus == 0) { return(null); } else if (conflictStatus == 2) { changed[i] = currentIteration; Converging = true; } if (syncSize == 2) { conflictStatus = allMDDs[i].sync2GDDs(allMDDs[j]); } else if (syncSize == 3) { conflictStatus = allMDDs[i].sync3GDDs(allMDDs[j], j); } if (conflictStatus == 0) { return(null); } else if (conflictStatus == 2) { changed[i] = currentIteration; Converging = true; } } } } } CostTreeSearchSolver.passed++; if (allMDDs[0].levels == null) { return(null); } AStarMDD findSolution = new AStarMDD(allMDDs, runner, conflictTable, CBS_CAT); LinkedList <Move>[] ans = findSolution.Solve(); generated = findSolution.generated; expanded = findSolution.expanded; caViolations = findSolution.conflictAvoidanceViolations; return(ans); }
public override LinkedList <Move>[] Solve(HashSet <TimedMove> conflictTable, HashSet_U <TimedMove> CBS_CAT) { AStarMDD findSolution; LinkedList <Move>[] subCheck; MDD[] match; MddMatchAndPrune matcher = new MddMatchAndPrune(runner); foreach (MDD checkValid in allMDDs) { if (checkValid.levels == null) { return(null); } } if (maxGroupChecked >= 2) { match = new MDD[2]; for (int i = allMDDs.Length - 1; i >= 0; i--) { for (int j = i + 1; j < allMDDs.Length; j++) { match[0] = allMDDs[i]; match[1] = allMDDs[j]; //matcher.initialize(match); //if (matcher.pruneMDDs() == false) findSolution = new AStarMDD(match, runner, conflictTable, CBS_CAT); subCheck = findSolution.Solve(); if (subCheck == null || subCheck[0] == null) { return(null); } } } } if (maxGroupChecked >= 3) { match = new MDD[3]; for (int i = allMDDs.Length - 2; i >= 0; i--) { for (int j = i + 1; j < allMDDs.Length - 1; j++) { for (int t = j + 1; t < allMDDs.Length; t++) { match[0] = allMDDs[i]; match[1] = allMDDs[j]; match[2] = allMDDs[t]; //matcher.initialize(match); //if (matcher.pruneMDDs() == false) findSolution = new AStarMDD(match, runner, conflictTable, CBS_CAT); subCheck = findSolution.Solve(); if (subCheck == null || subCheck[0] == null) { return(null); } } } } } if (maxGroupChecked >= 4) { match = new MDD[4]; for (int i = allMDDs.Length - 3; i >= 0; i--) { for (int j = i + 1; j < allMDDs.Length - 2; j++) { for (int t = j + 1; t < allMDDs.Length - 1; t++) { for (int m = t + 1; m < allMDDs.Length; m++) { match[0] = allMDDs[i]; match[1] = allMDDs[j]; match[2] = allMDDs[t]; match[3] = allMDDs[m]; //matcher.initialize(match); //if (matcher.pruneMDDs() == false) findSolution = new AStarMDD(match, runner, conflictTable, CBS_CAT); subCheck = findSolution.Solve(); if (subCheck == null || subCheck[0] == null) { return(null); } } } } } } CostTreeSearchSolver.passed++; if (allMDDs[0].levels == null) { return(null); } findSolution = new AStarMDD(allMDDs, runner, conflictTable, CBS_CAT); LinkedList <Move>[] ans = findSolution.Solve(); generated = findSolution.generated; expanded = findSolution.expanded; caViolations = findSolution.conflictAvoidanceViolations; return(ans); }
public override SinglePlan[] Solve(Dictionary <TimedMove, List <int> > conflictTable, Dictionary <TimedMove, List <int> > CBS_CAT) { MDD[] match = new MDD[2]; bool Converging = true; int[] changed = new int[allMDDs.Length]; int currentIteration = 0; MDD.PruningDone conflictStatus = MDD.PruningDone.NOTHING; while (Converging) { currentIteration++; Converging = false; for (int i = allMDDs.Length - 1; i >= 0; i--) { for (int j = i + 1; j < allMDDs.Length; j++) { if (changed[i] >= currentIteration - 1 || changed[j] >= currentIteration - 1) // If at least one of the two MDDs was changed during the last iteration { conflictStatus = allMDDs[i].SyncMDDs(allMDDs[j], this.syncSize == 3); if (conflictStatus == MDD.PruningDone.EVERYTHING) { return(null); } else if (conflictStatus == MDD.PruningDone.SOME) { changed[i] = currentIteration; Converging = true; } conflictStatus = allMDDs[i].SyncMDDs(allMDDs[j], this.syncSize == 3); if (conflictStatus == MDD.PruningDone.EVERYTHING) { return(null); } else if (conflictStatus == MDD.PruningDone.SOME) { changed[i] = currentIteration; Converging = true; } } } } } CostTreeSearchSolver.passed++; if (allMDDs[0].levels == null) { return(null); } AStarMDD findSolution = new AStarMDD(allMDDs, runner, conflictTable, CBS_CAT); SinglePlan[] ans = findSolution.Solve(); generated = findSolution.generated; expanded = findSolution.expanded; caViolations = findSolution.conflictAvoidanceViolations; return(ans); }