Examples of GDLearnerGraph


Examples of statechum.analysis.learning.linear.GDLearnerGraph

   * @param randomWalkGenerator random number generator to be used in walk generation.
   */
  public void chooseStatePairs_internal(double threshold, double scale, int ThreadNumber,
      final Class<? extends DetermineDiagonalAndRightHandSideInterface> ddrh, StatesToConsider filter, StateBasedRandom randomWalkGenerator)
  {
    GDLearnerGraph ndGraph = new GDLearnerGraph(coregraph, filter, false);
    switch(coregraph.config.getGdScoreComputationAlgorithm())
    {
    case SCORE_RANDOMPATHS:
    case SCORE_TESTSET:
      // build (1) deterministic machines for each state and (2) walks from each state.
      ndGraph.computeWalkSequences(randomWalkGenerator, ThreadNumber);
      break;
    case SCORE_LINEAR:
      break;
    default:
      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];
      if (index >= 0)
      {
        double value = solver.j_x[incompatiblePairs[i]];
        if (value > threshold) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*value), 0));
      }
      else // PAIR_INCOMPATIBLE
        if (threshold < GDLearnerGraph.PAIR_INCOMPATIBLE) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*GDLearnerGraph.PAIR_INCOMPATIBLE), 0));
    }
  }
View Full Code Here

Examples of statechum.analysis.learning.linear.GDLearnerGraph

   * @param randomWalkGenerator random number generator to be used in walk generation.
   */
  public void chooseStatePairs_internal(double threshold, double scale, int ThreadNumber,
      final Class<? extends DetermineDiagonalAndRightHandSideInterface> ddrh, StatesToConsider filter, StateBasedRandom randomWalkGenerator)
  {
    GDLearnerGraph ndGraph = new GDLearnerGraph(coregraph, filter, false);
    switch(coregraph.config.getGdScoreComputationAlgorithm())
    {
    case SCORE_RANDOMPATHS:
    case SCORE_TESTSET:
      // build (1) deterministic machines for each state and (2) walks from each state.
      ndGraph.computeWalkSequences(randomWalkGenerator, ThreadNumber);
      break;
    case SCORE_LINEAR:
      break;
    default:
      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];
      if (index >= 0)
      {
        double value = solver.j_x[incompatiblePairs[i]];
        if (value > threshold) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*value), 0));
      }
      else // PAIR_INCOMPATIBLE
        if (threshold < GDLearnerGraph.PAIR_INCOMPATIBLE) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*GDLearnerGraph.PAIR_INCOMPATIBLE), 0));
    }
  }
View Full Code Here

Examples of statechum.analysis.learning.linear.GDLearnerGraph

   * @param randomWalkGenerator random number generator to be used in walk generation.
   */
  public void chooseStatePairs_internal(double threshold, double scale, int ThreadNumber,
      final Class<? extends DetermineDiagonalAndRightHandSideInterface> ddrh, StatesToConsider filter, StateBasedRandom randomWalkGenerator)
  {
    GDLearnerGraph ndGraph = new GDLearnerGraph(coregraph, filter, false);
    switch(coregraph.config.getGdScoreComputationAlgorithm())
    {
    case SCORE_RANDOMPATHS:
    case SCORE_TESTSET:
      // build (1) deterministic machines for each state and (2) walks from each state.
      ndGraph.computeWalkSequences(randomWalkGenerator, ThreadNumber);
      break;
    case SCORE_LINEAR:
      break;
    default:
      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];
      if (index >= 0)
      {
        double value = solver.j_x[incompatiblePairs[i]];
        if (value > threshold) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*value), 0));
      }
      else // PAIR_INCOMPATIBLE
        if (threshold < GDLearnerGraph.PAIR_INCOMPATIBLE) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*GDLearnerGraph.PAIR_INCOMPATIBLE), 0));
    }
  }
View Full Code Here

Examples of statechum.analysis.learning.linear.GDLearnerGraph

    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);
      Assert.assertEquals(state_to_int_map.size(), numberToStateNoReject.length);
      Collection<CmpVertex> states_int = state_to_int_map.keySet();
      Assert.assertEquals(ndGraph.getStateNumber(),state_to_int_map.values().size());
      Assert.assertArrayEquals(states_int.toArray(),numberToStateNoReject);
     
      Set<CmpVertex> expectedIgnoredStates = new TreeSet<CmpVertex>();for(String st:expectedToRemain) expectedIgnoredStates.add(gr.findVertex(st));
      Assert.assertEquals(states_int,expectedIgnoredStates);
     
View Full Code Here

Examples of statechum.analysis.learning.linear.GDLearnerGraph

   * @param randomWalkGenerator random number generator to be used in walk generation.
   */
  public void chooseStatePairs_internal(double threshold, double scale, int ThreadNumber,
      final Class<? extends DetermineDiagonalAndRightHandSideInterface> ddrh, StatesToConsider filter, StateBasedRandom randomWalkGenerator)
  {
    GDLearnerGraph ndGraph = new GDLearnerGraph(coregraph, filter, false);
    switch(coregraph.config.getGdScoreComputationAlgorithm())
    {
    case SCORE_RANDOMPATHS:
    case SCORE_TESTSET:
      // build (1) deterministic machines for each state and (2) walks from each state.
      ndGraph.computeWalkSequences(randomWalkGenerator, ThreadNumber);
      break;
    case SCORE_LINEAR:
      break;
    default:
      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];
      if (index >= 0)
      {
        double value = solver.j_x[incompatiblePairs[i]];
        if (value > threshold) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*value), 0));
      }
      else // PAIR_INCOMPATIBLE
        if (threshold < GDLearnerGraph.PAIR_INCOMPATIBLE) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*GDLearnerGraph.PAIR_INCOMPATIBLE), 0));
    }
  }
View Full Code Here

Examples of statechum.analysis.learning.linear.GDLearnerGraph

    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);
      Assert.assertEquals(state_to_int_map.size(), numberToStateNoReject.length);
      Collection<CmpVertex> states_int = state_to_int_map.keySet();
      Assert.assertEquals(ndGraph.getStateNumber(),state_to_int_map.values().size());
      Assert.assertArrayEquals(states_int.toArray(),numberToStateNoReject);
     
      Set<CmpVertex> expectedIgnoredStates = new TreeSet<CmpVertex>();for(String st:expectedToRemain) expectedIgnoredStates.add(gr.findVertex(st));
      Assert.assertEquals(states_int,expectedIgnoredStates);
     
View Full Code Here

Examples of statechum.analysis.learning.linear.GDLearnerGraph

   * @param randomWalkGenerator random number generator to be used in walk generation.
   */
  public void chooseStatePairs_internal(double threshold, double scale, int ThreadNumber,
      final Class<? extends DetermineDiagonalAndRightHandSideInterface> ddrh, StatesToConsider filter, StateBasedRandom randomWalkGenerator)
  {
    GDLearnerGraph ndGraph = new GDLearnerGraph(coregraph, filter, false);
    switch(coregraph.config.getGdScoreComputationAlgorithm())
    {
    case SCORE_RANDOMPATHS:
    case SCORE_TESTSET:
      // build (1) deterministic machines for each state and (2) walks from each state.
      ndGraph.computeWalkSequences(randomWalkGenerator, ThreadNumber);
      break;
    case SCORE_LINEAR:
      break;
    default:
      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];
      if (index >= 0)
      {
        double value = solver.j_x[incompatiblePairs[i]];
        if (value > threshold) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*value), 0));
      }
      else // PAIR_INCOMPATIBLE
        if (threshold < GDLearnerGraph.PAIR_INCOMPATIBLE) coregraph.pairsAndScores.add(ndGraph.getPairScore(i, (int)(scale*GDLearnerGraph.PAIR_INCOMPATIBLE), 0));
    }
  }
View Full Code Here

Examples of statechum.analysis.learning.linear.GDLearnerGraph

public class StructuralDifferencesPaper {
  static final Configuration config = Configuration.getDefaultConfiguration();

  public static void dumpEquations()
  {
    GDLearnerGraph ndGraph = new GDLearnerGraph(buildLearnerGraph("A-a->B-a->B-b->A / B-c->C / E-a->F-a->F-d->F-b->E-c->F""dumpEquations",config,null),LearnerGraphND.ignoreRejectStates, false);
    final int [] incompatiblePairs = new int[ndGraph.getPairNumber()];
    final int pairsNumber = incompatiblePairs.length;
    for(int i=0;i<incompatiblePairs.length;++i) incompatiblePairs[i]=i;// emulate the behaviour or non-public part for(int i=0;i<incompatiblePairs.length;++i) incompatiblePairs[i]=PAIR_OK;final int pairsNumber = ndGraph.findIncompatiblePairs(incompatiblePairs,1);

    LSolver solver = ndGraph.buildMatrix_internal(incompatiblePairs, pairsNumber, 1,null);

    System.out.println(ndGraph.dumpEquations(solver, incompatiblePairs, null).toString())}
View Full Code Here

Examples of statechum.analysis.learning.linear.GDLearnerGraph

    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);
      Assert.assertEquals(state_to_int_map.size(), numberToStateNoReject.length);
      Collection<CmpVertex> states_int = state_to_int_map.keySet();
      Assert.assertEquals(ndGraph.getStateNumber(),state_to_int_map.values().size());
      Assert.assertArrayEquals(states_int.toArray(),numberToStateNoReject);
     
      Set<CmpVertex> expectedIgnoredStates = new TreeSet<CmpVertex>();for(String st:expectedToRemain) expectedIgnoredStates.add(gr.findVertex(st));
      Assert.assertEquals(states_int,expectedIgnoredStates);
     
View Full Code Here

Examples of statechum.analysis.learning.linear.GDLearnerGraph

    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);
      Assert.assertEquals(state_to_int_map.size(), numberToStateNoReject.length);
      Collection<CmpVertex> states_int = state_to_int_map.keySet();
      Assert.assertEquals(ndGraph.getStateNumber(),state_to_int_map.values().size());
      Assert.assertArrayEquals(states_int.toArray(),numberToStateNoReject);
     
      Set<CmpVertex> expectedIgnoredStates = new TreeSet<CmpVertex>();for(String st:expectedToRemain) expectedIgnoredStates.add(gr.findVertex(st));
      Assert.assertEquals(states_int,expectedIgnoredStates);
     
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.