Package statechum.analysis.learning.rpnicore

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


        {
          ExperimentResult outcome = new ExperimentResult();
          while(!outcome.experimentValid)
          {
            int mutations = mutationsPerStage * (mutationStage+1);
            LearnerGraphND origGraph = mg.nextMachine(alphabet, experiment,config,converter);
            GraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> mutator = new GraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(origGraph,r);
            mutator.mutate(mutations);
            LearnerGraphND origAfterRenaming = new LearnerGraphND(origGraph.config);
            Map<CmpVertex,CmpVertex> origToNew = copyStatesAndTransitions(origGraph,origAfterRenaming);
            LearnerGraphND mutated = (LearnerGraphND)mutator.getMutated();
            Set<Transition> appliedMutations = new HashSet<Transition>();
            for(Transition tr:mutator.getDiff())
            {
              CmpVertex renamedFrom = origToNew.get(tr.getFrom());if (renamedFrom == null) renamedFrom = tr.getFrom();
              CmpVertex renamedTo = origToNew.get(tr.getTo());if (renamedTo == null) renamedTo = tr.getTo();
View Full Code Here


          }
          ++artificialTargetSize;
        }
      }
     
      LearnerGraphND outcome = new LearnerGraphND(machine.config);AbstractLearnerGraph.copyGraphs(machine,outcome);
      return outcome;
    }
View Full Code Here

      }
  }
 
  public static void printTraceLeadingTo(LearnerGraph graph, String vert)
  {
    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)
      {
View Full Code Here

   * @return an association between vertices and deterministic graphs. Where built as an inverse of the original graph at each of its vertices, each graph can be large but this does not have to be so
   * even in the worst case since we can trim all graphs at the number of transitions corresponding to the length of the paths at the point of construction.
   */
  public static Map<CmpVertex,LearnerGraph> constructPathsFromEachState(LearnerGraph graph, boolean directionForward)
  {
    LearnerGraphND forwardOrInverseGraph = null;
   
    if (directionForward)
    {
      forwardOrInverseGraph = new LearnerGraphND(graph,graph.config);
    }
    else
    {
      Configuration shallowCopy = graph.config.copy();shallowCopy.setLearnerCloneGraph(false);
      forwardOrInverseGraph = new LearnerGraphND(shallowCopy);forwardOrInverseGraph.initEmpty();
      AbstractPathRoutines.buildInverse(graph,LearnerGraphND.ignoreNone,forwardOrInverseGraph)// do the inverse to the tentative graph
    }

    Map<CmpVertex,LearnerGraph> outcome = new TreeMap<CmpVertex,LearnerGraph>();
    for(CmpVertex v:graph.transitionMatrix.keySet())
View Full Code Here

      }
  }
 
  public static void printTraceLeadingTo(LearnerGraph graph, String vert)
  {
    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)
      {
View Full Code Here

   * @return inverted graph
   */
  public static LearnerGraphND computeInverseGraph(LearnerGraph graph)
  {
    Configuration shallowCopy = graph.config.copy();shallowCopy.setLearnerCloneGraph(false);
    LearnerGraphND inverseGraph = new LearnerGraphND(shallowCopy);inverseGraph.initEmpty();
    AbstractPathRoutines.buildInverse(graph,LearnerGraphND.ignoreNone,inverseGraph)// do the inverse to the tentative graph
    return inverseGraph;
  }
View Full Code Here

  public void testParseAutomataAndComputeDiff2()
  {
    ConvertALabel converter = null;
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
    Random rnd=new Random(0);
    LearnerGraphND previous = null;
   
    for(int states=1;states < 100;states++)
    {
      final int alphabet = 2*states;
      MachineGenerator mg = new MachineGenerator(states, 400 , (int)Math.round((double)states/5));mg.setGenerateConnected(true);
      LearnerGraphND graph = mg.nextMachine(alphabet,-states, config, converter);
     
      LearnerGraphND parsedOutcome = new LearnerGraphND(config);
      StatechumProcess.parseStatemachine(StatechumProcess.constructFSM(graph), parsedOutcome, converter,true);
      DifferentFSMException diffException = WMethod.checkM(graph, parsedOutcome);
      Assert.assertNull(diffException);

      Map<VertID,VertID> map = new TreeMap<VertID,VertID>();
      for(int i=0;i<20;++i) map.put(graph.pathroutines.pickRandomState(rnd),graph.pathroutines.pickRandomState(rnd));
      Map<VertID,VertID> mapOutcome = StatechumProcess.parseMap(StatechumProcess.mapToObject(map));
      Assert.assertEquals(map,mapOutcome);
     
      if (previous != null)
      {
        LearnerGraphND shouldBeLikePrevious = new LearnerGraphND(graph,config);
        OtpErlangObject difference = DifferenceVisualiser.ChangesToGraph.computeGD(graph, previous, config);
        DifferenceVisualiser.ChangesToGraph.load(difference).applyDiff(shouldBeLikePrevious, config);
        DifferentFSMException ex = WMethod.checkM(previous, shouldBeLikePrevious);
        Assert.assertNull(ex);
      }
View Full Code Here

 
  @Test
  public void testSetRed1()
  {
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
    LearnerGraphND grA = new LearnerGraphND(config);
    OtpErlangObject grAerlang = ErlangLabel.parseText("{statemachine,['P1000','P1002','N1000'],"+
              "[{'P1000',a,'P1000'},"+
              " {'P1000',b,'P1002'},"+
              " {'P1000',c,'N1000'},"+
              " {'P1002',c,'P1002'},"+
              " {'P1002',d,'P1002'}],"+
              "'P1000',"+
              "[d,b,c,a]}");
    Synapse.StatechumProcess.parseStatemachine(grAerlang,grA,null,true);
    Assert.assertEquals(0, grA.getRedStateNumber());
    Synapse.StatechumProcess.setReds(new OtpErlangList(new OtpErlangObject[]{new OtpErlangAtom("P1002")}), grA);
    Assert.assertEquals(JUConstants.RED,grA.findVertex("P1002").getColour());
    Assert.assertEquals(1, grA.getRedStateNumber());
  }
View Full Code Here

 
  @Test
  public void testSetRed2()
  {
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
    final LearnerGraphND grA = new LearnerGraphND(config);
    OtpErlangObject grAerlang = ErlangLabel.parseText("{statemachine,['P1000','P1002','N1000'],"+
              "[{'P1000',a,'P1000'},"+
              " {'P1000',b,'P1002'},"+
              " {'P1000',c,'N1000'},"+
              " {'P1002',c,'P1002'},"+
              " {'P1002',d,'P1002'}],"+
              "'P1000',"+
              "[d,b,c,a]}");
    Synapse.StatechumProcess.parseStatemachine(grAerlang,grA,null,true);
    Assert.assertEquals(0, grA.getRedStateNumber());
    checkForCorrectException(new whatToRun() { public @Override void run() {
      Synapse.StatechumProcess.setReds(new OtpErlangTuple(new OtpErlangObject[]{new OtpErlangAtom("P1002")}), grA);
    }},ClassCastException.class,"OtpErlangTuple");
  }
View Full Code Here

 
  @Test
  public void testSetRed3()
  {
    Configuration config = Configuration.getDefaultConfiguration().copy();config.setGdFailOnDuplicateNames(false);
    final LearnerGraphND grA = new LearnerGraphND(config);
    OtpErlangObject grAerlang = ErlangLabel.parseText("{statemachine,['P1000','P1002','N1000'],"+
              "[{'P1000',a,'P1000'},"+
              " {'P1000',b,'P1002'},"+
              " {'P1000',c,'N1000'},"+
              " {'P1002',c,'P1002'},"+
              " {'P1002',d,'P1002'}],"+
              "'P1000',"+
              "[d,b,c,a]}");
    Synapse.StatechumProcess.parseStatemachine(grAerlang,grA,null,true);
    Assert.assertEquals(0, grA.getRedStateNumber());
    checkForCorrectException(new whatToRun() { public @Override void run() {
      Synapse.StatechumProcess.setReds(new OtpErlangList(new OtpErlangObject[]{new OtpErlangString("P1002")}), grA);
    }},ClassCastException.class,"OtpErlangString");
  }
View Full Code Here

TOP

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

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.