Package statechum.analysis.learning

Examples of statechum.analysis.learning.StatePair


     
      // Special configuration is necessary to ensure that computePairCompatibilityScore_internal
      // builds mergedVertices using g's vertices rather than StringVertices or clones of g's vertices.
      Configuration VertexCloneConf = (Configuration)conf.clone();VertexCloneConf.setLearnerUseStrings(false);VertexCloneConf.setLearnerCloneGraph(false);
      LearnerGraph s=new LearnerGraph(g,VertexCloneConf);
      if (s.pairscores.computePairCompatibilityScore_internal(new StatePair(s.findVertex(pair.getQ().getID()),s.findVertex(pair.getR().getID())),mergedVertices) < 0)
        throw new IllegalArgumentException("elements of the pair are incompatible");

      // make a loop
      Set<String> usedInputs = new HashSet<String>();
      for(DirectedSparseEdge e:(Set<DirectedSparseEdge>)newBlue.getInEdges())
View Full Code Here


     
      // Special configuration is necessary to ensure that computePairCompatibilityScore_internal
      // builds mergedVertices using g's vertices rather than StringVertices or clones of g's vertices.
      Configuration VertexCloneConf = conf.copy();VertexCloneConf.setLearnerUseStrings(false);VertexCloneConf.setLearnerCloneGraph(false);
      LearnerGraph s=new LearnerGraph(g,VertexCloneConf);
      if (s.pairscores.computePairCompatibilityScore_internal(new StatePair(s.findVertex(pair.getQ()),s.findVertex(pair.getR())),mergedVertices) < 0)
        throw new IllegalArgumentException("elements of the pair are incompatible");

      // make a loop
      Set<Label> usedInputs = new HashSet<Label>();
      for(DirectedSparseEdge e:(Set<DirectedSparseEdge>)newBlue.getInEdges())
View Full Code Here

      {
        CmpVertex prevVertex = null;
        for(CmpVertex v:vertices)
        {
          if (prevVertex != null)
            pairsList.add(new StatePair(prevVertex,v));
          prevVertex = v;
        }
      }
      for(Collection<CmpVertex> vertices:labelFromStates.values())
      {
        CmpVertex prevVertex = null;
        for(CmpVertex v:vertices)
        {
          if (prevVertex != null)
            pairsList.add(new StatePair(prevVertex,v));
          prevVertex = v;
        }
      }
      /*
      LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
View Full Code Here

        "A2-c->A21-c->A22-e->A23 /"+
        "A3-c->A31-c->A32 / A31-d-#A34 /"+
        "A4-c->A41-c->A42-f-#A43 /"+
        "A5-c->A51-c->A52"
        , "testBuildPTAofQuestions1",config,converter);
    StatePair pair = new StatePair(graph.findVertex("A1"),graph.findVertex("A2"));
    LearnerGraph merged = MergeStates.mergeAndDeterminize_general(graph, pair);
    compareGraphs(buildLearnerGraph("A1-a->B1-b->A1-c->C-d-#R4 / C-c->CC / CC-f-#R3 / CC-e->D", "expected",config,converter),merged);
    PTASequenceEngine questions = ComputeQuestions.getQuestionPta(pair, graph, merged, null);
    LearnerGraph updatedGraphExpected = new LearnerGraph(graph,config),
      updatedGraphActual = ComputeQuestions.constructGraphWithQuestions(pair, graph, merged);
View Full Code Here

   */
  private void checkQuestionAugmentation(String fsm, String name)
  {
    Configuration config = mainConfiguration.copy();config.setLearnerCloneGraph(false);
    LearnerGraph graph = buildLearnerGraph(fsm,name,config,converter);
    StatePair pair = new StatePair(graph.findVertex("A"),graph.findVertex("B"));
    LearnerGraph merged = MergeStates.mergeAndDeterminize_general(graph, pair);
    PTASequenceEngine questions = ComputeQuestions.computeQS_general(pair, graph, merged, new ComputeQuestions.QSMQuestionGenerator());
    LearnerGraph updatedGraphExpected = new LearnerGraph(graph,config),updatedGraphActual = new LearnerGraph(graph,config);
    updatedGraphActual.transitionMatrix.putAll(((NonExistingPaths)questions.getFSM()).getNonExistingTransitionMatrix());
    updatedGraphActual.learnerCache.invalidate();
View Full Code Here

        "A2-c->A21-c->A22-e->A23 /"+
        "A3-c->A31-c->A32 / A31-d-#A34 /"+
        "A4-c->A41-c->A42-f-#A43 /"+
        "A5-c->A51-c->A52"
        , "testBuildPTAofQuestions1",mainConfiguration,converter);
    StatePair pair = new StatePair(graph.findVertex("A1"),graph.findVertex("A2"));
    LearnerGraph merged = MergeStates.mergeAndDeterminize_general(graph, pair);
    compareGraphs(buildLearnerGraph("A1-a->B1-b->A1-c->C-d-#R4/C-c->CC/CC-f-#R3/CC-e->D", "testQuestionAnswering2b",mainConfiguration,converter),merged);
    PTASequenceEngine questions = ComputeQuestions.computeQS_general(pair, graph, merged, new ComputeQuestions.QSMQuestionGenerator());
    // the IF part we're augmenting with is a dummy one
    LearnerGraph[] ifthenCollection = new LearnerGraph[]{buildLearnerGraph("A-s->B / P-c->Q-d-#R / S-c->S1-c->S2-e->S3 / S==THEN==A==THEN==P", "testQuestionAnswering1", mainConfiguration,converter)};
View Full Code Here

   */
  public static List<List<String>> computeQS(final StatePair pair, LearnerGraph original, LearnerGraph merged)
  {
    List<List<String>> result = null;
    if (original.config.getQuestionGenerator() == Configuration.QuestionGeneratorKind.ORIGINAL)
      result = computeQS_orig(new StatePair(merged.getStateLearnt(),merged.getStateLearnt()), original, merged);
    else
    {
      QuestionConstructor qConstructor=null;
      switch(original.config.getQuestionGenerator())
      {
View Full Code Here

     
      // Special configuration is necessary to ensure that computePairCompatibilityScore_internal
      // builds mergedVertices using g's vertices rather than StringVertices or clones of g's vertices.
      Configuration VertexCloneConf = conf.copy();VertexCloneConf.setLearnerUseStrings(false);VertexCloneConf.setLearnerCloneGraph(false);
      LearnerGraph s=new LearnerGraph(g,VertexCloneConf);
      if (s.pairscores.computePairCompatibilityScore_internal(new StatePair(s.findVertex(pair.getQ().getID()),s.findVertex(pair.getR().getID())),mergedVertices) < 0)
        throw new IllegalArgumentException("elements of the pair are incompatible");

      // make a loop
      Set<String> usedInputs = new HashSet<String>();
      for(DirectedSparseEdge e:(Set<DirectedSparseEdge>)newBlue.getInEdges())
View Full Code Here

      Queue<StatePair> currentExplorationBoundary = new LinkedList<StatePair>();// FIFO queue
      currentExplorationBoundary.add(pair);currentExplorationBoundary.offer(null);
     
      while(!foundKTail)
      {
        StatePair currentPair = currentExplorationBoundary.remove();
        if (currentPair == null)
        {// we got to the end of a wave
          if (currentExplorationBoundary.isEmpty())
            break;// we are at the end of the last wave, stop looping.

          // mark the end of a wave.
          currentExplorationBoundary.offer(null);
        }
        else
        {
          Map<Label,CmpVertex> targetRed = coregraph.transitionMatrix.get(currentPair.getR()),
            targetBlue = coregraph.transitionMatrix.get(currentPair.getQ());
   
          for(Entry<Label,CmpVertex> redEntry:targetRed.entrySet())
          {
            CmpVertex nextBlueState = targetBlue.get(redEntry.getKey());
            if (nextBlueState != null)
            {// both states can make a transition
              if (!AbstractLearnerGraph.checkCompatible(redEntry.getValue(),nextBlueState,coregraph.pairCompatibility))
                return -1;// incompatible states
             
//              if(RPNIUniversalLearner.state_outgoing.get(currentPair.getQ())==null || RPNIUniversalLearner.state_outgoing.get(currentPair.getQ()).get(redEntry.getKey())==null)
                 matchscore++;
             
//              else if(RPNIUniversalLearner.state_outgoing.get(currentPair.getQ()).get(redEntry.getKey()) > 0.0)
//                           matchscore++;
             
             
              StatePair nextStatePair = new StatePair(nextBlueState,redEntry.getValue());
              currentExplorationBoundary.offer(nextStatePair);
              }               
            // if the red can make a move, but the blue one cannot, ignore this case.
          }
        }
View Full Code Here

  @Test
  public final void testCheckGraphNumeric3()
  {
    LearnerGraph textGraph = new LearnerGraph(buildGraph("A-a->A-c->C","testCheckGraphNumeric"),config);
    LearnerGraph numericGraph = new LearnerGraph(config);CmpVertex newInit = Transform.addToGraph(numericGraph, textGraph);
    numericGraph = MergeStates.mergeAndDeterminize_general(numericGraph, new StatePair(numericGraph.paths.getVertex(new LinkedList<String>()),newInit));
    Assert.assertTrue(numericGraph.wmethod.checkGraphNumeric());
  }
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.StatePair

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.