Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Comparing the query complexity of active learning algorithms for deterministic finite automata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
Show more breadcrumbs
Muhammad Raufu Miah
Comparing the query complexity of active learning algorithms for deterministic finite automata
Commits
6d4985d7
Commit
6d4985d7
authored
Mar 31, 2024
by
Muhammad Raufu Miah
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
1a70ef1d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
ExampleRandomDFA.java
+52
-0
52 additions, 0 deletions
ExampleRandomDFA.java
with
52 additions
and
0 deletions
ExampleRandomDFA.java
0 → 100644
+
52
−
0
View file @
6d4985d7
import
net.automatalib.alphabet.Alphabet
;
import
net.automatalib.automaton.fsa.CompactDFA
;
import
net.automatalib.util.automaton.minimizer.hopcroft.HopcroftMinimization
;
import
net.automatalib.util.automaton.random.RandomAutomata
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Random
;
public
class
ExampleRandomDFA
extends
DefaultLearningExample
.
DefaultDFALearningExample
<
Integer
>
{
public
ExampleRandomDFA
(
Random
rand
,
int
numInputs
,
int
size
,
double
acceptanceRatio
,
Alphabet
<
Integer
>
alphabet
)
{
super
(
alphabet
,
randomDFAWithAcceptanceRatio
(
rand
,
size
,
alphabet
,
acceptanceRatio
));
}
private
static
CompactDFA
<
Integer
>
randomDFAWithAcceptanceRatio
(
Random
rand
,
int
size
,
Alphabet
<
Integer
>
alphabet
,
double
acceptanceRatio
)
{
CompactDFA
<
Integer
>
newDFA
=
null
;
CompactDFA
<
Integer
>
dfa
=
null
;
do
{
boolean
flag
=
true
;
int
counter
=
0
;
while
(
flag
)
{
dfa
=
RandomAutomata
.
randomDFA
(
rand
,
size
,
alphabet
);
// Iterate over all states of dfa and make them rejecting
if
(
dfa
.
size
()==(
size
))
{
flag
=
false
;
}
}
for
(
Integer
state
:
dfa
.
getStates
())
{
dfa
.
setAccepting
(
state
,
false
);
}
// there should be size*acceptanceRatio accepting states, the accepting states should be randomly picked from the states but no double assingnments
ArrayList
<
Integer
>
stateIndices
=
new
ArrayList
<>(
dfa
.
getStates
());
Collections
.
shuffle
(
stateIndices
,
rand
);
int
numAcceptingStates
=
(
int
)
(
size
*
acceptanceRatio
);
if
(
numAcceptingStates
==
0
)
{
numAcceptingStates
=
1
;
}
for
(
int
i
=
0
;
i
<
numAcceptingStates
;
i
++)
{
dfa
.
setAccepting
(
stateIndices
.
get
(
i
),
true
);
}
newDFA
=
HopcroftMinimization
.
minimizeDFA
(
dfa
,
alphabet
);
if
(
newDFA
.
size
()
!=
size
){
rand
=
new
Random
(
333
+
counter
);
}
}
while
(
newDFA
.
size
()
!=
size
);
return
newDFA
;
}
}
\ No newline at end of file
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