コード例 #1
0
        //
        // Construct the main Hypergraph
        //
        private void ConstructHypergraph()
        {
            // Resets all saved data to allow multiple problems
            GenericInstantiator.Instantiator.Clear();

            // Build the hypergraph through instantiation
            graph = instantiator.Instantiate(figure, givens);

            // Construct the hypergraph wrapper to give access to the front-end.
            hgWrapper = new EngineUIBridge.HypergraphWrapper(graph);

            if (Utilities.DEBUG)
            {
                graph.DumpNonEquationClauses();
                graph.DumpEquationClauses();
            }
        }
コード例 #2
0
ファイル: Utilities.cs プロジェクト: boubre/TutorAI
        //
        // Acquires the hypergraph index value of the given nodes using structural equality
        //
        public static List <int> CollectGraphIndices(Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> graph, List <ConcreteAST.GroundedClause> clauses)
        {
            List <int> indices = new List <int>();

            foreach (ConcreteAST.GroundedClause gc in clauses)
            {
                int index = Utilities.StructuralIndex(graph, gc);
                if (index != -1)
                {
                    indices.Add(index);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("We expect to find the given node (we did not): " + gc.ToString());
                }
            }

            return(indices);
        }
コード例 #3
0
ファイル: Utilities.cs プロジェクト: boubre/TutorAI
        // Acquire the index of the clause in the hypergraph based only on structure
        public static int StructuralIndex(Hypergraph.Hypergraph <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> graph, ConcreteAST.GroundedClause g)
        {
            //
            // Handle general case
            //
            List <Hypergraph.HyperNode <ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> > vertices = graph.vertices;

            for (int v = 0; v < vertices.Count; v++)
            {
                if (vertices[v].data.StructurallyEquals(g))
                {
                    return(v);
                }

                if (vertices[v].data is ConcreteAST.Strengthened)
                {
                    if ((vertices[v].data as ConcreteAST.Strengthened).strengthened.StructurallyEquals(g))
                    {
                        return(v);
                    }
                }
            }

            //
            // Handle strengthening by seeing if the clause is found without a 'strengthening' component
            //
            ConcreteAST.Strengthened streng = g as ConcreteAST.Strengthened;
            if (streng != null)
            {
                int index = StructuralIndex(graph, streng.strengthened);
                if (index != -1)
                {
                    return(index);
                }
            }

            return(-1);
        }