Package statechum

Examples of statechum.Trace


    List<Trace> chunks=new ArrayList<Trace>();
       for(int f=0; f < t.size(); f++)
      {
         if(f < (t.size()-chunkLen+1))
         {
           Trace traceToMarkov=new Trace(t.getList().subList(f, f+chunkLen), true); // get trace from the path
           chunks.add(traceToMarkov);
         }
      }
       return chunks;
  }
View Full Code Here


    }
    for(Entry<Label,CmpVertex> state:states.entrySet())
    {
      for(Label label:graph.getCache().getAlphabet())
      {
        MarkovOutcome transition = MarkovMatrix.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:graph.getCache().getAlphabet())
    {
      boolean nonUnique = false;
      Label unique = null;
      for(Label lbl:graph.getCache().getAlphabet())
      {
        if (MarkovMatrix.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:graph.getCache().getAlphabet())
        {
          List<Label> seq = new LinkedList<Label>(prefix);seq.add(lbl);
          if (MarkovMatrix.containsKey(new Trace(seq,true)))
          {
            if (unique == null)
              unique = seq;
            else
            {
View Full Code Here

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

                    Collection<Trace> allPrefixTraces = new LinkedList<Trace>();
                    Collection<VertID> verticesInHardFacts=mergedToHard.get(v);
                    if (verticesInHardFacts != null)
                    {
                        for (VertID hard : verticesInHardFacts) {
                            Trace path = new Trace(vertToPath.get(hardFacts.findVertex(hard)));
                            allPrefixTraces.add(path);

                            // Walk the hardFacts from here to determine all possible paths from this state, then determine their code coverage
                            CmpVertex hardv = hardFacts.findVertex(hard);
                            Collection<Trace> paths = getPaths(path, hardv, hardFacts);
View Full Code Here

        Map<Label, CmpVertex> edges = hardFacts.getTransitionMatrix().get(v);
        if (edges.isEmpty()) {
            result.add(prefix);
        } else {
            for (Map.Entry<Label, CmpVertex> e : edges.entrySet()) {
                Trace newPath = prefix.clone();
                newPath.add(e.getKey());
                result.addAll(getPaths(newPath, e.getValue(), hardFacts));
            }
        }

        return result;
View Full Code Here

  final Label lblA = AbstractLearnerGraph.generateNewLabel("a", config, converter),lblB = AbstractLearnerGraph.generateNewLabel("b", config, converter),lblC = AbstractLearnerGraph.generateNewLabel("c", config, converter),
      lblD = AbstractLearnerGraph.generateNewLabel("d", config, converter),lblU = AbstractLearnerGraph.generateNewLabel("u", config, converter);
 
  @Test
  public void testGetChunks1() {
    List<Trace> l = MarkovUniversalLearner.get_chunks(new Trace(Arrays.asList(new Label[]{}),true),1);
    Assert.assertTrue(l.isEmpty());
  }
View Full Code Here

    Assert.assertTrue(l.isEmpty());
  }

  @Test
  public void testGetChunks2a() {
    List<Trace> l = MarkovUniversalLearner.get_chunks(new Trace(Arrays.asList(new Label[]{lblA,lblB,lblC}),true),4);
    Assert.assertTrue(l.isEmpty());
  }
View Full Code Here

    Assert.assertTrue(l.isEmpty());
  }

  @Test
  public void testGetChunks2b() {
    List<Trace> l = MarkovUniversalLearner.get_chunks(new Trace(Arrays.asList(new Label[]{lblA,lblB,lblC}),true),10);
    Assert.assertTrue(l.isEmpty());
  }
View Full Code Here

    Assert.assertTrue(l.isEmpty());
  }

  @Test
  public void testGetChunks3() {
    List<Trace> l = MarkovUniversalLearner.get_chunks(new Trace(Arrays.asList(new Label[]{lblA,lblB,lblC}),true),1);
    Assert.assertEquals(3,l.size());
    Assert.assertEquals(new Trace(Arrays.asList(new Label[]{lblA}),true),l.get(0));
    Assert.assertEquals(new Trace(Arrays.asList(new Label[]{lblB}),true),l.get(1));
    Assert.assertEquals(new Trace(Arrays.asList(new Label[]{lblC}),true),l.get(2));
  }
View Full Code Here

    Assert.assertEquals(new Trace(Arrays.asList(new Label[]{lblC}),true),l.get(2));
  }

  @Test
  public void testGetChunks4() {
    List<Trace> l = MarkovUniversalLearner.get_chunks(new Trace(Arrays.asList(new Label[]{lblA,lblB,lblC}),true),2);
    Assert.assertEquals(2,l.size());
    Assert.assertEquals(new Trace(Arrays.asList(new Label[]{lblA,lblB}),true),l.get(0));
    Assert.assertEquals(new Trace(Arrays.asList(new Label[]{lblB,lblC}),true),l.get(1));
  }
View Full Code Here

TOP

Related Classes of statechum.Trace

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.