Commit e83cec37 authored by Michele's avatar Michele

added figure 2.5 from thesis

parent 082cdd45
......@@ -9,6 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- License
- Name: new name is Alnos
## [v0.2.0] - 2015-10-27
### Added
......
## Synopsis
The active-learning-nondeterministic-systems is an implementation of an
**Alnos** is an implementation of an
adaptation of
[L*](http://www.cs.berkeley.edu/~dawnsong/teaching/s10/papers/angluin87.pdf) to
nondeterministic systems. The code is based on these scientific papers:
......
# 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.
# This file is used to learn the IOTS depicted in Figure 2.5 of my PhD thesis.
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
import helpers.graphhelper as gh
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
inputs = set(['b'])
outputs = set(['t','c'])
quiescence = 'd'
I1=InputOutputLTS(8, 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(1,'b',6)
I1.addTransition(2,'b',4)
I1.addTransition(3,'t',0)
I1.addTransition(3,'c',0)
I1.addTransition(3,'b',6)
I1.addTransition(4,'c',5)
I1.addTransition(4,'b',6)
I1.addTransition(5,'b',6)
I1.addTransition(5,'t',0)
I1.addTransition(5,'c',0)
# Chaos
I1.addTransition(6,'b',6)
I1.addTransition(6,'t',6)
I1.addTransition(6,'c',6)
I1.addTransition(6,'d',7)
I1.addTransition(7,'b',6)
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")
gh.createDOTFile(I1, path + "figure2-5", "pdf")
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)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment