Package cern.colt.list

Examples of cern.colt.list.ObjectArrayList


     * @param formula
     * @return List of {@link ITabularFormula}
     */
    public static ObjectArrayList createCTF(ITabularFormula formula)
    {
        ObjectArrayList ctf = new ObjectArrayList();

        ObjectArrayList tiers = formula.getTiers();

        ITabularFormula f = new SimpleFormula();
        f.unionOrAdd(formula.getTier(0).clone());
        ctf.add(f);

        for (int i = 1; i < tiers.size(); i++)
        {
            ITier tier = ((ITier) tiers.get(i)).clone();
            //  Search possible CTFs to which the tier may join
            if (!joinTier(ctf, tier))
            {
                f = new SimpleFormula();
                f.unionOrAdd(tier);
View Full Code Here


            {
                builder.append("<empty>\n");
            }
            else
            {
                ObjectArrayList tiers = formula.getTiers();
                for (int j = 0; j < tiers.size(); j++)
                {
                    ITier tier = (ITier) tiers.get(j);
                    for (ITripletValue tripletValue : tier)
                    {
                        for (int i = 0; i < formula.getVarCount(); i++)
                        {
                            int varName = formula.getPermutation().get(i);
View Full Code Here

            builder.append("p cnf ");
            builder.append(formula.getVarCount());
            builder.append(" ");
            builder.append(formula.getClausesCount());
            builder.append('\n');
            ObjectArrayList tiers = formula.getTiers();
            for (int i = 0; i < tiers.size(); i++)
            {
                ITier tier = (ITier) tiers.get(i);
                for (ITripletValue tripletValue : tier)
                {
                    if (tripletValue.isNotA()) builder.append('-');
                    builder.append(tier.getAName());
                    builder.append(' ');
View Full Code Here

     */
    public static ObjectArrayList createHyperStructuresSystem(ObjectArrayList cts, ICompactTripletsStructure sBasic, Properties statistics) throws EmptyStructureException
    {
        VarPairsIndexFactory.getInstance().clear();
       
        final ObjectArrayList hss = new ObjectArrayList();
       
        try
        {
            statistics.put(BASIC_CTS_INITIAL_CLAUSES_COUNT, String.valueOf(sBasic.getClausesCount()));
           
            //  List of ITier
            ObjectArrayList basicTiers = sBasic.getTiers();
           
            IHyperStructure basicGraph = createFirstHSSTier(cts, hss, sBasic, basicTiers);
           
            StructuresForConcordantShift structuresForConcordantShift = new StructuresForConcordantShift(hss.size());
           
            for (int j = 1; j < basicTiers.size(); j++)
            {
                if (LOGGER.isDebugEnabled())
                {
                    LOGGER.debug("Building HSS tier #{} of {}", j+1, basicTiers.size());
                }
            
                final int nextTierIndex = j;
                final int prevTierIndex = nextTierIndex - 1;
                final ITier basicPrevTier = (ITier) basicTiers.get(prevTierIndex);
                final ITier basicNextTier = (ITier) basicTiers.get(nextTierIndex);
   
                OpenIntObjectHashMap basicPrevTierVertices = (OpenIntObjectHashMap) basicGraph.getTiers().get(prevTierIndex);
               
                if (LOGGER.isDebugEnabled())
                {
View Full Code Here

    private static void createOrUpdateNextTierVertexInHSS(final int nextTierIndex,
            final ITier basicNextTier, final ObjectArrayList hss,
            int tierKeyOfTheVertexToShift, ITripletValue adjoinTarget, EdgeKind edgeKind,
            int vertexIndex, int verticesCount, boolean showProgressToLog, StructuresForConcordantShift structuresForConcordantShift)
    {
        ObjectArrayList substructureEdges = concordantShift(
                hss, nextTierIndex, tierKeyOfTheVertexToShift, basicNextTier.getCName(),
                adjoinTarget.isNotC() ? Value.AllNegative : Value.AllPlain,
                vertexIndex, verticesCount, showProgressToLog, structuresForConcordantShift);

        for (int h = 0; h < hss.size(); h++)
        {
            IHyperStructure hs = (IHyperStructure) hss.get(h);
            OpenIntObjectHashMap prevTierVertices = (OpenIntObjectHashMap) hs.getTiers().get(nextTierIndex - 1);
            IVertex prevTierVertex = (IVertex) prevTierVertices.get(tierKeyOfTheVertexToShift);
            ICompactTripletsStructure substructureEdge = (ICompactTripletsStructure) substructureEdges.get(h);
           
            if (substructureEdge.isEmpty())
            {
                //  Mark all vertices of HSS tierIndex with empty edges
                prevTierVertex.foundEmptyEdge(edgeKind);
View Full Code Here

           
            for (int h = 0; h < hss.size(); h++)
            {
                IHyperStructure hs = (IHyperStructure) hss.get(h);
                OpenIntObjectHashMap sTierVertices = (OpenIntObjectHashMap) hs.getTiers().get(s);
                ObjectArrayList intersections = (ObjectArrayList) structuresForConcordantShift.hsIntersections.get(h);
                intersections.clear();
               
                for (int sv = 0; sv < sTierSize; sv++)
                {
                    IVertex sTierVertex = (IVertex) sTierVertices.values().get(sv);
                   
                    ICompactTripletsStructure clone = (ICompactTripletsStructure) ((ICompactTripletsStructure) structuresForConcordantShift.substructureEdges.get(h)).clone();
                    clone.intersect(sTierVertex.getCTS());
                    intersections.add(clone);
                }
            }
           
            //  Unify intersections
            int intersectionsSize = ((ObjectArrayList) structuresForConcordantShift.hsIntersections.get(0)).size();
           
            if (intersectionsSize == 0)
            {
                clear(structuresForConcordantShift.substructureEdges);
                return structuresForConcordantShift.substructureEdges;
            }
           
            for (int v = 0; v < intersectionsSize; v++)
            {
                structuresForConcordantShift.coincidentIntersections.clear();
                for (int h = 0; h < hss.size(); h++)
                {
                    ObjectArrayList intersections = (ObjectArrayList) structuresForConcordantShift.hsIntersections.get(h);
                    ICompactTripletsStructure intersection = (ICompactTripletsStructure) intersections.get(v);
                    structuresForConcordantShift.coincidentIntersections.add(intersection);
                }
               
                try
                {
                    unifyIntermediateSubstructures(structuresForConcordantShift.coincidentIntersections);
                }
                catch(EmptyStructureException e)
                {
                    //  If some intersection is empty => all intersections should be empty
                    clear(structuresForConcordantShift.coincidentIntersections);
                }
            }
           
            //  Parallel union
           
            for (int h = 0; h < hss.size(); h++)
            {
                ObjectArrayList intersections = (ObjectArrayList) structuresForConcordantShift.hsIntersections.get(h);
                ICompactTripletsStructure substructureEdge = (ICompactTripletsStructure) intersections.get(0);
                structuresForConcordantShift.substructureEdges.set(h, substructureEdge);
            }
           
            for (int ks = 1; ks < intersectionsSize; ks++)
            {
                for (int h = 0; h < hss.size(); h++)
                {
                    ObjectArrayList intersections = (ObjectArrayList) structuresForConcordantShift.hsIntersections.get(h);
                    ICompactTripletsStructure substructureEdge = (ICompactTripletsStructure) structuresForConcordantShift.substructureEdges.get(h);
                    ICompactTripletsStructure intersection = (ICompactTripletsStructure) intersections.get(ks);
                    substructureEdge.union(intersection);
                }
            }
           
            try
View Full Code Here

        for (int j = 0; j < keys.size(); j++)
        {
            int vertexTierKey = keys.get(j);
           
            //  List of ICompactTripletsStructureHolder
            ObjectArrayList vertices = new ObjectArrayList(hss.size());
           
            for (int i = 0; i < hss.size(); i++)
            {
                IHyperStructure hs = (IHyperStructure) hss.get(i);
                       
                IVertex vertex = (IVertex) ((OpenIntObjectHashMap) hs.getTiers().get(tierIndex)).get(vertexTierKey);
               
                vertices.add(vertex);
            }
           
            try
            {
                if (hss.size() > 1)
                {
                    unify(vertices);
                }
                else
                {
                    //  Cross-hyperstructure unification is not applicable for
                    //  HSS if there's less than 2 structures in it.
                    //  But if we have any empty substructure-vertex in vertices
                    //  we should remove this vertex from the basic graph
                    for (int i = 0; i < vertices.size(); i++)
                    {
                        IVertex vertex = (IVertex) vertices.get(i);
                        if (vertex.getCTS().isEmpty())
                        {
                            throw new EmptyStructureException(vertex.getCTS());
                        }
                    }
View Full Code Here

        final int widthOfTierHeader = ("(,,) j=".length()
                                       + 3 * getLegendName(varCount).length()
                                       + String.valueOf(varCount - 2).length()) * widthOfZeroChar;
       
        //  List of ITier
        ObjectArrayList ctsTiers = hs.getBasicCTS().getTiers();
        final int tiersCount = ctsTiers.size();
       
        final int widthOfValuesArea = 8 * (widthOfZeroChar * 3 + widthBetweenChars * 2) + 8 * widthBetweenTriplets + offsetLeft;
       
        image = new BufferedImage(widthOfValuesArea + widthOfTierHeader + offsetRight,
                                  heightOfZeroChar * tiersCount + heightBetweenTriplets * (tiersCount - 1) + offsetTop + offsetBottom,
                                  BufferedImage.TYPE_3BYTE_BGR);
       
        final Graphics2D graphics = (Graphics2D) image.getGraphics();
        graphics.setColor(Color.WHITE);
        graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
       
        graphics.setFont(font);
        graphics.setColor(Color.BLACK);
       
        //  List of OpenIntObjectHashMap
        ObjectArrayList tiers = hs.getTiers();
        for (int i = 0; i < tiers.size(); i++)
        {
            final OpenIntObjectHashMap tier = (OpenIntObjectHashMap) tiers.get(i);
            ITier ctsTier =  (ITier) ctsTiers.get(i);

            final int tierIndex = i;
           
            final int y = offsetTop + heightOfZeroChar + tierIndex * heightOfZeroChar + tierIndex * heightBetweenTriplets;
 
View Full Code Here

//        {
//            LOGGER.info("Skipping quickFindHSSRoute to test full HSS reduction to elementary HSS");
//            return new ObjectArrayList(new Object[] { null });
//        }

        ObjectArrayList result = new ObjectArrayList(tiersCount);
        ObjectArrayList structures = new ObjectArrayList();

        OpenIntObjectHashMap verticesFromLastTiers = new OpenIntObjectHashMap();
        fillVerticesFromLastTier(hss, structures, verticesFromLastTiers);

        byte prevVertexTierKey = findIntersectionWithFirstTier(hss, result, structures, verticesFromLastTiers);

        if (prevVertexTierKey == -1)
        {
            throw new AssertionError("There must be at least one non-empty same-name intersection of last-tier vertex with first-tier vertex of HSS");
        }
       
        for (int j = 1; j < tiersCount - 1; j++)
        {
            ObjectArrayList intersections = new ObjectArrayList();
            ObjectArrayList targetVertices = new ObjectArrayList();
           
            boolean allNotEmpty = true;
            //  Check bottomVertex1
            for (int h = 0; h < hss.size(); h++)
            {
                IHyperStructure hs = (IHyperStructure) hss.get(h);
               
                OpenIntObjectHashMap prevTier = (OpenIntObjectHashMap) hs.getTiers().get(j - 1);
               
                IVertex prevTierVertex = (IVertex) prevTier.get(prevVertexTierKey);
               
                OpenIntObjectHashMap nextTier = (OpenIntObjectHashMap) hs.getTiers().get(j);

                IVertex bottomVertex1 = prevTierVertex.getBottomVertex1();

                if (bottomVertex1 == null)
                {
                    allNotEmpty = false;
                    break;
                }
               
                IVertex nextTierVertex = (IVertex) nextTier.get(bottomVertex1.getTripletValue().getTierKey());
               
                if (nextTierVertex == null)
                {
                    allNotEmpty = false;
                    break;
                }
               
                ICompactTripletsStructure clone = (ICompactTripletsStructure) ((ICompactTripletsStructure) structures.get(h)).clone();
               
                clone.intersect(nextTierVertex.getCTS());
               
                if (clone.isEmpty())
                {
                    allNotEmpty = false;
                    break;
                }
               
                targetVertices.add(nextTierVertex);
                intersections.add(clone);
            }
           
            allNotEmpty = allNotEmpty && forwardFilterPassed(hss, targetVertices, j, tiersCount, intersections, verticesFromLastTiers);
           
            if (allNotEmpty)
            {
                //  Intersection with bottomVertex1
                OpenIntObjectHashMap prevTier = (OpenIntObjectHashMap) basicGraph.getTiers().get(j - 1);
               
                IVertex prevTierVertex = (IVertex) prevTier.get(prevVertexTierKey);
               
                IVertex vertex = prevTierVertex.getBottomVertex1();
               
                result.add(vertex);
               
                prevVertexTierKey = vertex.getTripletValue().getTierKey();
               
                updateStructures(hss, structures, j, prevVertexTierKey);
               
                continue;
            }
            intersections = new ObjectArrayList();
            targetVertices = new ObjectArrayList();
            allNotEmpty = true;
            //  Check bottomVertex2
            for (int h = 0; h < hss.size(); h++)
            {
                IHyperStructure hs = (IHyperStructure) hss.get(h);
               
                OpenIntObjectHashMap prevTier = (OpenIntObjectHashMap) hs.getTiers().get(j - 1);
               
                IVertex prevTierVertex = (IVertex) prevTier.get(prevVertexTierKey);
               
                OpenIntObjectHashMap nextTier = (OpenIntObjectHashMap) hs.getTiers().get(j);

                IVertex bottomVertex2 = prevTierVertex.getBottomVertex2();

                if (bottomVertex2 == null)
                {
                    allNotEmpty = false;
                    break;
                }

                IVertex nextTierVertex = (IVertex) nextTier.get(bottomVertex2.getTripletValue().getTierKey());

                if (nextTierVertex == null)
                {
                    allNotEmpty = false;
                    break;
                }

                ICompactTripletsStructure clone = (ICompactTripletsStructure) ((ICompactTripletsStructure) structures.get(h)).clone();

                clone.intersect(nextTierVertex.getCTS());
               
                if (clone.isEmpty())
                {
                    allNotEmpty = false;
                    break;
                }
               
                targetVertices.add(nextTierVertex);
                intersections.add(clone);
            }
           
            allNotEmpty = allNotEmpty && forwardFilterPassed(hss, targetVertices, j, tiersCount, intersections, verticesFromLastTiers);
           
View Full Code Here

            int tierSize = ((OpenIntObjectHashMap) basicGraph.getTiers().get(j)).size();
           
            for (int s = 0; s < tierSize; s++)
            {
                boolean allSameNameIntersectionsNotEmpty = true;
                ObjectArrayList intersections = new ObjectArrayList();
                ObjectArrayList targetVertices = new ObjectArrayList();
               
                for (int h = 0; h < hss.size(); h++)
                {
                    IHyperStructure hs = (IHyperStructure) hss.get(h);
                   
                    OpenIntObjectHashMap tierVertices = (OpenIntObjectHashMap) hs.getTiers().get(j);
                   
                    IVertex tierVertex = (IVertex) tierVertices.values().get(s);
                   
                    ICompactTripletsStructure clone = (ICompactTripletsStructure) ((ICompactTripletsStructure) structures.get(h)).clone();
                   
                    clone.intersect(tierVertex.getCTS());
                   
                    if (clone.isEmpty())
                    {
                        allSameNameIntersectionsNotEmpty = false;
                        break;
                    }
                   
                    targetVertices.add(tierVertex);
                    intersections.add(clone);
                }
               
                allSameNameIntersectionsNotEmpty = allSameNameIntersectionsNotEmpty
                                                && forwardFilterPassed(hss, targetVertices, j, tiersCount, intersections, verticesFromLastTiers);
View Full Code Here

TOP

Related Classes of cern.colt.list.ObjectArrayList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.