Skip to content

Use of Mapper Class #52

@bazali

Description

@bazali

Hello!
I have read a document on Active Automata Learning from the following link:
https://www.kma.informatik.tu-darmstadt.de/fileadmin/user_upload/Group_KMA/ESF-WS/bernhard.pdf

Now,
I want to write the code for Mapper Module to learn the behavior of a stack with following code:

public static class StackDemoUsingArray{
    public static final int maxSize=3;
	   private Object[] stackArray=new Object[maxSize];
	   public int size=0;  	   
	   
	   //pushing operation
	   public Boolean push(Object j) {
		   if(size<maxSize) {		   
			   stackArray[size] = j;
			   size++;
			   return true;
		   }
		   else
			   return false;
	   }    	   
	   //pop operation
	   public Object pop() {
		   if(size==0)
			   return null;
			   //return "baz";
		   else
			   size--;
			   return stackArray[size];    		   		
	   }    	   
}

And the final Learned Model/targeted model should somewhat as (screen shots taken from the above link):
mod

I have modify the code of Example2 in the de.leranlib.examples.exmaple2. The modified code is as:

  1. first of all i replace the code of stack already given in example2 with name i.e., public static class BoundedStringQueue with the above one

  2. and modified code of Mapper as:
    // instantiate test driver
    SimplePOJOTestDriver driver = new SimplePOJOTestDriver(
    StackDemoUsingArray.class); //Working Fine .... OK

     // create learning alphabet
     Method mPush = StackDemoUsingArray.class.getMethod(
             "push", new Class<?>[]{Object.class});
     Method mPop = StackDemoUsingArray.class.getMethod(
             "pop", new Class<?>[]{});
             
     // offer
    AbstractMethodInput push1 = driver.addInput("push1", mPush, "1");
    AbstractMethodInput push2 = driver.addInput("push2", mPush, "2");        
     // poll
     AbstractMethodInput pop = driver.addInput("pop", mPop);
    

And
// create initial set of suffixes
List<Word> suffixes = new ArrayList<>();
suffixes.add(Word.fromSymbols(push1));
suffixes.add(Word.fromSymbols(push2));
suffixes.add(Word.fromSymbols(pop));

And rest of code is same as in de.leranlib.examples.exmaple2. I obtained the following learned model(its not the complete model but a short part of big one....bcoz i was unable to upload here):

learned modell

My questions are:

  1. In my learned model there should be transition labels like push1/ok and push2/ok instead of push1[]/true and push2[]/true And at the final states (end states) it should be like push1/nok and push2/nok instead of push1[]/false and push2[]/false. It looks that Mapper is working only in forward direction (mapping abstract to concrete) but not in backward direction. Besides, the symbol [] with push and pop should not be appeared. How/Where should I modify in code of Mapper so that i will be able to learn the exact model.

  2. After that i will infer the following model:
    mod-k stack

Please, guide me how to write/modify the code of Mapper so that it can transform the symbols form Abstract to Concrete and then back from Concrete to Abstract. e.g true to OK , false to NOK, upon receiving 51from SUL to odd and 2012 to even etc...

thanks...

Ali

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions