Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Alnos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Michele Volpato
Alnos
Commits
1b76707a
Commit
1b76707a
authored
Sep 18, 2017
by
Michele Volpato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working on old example for deterministic tictactoe, problem with placeholder and output generation
parent
66757b6f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
15 deletions
+20
-15
examples/tictactoe/completetesting.py
examples/tictactoe/completetesting.py
+2
-1
examples/tictactoe/learn.py
examples/tictactoe/learn.py
+1
-1
examples/tictactoe/tictacoracle.py
examples/tictactoe/tictacoracle.py
+1
-1
examples/tictactoe/tictacpurpose.py
examples/tictactoe/tictacpurpose.py
+7
-7
examples/tictactoe/tictacteacher.py
examples/tictactoe/tictacteacher.py
+1
-1
learning/learning.py
learning/learning.py
+7
-3
learning/observationtable.py
learning/observationtable.py
+1
-1
No files found.
examples/tictactoe/completetesting.py
View file @
1b76707a
...
...
@@ -52,7 +52,8 @@ class CompleteTicTacToeTester(AbstractTester):
model
.
move
(
action
)
if
output
not
in
model
.
outputs
():
self
.
_logger
.
info
(
"Found a counterexample: "
+
str
(
ce
)
+
" output: "
+
str
(
output
))
+
str
(
ce
)
+
" output: "
+
str
(
output
)
+
" not in "
+
str
(
model
.
outputs
()))
self
.
_teacher
.
reset
()
model
.
reset
()
...
...
examples/tictactoe/learn.py
View file @
1b76707a
...
...
@@ -45,7 +45,7 @@ import helpers.bisimulation as bi
import
csv
logging
.
basicConfig
(
level
=
logging
.
INFO
)
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
logger
=
logging
.
getLogger
(
__name__
)
HOST
=
'localhost'
...
...
examples/tictactoe/tictacoracle.py
View file @
1b76707a
...
...
@@ -43,7 +43,7 @@ class TicTacToeOracle(AbstractOracle):
if
len
(
outputs
)
>
0
:
return
True
else
:
# Check trace, if it has more outputs or more i
m
puts in a row,
# Check trace, if it has more outputs or more i
n
puts in a row,
# then return True
if
trace
==
():
return
False
...
...
examples/tictactoe/tictacpurpose.py
View file @
1b76707a
...
...
@@ -58,23 +58,23 @@ class TicTacToeOutputPurpose(Purpose):
if
(
trace
!=
None
and
len
(
trace
)
>
0
and
trace
[
-
1
]
not
in
inputs
):
return
set
([
'delta'
])
else
:
if
(
outputs
!=
None
and
len
(
outputs
)
>
0
):
return
outputs
else
:
#
if (outputs != None and len(outputs) > 0):
#
return outputs
#
else:
# In this SUL we have many outputs (>4000)
# for this reason we use a placeholder
# We also need a way to compare a set of outputs with the
# placeholder
return
'PLACEHOLDER'
return
set
([
'PLACEHOLDER'
])
def
isIncluded
(
self
,
set1
,
set2
):
if
set2
==
'PLACEHOLDER'
:
if
'PLACEHOLDER'
in
set2
:
return
True
else
:
if
set1
==
'PLACEHOLDER'
:
if
'PLACEHOLDER'
in
set1
:
return
False
else
:
return
set1
.
issubset
(
set2
)
def
allOutputs
(
self
):
return
set
(
itertools
.
product
(
'XO_'
,
repeat
=
9
))
return
set
(
map
(
''
.
join
,
itertools
.
product
(
'XO_'
,
repeat
=
9
)
))
examples/tictactoe/tictacteacher.py
View file @
1b76707a
...
...
@@ -42,7 +42,7 @@ class TicTacToeTeacher(AbstractTeacher):
self
.
_socket
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
_socket
.
connect
((
host
,
port
))
self
.
_outputs
=
set
(
itertools
.
product
(
'XO_'
,
repeat
=
9
))
self
.
_outputs
=
set
(
map
(
''
.
join
,
itertools
.
product
(
'XO_'
,
repeat
=
9
)
))
# counter for inputs:
self
.
_count
=
0
...
...
learning/learning.py
View file @
1b76707a
...
...
@@ -318,7 +318,7 @@ class LearningAlgorithm:
def
getHypothesis
(
self
,
chaos
=
False
):
# If table is not closed, ERROR
if
self
.
_table
.
isNotGloballyClosed
():
self
.
_logger
.
error
(
"Tried to get hypotheses with table not closed
"
)
self
.
_logger
.
warning
(
"Trying to create a model from a not closed table
"
)
return
None
,
None
# Get equivalence classes
rows
=
self
.
_table
.
getEquivalenceClasses
(
chaos
)
...
...
@@ -330,7 +330,7 @@ class LearningAlgorithm:
# assign to each equivalence class a state number
# start with equivalence class of empty trace to 0
# TODO: is () always the representative of an equivalence class?
# NO
# NO
, we might have more than one row representing (). TODO: FIX
rowForEmpty
=
()
# search for the representative for ()
for
row
in
rows
:
...
...
@@ -338,6 +338,8 @@ class LearningAlgorithm:
# private. Change to public, or add a public version
if
self
.
_table
.
_moreSpecificRow
(
row
,
rowForEmpty
,
chaos
):
rowForEmpty
=
row
self
.
_logger
.
debug
(
"Creating "
+
(
"HPlus"
if
chaos
else
"HMinus"
)
+
": Row representing (): "
+
str
(
row
))
break
assignments
=
{
rowForEmpty
:
0
}
...
...
@@ -351,7 +353,7 @@ class LearningAlgorithm:
for
row
in
rows
:
enabledOuptuts
=
self
.
_table
.
getOutputs
(
row
)
allLabels
=
self
.
_getAllLabels
(
row
,
enabledOuptuts
)
self
.
_logger
.
debug
(
"All labels: "
+
str
(
allLabels
))
for
label
in
allLabels
:
# create row and search it in the table
extension
=
row
+
(
label
,)
...
...
@@ -408,6 +410,8 @@ class LearningAlgorithm:
if
self
.
_outputPurpose
!=
None
:
enabledOutputs
=
self
.
_outputPurpose
.
getEnabled
(
row
)
allLabels
=
enabledInputs
.
union
(
enabledOutputs
)
self
.
_logger
.
debug
(
"enabledInputs: "
+
str
(
enabledInputs
))
self
.
_logger
.
debug
(
"enabledOutputs: "
+
str
(
enabledOutputs
))
return
allLabels
# Generate DOT files for hypotheses. hyp = hMinus|hPlus|both
...
...
learning/observationtable.py
View file @
1b76707a
...
...
@@ -753,7 +753,7 @@ class Table:
outputs1
=
self
.
_entries
[
th
.
flatten
(
row1
,
self
.
_quiescence
)][
0
]
outputs2
=
self
.
_entries
[
th
.
flatten
(
row2
,
self
.
_quiescence
)][
0
]
#
If they enable the same inputs, c
heck each entry.
#
C
heck each entry.
for
column
in
self
.
_columns
:
entry1
=
th
.
flatten
(
row1
+
column
,
self
.
_quiescence
)
entry2
=
th
.
flatten
(
row2
+
column
,
self
.
_quiescence
)
...
...
Write
Preview
Markdown
is supported
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