Package statechum.analysis.learning.rpnicore.AbstractLearnerGraph

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


  private final void TestScoreComputationWithFilters(Class<? extends StatesToConsider> filterClass)
  {
    LearnerGraph gr=buildLearnerGraph(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


   *
   * @return an instance of filter.
   */
  public static StatesToConsider createInstanceOfFilter(Class<? extends StatesToConsider> filterClass,LearnerGraph gr)
  {
    StatesToConsider filter = null;
    try {
      java.lang.reflect.Constructor<? extends StatesToConsider> constructor = filterClass.getConstructor(new Class []{});
      filter = constructor.newInstance(new Object[]{});
    } catch (Exception e) {
      // if we failed, filter stays at null, we'll try again.
View Full Code Here

   */
  private final void checkConsideringIgnoredStates(String graph, String graphName, Class<? extends StatesToConsider> filterClass, String [] expectedToRemain)
  {
    Configuration conf = Configuration.getDefaultConfiguration().copy();conf.setTransitionMatrixImplType(STATETREE.STATETREE_SLOWTREE);
    LearnerGraph gr=buildLearnerGraph(graph,graphName,conf,null);
    StatesToConsider filter = createInstanceOfFilter(filterClass, gr);
    for(boolean direction:new boolean[]{false,true})
    {
      GDLearnerGraph ndGraph = new GDLearnerGraph(gr,filter, direction);
      Map<CmpVertex,Integer> state_to_int_map = new TreeMap<CmpVertex,Integer>();
      CmpVertex [] numberToStateNoReject = gr.buildStateToIntegerMap(filter,state_to_int_map);
View Full Code Here

  public <TARGET_A_TYPE,CACHE_A_TYPE extends CachedData<TARGET_A_TYPE,CACHE_A_TYPE>> void removeReachableStatesFromWhichInitIsNotReachable(AbstractLearnerGraph<TARGET_A_TYPE,CACHE_A_TYPE> outcome)
  {
    final Set<CmpVertex> reachableStates = computeReachableStatesFromWhichInitIsNotReachable();
   
    buildForward(coregraph, new StatesToConsider(){

      @Override
      public boolean stateToConsider(CmpVertex vert) {
        return !reachableStates.contains(vert);
      }}, outcome);
View Full Code Here

           
            // Perhaps I should be numbering states directly here instead of using numberNonNegativeElements afterwards,
            // but this is not simple to do: I have to give numbers in the order in which triangular traversal visits states.
          }
        });
      GDLearnerGraph.performRowTasks(handlerList, ThreadNumber, grCombined.transitionMatrix,new StatesToConsider() {
        public boolean stateToConsider(CmpVertex vert) {
          return statesOfA.contains(vert);
        }
      }, GDLearnerGraph.partitionWorkLoadLinear(ThreadNumber,statesOfA.size()));
      final int numberOfPairs = GDLearnerGraph.numberNonNegativeElements(pairScores);
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=new LearnerGraph(buildGraph("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=new LearnerGraph(buildGraph("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

  }
 
  public static void printTraceLeadingTo(LearnerGraph graph, String vert)
  {
    LearnerGraphND ptaInverse = new LearnerGraphND(graph.config);
    AbstractPathRoutines.buildInverse(graph, new StatesToConsider() {
      @Override public boolean stateToConsider(@SuppressWarnings("unused") CmpVertex v) { return true; }}
      , ptaInverse);
    CmpVertex v=ptaInverse.findVertex(vert);
    for(int i=0;i<10;++i)
    {
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.