void UpdateReference(DefaultState successor) { List <DefaultAction> neighborsList = new List <DefaultAction>(); domain.generatePredecessors(successor, ref neighborsList); foreach (DefaultAction action in neighborsList) { if (isNeighborToStartAndPreviousStateIsNotStart(successor, action.state)) { dictionary[successor].previousState = startState; //openDictionary[successor].action = new ARAstarAction(neighbor, successor); dictionary[successor].action = domain.generateAction(action.state, successor); dictionary[successor].isDirty = true; break; } else if (dictionary.ContainsKey(action.state) && dictionary[action.state].isDirty) { if (dictionary[successor].previousState != null && predIsDirtyWithLeastCost(successor, action.state)) { dictionary[successor].previousState = action.state; //openDictionary[successor].action = new ARAstarAction(neighbor, successor); dictionary[successor].action = domain.generateAction(action.state, successor); dictionary[successor].isDirty = true; } } } }
public void UpdateReferences(float inflationFactor, PlanningDomainBase domain) { List<DefaultState> neighborsList = new List<DefaultState>(); foreach(KeyValuePair<DefaultState, ARAstarNode> node in close) { if(node.Value.weightExpanded > inflationFactor) { float best_g = Mathf.Infinity; node.Value.weightExpanded = inflationFactor; domain.generateNeighbors(node.Key, ref neighborsList); foreach(DefaultState neighbor in neighborsList) { if(close.ContainsKey(neighbor)) { if(close[neighbor].g < best_g){ best_g = close[neighbor].g; close[neighbor].weightExpanded = inflationFactor; close[node.Key].previousState = neighbor; //close[node.Key].action = new ARAstarAction(neighbor, node.Key); close[node.Key].action = domain.generateAction(neighbor, node.Key); } } } } } }
public void UpdateReferences(float inflationFactor, PlanningDomainBase domain) { List <DefaultState> neighborsList = new List <DefaultState>(); foreach (KeyValuePair <DefaultState, ARAstarNode> node in close) { if (node.Value.weightExpanded > inflationFactor) { float best_g = Mathf.Infinity; node.Value.weightExpanded = inflationFactor; domain.generateNeighbors(node.Key, ref neighborsList); foreach (DefaultState neighbor in neighborsList) { if (close.ContainsKey(neighbor)) { if (close[neighbor].g < best_g) { best_g = close[neighbor].g; close[neighbor].weightExpanded = inflationFactor; close[node.Key].previousState = neighbor; //close[node.Key].action = new ARAstarAction(neighbor, node.Key); close[node.Key].action = domain.generateAction(neighbor, node.Key); } } } } } }
/// <summary> /// Updates the vertex. /// </summary> /// <param name='node'> /// Node to be updated /// </param> void UpdateVertex(ARAstarNode node) { //[06] if (!currentStart.Equals(node.action.state)) { float minCost = Mathf.Infinity; //List<DefaultState> neighbors = new List<DefaultState>(); //domain.generateNeighbors(node.action.state, ref neighbors); List <DefaultAction> transitions = new List <DefaultAction>(); selectedPlanningDomain.generatePredecessors(node.action.state, ref transitions); foreach (DefaultAction action in transitions) { if (Visited.ContainsState(action.state)) //Was visited { if (Visited.nodeForState(action.state).g + action.cost < minCost && !Visited.nodeForState(action.state).previousState.Equals(node.action.state)) { minCost = Visited.nodeForState(action.state).g + action.cost; node.previousState = action.state; } } } //node.action = new ARAstarAction(node.previousState, node.action.state); node.action = selectedPlanningDomain.generateAction(node.previousState, node.action.state); node.rhs = minCost; } if (selectedPlanningDomain.equals(node.action.state, goalState, false)) { goalPair = new KeyValuePair <DefaultState, ARAstarNode> (node.action.state, node); } if (Open.ContainsState(node.action.state)) { Open.Remove(node.action.state); } if (node.g != node.rhs) { if (!Close.Contains(node.action.state)) { Open.Insert(node); } else { Incons.Insert(node); } } Visited.insertNode(ref node); }
void updatePlanReference(PlanningDomainBase domain) { List <DefaultState> neighborsList = new List <DefaultState>(); foreach (DefaultState state in plan.Keys) { float ming = Mathf.Infinity; domain.generateNeighbors(state, ref neighborsList); foreach (DefaultState neighbor in neighborsList) { if (plan.ContainsKey(neighbor)) { if (plan[neighbor].g < ming) { ming = plan[neighbor].g; plan[state].previousState = neighbor; //plan[state].action = new ARAstarAction(neighbor, state); plan[state].action = domain.generateAction(neighbor, state); } } } } }
void updatePlanReference(PlanningDomainBase domain) { List<DefaultState> neighborsList = new List<DefaultState>(); foreach(DefaultState state in plan.Keys) { float ming = Mathf.Infinity; domain.generateNeighbors(state, ref neighborsList); foreach(DefaultState neighbor in neighborsList) { if(plan.ContainsKey(neighbor)) { if(plan[neighbor].g < ming) { ming = plan[neighbor].g; plan[state].previousState = neighbor; //plan[state].action = new ARAstarAction(neighbor, state); plan[state].action = domain.generateAction(neighbor, state); } } } } }