Examples of CmpVertex


Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex

    ptaClassifier.updateMarkov(false);
 
    Map<Label,CmpVertex> states = new TreeMap<Label,CmpVertex>();
    for(Label l:ptaClassifier.graph.getCache().getAlphabet())
    {
      CmpVertex state = AbstractLearnerGraph.generateNewCmpVertex(VertexID.parseID(l.toString()), ptaClassifier.graph.config);states.put(l,state);
      outcome.transitionMatrix.put(state, outcome.createNewRow());
    }
    for(Entry<Label,CmpVertex> state:states.entrySet())
    {
      for(Label label:ptaClassifier.graph.getCache().getAlphabet())
      {
        MarkovOutcome transition = ptaClassifier.model.predictionsMatrix.get(new Trace(Arrays.asList(new Label[]{state.getKey(),label}),true));
        if (transition != null)
          if (transition == MarkovOutcome.positive) outcome.transitionMatrix.get(state.getValue()).put(label,states.get(label));
      }
    }   

    List<List<Label>> uniqueSequences = new LinkedList<List<Label>>();
    for(Label l1:ptaClassifier.graph.getCache().getAlphabet())
    {
      boolean nonUnique = false;
      Label unique = null;
      for(Label lbl:ptaClassifier.graph.getCache().getAlphabet())
      {
        if (ptaClassifier.model.predictionsMatrix.containsKey(new Trace(Arrays.asList(new Label[]{l1,lbl}),true)))
        {
          if (unique == null)
            unique = lbl;
          else
          {
            nonUnique = true;break;
          }
        }
      }
      if (unique != null && !nonUnique)
        uniqueSequences.add(Arrays.asList(new Label[]{l1,unique}));
     
    }
   
    List<List<Label>> sequencesUnique2=new LinkedList<List<Label>>();
    for(List<Label> prefix:uniqueSequences)
      {
        boolean nonUnique = false;
        List<Label> unique = null;
        for(Label lbl:ptaClassifier.graph.getCache().getAlphabet())
        {
          List<Label> seq = new LinkedList<Label>(prefix);seq.add(lbl);
          if (ptaClassifier.model.predictionsMatrix.containsKey(new Trace(seq,true)))
          {
            if (unique == null)
              unique = seq;
            else
            {
              nonUnique = true;break;
            }
          }
        }
       
        if (nonUnique == false && unique!= null)
          sequencesUnique2.add(unique);
      }
   
    for(List<Label> seq:sequencesUnique2)
    {
      System.out.println(seq);
      for(CmpVertex vert:trimmedReference.transitionMatrix.keySet())
      {
        CmpVertex target=trimmedReference.getVertex(vert,seq);
        if (target != null)
        {
          System.out.println("\t -> "+target);
          CmpVertex stateOfInterest = trimmedReference.getVertex(vert,seq.subList(0, 2));
          System.out.println("\t "+trimmedReference.transitionMatrix.get(stateOfInterest));
        }
       
      }
    }
View Full Code Here

Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex

   */
  protected static void statesIdentifiedUsingUniques(LearnerGraph referenceGraph, Collection<List<Label>> collectionOfUniqueSeq, Set<CmpVertex> correctlyIdentified,Collection<List<Label>> incorrectSequences)
  {
    for(List<Label> seq:collectionOfUniqueSeq)
    {
      int count=0;CmpVertex unique = null;
      for(CmpVertex v:referenceGraph.transitionMatrix.keySet())
      {
        if (referenceGraph.getVertex(v,seq) != null)
        {
          ++count;unique=v;
View Full Code Here

Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex

    return statesUniquelyIdentified;
  }
 
  public static CmpVertex checkSeqUniqueOutgoing(LearnerGraph referenceGraph, List<Label> seq)
  {
    CmpVertex vertexOfInterest = null;
    for(CmpVertex v:referenceGraph.transitionMatrix.keySet())
    {
      CmpVertex currTarget = referenceGraph.getVertex(v,seq);
      if (currTarget != null)
      {
        if (vertexOfInterest != null)
          return null;
View Full Code Here

Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex

  public static List<StatePair> getVerticesToMergeFor(LearnerGraph graph,List<List<List<Label>>> pathsToMerge)
  {
    List<StatePair> listOfPairs = new LinkedList<StatePair>();
    for(List<List<Label>> lotOfPaths:pathsToMerge)
    {
      CmpVertex firstVertex = graph.getVertex(lotOfPaths.get(0));
      for(List<Label> seq:lotOfPaths)
        listOfPairs.add(new StatePair(firstVertex,graph.getVertex(seq)));
    }
    return listOfPairs;
  }
View Full Code Here

Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex

    for(Set<CmpVertex> groupOfStates:verticesToMergeBasedOnInitialPTA)
    {
      Set<CmpVertex> validStatesInGroup = new TreeSet<CmpVertex>();validStatesInGroup.addAll(groupOfStates);validStatesInGroup.retainAll(validStates);
      if (validStatesInGroup.size() > 1)
      {
        CmpVertex v0=validStatesInGroup.iterator().next();
        for(CmpVertex v:validStatesInGroup)
        {
          if (v != v0)
            pairsList.add(new StatePair(v0,v));
          v0=v;
View Full Code Here

Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex

  public static <TARGET_A_TYPE,TARGET_B_TYPE,
    CACHE_A_TYPE extends CachedData<TARGET_A_TYPE, CACHE_A_TYPE>,
    CACHE_B_TYPE extends CachedData<TARGET_B_TYPE, CACHE_B_TYPE>>
    CmpVertex findVertexWithMostTransitions(AbstractLearnerGraph<TARGET_A_TYPE, CACHE_A_TYPE> coregraph, AbstractLearnerGraph<TARGET_B_TYPE, CACHE_B_TYPE> inverseGraph)
    {
      CmpVertex outcome = coregraph.getInit();
      long maxSize=0;
      for(CmpVertex v:coregraph.transitionMatrix.keySet())
      {
        long size = obtainSurroundingTransitions(coregraph,inverseGraph,v).size();
        if (size > maxSize)
View Full Code Here

Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex

      RedStatesFound.clear();coregraph.pairsAndScores.clear();
      currentExplorationBoundary.addAll(reds);
      if (coregraph.additionalExplorationRoot != null) currentExplorationBoundary.addAll(coregraph.additionalExplorationRoot);
      while(!currentExplorationBoundary.isEmpty())
      {
        CmpVertex currentRed = currentExplorationBoundary.remove();
 
        Collection<Entry<Label,CmpVertex>> surrounding = decisionProcedure == null?null:decisionProcedure.getSurroundingTransitions(currentRed);
        if (surrounding == null) surrounding = coregraph.transitionMatrix.get(currentRed).entrySet();
        for(Entry<Label,CmpVertex> BlueEntry:surrounding)
          if (BlueEntry.getValue().getColour() == null ||
              BlueEntry.getValue().getColour() == JUConstants.BLUE)
          {// the next vertex is not marked red, hence it has to become blue
            CmpVertex currentBlueState = BlueEntry.getValue();
           
            int numberOfCompatiblePairs = 0;
            for(CmpVertex oldRed:reds)
            {
              PairScore pair = obtainPair(currentBlueState,oldRed,decisionProcedure);
              if (pair.getScore() >= coregraph.config.getGeneralisationThreshold())
              {
                coregraph.pairsAndScores.add(pair);
                ++numberOfCompatiblePairs;
                if (GlobalConfiguration.getConfiguration().isAssertEnabled() && coregraph.config.getDebugMode()) PathRoutines.checkPTAConsistency(coregraph, currentBlueState);
              }
            }
           
            if (numberOfCompatiblePairs == 0)
              RedStatesFound.add(currentBlueState);
             
            // This node is current a blue node and remains blue until I decide which of the currently potentially red nodes become red.
            currentBlueState.setColour(JUConstants.BLUE);
          }
      }
 
      // Now that we have a collection of all potentially red vertices, pick one to make red and then then check if others can remain blue.
      CmpVertex newRedNode = null;
      if (!RedStatesFound.isEmpty())
      {
        if (RedStatesFound.size() > 1 && decisionProcedure != null)
          newRedNode = decisionProcedure.selectRedNode(coregraph, reds, RedStatesFound);
        else
          newRedNode = RedStatesFound.iterator().next();
        // mark this blue node as red and rebuild a collection of blue and potentially red states.
        newRedNode.setColour(JUConstants.RED);
        reds.add(newRedNode);
      }
      else
        if (!coregraph.pairsAndScores.isEmpty() && decisionProcedure != null)
        {// the pairs chosen so far might all be the wrong ones, hence we could attempt to avoid the disaster if we can do something clever and whoever registered a decision procedure is given a chance to do it. 
          newRedNode = decisionProcedure.resolvePotentialDeadEnd(coregraph, reds, coregraph.pairsAndScores);
          if (newRedNode != null)
          {
            newRedNode.setColour(JUConstants.RED);
            reds.add(newRedNode);RedStatesFound.add(newRedNode);
          }
        }
    }
    while(!RedStatesFound.isEmpty());
View Full Code Here

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

Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex

        ++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

Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex

        {
          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
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.