Package statechum.DeterministicDirectedSparseGraph

Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex


   * @return the target state, null if there is no transition with this input not only from r but also from all states associated to it
   * using mergedVertices.
   */
  protected CmpVertex findNextRed(Map<CmpVertex,List<CmpVertex>> mergedVertices, CmpVertex r, Label input)
  {
    CmpVertex target = null;
    List<CmpVertex> associatedVertices = mergedVertices.get(r);
    if (associatedVertices != null)
    {
      Iterator<CmpVertex> associatedIt = associatedVertices.iterator();
      while(associatedIt.hasNext() && target == null)
View Full Code Here


        ++score;
      Map<Label,CmpVertex> targetBlue = coregraph.transitionMatrix.get(currentPair.getQ());

      for(Entry<Label,CmpVertex> blueEntry:targetBlue.entrySet())
      {
        CmpVertex nextRedState = coregraph.transitionMatrix.get(currentPair.getR()).get(blueEntry.getKey());
        if (nextRedState != null)
        {// both states can make a transition - this would be the case of "non-determinism" for Merge&Determinize
          boolean newRedFromPta = redFromPta;
         
          // PTA does not have loops, but the original automaton has
View Full Code Here

        {
          singleton = true;
          for(Label lbl:equivalenceClass.getOutgoing().keySet().toArray(new Label[0]))
          {
            ArrayList<CmpVertex> targets = equivalenceClass.getOutgoing().get(lbl);
            CmpVertex firstVertex = targets.get(0);
            if (targets.size() > 1)
            {
              singleton = false;/*
              AMEquivalenceClass<CmpVertex,LearnerGraphCachedData> firstEquivalenceClass = stateToEquivalenceClass.get(firstVertex);
              int firstEqNumber = firstEquivalenceClass.getNumber();*/
              int i=1;
              while(i<targets.size()) // here we benefit from the ability to iterate over a collection that may be updated as we iterate through it.
              {
                CmpVertex target = targets.get(i);
                if (!mergePair(new StatePair(firstVertex,target), stateToEquivalenceClass,mergingDetails))
                {
                  AMEquivalenceClass<CmpVertex,LearnerGraphCachedData> firstEquivalenceClass = stateToEquivalenceClass.get(firstVertex);
                  if (setOfEquivalenceClassesOnStack.get(firstEquivalenceClass) == null)
                  {// if a merge added something and the equivalence class is not already on the stack, add it.
View Full Code Here

        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
           
View Full Code Here

        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;// definitely incompatible states, fail regardgless whether we should look for a single or all paths.
           
View Full Code Here

    // I iterate over the elements of the original graph in order to be able to update the target one.
    for(Entry<CmpVertex,Map<Label,CmpVertex>> entry:coregraph.transitionMatrix.entrySet())
      if ( (recursive || entry.getKey() == pair.getR()) && entry.getKey().getColour() == JUConstants.RED)
      {// only checks for specific state of interest if we are supposed to be non-recursive.
        CmpVertex vert = entry.getKey();
        if (mergedVertices.containsKey(vert))
        {// there are some vertices to merge with this one.
          inputsUsed.clear();inputsUsed.addAll(entry.getValue().keySet());// the first entry is either a "derivative" of a red state or a branch of PTA into which we are now merging more states.
          for(CmpVertex toMerge:mergedVertices.get(vert))
          {// for every input, I'll have a unique target state - this is a feature of PTA
View Full Code Here

  {
    assert (enteredName == null)? (ExpectedResult >= 0):true;
    final DirectedSparseGraph g = buildGraph(fsmString, "sample FSM");
    final LearnerGraph fsm = new LearnerGraph(g,config);
    assertEquals(ExpectedResult, fsm.paths.tracePath(Arrays.asList(path)));
    CmpVertex expected = (enteredName == null)? null:new LearnerGraph(g, conf).findVertex(enteredName);
    Vertex receivedA = RPNIBlueFringeLearnerOrig.getVertex(g, Arrays.asList(path));
    CmpVertex receivedB = new LearnerGraph(g,conf).paths.getVertex(Arrays.asList(path));
    if (expected == null)
    {
      Assert.assertNull(receivedA);Assert.assertNull(receivedB);
    }
    else
    {
      assertEquals(expected.getID(),receivedA.getUserDatum(JUConstants.LABEL));
      assertEquals(expected.getID(),receivedB.getID());
      assertEquals(expected.isAccept(),DeterministicDirectedSparseGraph.isAccept(receivedA));
      assertEquals(expected.isAccept(),receivedB.isAccept());
    }
  }
View Full Code Here

    assert (enteredName == null) == (ExpectedResult >= 0);
    final DirectedSparseGraph g = buildGraph(fsmString, "sample FSM");
    final LearnerGraph fsm = new LearnerGraph(g,config);
    assertEquals(ExpectedResult, fsm.paths.tracePath(Arrays.asList(path),fsm.findVertex(startingState)));
    Vertex starting = DeterministicDirectedSparseGraph.findVertexNamed(new VertexID(startingState),g);
    CmpVertex expected = (enteredName == null)? null:new LearnerGraph(g, conf).findVertex(new VertexID(enteredName));
    Vertex received = RPNIBlueFringeLearnerOrig.getVertex(g, starting, Arrays.asList(path));
    if (expected == null)
      Assert.assertNull(received);
    else
    {
      assertEquals(expected.getID(),received.getUserDatum(JUConstants.LABEL));
      assertEquals(expected.isAccept(),DeterministicDirectedSparseGraph.isAccept(received));
    }
  }
View Full Code Here

    {// checking that all the old questions are included in the new ones
      assert scoreComputer.config.getQuestionGenerator() == QuestionGeneratorKind.CONVENTIONAL;
      assert scoreComputer.config.getQuestionPathUnionLimit() < 0;
     
      Collection<List<String>> questionsOrigA = ComputeQuestions.computeQS_orig(pair, scoreComputer,MergeStates.mergeAndDeterminize(scoreComputer, pair));
      CmpVertex Rnew = tempNew.getStateLearnt();
      assert Rnew == tempNew.getVertex(scoreComputer.wmethod.computeShortPathsToAllStates().get(pair.getR()));
      Collection<List<String>> questionsOrigB = ComputeQuestions.computeQS_orig(new StatePair(Rnew,Rnew), scoreComputer,tempNew);
      PTASequenceSet newQuestions =new PTASequenceSet();newQuestions.addAll(questions);
      assert newQuestions.containsAll(questionsOrigA);
      assert newQuestions.containsAll(questionsOrigB);
View Full Code Here

        {
          System.out.println("CANCELLED");
          return null;
        }
       
        CmpVertex tempVertex = temp.getVertex(question);
       
        if(answer.firstElem == USER_ACCEPTED)
        {
          //sPlus.add(question);
          topLearner.AugmentPTA(initialPTA, RestartLearningEnum.restartHARD, question, true,JUConstants.AMBER);
          //initialPTA.paths.augmentPTA(question, true,JUConstants.AMBER);
          ++plusSize;
          if (ans != null) System.out.println(howAnswerWasObtained+question.toString()+ " <yes>");
          if(!tempVertex.isAccept())
          {
            restartLearning = true;break;
          }
        }
        else
          if(answer.firstElem >= 0)
          {// The sequence has been rejected by a user
            assert answer.firstElem < question.size();
            LinkedList<String> subAnswer = new LinkedList<String>();subAnswer.addAll(question.subList(0, answer.firstElem+1));
            //sMinus.add(subAnswer);
            topLearner.AugmentPTA(initialPTA, RestartLearningEnum.restartHARD, subAnswer, false,JUConstants.AMBER);
            //initialPTA.paths.augmentPTA(subAnswer, false,JUConstants.AMBER);
            ++minusSize;
            // important: since vertex IDs are
            // only unique for each instance of ComputeStateScores, only once
            // instance should ever receive calls to augmentPTA
            if (ans != null) System.out.println(howAnswerWasObtained+question.toString()+ " <no> at position "+answer.firstElem+", element "+question.get(answer.firstElem));
            if( (answer.firstElem < question.size()-1) || tempVertex.isAccept())
            {
              assert accepted == true;
              restartLearning = true;break;
            }
          }
View Full Code Here

TOP

Related Classes of statechum.DeterministicDirectedSparseGraph.CmpVertex

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.