Package statechum.analysis.learning.rpnicore.AbstractLearnerGraph

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


 
  protected DoubleMatrix1D getExpectedMatrix1DSlowly(LearnerGraph gr)
  {
    int size=gr.getStateNumber()*(gr.getStateNumber()+1)/2;
    DoubleMatrix1D result = DoubleFactory1D.dense.make(size);
    StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    DetermineDiagonalAndRightHandSide ddrhInstance = ndGraph.new DDRH_default();
    for(Entry<CmpVertex,Map<Label,List<CmpVertex>>> entryA:ndGraph.matrixForward.transitionMatrix.entrySet())
    {
      // Now iterate through states
View Full Code Here


  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<Label,List<CmpVertex>>> entryA:ndGraph.matrixForward.transitionMatrix.entrySet())
    {
      // Now iterate through states
      Iterator<Entry<CmpVertex,Map<Label,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=buildLearnerGraph(machineCompatibility2+
        "\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();
View Full Code Here

 
  protected DoubleMatrix1D getExpectedMatrix1DSlowly(LearnerGraph gr)
  {
    int size=gr.getStateNumber()*(gr.getStateNumber()+1)/2;
    DoubleMatrix1D result = DoubleFactory1D.dense.make(size);
    StatesToConsider filter = LearnerGraphND.ignoreRejectStates;
    GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, false);
    DetermineDiagonalAndRightHandSide ddrhInstance = ndGraph.new DDRH_default();
    for(Entry<CmpVertex,Map<String,List<CmpVertex>>> entryA:ndGraph.matrixForward.transitionMatrix.entrySet())
    {
      // Now iterate through states
View Full Code Here

  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

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.