예제 #1
0
        public List<ProblemAnalyzer.Problem<Hypergraph.EdgeAnnotation>> AnalyzeFigure()
        {
            // Precompute all coordinate-based interesting relations (problem goal nodes)
            // These become the basis for the template-based problem generation (these are the goals)
            Precompute();

            // Handle givens that strengthen the intrinsic parts of the figure; modifies if needed
            givens = DoGivensStrengthenFigure();

            // Use a worklist technique to instantiate nodes to construct the hypergraph for this figure
            ConstructHypergraph();

            // Create the integer-based hypergraph representation
            ConstructPebblingHypergraph();

            // Pebble that hypergraph
            Pebble();

            // Analyze paths in the hypergraph to generate the pair of <forward problems, backward problems> (precomputed nodes are goals)
            KeyValuePair<List<ProblemAnalyzer.Problem<Hypergraph.EdgeAnnotation>>, List<ProblemAnalyzer.Problem<Hypergraph.EdgeAnnotation>>> problems = GenerateTemplateProblems();

            // Combine the problems together into one list
            List<ProblemAnalyzer.Problem<Hypergraph.EdgeAnnotation>> candidateProbs = new List<ProblemAnalyzer.Problem<Hypergraph.EdgeAnnotation>>();
            candidateProbs.AddRange(problems.Key);
            // candidateProbs.AddRange(problems.Value);

            // Determine which, if any, of the problems are interesting (using definition that 100% of the givens are used)
            interestingCalculator = new ProblemAnalyzer.InterestingProblemCalculator(graph, figure, givens);
            List<ProblemAnalyzer.Problem<Hypergraph.EdgeAnnotation>> interestingProblems = interestingCalculator.DetermineInterestingProblems(candidateProbs);

            // Partition the problem-space based on the query vector defined (by us or the user)
            problemSpacePartitions = new ProblemAnalyzer.PartitionedProblemSpace(graph, queryVector);
            problemSpacePartitions.ConstructPartitions(interestingProblems);

            // Validate that we have generated all of the original problems from the text.     NO GOALS; no validation
            // List<ProblemAnalyzer.Problem> generatedBookProblems = problemSpacePartitions.ValidateOriginalProblems(givens, goals);

            if (Utilities.PROBLEM_GEN_DEBUG) problemSpacePartitions.DumpPartitions();

            //if (Utilities.DEBUG)
            //{
            //    Debug.WriteLine("\nAll " + generatedBookProblems.Count + " Book-specified problems: \n");
            //    foreach (ProblemAnalyzer.Problem bookProb in generatedBookProblems)
            //    {
            //        Debug.WriteLine(bookProb.ConstructProblemAndSolution(graph));
            //    }
            //}

            //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"generatedProblems.txt", true))
            //{
            //    //
            //    // Forward Problems
            //    //
            //    foreach (GeometryTutorLib.ProblemAnalyzer.Problem<GeometryTutorLib.Hypergraph.EdgeAnnotation> problem in interestingProblems)
            //    {
            //        file.WriteLine(problem.ConstructProblemAndSolution(graph).ToString());
            //    }

            //    //
            //    // Converse Problems
            //    //
            //    foreach (GeometryTutorLib.ProblemAnalyzer.Problem<GeometryTutorLib.Hypergraph.EdgeAnnotation> problem in problems.Value)
            //    {
            //        file.WriteLine(problem.ConstructProblemAndSolution(graph).ToString());
            //    }
            //}

            // Adding all the backward problems to the interesting forward problems.
            interestingProblems.AddRange(problems.Value);

            return interestingProblems;
        }
예제 #2
0
        public List <ProblemAnalyzer.Problem <Hypergraph.EdgeAnnotation> > AnalyzeFigure()
        {
            // Precompute all coordinate-based interesting relations (problem goal nodes)
            // These become the basis for the template-based problem generation (these are the goals)
            Precompute();

            // Handle givens that strengthen the intrinsic parts of the figure; modifies if needed
            givens = DoGivensStrengthenFigure();

            // Use a worklist technique to instantiate nodes to construct the hypergraph for this figure
            ConstructHypergraph();

            // Create the integer-based hypergraph representation
            ConstructPebblingHypergraph();

            // Pebble that hypergraph
            Pebble();

            // Analyze paths in the hypergraph to generate the pair of <forward problems, backward problems> (precomputed nodes are goals)
            KeyValuePair <List <ProblemAnalyzer.Problem <Hypergraph.EdgeAnnotation> >, List <ProblemAnalyzer.Problem <Hypergraph.EdgeAnnotation> > > problems = GenerateTemplateProblems();

            // Combine the problems together into one list
            List <ProblemAnalyzer.Problem <Hypergraph.EdgeAnnotation> > candidateProbs = new List <ProblemAnalyzer.Problem <Hypergraph.EdgeAnnotation> >();

            candidateProbs.AddRange(problems.Key);
            // candidateProbs.AddRange(problems.Value);

            // Determine which, if any, of the problems are interesting (using definition that 100% of the givens are used)
            interestingCalculator = new ProblemAnalyzer.InterestingProblemCalculator(graph, figure, givens);
            List <ProblemAnalyzer.Problem <Hypergraph.EdgeAnnotation> > interestingProblems = interestingCalculator.DetermineInterestingProblems(candidateProbs);

            // Partition the problem-space based on the query vector defined (by us or the user)
            problemSpacePartitions = new ProblemAnalyzer.PartitionedProblemSpace(graph, queryVector);
            problemSpacePartitions.ConstructPartitions(interestingProblems);

            // Validate that we have generated all of the original problems from the text.     NO GOALS; no validation
            // List<ProblemAnalyzer.Problem> generatedBookProblems = problemSpacePartitions.ValidateOriginalProblems(givens, goals);

            if (Utilities.PROBLEM_GEN_DEBUG)
            {
                problemSpacePartitions.DumpPartitions();
            }

            //if (Utilities.DEBUG)
            //{
            //    Debug.WriteLine("\nAll " + generatedBookProblems.Count + " Book-specified problems: \n");
            //    foreach (ProblemAnalyzer.Problem bookProb in generatedBookProblems)
            //    {
            //        Debug.WriteLine(bookProb.ConstructProblemAndSolution(graph));
            //    }
            //}

            //using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"generatedProblems.txt", true))
            //{
            //    //
            //    // Forward Problems
            //    //
            //    foreach (GeometryTutorLib.ProblemAnalyzer.Problem<GeometryTutorLib.Hypergraph.EdgeAnnotation> problem in interestingProblems)
            //    {
            //        file.WriteLine(problem.ConstructProblemAndSolution(graph).ToString());
            //    }

            //    //
            //    // Converse Problems
            //    //
            //    foreach (GeometryTutorLib.ProblemAnalyzer.Problem<GeometryTutorLib.Hypergraph.EdgeAnnotation> problem in problems.Value)
            //    {
            //        file.WriteLine(problem.ConstructProblemAndSolution(graph).ToString());
            //    }
            //}

            // Adding all the backward problems to the interesting forward problems.
            interestingProblems.AddRange(problems.Value);

            return(interestingProblems);
        }