Beispiel #1
0
        private List <State> getState(Hashtable fluentsState)
        {
            List <State> result  = new List <State>();
            Hashtable    fluents = null;
            List <State> states  = AraSystem.GetInstance().States;

            for (int i = 0; i < states.Count; i++)
            {
                fluents = states[i].Fluents;
                bool found = true;
                foreach (Fluent f in fluentsState.Keys)
                {
                    if ((bool)fluentsState[f] != (bool)fluents[f])
                    {
                        found = false;
                        break;
                    }
                }
                if (found)
                {
                    result.Add(states[i]);
                }
            }
            return(result);
        }
Beispiel #2
0
 public static AraSystem GetInstance()
 {
     if (araSystem == null)
     {
         araSystem = new AraSystem();
     }
     return(araSystem);
 }
 private void clearColor()
 {
     foreach (State s in AraSystem.GetInstance().States)
     {
         s.Color = null;
         foreach (Arc r in s.Arcs)
         {
             r.Color = null;
         }
     }
 }
        internal bool Execute()
        {
            clearColor();
            Stack <QueryState> routes = new Stack <QueryState>();

            routes.Push(new QueryState(AraSystem.GetInstance().InitState, actions.ToList()));
            List <State> result = new List <State>();

            while (routes.Count > 0)
            {
                QueryState  queryState = routes.Pop();
                ActionAgent acg        = queryState.GetNextActionAgent();
                if (acg == null)
                {
                    result.Add(queryState.State);
                    continue;
                }
                foreach (Arc arc in queryState.State.Arcs)
                {
                    if (arc.Action == acg.Action && arc.Agent == acg.Agent)
                    {
                        arc.Color = Microsoft.Glee.Drawing.Color.Red;
                        routes.Push(new QueryState(arc.State, queryState.GetNextRoute()));
                    }
                }
            }
            List <State> wantedResultStates = ResultFormula.GetResultStates();

            bool isFound = true;

            foreach (State s in result)
            {
                s.Color = Microsoft.Glee.Drawing.Color.Violet;
                isFound = ResultFormula.ExpresState(s);
                if (QueryPossibility == Utility.QueryPossibility.Necessary && !isFound)
                {
                    s.Color = Microsoft.Glee.Drawing.Color.Yellow;
                    return(false);
                }
                if (QueryPossibility == Utility.QueryPossibility.Possibly && isFound)
                {
                    s.Color = Microsoft.Glee.Drawing.Color.Green;
                    return(true);
                }
            }
            return(isFound);
        }
        public static void Tester()
        {
            List <State> allStat = AraSystem.GetInstance().States;

            foreach (State s in allStat)
            {
                System.Diagnostics.Debug.WriteLine(String.Format("State {0} :", s.ToString()));
                foreach (Arc arc in s.Arcs)
                {
                    System.Diagnostics.Debug.WriteLine(String.Format("\t  {0} to {1}", arc.ToString(), arc.State.ToString()));
                }
            }

            /*Object[] expressions = value.ToArray();
             * Array.Reverse(expressions, 0, expressions.Length);
             * int counter = 0;
             * Fluent[] allFluents = new Fluent[fluents.Count];
             * foreach (Fluent f in fluents.Keys)
             * {
             *  allFluents[counter] = f;
             *  counter++;
             *  System.Diagnostics.Debug.Write(f + "\t");
             * }
             *
             * System.Diagnostics.Debug.Write("\n------------------------------\n");
             * Hashtable[] test = getTruthTable();
             * for (int i = 0; i < test.Length; i++)
             * {
             *  Hashtable h = test[i];
             *  for (int j = 0; j < h.Count; j++)
             *  {
             *      System.Diagnostics.Debug.Write(h[allFluents[j]] + "\t");
             *  }
             *  bool b = expressionValue(expressions, test[i]);
             *  System.Diagnostics.Debug.Write(">>>>  " + b);
             *  System.Diagnostics.Debug.Write("\n");
             * }
             */
        }
Beispiel #6
0
 internal static void LoadSystem(AraSystem system)
 {
     araSystem = system;
 }