public void ConstructAllImplied() { // // Calculate all the important points of intersection among shapes (as well as Circle-Circle intersections). // ShapeIntersectionCalculator shapeIntCalc = new ShapeIntersectionCalculator(this); List <CircleCircleIntersection> tempCCInter = new List <CircleCircleIntersection>(); shapeIntCalc.CalcCircleCircleIntersections(out tempCCInter); ccIntersections = tempCCInter; // // Generate ALL segment clauses // // Have we done this before? Hard-coded provides collinear relationships. CalculateCollinear(); GenerateSegmentClauses(); // Acquire all of the unlabeled points from the UI drawing. DrawingPointCalculator unlabeledCalc = new DrawingPointCalculator(points, segments, circles); unlabeledPoints = unlabeledCalc.GetUnlabeledPoints(); // Add the implied points to the complete list of points. allFigurePoints.AddRange(unlabeledPoints); // Using only segments, identify all polygons which are implied. PolygonCalculator polyCalc = new PolygonCalculator(segments); polygons = polyCalc.GetPolygons(); shapeIntCalc.CalcCirclePolygonIntersectionPoints(); shapeIntCalc.CalcPolygonPolygonIntersectionPoints(); // Determine what shapes are contained within what other shapes. ShapeContainmentCalculator shapeContainCalc = new ShapeContainmentCalculator(this); shapeContainCalc.CalcCircleCircleContainment(); shapeContainCalc.CalcCirclePolygonContainment(); shapeContainCalc.CalcPolygonPolygonContainment(); // Calculate all (selective) Segment-Segment Intersections CalculateIntersections(); // Find all circle-segment intersection points. // Segments (which are not part of a polygon) may intersect a circle; these are also added to the circle's interesting points. csIntersections = shapeIntCalc.FindCircleSegmentIntersections(); // Find all the angles based on intersections; duplicates are removed. CalculateAngles(); // Identify inscribed and circumscribed situations between a circle and polygon. AnalyzeCirclePolygonInscription(); // Determine which of the UI and implied (intersection) points apply to each circle. // Generates all arc clauses and arcInMiddle clauses. AnalyzeAllCirclePointRelationships(); // // All of the following calculations are used in stating the assumptions (user-defined givens) // CalculateSegmentBisectors(); CalculateAngleBisectors(); // Define in Properties->Build->Compilation Symbols to turn off this section #if !ATOMIC_REGION_OFF List <Sector> localMinorSectors = null; List <Sector> localMajorSectors = null; List <Semicircle> localSemicircles = null; foreach (Circle circle in circles) { circle.ConstructImpliedAreaBasedSectors(out localMinorSectors, out localMajorSectors, out localSemicircles); } // // Atomic region identification // atomicRegions = AtomicRegionIdentifier.AtomicIdentifierMain.GetAtomicRegions(allFigurePoints, circles, polygons); // // This is to ensure that we actually construct all the polygonalized versions of all the atomic regions. // foreach (AtomicRegion atom in atomicRegions) { Polygon poly = atom.GetPolygonalized(); if (Utilities.CONSTRUCTION_DEBUG) { Debug.WriteLine(poly); } } #endif // --- End timing --- stopwatch.Stop(); }
// Returns: <number of interesting problems, number of original problems generated> public ShadedAreaFigureStatisticsAggregator AnalyzeFigure() { ShadedAreaFigureStatisticsAggregator figureStats = new ShadedAreaFigureStatisticsAggregator(); // Set the number of atomic regions. figureStats.numAtomicRegions = this.implied.atomicRegions.Count; // Start overall timing figureStats.stopwatch.Start(); // Start stopwatch. stopwatch.Start(); // Handle givens that strengthen the intrinsic parts of the figure; modifies if needed given = DoGivensStrengthenFigure(); // Use a worklist technique to instantiate nodes to construct the hypergraph for this figure ConstructHypergraph(); // Track implicit and explicit facts. figureStats.totalImplicitFacts = figure.Count; figureStats.totalExplicitFacts = deductiveGraph.Size() - figure.Count; // Create the integer-based hypergraph representation ConstructPebblingHypergraph(); // Pebble that hypergraph Pebble(); // // Stop stopwatch and mark deduction timing. // stopwatch.Stop(); deductionTiming = stopwatch.Elapsed; stopwatch.Reset(); // // Restart stopwatch for solving. // stopwatch.Reset(); stopwatch.Start(); // // Acquire the list of strengthened (pebbled) polygon nodes. // List <int> pebbledIndices = pebblerGraph.GetPebbledNodes(); List <GeometryTutorLib.ConcreteAST.Strengthened> strengthenedNodes = deductiveGraph.GetStrengthenedNodes(pebbledIndices); // Perform any calculations required for shaded-area solution synthesis: strengthening, hierarchy construction, etc. AreaBasedCalculator areaCal = new AreaBasedCalculator(implied, strengthenedNodes); areaCal.PrepareAreaBasedCalculations(); figureStats.numShapes = areaCal.GetAllFigures().Count; // Save the roots of the hierarchy for interesting analysis. roots = areaCal.GetRootShapes(); figureStats.numRootShapes = roots.Count; // // Based on pebbling, we have a specific set of reachable nodes in the hypergraph. // Determine all the known values in the figure based on the pebbled hypergraph and all the known values stated in the problem. // List <GeometryTutorLib.ConcreteAST.GroundedClause> reachableConEqs = FindReachableCongEquationNodes(); List <GeometryTutorLib.ConcreteAST.GroundedClause> triangles = FindReachableTriangles(); known = GeometryTutorLib.Area_Based_Analyses.KnownValueAcquisition.AcquireAllKnownValues(known, reachableConEqs, triangles); // // Find the set of all equations for the shapes in this figure. // solutionAreaGenerator = new GeometryTutorLib.Area_Based_Analyses.AreaSolutionGenerator(areaCal.GetShapeHierarchy(), areaCal.GetUpdatedAtomicRegions()); solutionAreaGenerator.SolveAll(known, areaCal.GetAllFigures()); // // Stop the stopwatch for solving. // stopwatch.Stop(); this.solverTiming = stopwatch.Elapsed; // Acquire a single solution for this specific problem for validation purposes. KeyValuePair <GeometryTutorLib.Area_Based_Analyses.ComplexRegionEquation, double> result = solutionAreaGenerator.GetSolution(goalRegions); // Number of area facts figureStats.numAreaFacts = result.Key.expr.NumRegions(); #if HARD_CODED_UI UIDebugPublisher.getInstance().clearWindow(); UIDebugPublisher.getInstance().publishString("Original Problem: " + string.Format("{0:N4}", result.Value) + " = " + result.Key.CheapPrettyString()); #else if (Utilities.SHADED_AREA_SOLVER_DEBUG) { Debug.WriteLine("Original Problem: " + string.Format("{0:N4}", result.Value) + " = " + result.Key.CheapPrettyString()); } #endif // // Validate that calculated area value matches the value from the hard-coded problem. // Validate(result.Key, result.Value); figureStats.originalProblemInteresting = OriginalProblemInteresting(); //figureStats.numCalculableRegions = solutionAreaGenerator.GetNumComputable(); //figureStats.numIncalculableRegions = solutionAreaGenerator.GetNumIncomputable(); //Debug.WriteLine("Calculable Regions: " + figureStats.numCalculableRegions); //Debug.WriteLine("Incalculable Regions: " + figureStats.numIncalculableRegions); //Debug.WriteLine("Total: " + (figureStats.numCalculableRegions + figureStats.numIncalculableRegions)); // Stop overall timing. figureStats.stopwatch.Stop(); if (Utilities.SHADED_AREA_SOLVER_DEBUG) { solutionAreaGenerator.PrintAllSolutions(); } return(figureStats); }