Package statechum.analysis.learning

Examples of statechum.analysis.learning.PairOfPaths


  @Test
  public void testWritePairsToXML2()
  {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    LearnerGraph gr = buildLearnerGraph("A-a->A-b->B-c->C", "testWritePairsToXML1",mainConfiguration,converter);
    PairOfPaths pair1 = new PairOfPaths(gr,new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2)),
        pair2 = new PairOfPaths(gr,new PairScore(gr.findVertex(VertexID.parseID("B")), gr.findVertex(VertexID.parseID("C")),1,2));
    List<PairOfPaths> list = new LinkedList<PairOfPaths>();list.add(pair1);list.add(pair2);
    PairOfPaths.writePairs(list, mainConfiguration, outputStream);
   
    // Now load this.
    List<PairOfPaths> loaded = PairOfPaths.readPairs(new StringReader(outputStream.toString()), mainConfiguration,converter);
    Assert.assertEquals(2,loaded.size());
   
    PairOfPaths r=loaded.get(0);
    Assert.assertEquals("A",gr.getVertex(r.getQ()).getStringId());Assert.assertEquals("C",gr.getVertex(r.getR()).getStringId());
    r=loaded.get(1);
    Assert.assertEquals("B",gr.getVertex(r.getQ()).getStringId());Assert.assertEquals("C",gr.getVertex(r.getR()).getStringId());
  }
View Full Code Here


  @Test
  public void testWritePairsToXML3()
  {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    LearnerGraph gr = buildLearnerGraph("A-a->A-b->B-c->C", "testWritePairsToXML1",mainConfiguration,converter);
    PairOfPaths pair1 = new PairOfPaths(gr,new PairScore(null, gr.findVertex(VertexID.parseID("C")),1,2)),
        pair2 = new PairOfPaths(gr,new PairScore(gr.findVertex(VertexID.parseID("B")), gr.findVertex(VertexID.parseID("C")),1,2));
    List<PairOfPaths> list = new LinkedList<PairOfPaths>();list.add(pair1);list.add(pair2);
    PairOfPaths.writePairs(list, mainConfiguration, outputStream);
   
    // Now load this.
    List<PairOfPaths> loaded = PairOfPaths.readPairs(new StringReader(outputStream.toString()), mainConfiguration,converter);
    Assert.assertEquals(2,loaded.size());
   
    PairOfPaths r=loaded.get(0);
    Assert.assertNull(r.getQ());Assert.assertEquals("C",gr.getVertex(r.getR()).getStringId());
    r=loaded.get(1);
    Assert.assertEquals("B",gr.getVertex(r.getQ()).getStringId());Assert.assertEquals("C",gr.getVertex(r.getR()).getStringId());
  }
View Full Code Here

 
  @Test
  public void testRebuildStack1()
  {
    LearnerGraph gr = buildLearnerGraph("A-a->A-b->B-c->C", "testWritePairsToXML1",mainConfiguration,converter);
    PairOfPaths pair1 = new PairOfPaths(gr,new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    Stack<PairScore> stack=new Stack<PairScore>();
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    pair1.rebuildStack(gr, stack);
    Assert.assertEquals(1,stack.size());
    PairScore r = stack.pop();
    Assert.assertEquals("A",r.getQ().getStringId());Assert.assertEquals("C",r.getR().getStringId());
 
View Full Code Here

 
  @Test
  public void testRebuildStack2()
  {
    LearnerGraph gr = buildLearnerGraph("A-a->A-b->B-c->C", "testWritePairsToXML1",mainConfiguration,converter);
    PairOfPaths pair1 = new PairOfPaths(gr,new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    Stack<PairScore> stack=new Stack<PairScore>();
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("A")),1,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("C")), gr.findVertex(VertexID.parseID("C")),1,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    pair1.rebuildStack(gr, stack);
    Assert.assertEquals(1,stack.size());
    PairScore r = stack.pop();
    Assert.assertEquals("A",r.getQ().getStringId());Assert.assertEquals("C",r.getR().getStringId());
  }
View Full Code Here

 
  @Test
  public void testRebuildStack3()
  {
    LearnerGraph gr = buildLearnerGraph("A-a->A-b->B-c->C", "testWritePairsToXML1",mainConfiguration,converter);
    PairOfPaths pair1 = new PairOfPaths(gr,new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    Stack<PairScore> stack=new Stack<PairScore>();
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("C")), gr.findVertex(VertexID.parseID("C")),1,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("A")),1,2));
    pair1.rebuildStack(gr, stack);
    Assert.assertEquals(1,stack.size());
    PairScore r = stack.pop();
    Assert.assertEquals("A",r.getQ().getStringId());Assert.assertEquals("C",r.getR().getStringId());
 
View Full Code Here

 
  @Test
  public void testRebuildStackFail1()
  {
    final LearnerGraph gr = buildLearnerGraph("A-a->A-b->B-c->C", "testWritePairsToXML1",mainConfiguration,converter);
    final PairOfPaths pair1 = new PairOfPaths(gr,new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    final Stack<PairScore> stack=new Stack<PairScore>();
    Helper.checkForCorrectException(new whatToRun() { public @Override void run() {
      pair1.rebuildStack(gr, stack);
    }},IllegalArgumentException.class,"pair not found");
  }
View Full Code Here

 
  @Test
  public void testRebuildStackFail2()
  {
    final LearnerGraph gr = buildLearnerGraph("A-a->A-b->B-c->C", "testWritePairsToXML1",mainConfiguration,converter);
    final PairOfPaths pair1 = new PairOfPaths(gr,new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    final Stack<PairScore> stack=new Stack<PairScore>();
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("A")),2,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("C")), gr.findVertex(VertexID.parseID("C")),2,2));
    Helper.checkForCorrectException(new whatToRun() { public @Override void run() {
      pair1.rebuildStack(gr, stack);
    }},IllegalArgumentException.class,"pair not found");
  }
View Full Code Here

 
  @Test
  public void testRebuildStackFail3()
  {
    final LearnerGraph gr = buildLearnerGraph("A-a->A-b->B-c->C", "testWritePairsToXML1",mainConfiguration,converter);
    final PairOfPaths pair1 = new PairOfPaths(gr,new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    final Stack<PairScore> stack=new Stack<PairScore>();
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("B")), gr.findVertex(VertexID.parseID("C")),1,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("B")),1,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("A")),2,2));
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("C")), gr.findVertex(VertexID.parseID("C")),2,2));
    Helper.checkForCorrectException(new whatToRun() { public @Override void run() {
      pair1.rebuildStack(gr, stack);
    }},IllegalArgumentException.class,"pair not found");
  }
View Full Code Here

 
  @Test
  public void testRebuildStackFail4()
  {
    final LearnerGraph gr = buildLearnerGraph("A-a->A-b->B-c->C", "testWritePairsToXML1",mainConfiguration,converter);
    final PairOfPaths pair1 = new PairOfPaths(gr,new PairScore(gr.findVertex(VertexID.parseID("A")), gr.findVertex(VertexID.parseID("C")),1,2));
    final Stack<PairScore> stack=new Stack<PairScore>();
    stack.push(new PairScore(gr.findVertex(VertexID.parseID("C")), gr.findVertex(VertexID.parseID("C")),2,2));
    Helper.checkForCorrectException(new whatToRun() { public @Override void run() {
      pair1.rebuildStack(gr, stack);
    }},IllegalArgumentException.class,"pair not found");
  }
View Full Code Here

            {
              CmpVertex redVertex = null;
              if (listOfPairsToWrite != null)
              {
                redVertex = tentativeRedNodes.iterator().next();
                listOfPairsToWrite.add(new PairOfPaths(coregraph, new PairScore(null, redVertex, 0, 0)));
              }
             
              if(listOfPairsToCheckAgainstIterator != null)
              {
                PairOfPaths pair = listOfPairsToCheckAgainstIterator.next();
                Assert.assertNull(pair.getQ());
                redVertex = coregraph.getVertex(pair.getR());
              }
              return redVertex;
            }

            @SuppressWarnings("unused")
            @Override
            public CmpVertex resolveDeadEnd(LearnerGraph coregraph,
                Collection<CmpVertex> reds,
                Collection<PairScore> pairs) {
              return null;
            }});
          if (!outcome.isEmpty())
          {
            if (listOfPairsToWrite != null)
            {
              //System.out.println("Optimized: "+useOptimizedMerge+", matrix: "+graph.config.getTransitionMatrixImplType()+", pair : "+outcome.peek());
              listOfPairsToWrite.add(new PairOfPaths(graph, outcome.peek()));
            }
           
            if(listOfPairsToCheckAgainstIterator != null)
            {
              PairOfPaths pair = listOfPairsToCheckAgainstIterator.next();
              //System.out.println("chosen "+outcome.peek()+", expected "+new PairScore(graph.getVertex(pair.getQ()),graph.getVertex(pair.getR()),0,0));
              pair.rebuildStack(graph, outcome);
            }
          }
         
          return outcome;
        }
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.PairOfPaths

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.