/// <summary> /// /// </summary> /// <param name="problemInstance"></param> /// <param name="minDepth"></param> /// <param name="runner"></param> /// <param name="minCost">Not taken into account</param> public virtual void Setup(ProblemInstance problemInstance, int minDepth, Run runner, int minCost = -1) { this.instance = problemInstance; this.runner = runner; this.ClearPrivateStatistics(); this.totalCost = 0; this.solutionDepth = -1; this.targetCost = int.MaxValue; this.lowLevelGeneratedCap = int.MaxValue; this.milliCap = int.MaxValue; this.goalNode = null; this.solution = null; this.maxCost = int.MaxValue; this.topMost = this.SetGlobals(); this.minDepth = minDepth; CbsNode root = new CbsNode(instance.m_vAgents.Length, this.solver, this.singleAgentSolver, this); // Problem instance and various strategy data is all passed under 'this'. // Solve the root node bool solved = root.Solve(minDepth); if (solved && root.totalCost <= this.maxCost) { this.openList.Add(root); this.highLevelGenerated++; this.closedList.Add(root, root); } }
public virtual void Setup(ProblemInstance problemInstance, int minDepth, Run runner) { this.instance = problemInstance; this.runner = runner; this.ClearPrivateStatistics(); this.totalCost = 0; this.solutionDepth = -1; this.targetCost = int.MaxValue; this.lowLevelGeneratedCap = int.MaxValue; this.milliCap = int.MaxValue; this.goalNode = null; this.solution = null; if (problemInstance.parameters.ContainsKey(Trevor.MAXIMUM_COST_KEY)) { this.maxCost = (int)(problemInstance.parameters[Trevor.MAXIMUM_COST_KEY]); } else { this.maxCost = int.MaxValue; } this.topMost = this.SetGlobals(); this.minDepth = minDepth; CbsNode root = new CbsNode(instance.m_vAgents.Length, problemInstance, this.solver, this.singleAgentSolver, runner); // Solve the root node bool solved = root.Solve(minDepth); if (solved && root.totalCost <= this.maxCost) { this.openList.Add(root); this.highLevelGenerated++; this.closedList.Add(root, root); this.addToGlobalConflictCount(root.GetConflict()); } }
public bool Solve() { //Debug.WriteLine("Solving Sub-problem On Level - " + mergeThreshold); if (root.Solve(minCost) == false) { AgentState.EquivalenceOverDifferentTimes = true; return(false); } fBound = root.totalCost; //fBound must be <= maxCost while (fBound < maxCost) { nextF = int.MaxValue; // Check if max time has been exceeded if (runner.ElapsedMilliseconds() > Constants.MAX_TIME) { totalCost = Constants.TIMEOUT_COST; Console.WriteLine("Out of time"); this.Clear(); AgentState.EquivalenceOverDifferentTimes = true; return(false); } if (Expand(root, root.GetConflict())) { AgentState.EquivalenceOverDifferentTimes = true; return(true); } fBound = nextF; } totalCost = Constants.NO_SOLUTION_COST; this.Clear(); AgentState.EquivalenceOverDifferentTimes = true; return(false); }