Package statechum.analysis.learning.rpnicore.AbstractLearnerGraph

Examples of statechum.analysis.learning.rpnicore.AbstractLearnerGraph.StatesToConsider


  protected DoubleMatrix2D getExpectedMatrix2DSlowly(LearnerGraph gr)
  {
    int size=gr.getStateNumber()*(gr.getStateNumber()+1)/2;
    DoubleMatrix2D result = DoubleFactory2D.sparse.make(size,size,0);
    StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    for(Entry<CmpVertex,Map<String,List<CmpVertex>>> entryA:ndGraph.matrixForward.transitionMatrix.entrySet())
    {
      // Now iterate through states
      Iterator<Entry<CmpVertex,Map<String,List<CmpVertex>>>> stateB_It = ndGraph.matrixForward.transitionMatrix.entrySet().iterator();
View Full Code Here


 
  /** Uses computePairCompatibilityScore_general to identify incompatible pairs of states. */
  protected static Set<StatePair> buildSetOfIncompatiblePairsSlowly(final LearnerGraph gr,int ThreadNumber)
  {
    final Set<StatePair> result = Collections.synchronizedSet(new LinkedHashSet<StatePair>());
    final StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    final GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    List<GDLearnerGraph.HandleRow<List<CmpVertex>>> handlerList = new LinkedList<GDLearnerGraph.HandleRow<List<CmpVertex>>>();
    for(int threadCnt=0;threadCnt<ThreadNumber;++threadCnt)
    handlerList.add(new GDLearnerGraph.HandleRow<List<CmpVertex>>()
    {
View Full Code Here

  }

  protected final void findIncompatibleTestHelper(LearnerGraph gr,List<StringPair> incompatibles_list)
  {
    HashSet<StatePair> incompatibles = new HashSet<StatePair>();
    StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    for(StringPair p:incompatibles_list)
    {
      incompatibles.add(new StatePair(gr.findVertex(p.firstElem),gr.findVertex(p.secondElem)));
      incompatibles.add(new StatePair(gr.findVertex(p.secondElem),gr.findVertex(p.firstElem)));
    }
    Set<StatePair> incompatiblePairs = new HashSet<StatePair>();
    for(StatePair s:buildSetOfIncompatiblePairsSlowly(gr,ThreadNumber))
    {
      incompatiblePairs.add(s);incompatiblePairs.add(new StatePair(s.secondElem,s.firstElem));
    }
    // incompatiblePairs these are the pairs which cannot be merged which may be a larger set than
    // the set of clearly incompatible pairs, because incompatiblePairs is computed based on
    // the outcome of computePairCompatibilityScore_general. The difference between computing incompatibility of pairs
    // and doing computePairCompatibilityScore_general is that when pairs are merged, more traces
    // are created, hence it is possible that some of those new traces will be in conflict.
    // Example: states A3 and A2 in findIncompatibleStates6()
    HashSet<StatePair> pairs_extra = new HashSet<StatePair>();pairs_extra.addAll(incompatibles);pairs_extra.removeAll(incompatiblePairs);
    Assert.assertTrue("compatible pairs included :"+pairs_extra,pairs_extra.isEmpty());// this is a check that incompatibles_list does not include any compatible pairs

    final int size=ndGraph.getPairNumber();
    final int highNumber = 10000;
    int pairs[]=new int[size];for(int i=0;i<pairs.length;++i) pairs[i]=highNumber;
   
    // reverseMap maps state pair number to the actual state pairs, we slowly build it here
    // rather then rely on getPairScore() which may have not even been written when
    // I was doing this kind of testing.
    reverseMap = new HashMap<Integer,StatePair>();
    for(CmpVertex A:gr.transitionMatrix.keySet())
      if (filter.stateToConsider(A))
        for(CmpVertex B:gr.transitionMatrix.keySet())
          if (filter.stateToConsider(B))
            reverseMap.put(ndGraph.vertexToIntNR(A, B), new StatePair(A,B));
    Assert.assertEquals(size,reverseMap.size());
   
    ndGraph.buildMatrix(ThreadNumber);
    ndGraph.findIncompatiblePairs(pairs,ThreadNumber);
View Full Code Here

  private final void TestScoreComputationWithFilters(Class<? extends StatesToConsider> filterClass)
  {
    LearnerGraph gr=new LearnerGraph(buildGraph(machineCompatibility2+
        "\nB-b-#G\n","TestComputeStateCompatibility_checking_filtering2"),config);
    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();
View Full Code Here

  /** Tests the workload distribution. */
  @Test
  public final void testPerformRowTasks_A_1()
  {
    LearnerGraph gr=new LearnerGraph(Configuration.getDefaultConfiguration());gr.getInit().setAccept(false);
    StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    int ThreadNumber=4;
    Assert.assertArrayEquals(new int[]{0,0,0,0,0},GDLearnerGraph.partitionWorkLoadTriangular(ThreadNumber,ndGraph.getStateNumber()));
    Assert.assertArrayEquals(new int[]{0,0,0,0,0},GDLearnerGraph.partitionWorkLoadLinear(ThreadNumber,ndGraph.getStateNumber()));

View Full Code Here

  /** Tests the workload distribution. */
  @Test
  public final void testPerformRowTasks_A_2()
  {
    LearnerGraph gr=new LearnerGraph(Configuration.getDefaultConfiguration());
    StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    int ThreadNumber=4;
    Assert.assertArrayEquals(new int[]{0,0,0,0,1},GDLearnerGraph.partitionWorkLoadTriangular(ThreadNumber,ndGraph.getStateNumber()));

    final Map<Integer,Integer> threadToRowNumber = Collections.synchronizedMap(new TreeMap<Integer,Integer>());
View Full Code Here

  /** Tests the workload distribution. */
  @Test
  public final void testPerformRowTasks_A_3()
  {
    LearnerGraph gr=buildLearnerGraph("A-a->B-a-#C\nA-b-#D\nA-c-#E\nB-b-#F\nB-c-#G","testPerformRowTasks_A_3",Configuration.getDefaultConfiguration());
    StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    int ThreadNumber=4;

    final Map<Integer,Integer> threadToRowNumber = Collections.synchronizedMap(new TreeMap<Integer,Integer>());
   
View Full Code Here

  /** Tests that conversion between numerical state pairs and back works. */
  @Test
  public final void testNumberToState_and_Back()
  {
    LearnerGraph gr=buildLearnerGraph("A-a->Q\nA-b->C\nA-d->C\nD-a->C\nD-b->C\nD-d->C-a->C\nD-c->A-c-#R\nC-f-#T\nC-e->G-a-#K\nG-b->S-a-#U","TestFindIncompatibleStatesB",Configuration.getDefaultConfiguration());
    StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    for(CmpVertex A:gr.transitionMatrix.keySet())
      if (filter.stateToConsider(A))
        for(CmpVertex B:gr.transitionMatrix.keySet())
          if (filter.stateToConsider(B))
          {
            PairScore received1 = ndGraph.getPairScore(ndGraph.vertexToIntNR(A,B), 1, 2);
            Assert.assertTrue(
                received1.equals(new PairScore(A,B,1,2)) ||
                received1.equals(new PairScore(B,A,1,2))
View Full Code Here

    LearnerGraphND expected = buildLearnerGraphND("C-c->A\nU-a->V-b->U","testBuildInverse7",config,converter);
    expected.transitionMatrix.put(AbstractLearnerGraph.generateNewCmpVertex(VertexID.parseID("D"), graph.config), graph.createNewRow());
    expected.setInit(expected.findVertex("A"));
   
    LearnerGraphND actual = new LearnerGraphND(Configuration.getDefaultConfiguration());actual.initEmpty();
    AbstractPathRoutines.buildInverse(graph, new StatesToConsider() {

      @Override
      public boolean stateToConsider(CmpVertex vert) {
        return !vert.getStringId().equals("B");
      }
View Full Code Here

  {
    LearnerGraphND graph = buildLearnerGraphND("A-a->B-a->C\nA<-c-B-b-#D\nB-d->A-c->C\nU-b->V-a->U",
      "testConvertToND6",config,converter);
   
    LearnerGraphND actual = new LearnerGraphND(Configuration.getDefaultConfiguration());actual.initEmpty();
    AbstractPathRoutines.buildInverse(graph, new StatesToConsider() {

      @Override
      public boolean stateToConsider(@SuppressWarnings("unused") CmpVertex vert) {
        return false;
      }
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.rpnicore.AbstractLearnerGraph.StatesToConsider

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.