Пример #1
0
        private static GeometryTestbed.FigSynthShadedAreaProblem ConstructProblem(FigSynthProblem problem)
        {
            GeometryTestbed.FigSynthShadedAreaProblem shadedArea = new GeometryTestbed.FigSynthShadedAreaProblem(true, true);

            //
            // Name the problem (uniquely).
            //
            shadedArea.SetName("Fig-Synthesized " + (figCounter++));

            //
            // Construct the points.
            //
            List<Point> points = problem.CollectPoints();
            shadedArea.SetPoints(points);

            //
            // Construct the collinear relationships.
            //
            List<Segment> segments;
            List<Collinear> collinear;

            AcquireCollinearAndSegments(problem.CollectSegments(), points, out segments, out collinear);

            shadedArea.SetSegments(segments);
            shadedArea.SetCollinear(collinear);

            //
            // Construct circles.
            //
            shadedArea.SetCircles(problem.CollectCircles());

            //
            // Invoke the parser.
            //
            shadedArea.InvokeParser();

            //
            // Set the wanted atomic regions.
            //
            shadedArea.SetWantedRegions(shadedArea.GetRemainingRegionsFromParser(problem));

            //
            // Set the known values.
            // Acquire all of the givens using constant propagation for each figure construction.
            //
            shadedArea.SetKnowns(problem.AcquireKnowns());

            //
            // Set the problem given clauses.
            //
            List<GroundedClause> givens = problem.GetGivens();
            problem.GetMidpoints().ForEach(m => givens.Add(m));
            shadedArea.SetGivens(givens);

            //
            // Set the actual area of the solution (area of wanted regions).
            //
            shadedArea.SetSolutionArea(problem.GetCoordinateArea());

            return shadedArea;
        }
Пример #2
0
        private static GeometryTestbed.FigSynthShadedAreaProblem ConstructProblem(FigSynthProblem problem)
        {
            GeometryTestbed.FigSynthShadedAreaProblem shadedArea = new GeometryTestbed.FigSynthShadedAreaProblem(true, true);

            //
            // Name the problem (uniquely).
            //
            shadedArea.SetName("Fig-Synthesized " + (figCounter++));

            //
            // Construct the points.
            //
            List <Point> points = problem.CollectPoints();

            shadedArea.SetPoints(points);

            //
            // Construct the collinear relationships.
            //
            List <Segment>   segments;
            List <Collinear> collinear;

            AcquireCollinearAndSegments(problem.CollectSegments(), points, out segments, out collinear);

            shadedArea.SetSegments(segments);
            shadedArea.SetCollinear(collinear);

            //
            // Construct circles.
            //
            shadedArea.SetCircles(problem.CollectCircles());

            //
            // Invoke the parser.
            //
            shadedArea.InvokeParser();

            //
            // Set the wanted atomic regions.
            //
            shadedArea.SetWantedRegions(shadedArea.GetRemainingRegionsFromParser(problem));

            //
            // Set the known values.
            // Acquire all of the givens using constant propagation for each figure construction.
            //
            shadedArea.SetKnowns(problem.AcquireKnowns());

            //
            // Set the problem given clauses.
            //
            List <GroundedClause> givens = problem.GetGivens();

            problem.GetMidpoints().ForEach(m => givens.Add(m));
            shadedArea.SetGivens(givens);

            //
            // Set the actual area of the solution (area of wanted regions).
            //
            shadedArea.SetSolutionArea(problem.GetCoordinateArea());

            return(shadedArea);
        }
Пример #3
0
        private static bool ConstructProblemsToSolve(List <FigSynthProblem> problems)
        {
            List <FigSynthShadedAreaProblem> shadedAreaProblems = new List <FigSynthShadedAreaProblem>();

            int  problemCount = 0;
            bool worked       = true;

            foreach (FigSynthProblem problem in problems)
            {
                if (Utilities.FIGURE_SYNTHESIZER_DEBUG)
                {
                    string label = "";
                    for (int i = 0; i < 80 / ((problemCount / 10) + 1); i++)
                    {
                        label += problemCount + " ";
                    }
                    System.Diagnostics.Debug.WriteLine(label);

                    System.Diagnostics.Debug.WriteLine(problem.ToString());
                    problemCount++;
                }

                try
                {
                    // Create the problem
                    GeometryTestbed.FigSynthShadedAreaProblem shadedProb = ConstructProblem(problem);

                    // Add the problem to a running list (nothing done with the list yet).
                    shadedAreaProblems.Add(shadedProb);

                    // Actually run this problem (and solve).
                    shadedProb.Run();

                    // Data dump for statistics gathering.
                    System.Diagnostics.Debug.WriteLine(shadedProb.ToString());
                }
                catch (ArgumentException e)
                {
                    System.Diagnostics.Debug.WriteLine("Argument: " + e.ToString());
                    worked = false;
                }
                catch (NotImplementedException e)
                {
                    System.Diagnostics.Debug.WriteLine("\t\t Unimplmented");
                    worked = false;
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine("Failed: " + e.ToString());
                    worked = false;
                }

#if HARD_CODED_UI
                //if (!drawnAProblem)
                //{
                //    UIProblemDrawer.getInstance().draw(shadedProb.MakeUIProblemDescription());
                //    shadedProb.Run();
                //    return shadedAreaProblems;
                //}
                //drawnAProblem = true;
#endif
            }

            return(worked);
        }