Package statechum.DeterministicDirectedSparseGraph

Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex


        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

 
  @Test(expected = IllegalArgumentException.class)
  public final void testMerge_fail1a()
  {
    DirectedSparseGraph g=FsmParser.buildLearnerGraph(largeGraph1_invalid5,"testMerge_fail1",config,getLabelConverter()).pathroutines.getGraph();
    CmpVertex
      a = DeterministicDirectedSparseGraph.findVertexNamed(VertexID.parseID("A"), g),
      b = DeterministicDirectedSparseGraph.findVertexNamed(VertexID.parseID("B"), g);
    StatePair pair = new StatePair(b,a);// A is red
    MergeStates.mergeAndDeterminize(g, pair,testConfig);
  }
View Full Code Here

   
  @Test(expected = IllegalArgumentException.class)
  public final void testMerge_fail2()
  {
    LearnerGraph l=buildLearnerGraph(largeGraph1_invalid5,"testMerge_fail1",testConfig,getLabelConverter());
    CmpVertex
      a = l.findVertex(VertexID.parseID("A")),
      b = l.findVertex(VertexID.parseID("B"));
    StatePair pair = new StatePair(b,a);// A is red
    MergeStates.mergeAndDeterminize(l, pair);
  }
View Full Code Here

  @Test(expected = IllegalArgumentException.class)
  public final void testMerge_fail3()
  {
    LearnerGraph l=buildLearnerGraph(largeGraph1_invalid5,"testMerge_fail1",testConfig,getLabelConverter());
    CmpVertex
      a = l.findVertex(VertexID.parseID("A")),
      b = l.findVertex(VertexID.parseID("B"));
    StatePair pair = new StatePair(b,a);// A is red
    MergeStates.mergeAndDeterminize_general(l, pair);
  }
View Full Code Here

  private final void testChooseStatePairsInternal(DirectedSparseGraph g,LearnerGraph l, String [] initialReds, String [][] expectedReds,
      List<PairScore> expectedPairs,InterfaceChooserToTest chooser)
  {
    for(String red:initialReds)
    {
      CmpVertex v = l.findVertex(VertexID.parseID(red));v.setColour(JUConstants.RED);
    }
    Stack<? extends StatePair> pairs = chooser.choosePairs();

    Map<Long,Set<PairScore>> distribution = new HashMap<Long,Set<PairScore>>();// maps scores to sets of states which should correspond to them. The aim is to verify the contents of the stack regardless of the order in which elements with the same score are arranged.
View Full Code Here

    Label a=AbstractLearnerGraph.generateNewLabel("a", config,getLabelConverter()),b=AbstractLearnerGraph.generateNewLabel("b", config,getLabelConverter());
    gr.paths.augmentPTA(Arrays.asList(new Label[]{a,a}),true,false,null);
    gr.paths.augmentPTA(Arrays.asList(new Label[]{a,b}),true,false,null);
    gr.paths.augmentPTA(Arrays.asList(new Label[]{b}),true,false,null);
   
    CmpVertex A=gr.paths.getVertex(Arrays.asList(new Label[]{})),
        B=gr.paths.getVertex(Arrays.asList(new Label[]{a})),
        C=gr.paths.getVertex(Arrays.asList(new Label[]{a,a})),
        D=gr.paths.getVertex(Arrays.asList(new Label[]{a,b})),
        E=gr.paths.getVertex(Arrays.asList(new Label[]{b}));
           
View Full Code Here

        boolean accepted = pair.getQ().isAccept();
        Pair<Integer,String> answer = null;
        if (tentativeAutomaton.config.getUseLTL() && tentativeAutomaton.config.getUseSpin() && !ifthenAutomataAsText.isEmpty())
          answer = new Pair<Integer,String>(checkWithSPIN(question),null);
       
        CmpVertex tempVertex = temp.getVertex(question);
        boolean answerFromSpin = false;
        if(answer != null && answer.firstElem >= 0)
          answerFromSpin = true;
        else
        {
          if (Boolean.valueOf(GlobalConfiguration.getConfiguration().getProperty(GlobalConfiguration.G_PROPERTIES.ASSERT)))
            if (ptaHardFacts.paths.tracePathPrefixClosed(question) == AbstractOracle.USER_ACCEPTED)
              throw new IllegalArgumentException("question "+ question+ " has already been answered");
          List<Boolean> acceptedElements = null;
          acceptedElements = PathRoutines.mapPathToConfirmedElements(ptaHardFacts,question,ifthenAutomata);
         
          answer = topLevelListener.CheckWithEndUser(tentativeAutomaton, question,
              tempVertex.isAccept()?AbstractOracle.USER_ACCEPTED:question.size() - 1,
                  acceptedElements,
              new Object[] { "LTL","IFTHEN","IGNORE QUESTION","MARK AS INCOMPATIBLE"});
        }
        if (answer.firstElem == AbstractOracle.USER_CANCELLED)
        {
          System.err.println("CANCELLED");
          return null;
        }
        else
        if (answer.firstElem == AbstractOracle.USER_IGNORED)
        {// do nothing
          restartLearning = RestartLearningEnum.restartNONE;
          System.err.println("<ignore> "+question);
        }
        else
        if (answer.firstElem == AbstractOracle.USER_INCOMPATIBLE)
        {
          tentativeAutomaton.addToCompatibility(pair.firstElem, pair.secondElem, PAIRCOMPATIBILITY.INCOMPATIBLE);
          restartLearning = RestartLearningEnum.restartRECOMPUTEPAIRS;
        }
        else
        if (answer.firstElem == AbstractOracle.USER_ACCEPTED)
        {
          if(!answerFromSpin) // only add to hard facts when obtained directly from a user or from autofile
            AugumentPTA_and_QuestionPTA(ptaHardFacts,RestartLearningEnum.restartHARD,question, true,colourToAugmentWith);
         
          if (tentativeAutomaton.config.getUseLTL() && tentativeAutomaton.config.getUseSpin()) topLevelListener.AugmentPTA(ptaSoftFacts,RestartLearningEnum.restartSOFT,question, true,colourToAugmentWith);

          if (!tempVertex.isAccept())
          {// contradiction with the result of merging
            if(!answerFromSpin)
              restartLearning = RestartLearningEnum.restartHARD;
            else
              restartLearning = RestartLearningEnum.restartSOFT;
           
          }
        } 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));
          if(!answerFromSpin) // only add to hard facts when obtained directly from a user or from autofile
            AugumentPTA_and_QuestionPTA(ptaHardFacts, RestartLearningEnum.restartHARD,subAnswer, false,colourToAugmentWith);

          if (tentativeAutomaton.config.getUseLTL() && tentativeAutomaton.config.getUseSpin()) topLevelListener.AugmentPTA(ptaSoftFacts,RestartLearningEnum.restartSOFT,subAnswer, false,colourToAugmentWith);
          // important: since vertex IDs is
          // only unique for each instance of ComputeStateScores, only
          // one instance should ever receive calls to augmentPTA

          if ((answer.firstElem < question.size() - 1) || tempVertex.isAccept())
          {// contradiction with the result of merging
            assert accepted == true;
            if(!answerFromSpin)
              restartLearning = RestartLearningEnum.restartHARD;
            else
View Full Code Here

    Queue<CmpVertex> fringe = new LinkedList<CmpVertex>();
    Set<CmpVertex> statesInFringe = new HashSet<CmpVertex>();
    fringe.add(stateToStartFrom);statesInFringe.add(stateToStartFrom);
    while(!fringe.isEmpty())
    {
      CmpVertex currentState = fringe.remove();
      Map<Label,CmpVertex> targets = graph.transitionMatrix.get(currentState);
      if(targets != null && !targets.isEmpty())
        for(Entry<Label,CmpVertex> labelstate:targets.entrySet())
          for(CmpVertex target:graph.getTargets(labelstate.getValue()))
          {
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.