Package statechum.analysis.learning.rpnicore

Examples of statechum.analysis.learning.rpnicore.LearnerGraphND$ignoreNoneClass


     * @return Erlang coverage data for the supplied vertex.
     */
    public ErlangCoverageData getCoverageFromPickedVertex(CmpVertex vertex)
    {
      ErlangCoverageData result = null;
       LearnerGraphND gr = graphsOrig.get(currentGraph);
       if (vertex != null)
        result = gr.getCache().getErlangCoverage().get(vertex);
      return result;
    }
View Full Code Here


      CmpVertex result = null;
      if (jungVertex != null)
      {
        Object label = jungVertex.getUserDatum(JUConstants.LABEL);
        assert label != null;
        LearnerGraphND gr = graphsOrig.get(currentGraph);
        result = gr.findVertex(label.toString());
        assert result != null;
      }
     
      return result;
    }
View Full Code Here

    graphout.close();
  }
 
  public static void generateADLOutput(LearnerGraph g, String name) throws IOException{
    StringWriter graphout = new StringWriter();
    graphout.write(new LearnerGraphND(g,g.config).pathroutines.toADL());
    String fileRef = statechum.GlobalConfiguration.getConfiguration().getProperty(statechum.GlobalConfiguration.G_PROPERTIES.TEMP)+File.separator+name;
    File outputMachine  = new File(fileRef);
    write(graphout.toString(), outputMachine);
  }
View Full Code Here

    a.pathroutines.checkConsistency(a);
    b.pathroutines.checkConsistency(b);

    ThreadNumber = threads;
    Configuration cloneConfig = argConfig.copy();cloneConfig.setLearnerCloneGraph(true);// we need to clone attributes here because after key pair identification, attributes from graph B will be copied into vertices of A, otherwise these attributes may not make it into the patch.
    grCombined = new LearnerGraphND(a,cloneConfig);// I cannot simply do Transform.addToGraph here because patch has to be relative to graph A.
    grCombined.config.setLearnerCloneGraph(false);//reset the clone attribute
    grCombined.vertNegativeID=Math.max(grCombined.vertNegativeID, b.vertNegativeID);// we aim for new vertices in grCombined to have ids different from all vertices in B.
    grCombined.vertPositiveID=Math.max(grCombined.vertPositiveID, b.vertPositiveID);
    combined_initA = grCombined.getInit();
    origToNewB = new TreeMap<CmpVertex,CmpVertex>();
View Full Code Here

    Configuration gdConfig = a.config.copy();gdConfig.setGdFailOnDuplicateNames(false);
    init(a,b, threads,gdConfig);
    identifyKeyPairs();
    final List<PairScore> initialKeyPairs = new LinkedList<PairScore>();initialKeyPairs.addAll(frontWave);
    final Map<VertexID,VertexID> oldVerticesToNew = new TreeMap<VertexID,VertexID>();
    final LearnerGraphND outcome = new LearnerGraphND(a,gdConfig);
    final LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> mutator =
      new LearnerGraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(outcome,gdConfig,null);

    final EdgeAnnotation transitionAnnotation = new EdgeAnnotation();
    makeSteps();
View Full Code Here

        "q10-appendfile->q11 /" +
        "q13-retrievefile->q13","sd_cvs",config),
        markovD = buildLearnerGraphND(markovString.replace("PART2", "a").replace("PART3", "a"),"sd_markovD",config).pathroutines.buildDeterministicGraph(),
        edsm = buildLearnerGraph("a-initialise->b-connect->c-login->d-storefile->e-changedir->d-listfiles->e-retrievefile->e-logout->i-disconnect->l\nd-delete->d-makedir->d-changedir->f-listnames->d-logout->g-disconnect->j\nd-setfiletype->h-storefile->k-appendfile->m-setfiletype->n-rename->o-storefile->m\nd-appendfile->o-logout->p-disconnect->q","sd_edsm",config)
        ;
    LearnerGraphND
      markov = buildLearnerGraphND(markovString,"sd_markov",config);
    markovD.setName("sd_markovD");

    Set<Label> origAlphabet = cvsGraph.pathroutines.computeAlphabet();
    assert origAlphabet.equals(markov.pathroutines.computeAlphabet());
    assert origAlphabet.equals(markovD.pathroutines.computeAlphabet());
    assert origAlphabet.equals(edsm.pathroutines.computeAlphabet());
    final RandomPathGenerator generator = new RandomPathGenerator(cvsGraph,new Random(0),5,null);
    final int posOrNegPerChunk = 50;
    generator.generateRandomPosNeg(posOrNegPerChunk*2,1);
    Collection<List<Label>> sequences = cvsGraph.wmethod.getFullTestSet(1);//generator.getAllSequences(0).getData(PTASequenceEngine.truePred);

    PTASequenceEngine walkEngine = new PTA_FSMStructure(cvsGraph,null);
    SequenceSet ptaWalk = walkEngine.new SequenceSet();ptaWalk.setIdentity();
    ptaWalk = ptaWalk.cross(sequences);
   
   
   
    PTA_computePrecisionRecall precRec = null;
   
    {
      precRec = new PTA_computePrecisionRecall(markovD);
      precRec.crossWith(walkEngine);PosNegPrecisionRecall result = precRec.getPosNegPrecisionRecallNum();
      final String name = "Markov";
      System.out.println(name+": +precision "+result.getPosprecision()+" +recall: "+result.getPosrecall());
      System.out.println(name+": -precision "+result.getNegprecision()+" -recall: "+result.getNegrecall());
      System.out.println(name+": =precision "+result.getPrecision()+" =recall: "+result.getRecall());
    }

    {
      precRec = new PTA_computePrecisionRecall(edsm);
      precRec.crossWith(walkEngine);PosNegPrecisionRecall result = precRec.getPosNegPrecisionRecallNum();
      final String name = "EDSM";
      System.out.println(name+": +precision "+result.getPosprecision()+" +recall: "+result.getPosrecall());
      System.out.println(name+": -precision "+result.getNegprecision()+" -recall: "+result.getNegrecall());
      System.out.println(name+": =precision "+result.getPrecision()+" =recall: "+result.getRecall());
    }
   
    linearDiff(cvsGraph, markov);
    linearDiff(cvsGraph, new LearnerGraphND(edsm,config));
  }
View Full Code Here

  }

  static void linearDiff(LearnerGraph cvsGraphD, LearnerGraphND otherGraph)
  {
    GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData> gd = new GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData>();
    LearnerGraphND cvsGraph = new LearnerGraphND(cvsGraphD,config);
    ChangesCounter<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData>  rec3 = new ChangesCounter<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData>(cvsGraph,otherGraph,null);
    gd.computeGD(cvsGraph, otherGraph, 1, rec3, config);
    int intersection = cvsGraph.pathroutines.countEdges()-rec3.getRemoved();
    assert otherGraph.pathroutines.countEdges() == intersection+rec3.getAdded();
    System.out.println("PLTSDIFF, "+otherGraph.getName()+": precision = "+((double)intersection/otherGraph.pathroutines.countEdges())+" recall = "+((double)intersection/cvsGraph.pathroutines.countEdges()))
View Full Code Here

    write(graphout.toString(), outputMachine);
  }
 
  public static void generateADLOutput(LearnerGraph g, String name){
    StringWriter graphout = new StringWriter();
    graphout.write(new LearnerGraphND(g,g.config).pathroutines.toADL());
    String fileRef = statechum.GlobalConfiguration.getConfiguration().getProperty(statechum.GlobalConfiguration.G_PROPERTIES.TEMP)+File.separator+name;
    File outputMachine  = new File(fileRef);
    write(graphout.toString(), outputMachine);
  }
View Full Code Here

    runTestCompute_ND3(Configuration argConfig, int expectedKeyPairs, int threadNumber, final ConvertALabel converter)
  {
    final String name = "testComputeGD_ND2";
    Configuration cloneConfig = argConfig.copy();cloneConfig.setLearnerCloneGraph(true);
    String common = "A-a->B-p->B\nA-a->C-q->C\nA-a->D-r->D";
    LearnerGraphND grA = buildLearnerGraphND("A-a->E-s->E\nA-a->F-v->F\n"+common,name+"A",argConfig, converter);
    grA.findVertex("F").setColour(JUConstants.RED);grA.findVertex("B").setColour(JUConstants.AMBER);grA.findVertex("B").setDepth(3);
    CmpVertex newStateA = AbstractLearnerGraph.generateNewCmpVertex(VertexID.parseID(testA), argConfig),
      newStateB = AbstractLearnerGraph.generateNewCmpVertex(VertexID.parseID(testB), argConfig);
    newStateA.setHighlight(true);newStateB.setDepth(45);
    grA.transitionMatrix.put(newStateA,grA.createNewRow());grA.transitionMatrix.put(newStateB,grA.createNewRow());

    LearnerGraphND grB = buildLearnerGraphND("A-a->G-u->G\nA-a->H-t->H\n"+common,name+"B",argConfig, converter);
    CmpVertex newStateC = AbstractLearnerGraph.generateNewCmpVertex(VertexID.parseID(nameC), argConfig),
    newStateD = AbstractLearnerGraph.generateNewCmpVertex(VertexID.parseID(nameD), argConfig);
    newStateC.setColour(JUConstants.BLUE);newStateD.setOrigState(VertexID.parseID("P609"));
    grB.transitionMatrix.put(newStateC,grB.createNewRow());grB.transitionMatrix.put(newStateD,grB.createNewRow());

    VertexID origID = VertexID.parseID("test orig");
    grB.findVertex("B").setColour(JUConstants.GRAY);grB.findVertex("B").setOrigState(origID);grB.findVertex("B").setDepth(3);
   
    LearnerGraphND result = checkDiffBetweenND(grA, grB,expectedKeyPairs,0,threadNumber,argConfig,converter);
    Assert.assertEquals(JUConstants.GRAY,result.findVertex("B").getColour());
    Assert.assertEquals(origID,result.findVertex("B").getOrigState());
    Assert.assertNull(result.findVertex(testA));
    Assert.assertNull(result.findVertex(testB));
    Assert.assertNotNull(result.findVertex(nameC));
    Assert.assertNotNull(result.findVertex(nameD));
    Assert.assertTrue(DeterministicDirectedSparseGraph.deepEquals(newStateC,result.findVertex(nameC)));
    Assert.assertTrue(DeterministicDirectedSparseGraph.deepEquals(newStateD,result.findVertex(nameD)));

    // The last check: ensure that disconnected states are or are not key pairs.
    // This chunk of code simply returns GD, the checking is performed by the caller of this method.
    GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData> gd = new GD<List<CmpVertex>,List<CmpVertex>,LearnerGraphNDCachedData,LearnerGraphNDCachedData>();
    gd.init(grA, grB, threadNumber,argConfig);gd.identifyKeyPairs();
View Full Code Here

  {
    final String name = "testComputeGD_ND2";
    Configuration configND4 = config.copy();
    Configuration cloneConfig = configND4.copy();cloneConfig.setLearnerCloneGraph(true);
    String common = "A-a->B-p->B\nA-a->C-q->C\nA-a->D-r->D";
    LearnerGraphND grA = buildLearnerGraphND("A-a->E-s->E\nA-a->F-v->F\nC-p->S\n"+common,name+"A",configND4, converter);
    grA.findVertex("F").setColour(JUConstants.RED);grA.findVertex("B").setColour(JUConstants.AMBER);grA.findVertex("B").setDepth(3);
    grA.addToCompatibility(grA.findVertex("D"), grA.findVertex("S"),JUConstants.PAIRCOMPATIBILITY.INCOMPATIBLE);
    LearnerGraphND grB = buildLearnerGraphND("A-a->G-u->G\nA-a->H-t->H\nC-q->T\n"+common,name+"B",configND4, converter);
    VertexID origID = VertexID.parseID("test orig");
    grB.findVertex("B").setColour(JUConstants.GRAY);grB.findVertex("B").setOrigState(origID);grB.findVertex("B").setDepth(3);
    grB.addToCompatibility(grB.findVertex("B"), grB.findVertex("T"),JUConstants.PAIRCOMPATIBILITY.INCOMPATIBLE);
   
    LearnerGraphND result = checkDiffBetweenND(grA, grB, 6,0,threadNumber,configND4,converter);
/*
    ChangesDisplay disp = new ChangesDisplay(null);
    gd.computeGD(grA, grB, threadNumber, disp,config);System.out.println(disp.toString());*/
    Assert.assertEquals(JUConstants.GRAY,result.findVertex("B").getColour());
    Assert.assertEquals(origID,result.findVertex("B").getOrigState());
    Assert.assertTrue(result.pairCompatibility.compatibility.get(result.findVertex("T")).get(result.findVertex("B")) == JUConstants.PAIRCOMPATIBILITY.INCOMPATIBLE);
  }
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.rpnicore.LearnerGraphND$ignoreNoneClass

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.