public static void ClearTraces() { nextToSendForThisAgent = new Dictionary <Agent, Agent>(); agents = new List <Agent>(); amountOfPublicVariables = -1; TraceVariable.ClearTraces(); TraceOperator.ClearTraces(); TraceState.ClearTraces(); }
private void initializeVariablesStatesAndPlan() { Tuple <List <TraceVariable>, int> tuple = TraceVariable.getVariables(agent); variables = tuple.Item1; if (amountOfPublicVariables == -1) { amountOfPublicVariables = tuple.Item2; } else if (amountOfPublicVariables != tuple.Item2) { amountOfPublicVariables = Math.Min(amountOfPublicVariables, tuple.Item2); //throw new Exception("Public variables should be the same for all agents"); } states = new List <TraceState>(); plan = new List <string>(); }
private static List <TraceVariable> createVariables(Dictionary <Predicate, TraceVariable> myVariables, HashSet <GroundedPredicate> predicates, int agentID, int startVarID, bool isPrivate) { List <TraceVariable> variables = new List <TraceVariable>(); foreach (GroundedPredicate p in predicates) { Dictionary <int, string> vals = new Dictionary <int, string>(); vals.Add(0, p.ToString()); Predicate negation = p.Negate(); vals.Add(1, negation.ToString()); TraceVariable variable = new TraceVariable(agentID, startVarID, "var" + startVarID, isPrivate, 2, vals); variables.Add(variable); myVariables.Add(p, variable); startVarID++; } return(variables); }
private static void initializeDict(int agentID, Dictionary <int, int> dict, List <Predicate> predicates, bool myOperation, Agent agent) { foreach (Predicate p in predicates) { Predicate currP = p; bool artificial = false; if (p.Name.Contains(Domain.ARTIFICIAL_PREDICATE)) { if (!myOperation) { continue; } artificial = true; } TraceVariable var; int val; if (!p.Negation) { if (artificial) { currP = agent.ArtificialToPrivate[(GroundedPredicate)p]; if (currP.Negation) { currP = currP.Negate(); val = 1; goto mistake_with_negation_jump; } } val = 0; //regular } else { Predicate negation = p.Negate(); currP = negation; if (artificial) { currP = agent.ArtificialToPrivate[(GroundedPredicate)negation]; if (currP.Negation) { currP = currP.Negate(); val = 0; goto mistake_with_negation_jump; } } val = 1; //negation } mistake_with_negation_jump: var = TraceVariable.GetVariable(agentID, currP); int varID = var.varID; if (dict.ContainsKey(varID)) { if (dict[varID] != val) { //throw new Exception("The two keys must go to the same value!"); //this happens because we use some action like move block b1 from s3 to s4, to be on itself, which makes this not work well. //we can just ignore stupid actions like this, and we will just keep it as it is a "true" predicate (with the value of 0) dict[varID] = 0; } } else { dict.Add(varID, val); } } }