From d2eb362108df7e0f879e7ee1c086ae4534655828 Mon Sep 17 00:00:00 2001 From: Michele Date: Thu, 12 Nov 2015 17:37:09 +0100 Subject: [PATCH] Now it is not necessary to specify the alphabets when creating new LTSs --- examples/tictactoe/tictacteacher.py | 2 +- learning/learning.py | 5 +---- systems/implementations.py | 6 +++--- tests/InputOutputLTS_test.py | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/tictactoe/tictacteacher.py b/examples/tictactoe/tictacteacher.py index 00cc38e..305228a 100644 --- a/examples/tictactoe/tictacteacher.py +++ b/examples/tictactoe/tictacteacher.py @@ -51,7 +51,7 @@ class TicTacToeTeacher(AbstractTeacher): sys.exit() #self._socket.setblocking(0) - self._socket.settimeout(1) # 1 second timeout, for quiescence + self._socket.settimeout(0.5) # second timeout, for quiescence #logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) diff --git a/learning/learning.py b/learning/learning.py index 136d158..7f25e5d 100644 --- a/learning/learning.py +++ b/learning/learning.py @@ -342,8 +342,6 @@ class LearningAlgorithm: self._teacher.getOutputAlphabet().copy(), self._teacher.getQuiescence(), chaos) - #if not chaos: - # print(rows) # assign to each equivalence class a state number # start with equivalence class of empty trace to 0 assignments = {():0} @@ -362,8 +360,6 @@ class LearningAlgorithm: for label in allLabels: # create row and search it in the table extension = row + (label,) - #if not chaos: - # print(extension) if self._table.isInRows(extension): for target in rows: found = False @@ -372,6 +368,7 @@ class LearningAlgorithm: if self._table._moreSpecificRow(extension, target, chaos): hyp.addTransition(assignments[row], label, assignments[target]) + found = True break if not found: diff --git a/systems/implementations.py b/systems/implementations.py index 1fcdedf..1f7c55c 100644 --- a/systems/implementations.py +++ b/systems/implementations.py @@ -130,14 +130,14 @@ class InputOutputLTS(AbstractIOLTS): validState1 = state1 < self._numstates and state1 >= 0 validState2 = state2 < self._numstates and state2 >= 0 if validState1 and validState2: - if label in self._inputs or label in self._outputs: + #if label in self._inputs: #or label in self._outputs: key = (state1, label) if key in self._transitions.keys(): self._transitions[key].add(state2) else: self._transitions[key] = set([state2]) - else: - success = False + #else: + # success = False else: success = False return success diff --git a/tests/InputOutputLTS_test.py b/tests/InputOutputLTS_test.py index 8cefc56..daebeb4 100644 --- a/tests/InputOutputLTS_test.py +++ b/tests/InputOutputLTS_test.py @@ -48,7 +48,7 @@ class TestImplementations: success = I3.addTransition(1,'a',2) assert_equal(success, True) success = I3.addTransition(1,'c',2) - assert_equal(success, False) + assert_equal(success, True) success = I3.addTransition(-1,'a',2) assert_equal(success, False) success = I3.addTransition(1,'b',4) -- GitLab