Package statechum.analysis.learning.rpnicore

Examples of statechum.analysis.learning.rpnicore.LSolver

MacOS X - specific instructions

It may be advisable to build gcc first (gmp web page suggests it will not work when built with XCode so using a recent gcc may be advisable), It is worth noting that the full path of the interface is encoded in the shared libraries hence moving this interface is only possible if libraries are rebuilt. For this reason, LSolver is stuck in the rpnicore rather than in learner/linear. Instructions for building OpenBLAS on Linux, Uncompress the .zip, then from the main directory run
 make PREFIX=/usr/local/soft/OpenBLAS-be853da DYNAMIC_ARCH=1 UTEST_CHECK=1 NO_LAPACK=1	NO_AFFINITY=1 
The first parameter is responsible for building in support for all CPU architectures, otherwise only the current one will This will attempt to download CUnit and then fail.
 cd utest;make 
should build and install CUnit into utest. Subsequently doing the following command from the main directory (the one just above utest)
  ln -s utest/CUnit-2.1-2/include/CUnit . 
would fix unit tests that ship with OpenBLAS and they will run when the above make command is run. After doing
  make PREFIX=/usr/local/soft/OpenBLAS-be853da DYNAMIC_ARCH=1 UTEST_CHECK=1 NO_LAPACK=1 install 
OpenBLAS is available. SuiteSparse_config.mk should have
 CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar RANLIB = x86_64-w64-mingw32-ranlib F77 = x86_64-w64-mingw32-gfortran BLAS = /usr/local/soft/OpenBLAS-be853da/lib/libopenblas.lib INSTALL_LIB=/usr/local/soft/umfpack-5.6.1-openblas/lib INSTALL_INCLUDE=/usr/local/soft/umfpack-5.6.1-openblas/include 
OpenBLAS on Windows7-x86_64 First, build OpenBLAS with both options for Unix (above) and those mentioned in quickbuild.64bit.

When building UMFPACK, most options are the same as for Unix but there are a few changes,

Finally, Makefile in the UMFPACK/Demo directory has the "run" target, where it runs demos and records the results. Every time it runs a demo, the output has to be piped through d2u to correct line endings on Windows and through sed 's/e\([+-]\)0\([0-9]\+\)/e\1\2/g' to convert the differences in which exponents are output on Windows. Hence the extra content is like
 ... _demo | d2u |  sed  's/e\([+-]\)0\([0-9]\+\)/e\1\2/g' > my_ ... .out 

        "\nB-b-#G\n","TestComputeStateCompatibility_checking_filtering2",config,converter);
    StatesToConsider filter = TestLearnerGraphND.createInstanceOfFilter(filterClass, gr);
    double score_CC=1./2,score_BB=(2+score_CC*k)/4, score_AA=(1+k*score_BB)/2;
    {
      GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreNone, false);
      LSolver solver = ndGraph.buildMatrix(threadNumber);
      DoubleMatrix2D Ax=solver.toDoubleMatrix2D();
      Assert.assertEquals(6,Ax.columns());
    }
    Set<PairScore> pairsSet = addAllPermutations(gr.pairscores.chooseStatePairs(PAIR_INCOMPATIBLE*2,10,threadNumber,null,filter, new NonRandomRandom()));
    Set<PairScore> exp = addAllPermutations(Arrays.asList(new PairScore[]{
        new PairScore(gr.findVertex("A"),gr.findVertex("A"),(int)(10*score_AA),1),
 
View Full Code Here


      throw new IllegalArgumentException("computation algorithm "+coregraph.config.getGdScoreComputationAlgorithm()+" is not currently supported");
    }
   
    final int [] incompatiblePairs = new int[ndGraph.getStateNumber()*(ndGraph.getStateNumber()+1)/2];for(int i=0;i<incompatiblePairs.length;++i) incompatiblePairs[i]=GDLearnerGraph.PAIR_OK;
    final int pairsNumber = ndGraph.findIncompatiblePairs(incompatiblePairs,ThreadNumber);
    LSolver solver = ndGraph.buildMatrix_internal(incompatiblePairs, pairsNumber, ThreadNumber,ddrh);
    solver.solve(ThreadNumber);
    solver.freeAllButResult();// deallocate memory before creating a large array.
    coregraph.pairsAndScores.clear();
    // now fill in the scores in the array.
    for(int i=0;i<incompatiblePairs.length;++i)
    {
      int index = incompatiblePairs[i];
View Full Code Here

      throw new IllegalArgumentException("computation algorithm "+coregraph.config.getGdScoreComputationAlgorithm()+" is not currently supported");
    }
   
    final int [] incompatiblePairs = new int[ndGraph.getStateNumber()*(ndGraph.getStateNumber()+1)/2];for(int i=0;i<incompatiblePairs.length;++i) incompatiblePairs[i]=GDLearnerGraph.PAIR_OK;
    final int pairsNumber = ndGraph.findIncompatiblePairs(incompatiblePairs,ThreadNumber);
    LSolver solver = ndGraph.buildMatrix_internal(incompatiblePairs, pairsNumber, ThreadNumber,ddrh);
    solver.solve(ThreadNumber);
    solver.freeAllButResult();// deallocate memory before creating a large array.
    coregraph.pairsAndScores.clear();
    // now fill in the scores in the array.
    for(int i=0;i<incompatiblePairs.length;++i)
    {
      int index = incompatiblePairs[i];
View Full Code Here

  {
    final DoubleMatrix2D matrix = DoubleFactory2D.sparse.make(size,size);
    matrix.assign(randomGenerator);
    final DoubleMatrix1D b = DoubleFactory1D.dense.make(size);
    b.assign(randomGenerator);
    final LSolver solver = new LSolver(matrix,DoubleFactory1D.dense.make(matrix.rows(), 0));

    boolean singular = false;
    try
    {
      solver.solveExternally(1);
    }
    catch(IllegalArgumentException ex)
    {
      if (ex.getMessage().contains("singular"))
        singular = true;
      else
        throw ex;
    }
   
    if (!singular)
      TestSolver.verifyAxb(solver);
   
    LUDecompositionQuick coltSolver = new LUDecompositionQuick();
    coltSolver.decompose(matrix);coltSolver.setLU(matrix);
    DoubleMatrix1D vector = DoubleFactory1D.dense.make(matrix.rows(), 0);
   
    try
    {
      coltSolver.solve(vector);
    }
    catch(IllegalArgumentException ex)
    {
      if (ex.getMessage().contains("singular"))
        Assert.assertTrue(singular);
      else
        throw ex;
    }

    if (!singular)
    {
      for(int i=0;i<matrix.rows();++i)
        Assert.assertEquals(solver.j_x[i], vector.getQuick(i),Configuration.fpAccuracy);
      TestSolver.verifyAxb(matrix,solver.toDoubleMatrix1D(),vector);
    }
   
    try
    {
      for(int i=0;i<matrix.rows();++i) solver.j_x[i]=0;
      solver.solveUsingColt();
    }
    catch(IllegalArgumentException ex)
    {
      if (ex.getMessage().contains("singular"))
        Assert.assertTrue(singular);
View Full Code Here

   * Since it messes up the configuration of the graph, it has to be run at the end of every test method rather than multiple times.
   */
  protected void checkBuildMatrix(LearnerGraph gr, DoubleMatrix2D expectedAx, DoubleMatrix1D expectedB)
  {
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreRejectStates, false);
    LSolver solver = ndGraph.buildMatrix(threadNumber);
    DoubleMatrix2D Ax=solver.toDoubleMatrix2D();
    Assert.assertEquals(getExpectedMatrix2DSlowly(gr),Ax);
    if (expectedAx != null) Assert.assertEquals(expectedAx, Ax);
    DoubleMatrix1D b=solver.toDoubleMatrix1D();
    if (expectedB != null) Assert.assertEquals(expectedB, b);Assert.assertEquals(getExpectedMatrix1DSlowly(gr),b);
    solver.solveExternally(1);// check if we have a solution, just in case it fails.

    // Now check consistency.
    gr.config.setAttenuationK_testOnly(1);DoubleMatrix2D Ax1 = ndGraph.buildMatrix(threadNumber).toDoubleMatrix2D();
    gr.config.setAttenuationK(0);DoubleMatrix2D Ax0 = ndGraph.buildMatrix(threadNumber).toDoubleMatrix2D();
    DoubleMatrix1D one = DoubleFactory1D.dense.make(Ax1.rows(), 1), a=DoubleFactory1D.dense.make(Ax.rows(), 0);
View Full Code Here

  public final void testDumpEquations1()
  {
    GDLearnerGraph ndGraph = new GDLearnerGraph(buildLearnerGraph("A-a->B-a->B-b->A""testBuildMatrix1",config,converter),LearnerGraphND.ignoreRejectStates, false);
    final int [] incompatiblePairs = new int[ndGraph.getPairNumber()];for(int i=0;i<incompatiblePairs.length;++i) incompatiblePairs[i]=PAIR_OK;
    final int pairsNumber = ndGraph.findIncompatiblePairs(incompatiblePairs,threadNumber);
    LSolver solver = ndGraph.buildMatrix_internal(incompatiblePairs, pairsNumber, threadNumber,null);

    String outcome = ndGraph.dumpEquations(solver, incompatiblePairs, null).toString();
    Assert.assertEquals("2.0([A,A]:[A,A]) + -"+k+"([A,A]:[B,B]) = 1.0\n"+
        "4.0([B,A]:[B,A]) + -"+k+"([B,A]:[B,B]) = 1.0\n"+
        "-"+k+"([B,B]:[A,A]) + "+(4-k)+"([B,B]:[B,B]) = 2.0\n",outcome);
View Full Code Here

  {
    LearnerGraph graph = buildLearnerGraph("A-a->B-a->B-b->A""testBuildMatrix1",config,converter);
    GDLearnerGraph ndGraph = new GDLearnerGraph(graph,LearnerGraphND.ignoreRejectStates, false);
    final int [] incompatiblePairs = new int[ndGraph.getPairNumber()];for(int i=0;i<incompatiblePairs.length;++i) incompatiblePairs[i]=PAIR_OK;
    final int pairsNumber = ndGraph.findIncompatiblePairs(incompatiblePairs,threadNumber);
    LSolver solver = ndGraph.buildMatrix_internal(incompatiblePairs, pairsNumber, threadNumber,null);
    Map<CmpVertex,CmpVertex> newToOrig = new TreeMap<CmpVertex,CmpVertex>();
    String P67="P67",P99="B";
    newToOrig.put(graph.findVertex("A"),AbstractLearnerGraph.generateNewCmpVertex(VertexID.parseID(P67), graph.config));
    String outcome = ndGraph.dumpEquations(solver, incompatiblePairs, newToOrig).toString();
    Assert.assertEquals("2.0(["+P67+","+P67+"]:["+P67+","+P67+"]) + -"+k+"(["+P67+","+P67+"]:["+P99+","+P99+"]) = 1.0\n"+
View Full Code Here

  {
    LearnerGraph graph = buildLearnerGraph("A-a->B-a->B-b->A""testBuildMatrix1",config,converter);
    GDLearnerGraph ndGraph = new GDLearnerGraph(graph,LearnerGraphND.ignoreRejectStates, false);
    final int [] incompatiblePairs = new int[ndGraph.getPairNumber()];for(int i=0;i<incompatiblePairs.length;++i) incompatiblePairs[i]=PAIR_OK;
    final int pairsNumber = ndGraph.findIncompatiblePairs(incompatiblePairs,threadNumber);
    LSolver solver = ndGraph.buildMatrix_internal(incompatiblePairs, pairsNumber, threadNumber,null);
    Map<CmpVertex,CmpVertex> newToOrig = new TreeMap<CmpVertex,CmpVertex>();
    String P67="P67",P99="P99";
    newToOrig.put(graph.findVertex("A"),AbstractLearnerGraph.generateNewCmpVertex(VertexID.parseID(P67), graph.config));
    newToOrig.put(graph.findVertex("B"),AbstractLearnerGraph.generateNewCmpVertex(VertexID.parseID(P99), graph.config));
    String outcome = ndGraph.dumpEquations(solver, incompatiblePairs, newToOrig).toString();
View Full Code Here

        "\nB-b-#G\n","TestComputeStateCompatibility_checking_filtering2",config,converter);
    StatesToConsider filter = TestLearnerGraphND.createInstanceOfFilter(filterClass, gr);
    double score_CC=1./2,score_BB=(2+score_CC*k)/4, score_AA=(1+k*score_BB)/2;
    {
      GDLearnerGraph ndGraph = new GDLearnerGraph(gr,LearnerGraphND.ignoreNone, false);
      LSolver solver = ndGraph.buildMatrix(threadNumber);
      DoubleMatrix2D Ax=solver.toDoubleMatrix2D();
      Assert.assertEquals(6,Ax.columns());
    }
    Set<PairScore> pairsSet = addAllPermutations(gr.pairscores.chooseStatePairs(PAIR_INCOMPATIBLE*2,10,threadNumber,null,filter, new NonRandomRandom()));
    Set<PairScore> exp = addAllPermutations(Arrays.asList(new PairScore[]{
        new PairScore(gr.findVertex("A"),gr.findVertex("A"),(int)(10*score_AA),1),
 
View Full Code Here

      throw new IllegalArgumentException("computation algorithm "+coregraph.config.getGdScoreComputationAlgorithm()+" is not currently supported");
    }
   
    final int [] incompatiblePairs = new int[ndGraph.getStateNumber()*(ndGraph.getStateNumber()+1)/2];for(int i=0;i<incompatiblePairs.length;++i) incompatiblePairs[i]=GDLearnerGraph.PAIR_OK;
    final int pairsNumber = ndGraph.findIncompatiblePairs(incompatiblePairs,ThreadNumber);
    LSolver solver = ndGraph.buildMatrix_internal(incompatiblePairs, pairsNumber, ThreadNumber,ddrh);
    solver.solve(ThreadNumber);
    solver.freeAllButResult();// deallocate memory before creating a large array.
    coregraph.pairsAndScores.clear();
    // now fill in the scores in the array.
    for(int i=0;i<incompatiblePairs.length;++i)
    {
      int index = incompatiblePairs[i];
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.rpnicore.LSolver

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.