Example #1
0
 public SolutionAgg()
 {
     atomIndices = new IndexList();
     solEq = null;
     solArea = -1;
     solType = SolutionType.UNKNOWN;
 }
Example #2
0
        public static IndexList AcquireAtomicRegionIndices(List<Atomizer.AtomicRegion> complete, List<Atomizer.AtomicRegion> selections)
        {
            IndexList indices = new IndexList();

            foreach (Atomizer.AtomicRegion atom in selections)
            {
                int index = complete.IndexOf(atom);
                if (index == -1) throw new Exception("Atomic region not found during solution generations: " + atom.ToString());
                indices.Add(index);
            }

            return indices;
        }
Example #3
0
 public bool EqualSets(IndexList that)
 {
     return(Utilities.EqualOrderedSets(this.orderedIndices, that.orderedIndices));
 }
Example #4
0
        public static IndexList DifferenceIndices(IndexList left, IndexList right)
        {
            List <int> difference = Utilities.DifferenceIfSubsetOrderedSets(left.orderedIndices, right.orderedIndices);

            return(difference == null ? null : new IndexList(difference));
        }
Example #5
0
        public static IndexList UnionIndices(IndexList left, IndexList right)
        {
            List <int> orderedUnion = Utilities.UnionIfDisjointOrderedSets(left.orderedIndices, right.orderedIndices);

            return(orderedUnion == null ? null : new IndexList(orderedUnion));
        }
Example #6
0
 public bool EqualSets(IndexList that)
 {
     return Utilities.EqualOrderedSets(this.orderedIndices, that.orderedIndices);
 }
Example #7
0
        public static IndexList UnionIndices(IndexList left, IndexList right)
        {
            List<int> orderedUnion = Utilities.UnionIfDisjointOrderedSets(left.orderedIndices, right.orderedIndices);

            return orderedUnion == null ? null : new IndexList(orderedUnion);
        }
Example #8
0
        public static IndexList DifferenceIndices(IndexList left, IndexList right)
        {
            List<int> difference = Utilities.DifferenceIfSubsetOrderedSets(left.orderedIndices, right.orderedIndices);

            return difference == null ? null : new IndexList(difference);
        }
        //
        // Makes a region out of a list of indices (of atomic regions).
        //
        private Region MakeRegion(List<int> indices)
        {
            //
            // Find a shape, if it applies.
            //
            Figure fig = null;
            IndexList indicesList = new IndexList(indices);

            if (figureIndexMap.TryGetValue(indicesList, out fig)) return new ShapeRegion(fig);

            //
            // Default to a sequence of atoms.
            //
            List<AtomicRegion> atoms = new List<AtomicRegion>();

            foreach (int index in indices)
            {
                atoms.Add(figureAtoms[index]);
            }

            return new Region(atoms);
        }
        //
        // Catalyst routine to the recursive solver: returns solution equation and actual area.
        //
        public void SolveAll(KnownMeasurementsAggregator known, List<Figure> allFigures)
        {
            PreprocessAtomAreas(known);
            PreprocessShapeHierarchyAreas(known, allFigures);

            //
            // Using the atomic regions, explore all of the top-most shapes recursively.
            //
            for (int a = 0; a < figureAtoms.Count; a++)
            {
                IndexList atomIndexList = new IndexList(a);
                SolutionAgg agg = null;

                solutions.TryGetValue(atomIndexList, out agg);

                if (agg == null)
                {
                    Figure topShape = figureAtoms[a].GetTopMostShape();

                    // Shape Region?
                    ComplexRegionEquation startEq = new ComplexRegionEquation(null, new ShapeRegion(topShape));
                    double outerArea = topShape.GetArea(known);

                    // Invoke the recursive solver using the outermost region and catalyst.
                    //ProcessChildrenShapes(a, new ShapeRegion(topShape), topShape.Hierarchy(),
                    //             new List<TreeNode<Figure>>(),
                    //             startEq, outerArea, known);
                    SolveHelper(new ShapeRegion(topShape),
                                topShape.Hierarchy().Children(),
                                startEq, outerArea, known);
                }
                else if (agg.solType == SolutionAgg.SolutionType.COMPUTABLE)
                {
                    //solutions[atomIndexList] = agg;
                }
                else if (agg.solType == SolutionAgg.SolutionType.INCOMPUTABLE)
                {
                    //solutions[atomIndexList] = agg;
                }
                else if (agg.solType == SolutionAgg.SolutionType.UNKNOWN)
                {
                    //TBD
                }
            }

            //
            // Subtraction of shapes extracts as many atomic regions as possible of the strict atomic regions, now compose those together.
            //
            ComposeAllRegions();
        }
Example #11
0
 public bool Contains(IndexList indices)
 {
     return solutions.ContainsKey(indices);
 }
Example #12
0
 //
 // If the solution exists in the root solutions as incomputable, seek a solution from the extended
 //
 public bool TryGetValue(IndexList indices, out SolutionAgg solutionAgg)
 {
     return solutions.TryGetValue(indices, out solutionAgg);
 }
Example #13
0
 public bool Contains(IndexList indices)
 {
     return(solutions.ContainsKey(indices));
 }
Example #14
0
 //
 // If the solution exists in the root solutions as incomputable, seek a solution from the extended
 //
 public bool TryGetValue(IndexList indices, out SolutionAgg solutionAgg)
 {
     return(solutions.TryGetValue(indices, out solutionAgg));
 }