Package cern.colt.list

Examples of cern.colt.list.ObjectArrayList


    }

    private static boolean forwardFilterPassed(ObjectArrayList hss, ObjectArrayList sourceVertices, int j, int tiersCount, ObjectArrayList structures, OpenIntObjectHashMap verticesFromLastTiers)
        throws EmptyStructureException
    {
        ObjectArrayList substructures = new ObjectArrayList();
        for (int i = 0; i < structures.size(); i++)
        {
            substructures.add(((ICompactTripletsStructure) structures.get(i)).clone());
        }
       
        try
        {
            //  Forward filter
           
            unifyIntermediateSubstructures(substructures);
           
            for (int j2 = j + 1; j2 < tiersCount; j2++)
            {
                OpenIntObjectHashMap hsIntersections = new OpenIntObjectHashMap();
                for (int h = 0; h < hss.size(); h++)
                {
                    IHyperStructure hs = (IHyperStructure) hss.get(h);
                    OpenIntObjectHashMap nextTier = (OpenIntObjectHashMap) hs.getTiers().get(j2);
                    ObjectArrayList intersections = new ObjectArrayList();
                    hsIntersections.put(h, intersections);
                    for (int s = 0; s < nextTier.size(); s++)
                    {
                        ICompactTripletsStructure lastTierStructure = ((IVertex) verticesFromLastTiers.get(h)).getCTS();
                        IVertex nextTierVertex = (IVertex) nextTier.values().get(s);
                        ICompactTripletsStructure nextTierStructure = (ICompactTripletsStructure) nextTierVertex.getCTS().clone();
                        nextTierStructure.intersect(lastTierStructure);
                       
                        nextTierStructure.intersect((ICompactTripletsStructure) substructures.get(h));
                        intersections.add(nextTierStructure);
                    }
                   
                    if (intersections.size() == 0)
                    {
                        //  Cannot use this path
                        return false;
                    }
                }
               
                //  Unify intersections
                int intersectionsSize = ((ObjectArrayList) hsIntersections.get(0)).size();
               
                if (intersectionsSize == 0)
                {
                    return false;
                }
               
                boolean allEmpty = true;
               
                for (int v = 0; v < intersectionsSize; v++)
                {
                    ObjectArrayList coincidentIntersections = new ObjectArrayList(hss.size());
                    for (int h = 0; h < hss.size(); h++)
                    {
                        ObjectArrayList intersections = (ObjectArrayList) hsIntersections.get(h);
                        ICompactTripletsStructure intersection = (ICompactTripletsStructure) intersections.get(v);
                        coincidentIntersections.add(intersection);
                    }
                   
                    try
                    {
View Full Code Here


     * @return List of vertices from <code>hs</code> whose substructures has non-empty intersection
     * with substructure of the <code>vertex</code> argument.  
     */
    public static ObjectArrayList findNonEmptyIntersections(IHyperStructure hs, IVertex vertex)
    {
        ObjectArrayList result = new ObjectArrayList();
        for (int j = 0; j < hs.getTiers().size(); j++)
        {
            OpenIntObjectHashMap tierVertices = (OpenIntObjectHashMap) hs.getTiers().get(j);
            for (int i = 0; i < tierVertices.size(); i++)
            {
                IVertex tierVertex = (IVertex) tierVertices.values().get(i);
                ICompactTripletsStructure clone = ((ICompactTripletsStructure) tierVertex.getCTS().clone());
                clone.intersect(vertex.getCTS());
                if (!clone.isEmpty())
                {
                    result.add(tierVertex);
                }
            }
        }
        return result;
    }
View Full Code Here

     * @param ct List of {@link ITabularFormula}.
     * @return
     */
    public static ObjectArrayList cloneStructures(ObjectArrayList ct)
    {
        ObjectArrayList ctf = new ObjectArrayList();
        for (int i = 0; i < ct.size(); i++)
        {
            ctf.add(((ITabularFormula) ct.get(i)).clone());
        }
        return ctf;
    }
View Full Code Here

   
    public static ObjectArrayList loadHSS(String hssPath) throws IOException
    {
        LOGGER.info("Load HSS from {}...", hssPath);
       
        ObjectArrayList hss = new ObjectArrayList();
       
        String basicCTSPath = hssPath + File.separator + "basic-cts.cnf";
        LOGGER.info("Load Basic CTS from {}...", basicCTSPath);
        ITabularFormula basicCTS = loadFromFile(basicCTSPath);
        LOGGER.info("Basic CTS loaded");
       
        File[] allCTS = new File(hssPath).listFiles(new FilenameFilter() {
            public boolean accept(File dir, String name)
            {
                return name.endsWith(".cnf");
            }
        });
        LOGGER.info("{} more instances to load", allCTS.length - 1);
       
        String[] otherCTSPaths = new File(hssPath).list(new FilenameFilter()
        {
            public boolean accept(File dir, String name)
            {
                return name.endsWith("-other-cts.cnf");
            }
        });
       
        Arrays.sort(otherCTSPaths);
       
        for (String otherCTSPath : otherCTSPaths)
        {
            Matcher matcher = Pattern.compile("hss-(\\d+)-").matcher(otherCTSPath);
            matcher.find();
            final String hsIndex = matcher.group(1);
           
            LOGGER.debug("Load CTS from {}...", otherCTSPath);
            ITabularFormula otherCTS = loadFromFile(hssPath + File.separator + otherCTSPath);
            LOGGER.debug("CTS loaded");
            IHyperStructure hs = new SimpleHyperStructure((ICompactTripletsStructure) basicCTS, (ICompactTripletsStructure) otherCTS);
            hss.add(hs);
           
            String[] substructuresPaths = new File(hssPath).list(new FilenameFilter()
            {
                public boolean accept(File dir, String name)
                {
View Full Code Here

        return result;
    }

    public static ObjectArrayList findHSSRouteByReduce(ObjectArrayList hss, String hssTempPath) throws IOException
    {
        ObjectArrayList route = quickFindHSSRoute(hss);
        if (isValidHSSRoute(route))
        {
            return route;
        }
       
        IHyperStructure hs = (IHyperStructure) hss.get(0);
        ICompactTripletsStructure basicCTS = hs.getBasicCTS();
       
        //  Find next tier with one vertex
        for (int j = 0; j < basicCTS.getTiers().size(); j++)
        {
            //  TODO Configure hssTempPathReduced using CL options
            final String hssTempPathReduced = hssTempPath + "-reduced";
            if (j == 0)
            {
                if (basicCTS.getTier(0).size() > 1)
                {
                    //  First reduction
                    ObjectArrayList structures = new ObjectArrayList();
                    OpenIntObjectHashMap verticesFromLastTiers = new OpenIntObjectHashMap();
                   
                    fillVerticesFromLastTier(hss, structures, verticesFromLastTiers);
                   
                    ObjectArrayList result = new ObjectArrayList();
                    findIntersectionWithFirstTier(hss, result, structures, verticesFromLastTiers);
                   
                    ITier firstTier = basicCTS.getTier(0);
                    IVertex firstTierVertex = (IVertex) result.get(0);
                    firstTier.intersect(firstTierVertex.getTripletValue());
                    basicCTS.cleanup(0, 0);
                   
                    //  Unify CTS
                    ObjectArrayList cts = new ObjectArrayList();
                    cts.add(((IHyperStructure) hss.get(0)).getBasicCTS());
                    for (int h = 0; h < hss.size(); h++)
                    {
                        hs = (IHyperStructure) hss.get(h);
                        cts.add(hs.getOtherCTS());
                    }
                    unify(cts);
                    //  Update HSS by creating new one (it must be created non-empty)
                    Properties statistics = new Properties();
                    hss = createHyperStructuresSystem(cts, statistics);
                    saveHSS(hssTempPathReduced, hss);
                    //  Check if its possible to find HSS route now
                    route = quickFindHSSRoute(hss);
                    if (isValidHSSRoute(route))
                    {
                        return route;
                    }
                    //  Route not found. Reduce next tier
                   
                    //  Basic CTS may have been changed in newly created HSS
                    if (!basicCTS.getPermutation().sameAs(((IHyperStructure) hss.get(0)).getBasicCTS().getPermutation()))
                    {
                        //  Basic CTS changed
                        j = -1;
                        basicCTS = ((IHyperStructure) hss.get(0)).getBasicCTS();
                    }
                }
                continue;
            }
           
            ITier tier = basicCTS.getTier(j);
            if (tier.size() > 1)
            {
                //  Previous tier contains one vertex
                OpenIntObjectHashMap prevTier = (OpenIntObjectHashMap) ((IHyperStructure)hss.get(0)).getTiers().get(j - 1);
                IVertex prevVertex = (IVertex) prevTier.values().get(0);
               
                if (prevVertex.hasEmptyBottomEdge())
                {
                    //  If previous vertex contains only one bottom vertex
                    //  then we should keep that vertex (and move forward to reduce next HSS tier?)
                    if (prevVertex.getBottomVertex1() != null)
                    {
                        tier.intersect(prevVertex.getBottomVertex1().getTripletValue());
                    }
                    else if (prevVertex.getBottomVertex2() != null)
                    {
                        tier.intersect(prevVertex.getBottomVertex2().getTripletValue());
                    }
                   
                    basicCTS.cleanup(j, j);
                   
                    //  Unify CTS
                    ObjectArrayList cts = new ObjectArrayList();
                    cts.add(((IHyperStructure) hss.get(0)).getBasicCTS());
                    for (int h = 0; h < hss.size(); h++)
                    {
                        hs = (IHyperStructure) hss.get(h);
                        cts.add(hs.getOtherCTS());
                    }
                    unify(cts);
                    //  Update HSS by creating new one (it must be created non-empty)
                    Properties statistics = new Properties();
                    hss = createHyperStructuresSystem(cts, statistics);
                    saveHSS(hssTempPathReduced, hss);
                    //  Check if its possible to find HSS route now
                    route = quickFindHSSRoute(hss);
                    if (isValidHSSRoute(route))
                    {
                        return route;
                    }
                    //  Route not found. Reduce next tier
                   
                    //  Basic CTS may have been changed in newly created HSS
                    if (!basicCTS.getPermutation().sameAs(((IHyperStructure) hss.get(0)).getBasicCTS().getPermutation()))
                    {
                        //  Basic CTS changed
                        j = -1;
                        basicCTS = ((IHyperStructure) hss.get(0)).getBasicCTS();
                    }
                }
                else
                {
                    LOGGER.info("Backup HSS to {}...", hssTempPath);
                    saveHSS(hssTempPath, hss);
                   
                    ITripletValue bottomVertex1TripletValue = prevVertex.getBottomVertex1().getTripletValue();
                    ITripletValue bottomVertex2TripletValue = prevVertex.getBottomVertex2().getTripletValue();
                   
                    tier.intersect(bottomVertex1TripletValue);
                   
                    try
                    {
                        basicCTS.cleanup(j, j);
                       
                        //  Unify CTS
                        ObjectArrayList cts = new ObjectArrayList();
                        cts.add(((IHyperStructure) hss.get(0)).getBasicCTS());
                        for (int h = 0; h < hss.size(); h++)
                        {
                            hs = (IHyperStructure) hss.get(h);
                            cts.add(hs.getOtherCTS());
                        }
                        unify(cts);
                        //  Update HSS by creating new one (it must be created non-empty)
                        Properties statistics = new Properties();
                        hss = createHyperStructuresSystem(cts, statistics);
                    }
                    catch (EmptyStructureException e)
                    {
                        //  If HSS was built empty then 
                        //  restore HSS and keep vertex from bottomVertex2
                       
                        LOGGER.info("Restore HSS from backup {}", hssTempPath);
                        hss = loadHSS(hssTempPath);
                        LOGGER.info("done");
                       
                        basicCTS = ((IHyperStructure) hss.get(0)).getBasicCTS();
                        tier = basicCTS.getTier(j);
                        tier.intersect(bottomVertex2TripletValue);
                       
                        basicCTS.cleanup(j, j);
                       
                        //  Unify CTS
                        ObjectArrayList cts = new ObjectArrayList();
                        cts.add(((IHyperStructure) hss.get(0)).getBasicCTS());
                        for (int h = 0; h < hss.size(); h++)
                        {
                            hs = (IHyperStructure) hss.get(h);
                            cts.add(hs.getOtherCTS());
                        }
                        unify(cts);
                        //  Update HSS by creating new one (it must be created non-empty)
                        Properties statistics = new Properties();
                        hss = createHyperStructuresSystem(cts, statistics);
View Full Code Here

        public ObjectArrayList substructureEdges;
        public OpenIntObjectHashMap hsIntersections;
        public ObjectArrayList coincidentIntersections;
        public StructuresForConcordantShift(int hssSize)
        {
            substructureEdges = new ObjectArrayList(hssSize);
            hsIntersections = new OpenIntObjectHashMap(hssSize);
            coincidentIntersections = new ObjectArrayList(hssSize);
            for (int h = 0; h < hssSize; h++)
            {
                hsIntersections.put(h, new ObjectArrayList(8));
            }
        }
View Full Code Here

    public SimpleHyperStructure(ICompactTripletsStructure basicCTS, ICompactTripletsStructure otherCTS)
    {
        this.basicCTS = basicCTS;
        this.otherCTS = otherCTS;
       
        this.tiers = new ObjectArrayList();
    }
View Full Code Here

        return formula.getPermutation().get(formula.getPermutation().size() - 1) == varName;
    }

    public static ITier ensureTheOnlyTierWithVariableExistsAndGetTheTier(ITabularFormula formula, int varName)
    {
        ObjectArrayList tiers = formula.findTiersFor(varName);
        if (tiers == null)
        {
            return null;
        }
        if (tiers.size() == 1)
        {
            return (ITier) tiers.get(0);
        }
        return null;
    }
View Full Code Here

        return null;
    }

    public static ITier ensureTheOnlyTierWithVariablesExistsAndGetTheTier(ITabularFormula formula, int varName1, int varName2)
    {
        ObjectArrayList tiers = formula.findTiersFor(varName1, varName2);
        if (tiers == null)
        {
            return null;
        }
        if (tiers.size() == 1)
        {
            return (ITier) tiers.get(0);
        }
        return null;
    }
View Full Code Here

    private OpenIntIntHashMap internalToOriginalMap;

    public SimpleFormula()
    {
        permutation = new SimplePermutation();
        tiers = new ObjectArrayList();
        tiersHash1 = new OpenIntObjectHashMap();
        tiersHash2 = new OpenLongObjectHashMap();
        tiersHash3 = new OpenLongObjectHashMap();
    }
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.