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
ba6bd882
Commit
ba6bd882
authored
Apr 10, 2017
by
Michele Volpato
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added example fig1.2 thesis
parent
f298e894
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
2 deletions
+92
-2
examples/fig1-2.py
examples/fig1-2.py
+87
-0
examples/tictactoe_nd/nd_tictactoe.py
examples/tictactoe_nd/nd_tictactoe.py
+5
-2
No files found.
examples/fig1-2.py
0 → 100644
View file @
ba6bd882
# Copyright (c) 2015 Michele Volpato
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
import
random
seed
=
output
=
random
.
sample
(
range
(
99999999
),
1
)[
0
]
print
(
seed
)
random
.
seed
(
81077353
)
# 81077353
import
os
,
inspect
,
sys
# Include project dir in path
currentdir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
inspect
.
getfile
(
inspect
.
currentframe
())))
parentdir
=
os
.
path
.
dirname
(
currentdir
)
sys
.
path
.
append
(
parentdir
)
from
learning.learning
import
LearningAlgorithm
from
teachers.ltsteachers
import
InputOutputTeacher
from
systems.implementations
import
InputOutputLTS
from
teachers.ltsoracles
import
InputOutputPowerOracle
import
logging
import
helpers.bisimulation
as
bi
from
testing.randomtesting
import
RandomTester
from
systems.iopurpose
import
InputPurpose
,
OutputPurpose
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
logger
=
logging
.
getLogger
(
__name__
)
inputs
=
set
([
'b'
])
outputs
=
set
([
't'
,
'c'
])
quiescence
=
'delta'
I1
=
InputOutputLTS
(
6
,
inputs
,
outputs
,
quiescence
)
I1
.
addTransition
(
0
,
'b'
,
1
)
I1
.
addTransition
(
0
,
'b'
,
2
)
I1
.
addTransition
(
1
,
't'
,
3
)
I1
.
addTransition
(
1
,
'c'
,
3
)
I1
.
addTransition
(
2
,
'b'
,
4
)
I1
.
addTransition
(
3
,
'c'
,
0
)
I1
.
addTransition
(
3
,
't'
,
0
)
I1
.
addTransition
(
3
,
'b'
,
3
)
I1
.
addTransition
(
4
,
'c'
,
5
)
I1
.
addTransition
(
5
,
't'
,
0
)
#I1.makeInputEnabled()
T1
=
InputOutputTeacher
(
I1
)
O1
=
InputOutputPowerOracle
(
I1
)
outputExpert
=
OutputPurpose
(
set
([
't'
,
'c'
,
quiescence
]))
inputExpert
=
InputPurpose
(
set
([
'b'
]))
tester
=
RandomTester
(
T1
,
10000
,
50
)
currentdir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
inspect
.
getfile
(
inspect
.
currentframe
())))
path
=
os
.
path
.
join
(
currentdir
,
"dotFiles"
)
print
(
"Starting learning..."
)
# change printPath=None to printPath=path for dot files
L2
=
LearningAlgorithm
(
T1
,
O1
,
printPath
=
path
,
maxLoops
=
4
,
tablePreciseness
=
10000
,
logger
=
logger
,
tester
=
tester
,
outputPurpose
=
outputExpert
,
inputPurpose
=
inputExpert
)
minus
,
plus
=
L2
.
run
()
print
(
"Models learned. Check language equivalence..."
)
print
(
"hMinus bisimilar to target: "
+
str
(
bi
.
bisimilar
(
I1
,
minus
)))
print
(
"hPlus bisimilar to target: "
+
str
(
bi
.
bisimilar
(
I1
,
plus
)))
examples/tictactoe_nd/nd_tictactoe.py
View file @
ba6bd882
...
...
@@ -87,8 +87,11 @@ def moveRandom(moves):
if
numMoves
>
0
:
# System is nondeterministic.
moveNum
=
random
.
sample
(
range
(
numMoves
),
1
)[
0
]
#moveNum = 1
#moveNum = random.sample(range(numMoves), 1)[0]
# Make it less nondeterministic :) Only 2 choices
moveNum
=
random
.
sample
(
range
(
1
),
1
)[
0
]
# Uncomment next line to make it deterministic
# moveNum = 1
numMoves
=
0
for
j
in
range
(
9
):
if
((
moves
&
(
1
<<
j
))
!=
0
):
...
...
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