public TemplateProblemGenerator(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g,
                                 Pebbler.Pebbler pebbler,
                                 ProblemAnalyzer.PathGenerator generator)
 {
     graph = g;
     this.pebbler = pebbler;
     pathGenerator = generator;
 }
Esempio n. 2
0
        private bool EdgeSourcesKnown(Pebbler.PebblerHyperEdge<Hypergraph.EdgeAnnotation> edge, List<int> taken)
        {
            foreach (int src in edge.sourceNodes)
            {
                if (!taken.Contains(src)) return false;
            }

            return true;
        }
Esempio n. 3
0
        private int EdgeSourcesUnknownCount(Pebbler.PebblerHyperEdge<Hypergraph.EdgeAnnotation> edge, List<int> taken)
        {
            int count = 0;
            foreach (int src in edge.sourceNodes)
            {
                if (!taken.Contains(src)) count++;
            }

            return count;
        }
        //
        // Generates all forward directional problems using the template-based clauses from the pre-computation
        //
        private List<Problem<Hypergraph.EdgeAnnotation>> GenerateForwardProblems(List<GroundedClause> goalClauses,
                                                                                 Pebbler.HyperEdgeMultiMap<Hypergraph.EdgeAnnotation> edgeDatabase,
                                                                                 int numGivens)
        {
            //            System.Diagnostics.Debug.WriteLine("Forward");

            List<int> clauseIndices = AcquireGoalIndices(goalClauses);

            // The resultant structure of problems; graph size dictates associated array size in hashMap; number of givens is a limiting factor the size of problems
            ProblemHashMap<Hypergraph.EdgeAnnotation> problems = new ProblemHashMap<Hypergraph.EdgeAnnotation>(edgeDatabase, graph.vertices.Count, numGivens);

            // Generate all the problems based on the node indices
            foreach (int goalNode in clauseIndices)
            {
                if (Utilities.PROBLEM_GEN_DEBUG)
                {
                    System.Diagnostics.Debug.WriteLine("Template node; will generate problems (" + goalNode + "): " + graph.vertices[goalNode].data.ToString());
                }

                pathGenerator.GenerateProblemsUsingBackwardPathToLeaves(problems, edgeDatabase, goalNode);
            }

            return FilterForMinimalAndRedundantProblems(problems.GetAll());
        }
        private List<Problem<Hypergraph.EdgeAnnotation>> GenerateBackwardProblems(List<GroundedClause> goalClauses,
                                                                                  Pebbler.HyperEdgeMultiMap<Hypergraph.EdgeAnnotation> edgeDatabase)
        {
            System.Diagnostics.Debug.WriteLine("Backward");

            List<int> clauseIndices = AcquireGoalIndices(goalClauses);

            // The resultant structure of problems; graph size dictates associated array size in hashMap; number of givens is a limiting factor the size of problems
            // Problem generation limits the number of givens in BACKWARD problems to 4 (or the constant in the HashMap structure)
            ProblemHashMap<Hypergraph.EdgeAnnotation> problems = new ProblemHashMap<Hypergraph.EdgeAnnotation>(edgeDatabase, graph.vertices.Count);

            // Generate all the problems based on the node indices
            foreach (int goalNode in clauseIndices)
            {
                if (Utilities.PROBLEM_GEN_DEBUG)
                {
                    System.Diagnostics.Debug.WriteLine("Template node; will generate problems (" + goalNode + "): " + graph.vertices[goalNode].data.ToString());
                }

                pathGenerator.GenerateProblemsUsingBackwardPathToLeaves(problems, edgeDatabase, goalNode);
            }

            // Filter backward problems so that only problems with goal being the original figure givens persist.
            return FilterBackwardProblems(clauseIndices, FilterForMinimalAndRedundantProblems(problems.GetAll()));
        }