Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Learning RFSA in reverse
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Thomas
Learning RFSA in reverse
Commits
4ef3fa63
Commit
4ef3fa63
authored
5 years ago
by
Thomas
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
00b88da8
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
learnlib/DumpRFSAEQOracle.java
+41
-0
41 additions, 0 deletions
learnlib/DumpRFSAEQOracle.java
learnlib/GenRFSA.java
+33
-0
33 additions, 0 deletions
learnlib/GenRFSA.java
learnlib/RFSALearnAndCompare.java
+5
-0
5 additions, 0 deletions
learnlib/RFSALearnAndCompare.java
with
79 additions
and
0 deletions
learnlib/DumpRFSAEQOracle.java
0 → 100644
+
41
−
0
View file @
4ef3fa63
import
de.learnlib.api.oracle.MembershipOracle
;
import
de.learnlib.api.query.DefaultQuery
;
import
de.learnlib.oracle.equivalence.RandomWordsEQOracle
;
import
net.automatalib.automata.concepts.Output
;
import
net.automatalib.automata.fsa.FiniteStateAcceptor
;
import
net.automatalib.automata.fsa.NFA
;
import
javax.annotation.Nullable
;
import
java.util.Collection
;
import
java.util.Random
;
public
class
DumpRFSAEQOracle
<
A
extends
FiniteStateAcceptor
<?,
I
>,
I
,
D
>
extends
RandomWordsEQOracle
<
A
,
I
,
D
>
{
NFA
<?,
I
>
target
;
public
DumpRFSAEQOracle
(
NFA
<?,
I
>
target
,
MembershipOracle
<
I
,
D
>
mqOracle
,
int
minLength
,
int
maxLength
,
int
maxTests
)
{
this
(
target
,
mqOracle
,
minLength
,
maxLength
,
maxTests
,
new
Random
(),
1
);
}
public
DumpRFSAEQOracle
(
NFA
<?,
I
>
target
,
MembershipOracle
<
I
,
D
>
mqOracle
,
int
minLength
,
int
maxLength
,
int
maxTests
,
Random
random
)
{
this
(
target
,
mqOracle
,
minLength
,
maxLength
,
maxTests
,
random
,
1
);
}
public
DumpRFSAEQOracle
(
NFA
<?,
I
>
target
,
MembershipOracle
<
I
,
D
>
mqOracle
,
int
minLength
,
int
maxLength
,
int
maxTests
,
Random
random
,
int
batchSize
)
{
super
(
mqOracle
,
minLength
,
maxLength
,
maxTests
,
random
,
batchSize
);
this
.
target
=
target
;
}
/**
* tries to short-hand the equivalence test, because minimal RFSA can be compared to some extent
*/
@Nullable
@Override
public
DefaultQuery
<
I
,
D
>
findCounterExample
(
A
hypothesis
,
Collection
<?
extends
I
>
inputs
)
{
if
(
target
.
getStates
().
size
()
==
hypothesis
.
getStates
().
size
())
{
return
null
;
}
return
super
.
findCounterExample
(
hypothesis
,
inputs
);
}
}
This diff is collapsed.
Click to expand it.
learnlib/GenRFSA.java
0 → 100644
+
33
−
0
View file @
4ef3fa63
import
net.automatalib.automata.fsa.impl.compact.CompactNFA
;
import
net.automatalib.util.automata.builders.FSABuilder
;
import
net.automatalib.visualization.Visualization
;
public
class
GenRFSA
<
A
extends
CompactNFA
<
I
>,
S
,
I
>
{
public
CompactNFA
<
I
>
reverse
(
A
source
){
FSABuilder
<
Integer
,
I
,
CompactNFA
<
I
>>
builder
=
new
FSABuilder
<>(
new
CompactNFA
<>(
source
.
getInputAlphabet
(),
source
.
getStates
().
size
()));
for
(
int
a
:
source
.
getStates
())
{
if
(
source
.
isAccepting
(
a
))
builder
.
withInitial
(
a
);
for
(
I
i:
source
.
getInputAlphabet
())
for
(
int
c
:
source
.
getTransitions
(
a
,
i
))
builder
.
from
(
c
).
on
(
i
).
to
(
a
);
}
builder
.
withAccepting
(
source
.
getInitialStates
().
toArray
());
return
builder
.
create
();
}
public
public
static
void
main
(
String
[]
args
)
{
RandomNFAGen
c
=
new
RandomNFAGen
(
10
);
CompactNFA
<
Integer
>
nfa
=
c
.
get
();
GenRFSA
<
CompactNFA
<
Integer
>,
?,
Integer
>
genRFSA
=
new
GenRFSA
<>();
Visualization
.
visualize
(
nfa
);
Visualization
.
visualize
(
genRFSA
.
reverse
(
nfa
));
}
}
This diff is collapsed.
Click to expand it.
learnlib/RFSALearnAndCompare.java
+
5
−
0
View file @
4ef3fa63
import
de.learnlib.algorithms.nlstar.NLStarLearner
;
import
de.learnlib.algorithms.nlstar.NLStarLearnerBuilder
;
import
de.learnlib.filter.statistic.oracle.CounterOracle
;
import
de.learnlib.oracle.equivalence.RandomWordsEQOracle
;
import
de.learnlib.oracle.membership.SimulatorOracle
;
import
de.learnlib.util.Experiment
;
...
...
@@ -35,6 +36,10 @@ public class RFSALearnAndCompare<I> {
mqOracle
=
new
CounterOracle
<>(
sul
,
"membership queries learning"
);
mqOracle2
=
new
CounterOracle
<>(
sul2
,
"membership queries learning"
);
CounterOracle
<
I
,
Boolean
>
mqOracle_2
=
new
CounterOracle
<>(
sul
,
"membership queries testing"
);
CounterOracle
<
I
,
Boolean
>
mqOracle2_2
=
new
CounterOracle
<>(
sul2
,
"membership queries testing"
);
NLStarLearner
<
I
>
nlstar
=
new
NLStarLearnerBuilder
<
I
>().
withAlphabet
(
target
.
getInputAlphabet
())
// input alphabet
.
withOracle
(
mqOracle
)
// membership oracle
.
create
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment