Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Michele Volpato
Alnos
Commits
a9423172
Commit
a9423172
authored
Oct 22, 2015
by
Michele
Browse files
added experts handling
parent
12d69d20
Changes
6
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
a9423172
...
...
@@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
-
Validity of suspension automata.
-
Testing algorithms
-
Counterexample handling
-
Algorithms for double sets in the table
## [v0.1.0] - 2015-09-29
### Added
...
...
learning/learning.py
View file @
a9423172
...
...
@@ -542,7 +542,8 @@ class LearningAlgorithm2Sets(LearningAlgorithm):
def
__init__
(
self
,
teacher
,
oracle
,
tester
,
tablePreciseness
=
1000
,
modelPreciseness
=
0.1
,
closeStrategy
=
None
,
printPath
=
None
,
maxLoops
=
10
,
logger
=
None
):
printPath
=
None
,
maxLoops
=
10
,
logger
=
None
,
outputPurpose
=
None
,
inputPurpose
=
None
):
LearningAlgorithm
.
__init__
(
self
,
teacher
,
oracle
,
tester
,
tablePreciseness
,
modelPreciseness
,
closeStrategy
,
...
...
learning/observationtable.py
View file @
a9423172
...
...
@@ -598,15 +598,38 @@ class Table:
class
DoubleSetTable
(
Table
):
def
__init__
(
self
,
inputs
,
outputs
,
quiescence
,
closeStrategy
=
None
,
logger
=
None
):
closeStrategy
=
None
,
logger
=
None
,
outputPurpose
=
None
,
inputPurpose
=
None
):
Table
.
__init__
(
self
,
inputs
,
outputs
,
quiescence
,
closeStrategy
,
logger
)
# allows underspecification in inputs and outputs
self
.
_outputPurpose
=
outputPurpose
self
.
_inputPurpose
=
inputPurpose
# _entries is a dictionary (tuple of actions) -> (set(outputs), set(outputs))
# start with the empty sequence of actions and one letter extensions
self
.
_entries
=
{():(
set
(),
outputs
.
union
(
set
((
quiescence
,)
)))}
self
.
_entries
=
{():(
set
(),
self
.
_possibleOutputs
((
)))}
for
label
in
self
.
_inputs
:
self
.
_entries
[
tuple
(
label
)]
=
(
set
(),
outputs
.
union
(
set
((
quiescence
,))))
self
.
_entries
[
tuple
(
label
)]
=
(
set
(),
self
.
_possibleOutputs
(
tuple
(
label
)))
# given a trace, query outputPurpose for the outputs that are possibly
# enabled after it
def
_possibleOutputs
(
self
,
trace
):
if
self
.
_outputPurpose
==
None
:
return
self
.
_outputs
.
union
(
set
((
self
.
_quiescence
,)))
else
:
#TODO
return
self
.
_outputs
.
union
(
set
((
self
.
_quiescence
,)))
# given a trace, query inputPurpose for the inputs that are
# enabled after it
def
_possibleInputs
(
self
,
trace
):
if
self
.
_inputPurpose
==
None
:
return
self
.
_inputs
else
:
#TODO
return
self
.
_inputs
# get an empty nonfinal entry
def
_emptyEntry
(
self
):
...
...
systems/basepurpose.py
0 → 100644
View file @
a9423172
# Abstract class for experts
from
abc
import
ABCMeta
,
abstractmethod
class
Purpose
(
metaclass
=
ABCMeta
):
# Given a trace, return the set of enabled actions after that trace
@
abstractmethod
def
getEnabled
(
self
,
trace
):
pass
systems/iopurpose.py
0 → 100644
View file @
a9423172
# Classes representing experts for input and output labels
from
.basepurpose
import
Purpose
class
InputPurpose
(
Purpose
):
def
__init__
(
self
,
inputs
):
self
.
_inputs
=
inputs
.
copy
()
# Given a trace returns the set of inputs enabled after it.
def
getEnabled
(
self
,
trace
):
return
self
.
_inputs
class
OutputPurpose
(
Purpose
):
def
__init__
(
self
,
outputs
):
self
.
_outputs
=
outputs
.
copy
()
# Given a trace returns the set of outputs enabled after it.
def
getEnabled
(
self
,
trace
):
return
self
.
_outputs
tests/learning_algorithm2_test.py
View file @
a9423172
...
...
@@ -4,6 +4,7 @@ from nose.tools import *
from
learning.learning
import
LearningAlgorithm
,
LearningAlgorithm2Sets
from
teachers.ltsteachers
import
InputOutputTeacher
from
systems.implementations
import
InputOutputLTS
from
systems.iopurpose
import
InputPurpose
,
OutputPurpose
from
teachers.ltsoracles
import
InputOutputPowerOracle
import
helpers.graphhelper
as
gh
import
helpers.bisimulation
as
bi
...
...
@@ -50,9 +51,15 @@ class TestLearningAlgorithm2:
self
.
T1
=
InputOutputTeacher
(
self
.
I1
)
self
.
O1
=
InputOutputPowerOracle
(
self
.
I1
)
self
.
tester
=
RandomTester
(
self
.
T1
,
1000
,
20
)
self
.
tester
=
RandomTester
(
self
.
T1
,
1000
0
,
20
)
self
.
L1
=
LearningAlgorithm2Sets
(
self
.
T1
,
self
.
O1
,
self
.
tester
,
logger
=
logger
)
outputExpert
=
OutputPurpose
(
outputs
)
inputExpert
=
InputPurpose
(
inputs
)
self
.
L1
=
LearningAlgorithm2Sets
(
self
.
T1
,
self
.
O1
,
self
.
tester
,
logger
=
logger
,
tablePreciseness
=
10000
,
outputPurpose
=
outputExpert
,
inputPurpose
=
inputExpert
)
def
creation_test
(
self
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment