Package statechum.DeterministicDirectedSparseGraph

Examples of statechum.DeterministicDirectedSparseGraph.CmpVertex


   
    int firstCorrectPair = JUConstants.intUNKNOWN, cnt=0;
    for(PairScore p:pairs)
    {
      CmpVertex blue = correctGraph.getVertex(stateToPath.get(p.getQ()));if (blue != null && !blue.isAccept()) blue = null;
      CmpVertex red = correctGraph.getVertex(stateToPath.get(p.getR()));if (red != null && !red.isAccept()) red = null;
      if (blue == red)
      {
        // it would be right to merge this pair.
        correctPairs.add(p);
        if (firstCorrectPair == JUConstants.intUNKNOWN)
View Full Code Here


    Set<Label> deadLabels = new HashSet<Label>();
   
    Map<Label,CmpVertex> labelToState = new TreeMap<Label,CmpVertex>();
    for(Entry<CmpVertex,Map<Label,CmpVertex>> entry:graph.transitionMatrix.entrySet())
    {
      CmpVertex state = entry.getKey();
      for(Entry<Label,CmpVertex> target:entry.getValue().entrySet())
        if (!deadLabels.contains(target.getKey()))
        {// the label is not already recorded as leading to multiple different states.
          CmpVertex recordedState = labelToState.get(target.getKey());
            if (recordedState == null)
              // first time we've seen this label in use
              labelToState.put(target.getKey(),state);
            else
              if (recordedState != state)
View Full Code Here

  {
    LearnerGraphND ptaInverse = new LearnerGraphND(graph.config);
    AbstractPathRoutines.buildInverse(graph, new StatesToConsider() {
      @Override public boolean stateToConsider(@SuppressWarnings("unused") CmpVertex v) { return true; }}
      , ptaInverse);
    CmpVertex v=ptaInverse.findVertex(vert);
    for(int i=0;i<10;++i)
    {
      Map<Label,List<CmpVertex>> transitions = ptaInverse.transitionMatrix.get(v);
      if (transitions.size() > 1)
      {
        System.out.println(transitions);break;
      }
      List<CmpVertex> next = transitions.entrySet().iterator().next().getValue();
      if (next.size() > 1)
      {
        System.out.println(next);break;
      }
      CmpVertex nextState = next.iterator().next();
      System.out.println(v+"-"+transitions.entrySet().iterator().next().getKey()+"->"+nextState);
      v  = nextState;
    }
   
  }
View Full Code Here

          }

    for(CmpVertex vert:sourceStates)
      if (vert != pta.getInit())
      {
        CmpVertex newSource = AbstractLearnerGraph.generateNewCmpVertex(pta.nextID(true), pta.config);
        Map<Label,CmpVertex> row = pta.createNewRow();
        pta.transitionMatrix.put(newSource,row);row.put(uniqueFromInitial, pta.transitionMatrix.get(vert).get(uniqueFromInitial));
        statesOfInterest.add(newSource);
       
        CmpVertex tailState = AbstractLearnerGraph.generateNewCmpVertex(pta.nextID(true), pta.config);
        Map<Label,CmpVertex> tailRow = pta.createNewRow();
        pta.transitionMatrix.put(tailState,tailRow);pta.transitionMatrix.get(vert).put(uniqueFromInitial,tailState);
      }
      else
        statesOfInterest.add(vert);
View Full Code Here

            if (sourceStatesToMerge != null && transition.getValue().isAccept()) sourceStatesToMerge.add(entry.getKey());
          }
     
      for(Collection<CmpVertex> vertices:labelToStates.values())
      {
        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;
View Full Code Here

   
    /** There are cases when no selected pair is actually valid. The method below chooses a state to be marked as red because it is the only choice that we can make. */
    public CmpVertex resolvePotentialDeadEnd(LearnerGraph coregraph, @SuppressWarnings("unused") Collection<CmpVertex> reds, Collection<PairScore> pairs)
    {
     
      CmpVertex stateToMarkRed = null;
      List<PairScore> correctPairs = new ArrayList<PairScore>(pairs.size()), wrongPairs = new ArrayList<PairScore>(pairs.size());
      SplitSetOfPairsIntoRightAndWrong(coregraph, referenceGraph, pairs, correctPairs, wrongPairs);
      if (correctPairs.isEmpty())
        stateToMarkRed = wrongPairs.get(0).getQ();// no correct pairs found to merge, return the first wrong pair so the corresponding state is marked as red.
     
View Full Code Here

  public static class DefaultRedNodeSelectionProcedure implements PairScoreComputation.RedNodeSelectionProcedure
  {
    @Override
    public CmpVertex selectRedNode(@SuppressWarnings("unused") LearnerGraph gr, @SuppressWarnings("unused") Collection<CmpVertex> reds, Collection<CmpVertex> tentativeRedNodes)
    {
      CmpVertex redVertex = tentativeRedNodes.iterator().next();
      return redVertex;
    }
View Full Code Here

        // (b) checks that deadends are flagged. I could iterate this process for a number of decision rules, looking locally for the one that gives best quality of pairs
        // for a particular pairscore decision procedure.
        @Override
        public CmpVertex selectRedNode(@SuppressWarnings("unused") LearnerGraph gr, @SuppressWarnings("unused") Collection<CmpVertex> reds, Collection<CmpVertex> tentativeRedNodes)
        {
          CmpVertex redVertex = tentativeRedNodes.iterator().next();
          return redVertex;
        }

        @SuppressWarnings("unused")
        @Override
View Full Code Here

        // (b) checks that deadends are flagged. I could iterate this process for a number of decision rules, looking locally for the one that gives best quality of pairs
        // for a particular pairscore decision procedure.
        @Override
        public CmpVertex selectRedNode(@SuppressWarnings("unused") LearnerGraph coregraph, @SuppressWarnings("unused") Collection<CmpVertex> reds, Collection<CmpVertex> tentativeRedNodes)
        {
          CmpVertex redVertex = tentativeRedNodes.iterator().next();
          return redVertex;
        }

        @Override
        public CmpVertex resolvePotentialDeadEnd(LearnerGraph coregraph, Collection<CmpVertex> reds, List<PairScore> pairs)
        {
          dataCollector.updateDatasetWithPairs(pairs, coregraph, referenceGraph);
          CmpVertex red = LearnerThatUpdatesWekaResults.this.resolvePotentialDeadEnd(coregraph, reds, pairs);
          return red;
         
          //return null;// for no resolution
        }
       
View Full Code Here

    }

    /** Used to select the best red node based on what the subsequent collection of pairs will be. */
    public static CmpVertex selectRedNodeUsingQualityEstimator(LearnerGraph coregraph, Collection<CmpVertex> tentativeRedNodes, CollectionOfPairsEstimator pairQualityEstimator)
    {
      CmpVertex redVertex = null;double bestScore=-1;
     
      // It is not hard to calculate what blue states will directly surround a specific state chosen to become red, however those blue states may in turn immediately become red after evaluation and the same would apply
      // to the newly-discovered red states, so we effectively have to re-implement blue state calculation here. For this reason, it was decided not to do this but instead clone the state machine (possibly in a trimmed form)
      // and ask it for a list of pairs.
      // In practice, this algorithm turned out to be rather slow because there could be many red states to choose from and among those, many would lead to many pairs, all of which have to be scored.
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.