MealyLearner<I, O> , must fit any I,O interface?

28 views
Skip to first unread message

Rafael Martinez

unread,
Oct 9, 2018, 7:20:11 AM10/9/18
to LearnLib Q&A
Let's try to explain (sorry in advance for the long message):

My code is

MealyLearner<Integer, String> learner = new ExtensibleLStarMealyBuilder<Integer, String>()
                    .withAlphabet(alphabet)
                    .withOracle(mqOracle)
                    .create();

Where alphabet, mqOracle have been previously initialized, with appropriate values of oracles, suls, and mappers... 
(Otherwise, code would not compile...)

Then

  learner.startLearning();

builds, as expected, the first hypothesis model... It takes not much time, since Alphabet has only 1 symbol and the underlying model is one state....


Then I proceed to enrich types <Integer,String> into <AI,AO>, Abstract Input, Abstract Output...In the middle, some arrangments have to be made to mappers to make appropiate translations into,from <AI,AO>. Details ommitted...

  learner.startLearning();

Now , learner throws an exception. 

net.automatalib.incremental.ConflictException: Error inserting ECHO / ECHO_REPLY: Incompatible output symbols: ECHO_REPLY vs ECHO_REPLY

After inspecting automatalib code, I realize it to be fixed by overriding AI as well as AO "equals()" method...
Then after that... 

  learner.startLearning();

does not throw any Exception, but seems no to finish... It does not terminate...

Question: Is there any hidden interface or override method my customixed <AI,AO> must implement to fit exactly like <Integer,String> ?

Thanks in advance

Markus Frohme

unread,
Oct 9, 2018, 10:23:18 AM10/9/18
to Rafael Martinez, LearnLib Q&A
Hi Rafael,


when overriding the equals() method, it is good practice to implement a
proper hashCode() method as well (see [0]).


Since you seem quite capable of debugging, you can also try to dig a
little bit deeper and see, what part runs into an endless loop:

* Do you continously see the same counterexample but the hypothesis
doesn't refine?
* Does a single counterexample lead to a state blow-up of the hypothesis?

You can also (if possible) try to provide a minimal working example that
reproduces the error, so we can look into it directly.



[0] -
https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-


On Tue, October 9, 2018 1:20 pm, Rafael Martinez wrote:
> Let's try to explain (sorry in advance for the long message):
>
> My code is
>
> MealyLearner<Integer, String> learner = new
> ExtensibleLStarMealyBuilder<Integer, String>()
> .withAlphabet(alphabet)
> .withOracle(mqOracle)
> .create();
>
> Where alphabet, mqOracle have been previously initialized, with
> appropriate
> values of oracles, suls, and mappers...
> (Otherwise, code would not compile...)
>
> Then
>
> learner.startLearning();
>
> builds, as expected, the first hypothesis model... It takes not much time,
> since Alphabet has only 1 symbol and the underlying model is one state....
>
>
> Then I proceed to enrich types <Integer,String> into <AI,AO>, Abstract
> Input, Abstract Output...In the middle, *some arrangments have to be made
> to mappers *to make appropiate translations into,from <AI,AO>. Details
> ommitted...
>
> learner.startLearning();
>
> Now , learner throws an exception.
>
> net.automatalib.incremental.ConflictException: Error inserting ECHO /
> ECHO_REPLY: Incompatible output symbols: ECHO_REPLY vs ECHO_REPLY
>
> After inspecting automatalib code, I realize it to be fixed by overriding
> AI as well as AO "equals()" method...
> Then after that...
>
> learner.startLearning();
>
> does not throw any Exception, but seems no to finish... It does not
> terminate...
>
> Question: Is there any hidden interface or override method my customixed
> <AI,AO> must implement to fit exactly like <Integer,String> ?
>
> Thanks in advance
>
> --
> You received this message because you are subscribed to the Google Groups
> "LearnLib Q&A" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to learnlib-qa...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


Rafael Martinez

unread,
Oct 10, 2018, 3:41:53 AM10/10/18
to LearnLib Q&A
On Tuesday, October 9, 2018 at 4:23:18 PM UTC+2, Markus Frohme wrote:
Hi Rafael,


when overriding the equals() method, it is good practice to implement a
proper hashCode() method as well (see [0]).

Markus, once again you were right!

The hidden method we have to overwrite was

    @Override
    public int hashCode() 

No need to go further on inside debugging... 

Most probably a MealyLearner must keep track of the symbols in a sort of "Observation Table". I don't know the collection container (Collection, HashTable, etc...) but it must index its contents by the hash code... It the hash_code is wrong, failing for the "general contract" for the hashCode method, which states that equal objects must have equal hash codes, every instance of a symbol-class, though equivalent, will yield a new "symbol"... Hence the learner will enter an end-less loop...

I hope it makes sense...!

Perhaps you should highlight this issue on LearnLib API, when talking on templates <I,O>...

Thank you!
Reply all
Reply to author
Forward
0 new messages