Package statechum.analysis.learning.rpnicore

Examples of statechum.analysis.learning.rpnicore.LearnerGraph


    DirectedSparseGraph specGraph = FsmParser.buildGraph(spec, "specGraph");
    compare(specGraph, imp);
  }
 
  public static void compare(DirectedSparseGraph spec, DirectedSparseGraph imp){
    LearnerGraph specfsm =new LearnerGraph(spec, Configuration.getDefaultConfiguration());
    Visualiser v = new Visualiser(0);
    v.construct(specfsm.pathroutines.getGraph(),null);
    LearnerGraph wm = new LearnerGraph(imp,Configuration.getDefaultConfiguration());
    PosNegPrecisionRecall pr = compare(specfsm, wm);
    System.out.println(pr.getPosprecision()+", "+pr.getPosrecall()+", "+pr.getNegprecision()+", "+pr.getNegrecall());
  }
View Full Code Here


      int score = graph.pairscores.computePairCompatibilityScore_general(null, pairsList, verticesToMerge);
      if (score < 0)
        outcome = dREJECT;
      else
      {
        LearnerGraph merged = MergeStates.mergeCollectionOfVertices(graph, null, verticesToMerge);
        outcome = computeInconsistency(merged,model,checker,false);
      }
    }
   
    return outcome;
View Full Code Here

    Map<CmpVertex,Map<Label,UpdatablePairInteger>> state_outgoing_occurence=new HashMap<CmpVertex,Map<Label,UpdatablePairInteger>>();
    /** Maps states to a function associating labels to a probability of a transition with the label of interest from a state of interest. Computed from {@link MarkovUniversalLearner#state_outgoing_occurence}. */
    Map<CmpVertex,Map<Label,UpdatablePairDouble>> state_outgoing=new HashMap<CmpVertex,Map<Label,UpdatablePairDouble>>();

    final Configuration shallowCopy = graph.config.copy();shallowCopy.setLearnerCloneGraph(false);
    LearnerGraph outcome = new LearnerGraph(shallowCopy);
    LearnerGraph.copyGraphs(graph, outcome);
    final Set<Label> allElementsOfAlphabet = graph.learnerCache.getAlphabet();
    // mapping map to store all paths leave each state in different length
      for(CmpVertex vert:graph.transitionMatrix.keySet())
      {
View Full Code Here

    /** Maps states to a function associating labels to a probability of a transition with the label of interest from a state of interest. Computed from {@link MarkovUniversalLearner#state_outgoing_occurence}. */
    Map<CmpVertex,Map<Label,MarkovOutcome>> state_outgoing=predictTransitions();

    final Configuration shallowCopy = graph.config.copy();shallowCopy.setLearnerCloneGraph(false);
    LearnerGraph graphWithPredictedTransitions = new LearnerGraph(shallowCopy);
    LearnerGraph.copyGraphs(graph, graphWithPredictedTransitions);

    // in this part the tree is extended depend on their outgoing transition probabilities
     for(Entry<CmpVertex, Map<Label, MarkovOutcome>> outgoing:state_outgoing.entrySet())
     {
View Full Code Here

        else
          break;
      LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
      List<StatePair> pairsList = buildVerticesToMergeForPath(smallValueUniques);
      scoreAfterBigMerge = dREJECT;
      LearnerGraph merged = null;
      if (!pairsList.isEmpty())
      {
        int score = graph.pairscores.computePairCompatibilityScore_general(null, pairsList, verticesToMerge);
        if (score < 0)
          scoreAfterBigMerge = dREJECT;
        else
        {
          merged = MergeStates.mergeCollectionOfVertices(graph, null, verticesToMerge);
          //checker.setUniquePaths(smallValueUniques);
          scoreAfterBigMerge = computeInconsistency(merged,model,checker,false);
        }
      }
     
      //System.out.println("After big merge ("+threshold+") of "+smallValueUniques+" : "+scoreAfterBigMerge+" inconsistencies, "+merged.getStateNumber()+" states, originally "+graph.getStateNumber()+ " ");
      /*
      if (merged != null && referenceGraph!=null)
      {
        System.out.print("After big merge ("+threshold+"): "+scoreAfterBigMerge+" inconsistencies, "+merged.getStateNumber()+" states, originally "+graph.getStateNumber()+ " ");
        System.out.println(checkMergeValidity(referenceGraph,graph,smallValueUniques)?"VALID":"INVALID");
      }*/
    }

    {
      whatToMerge = thresholdToInconsistency.entrySet().iterator().next().getValue();
      List<StatePair> pairsList = buildVerticesToMergeForPath(whatToMerge);
      scoreAfterBigMerge = dREJECT;
      LearnerGraph merged = null;
      if (!pairsList.isEmpty())
      {
        LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
        int score = graph.pairscores.computePairCompatibilityScore_general(null, pairsList, verticesToMerge);
        if (score < 0)
View Full Code Here

     
      Iterator<List<String>> questionIt = questions.iterator();
      while(questionIt.hasNext()){
        List<String> question = questionIt.next();
        boolean accepted = DeterministicDirectedSparseGraph.isAccept(pair.getQ());
        Pair<Integer,String> answer = CheckWithEndUser(new LearnerGraph(model,Configuration.getDefaultConfiguration()),question, AbstractOracle.USER_CANCELLED,null, new Object [] {"Test"});
        if (answer.firstElem == AbstractOracle.USER_CANCELLED)
        {
          System.out.println("CANCELLED");
          return null;
        }
        Vertex tempVertex = getVertex(temp, question);
        if(answer.firstElem == AbstractOracle.USER_ACCEPTED){
          sPlus.add(question);
         
          if(!DeterministicDirectedSparseGraph.isAccept(tempVertex))
          {
              restartLearning = true;break;
          }
        }
        else if(answer.firstElem >= 0){
          assert answer.firstElem < question.size();
          LinkedList<String> subAnswer = new LinkedList<String>();subAnswer.addAll(question.subList(0, answer.firstElem+1));sMinus.add(subAnswer);
          // sMinus.add(question.subList(0, answer+1)); // KIRR: without a `proper' collection in the set, I cannot serialise the sets into XML

          if((answer.firstElem==question.size()-1)&&!DeterministicDirectedSparseGraph.isAccept(tempVertex)){
            continue;
          }
          assert accepted == true;
          restartLearning = true;
          break;
        }
        else if (answer.firstElem == AbstractOracle.USER_ACCEPTED-1){
          // sPlus = this.parentFrame.addTest(sPlus);
          if(sPlus == null)
            return new LearnerGraph(model,Configuration.getDefaultConfiguration());
          if(!containsSubString(sPlus, question))
            return learnMachine(sPlus, sMinus);
        }
       
      }
     
     
      if (restartLearning)
      {// restart learning
        model = createAugmentedPTA(sPlus, sMinus);// KIRR: node labelling is done by createAugmentedPTA
        DeterministicDirectedSparseGraph.findInitial(model).setUserDatum(JUConstants.COLOUR, JUConstants.RED, UserData.SHARED);
        setChanged();       
      }
      else
        // keep going with the existing model
        model = temp;
     
      possibleMerges = chooseStatePairs(model, sPlus, sMinus);
    }
    updateGraph(new LearnerGraph(model,Configuration.getDefaultConfiguration()));
    return new LearnerGraph(model,Configuration.getDefaultConfiguration());
  }
View Full Code Here

  @Before
  public final void setUp()
  {
    LearnerGraph.testMode=true;
    config = (Configuration)mainConfiguration.clone();config.setAllowedToCloneNonCmpVertex(true);
    fsm = new LearnerGraph(TestFSMAlgo.buildGraph("A-a->B-a->A-b-#C\nB-b->D-c->E", "TestPTATestSequenceEngine"),config);
    en = new PTA_FSMStructure(fsm);   
    engine_testLimitToGraph = new PTA_FSMStructure(new LearnerGraph(TestFSMAlgo.buildGraph(
        "A-a->B-a->F-b-#C\nB-c->D\nA-c->A\nB-b->D-c->E", "TestPTATestSequenceEngine"),config));
  }
View Full Code Here

    DirectedSparseVertex init = new DirectedSparseVertex();
    init.addUserDatum(JUConstants.INITIAL, true, UserData.SHARED);
    init.addUserDatum(JUConstants.ACCEPTED, false, UserData.SHARED);
    init.addUserDatum(JUConstants.LABEL, "A", UserData.SHARED);
    g.addVertex(init);
    PTASequenceEngine engine = new PTA_FSMStructure(new LearnerGraph(g,config));
    vertifyPTA(engine, 1, new String[][] {
        new String[] {}
      });
  }
View Full Code Here

    DirectedSparseVertex init = new DirectedSparseVertex();
    init.addUserDatum(JUConstants.INITIAL, true,UserData.SHARED);
    init.addUserDatum(JUConstants.ACCEPTED, true, UserData.SHARED);
    init.addUserDatum(JUConstants.LABEL, "A", UserData.SHARED);
    g.addVertex(init);
    PTASequenceEngine engine = new PTA_FSMStructure(new LearnerGraph(g,config));
    vertifyPTA(engine, 1, new String[][] {
        new String[] {}
    });
  }
View Full Code Here

  }

  @Test
  public final void test_sequenceSet3_5() // a more complex composition
  {
    fsm = new LearnerGraph(TestFSMAlgo.buildGraph("A-a->B-a->A-b-#C\nA-d->M-a->N\nB-b->D-c->E", "test_sequenceSet3_5"),config);
    en = new PTA_FSMStructure(fsm);   
    SequenceSet seq = en.new SequenceSet();seq.setIdentity();
    SequenceSet temp2 = seq.crossWithSet(Arrays.asList(new String[] {"b","a","d"}))
      .crossWithSet(Arrays.asList(new String[] {"b","a","d"}));
    Map<String,String> actual2 = getDebugDataMap(en,temp2.crossWithSet(Arrays.asList(new String[] {"a"})));
View Full Code Here

TOP

Related Classes of statechum.analysis.learning.rpnicore.LearnerGraph

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.