Package cern.colt.list

Examples of cern.colt.list.ObjectArrayList


    @Test
    public void testCreateCTS() throws IOException
    {
        ITabularFormula formula = Helper.loadFromFile("target/test-classes/simplesat-example.cnf");
        Helper.prettyPrint(formula);
        ObjectArrayList ctf = Helper.createCTF(formula);
        Helper.printFormulas(ctf);
        Helper.completeToCTS(ctf, formula.getPermutation());
        Helper.printFormulas(ctf);
       
        ICompactTripletsStructure s = (ICompactTripletsStructure)ctf.get(0);
       
        assertEquals(5, s.getVarCount());
        assertEquals(21, s.getClausesCount());
    }
View Full Code Here


    public void testConvertCTStructuresToRomanovSKTFileFormat() throws Exception
    {
        String filename = "target/test-classes/cnf-v22-c73-12.cnf";
        File file = new File(filename);
        ITabularFormula formula = Helper.loadFromFile(filename);
        ObjectArrayList ctf = Helper.createCTF(formula);
        System.out.println("CTF: " + ctf.size());

        Helper.completeToCTS(ctf, formula.getPermutation());
       
        System.out.println("CTS: " + ctf.size());
       
        Helper.convertCTStructuresToRomanovSKTFileFormat(ctf, "target/" + file.getName() + ".skt");
        Helper.saveToDIMACSFileFormat((ITabularFormula) ctf.get(0), "target/" + file.getName() + "-cts-0.cnf");
    }
View Full Code Here

    @Test
    public void testSaveLoadHSS() throws Exception
    {
        String filename = "target/test-classes/article-example.cnf";
        ITabularFormula formula = Helper.loadFromFile(filename);
        ObjectArrayList ct = Helper.createCTF(formula);
        Helper.completeToCTS(ct, formula.getPermutation());
        Helper.unify(ct);
        Properties statistics = new Properties();
        ObjectArrayList hss = Helper.createHyperStructuresSystem(ct, statistics);
        String hssPath = filename + "-hss";
        Helper.saveHSS(hssPath, hss);
        ObjectArrayList hss2 = Helper.loadHSS(hssPath);
       
        assertEquals(hss.size(), hss2.size());
       
        for (int h = 0; h < hss.size(); h++)
        {
            IHyperStructure hs = (IHyperStructure) hss.get(h);
            IHyperStructure hs2 = (IHyperStructure) hss2.get(h);
           
            assertEquals(hs.getTiers().size(), hs2.getTiers().size());
           
            for (int j = 0; j < hs.getTiers().size(); j++)
            {
View Full Code Here

                                  2,-3, 4,
                                  5, 6, 7,
                                  6, 7, 3,
                                  1, 5, 7);
       
        ObjectArrayList ct = Helper.createCTF(formula);
        Helper.completeToCTS(ct, formula.getPermutation());
       
        assertEquals(2, ct.size());
       
        String filename = "target/test-classes/file.skt";
       
        Helper.convertCTStructuresToRomanovSKTFileFormat(ct, filename);
View Full Code Here

    }
   
    @Test
    public void testBuildPartialIndex()
    {
        final ObjectArrayList cts = new ObjectArrayList();
       
        cts.add(Helper.createFormula(
                1, 2, 3,
                   2, 3, 4,
                      3, 4, 5,
                         4, 5, 6,
                            5, 6, 7));
        cts.add(Helper.createFormula(
                2, 5, 1,
                   5, 1, 3,
                      1, 3, 4,
                         3, 4, 6,
                            4, 6, 7));
       
        //  Full index should be built prior to partial
        VarPairsIndexFactory.getInstance().buildIndex(cts);
       
        VarPairsIndex index = VarPairsIndexFactory.getInstance().
            buildPartialIndex(cts, (ICompactTripletsStructureHolder) cts.get(0), 0, 0);
       
        index.forEachPair(new LongObjectProcedure()
        {
            public boolean apply(long key, Object value)
            {
                int varName1_ = (int) (key >> 21);
                int varName2_ = (int) (key & 0x1FFFFF);

                System.out.println(varName1_+ ", " + varName2_);
               
                LongArrayList tiers = (LongArrayList) value;
                for (int i = 0; i < tiers.size(); i++)
                {
                    long formulaAndTierIndex = tiers.get(i);
                    int formulaIndex = (int)(formulaAndTierIndex >> 32);
                    int tierIndex = (int)(formulaAndTierIndex & 0x00000000FFFFFFFFL);

                    ICompactTripletsStructure formula = (ICompactTripletsStructure)cts.get(formulaIndex);
                    ITier tier = formula.getTier(tierIndex);
                    System.out.println(tier);
                    Helper.prettyPrint(formula);
                }
               
View Full Code Here

    private int count = 0;
    private int maxCount = 0;
   
    public Object acquire(int key)
    {
        ObjectArrayList objects = (ObjectArrayList) map.get(key);
        if (objects == null || objects.size() == 0)
        {
            return null;
        }
        Object object = objects.getQuick(0);
        objects.remove(0);
        count--;
        return object;
    }
View Full Code Here

        count--;
        return object;
    }
    public void release(int key, Object object)
    {
        ObjectArrayList objects = (ObjectArrayList) map.get(key);
        if (objects == null)
        {
            objects = new ObjectArrayList();
            map.put(key, objects);
        }
        objects.add(object);
        count++;
        if (count > maxCount)
        {
            maxCount = count;
        }
View Full Code Here

            if (commandLine.hasOption(FIND_HSS_ROUTE_OPTION))
            {
                String hssPath = commandLine.getOptionValue(FIND_HSS_ROUTE_OPTION);
               
                stopWatch.start("Load HSS from " + hssPath);
                ObjectArrayList hss = Helper.loadHSS(hssPath);
                stopWatch.stop();
                stopWatch.printElapsed();
               
                findHSSRoute(commandLine, formulaFile, statistics, stopWatch, formula, null, null, hss, hssPath);
               
                return;
            }
           
            if (commandLine.hasOption(EVALUATE_OPTION))
            {
                String resultsFilename = commandLine.getOptionValue(EVALUATE_OPTION);
                boolean satisfiable = evaluateFormula(stopWatch, formula, resultsFilename);
                if (satisfiable)
                {
                    System.out.println("Formula evaluated as SAT");
                }
                else
                {
                    System.out.println("Formula evaluated as UNSAT");
                }
                //  Only evaluate formula value
                return;
            }
           
            //  Find if formula is SAT
           
            //  Clone initial formula to verify formula satisfiability later
            ITabularFormula formulaClone = null;
            if (Helper.EnableAssertions)
            {
                stopWatch.start("Clone initial formula");
                formulaClone = formula.clone();
                stopWatch.stop();
                stopWatch.printElapsed();
            }
           
            stopWatch.start("Create CTF");
            ObjectArrayList ct = Helper.createCTF(formula);
            timeElapsed = stopWatch.stop();
            printFormulas(ct);
            stopWatch.printElapsed();
           
            statistics.put(Helper.CTF_CREATION_TIME, String.valueOf(timeElapsed));
            statistics.put(Helper.CTF_COUNT, String.valueOf(ct.size()));
           
            LOGGER.info("CTF count: {}", ct.size());

            if (Helper.EnableAssertions)
            {
                assertNoTripletsLost(formula, ct);
            }

            //  Clone CTF to verify formula satisfiability against it later
            ObjectArrayList ctfClone = null;
           
            if (Helper.EnableAssertions)
            {
                ctfClone = Helper.cloneStructures(ct);
            }
           
            stopWatch.start("Create CTS");
            Helper.completeToCTS(ct, formula.getPermutation());
            timeElapsed = stopWatch.stop();
            printFormulas(ct);
            stopWatch.printElapsed();
           
            statistics.put(Helper.CTS_CREATION_TIME, String.valueOf(timeElapsed));
           
            if (commandLine.hasOption(CREATE_SKT_OPTION))
            {
                String sktFilename = formulaFile + ".skt";
                stopWatch.start("Convert CTS to " + sktFilename);
                Helper.convertCTStructuresToRomanovSKTFileFormat(ct, sktFilename);
                stopWatch.stop();
                stopWatch.printElapsed();
               
                return;
            }
           
            ObjectArrayList hss = unifyAndCreateHSS(statistics, stopWatch, ct);
           
            String hssPath = formulaFile + "-hss";
            stopWatch.start("Save HSS to " + hssPath + "...");
            Helper.saveHSS(hssPath, hss);
            stopWatch.stop();
View Full Code Here

        statistics.put(Helper.CTS_UNIFICATION_TIME, String.valueOf(timeElapsed));
       
        LOGGER.info("CTF: {}", cts.size());
       
        ObjectArrayList hss = null;
        try
        {
            stopWatch.start("Create HSS");
            hss = Helper.createHyperStructuresSystem(cts, statistics);
        }
        finally
        {
            timeElapsed = stopWatch.stop();
            stopWatch.printElapsed();
            if (hss != null)
            {
                statistics.put(Helper.BASIC_CTS_FINAL_CLAUSES_COUNT, String.valueOf(((IHyperStructure) hss.get(0)).getBasicCTS().getClausesCount()));
            }
            statistics.put(Helper.HSS_CREATION_TIME, String.valueOf(timeElapsed));
        }
        return hss;
    }
View Full Code Here

    {
        long timeElapsed;
        //  TODO Configure hssTempPath using CL options
        String hssTempPath = hssPath + "-temp";
        stopWatch.start("Find HSS route");
        ObjectArrayList route = Helper.findHSSRouteByReduce(hss, hssTempPath);
        timeElapsed = stopWatch.stop();
        stopWatch.printElapsed();
       
        statistics.put(Helper.SEARCH_HSS_ROUTE_TIME, String.valueOf(timeElapsed));
       
        if (Helper.EnableAssertions)
        {
            if (formulaClone != null)
            {
                if (!formula.equals(formulaClone))
                {
                    LOGGER.warn("Initial formula differs from its cloned version");
                }
            }
        }
       
        String hssImageFile = formulaFile + "-hss-0.png";
       
        if (commandLine.hasOption(HSS_IMAGE_OUTPUT_FILENAME_OPTION))
        {
            hssImageFile = commandLine.getOptionValue(HSS_IMAGE_OUTPUT_FILENAME_OPTION);
        }
       
        stopWatch.start("Write HSS as image to " + hssImageFile);
        Helper.writeToImage(((SimpleVertex) route.get(route.size() - 1)).getHyperStructure(), route, null, hssImageFile);
        stopWatch.stop();
        stopWatch.printElapsed();
       
        stopWatch.start("Verify formula is satisfiable using variable values from HSS route");
        verifySatisfiable(formula, route);
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.