final Collection<List<Label>> testSet = PaperUAS.computeEvaluationSet(referenceGraph,states*3,states*alphabet);
for(int attempt=0;attempt<2;++attempt)
{// try learning the same machine a few times
LearnerGraph pta = new LearnerGraph(config);
RandomPathGenerator generator = new RandomPathGenerator(referenceGraph,new Random(attempt),5,null);
// test sequences will be distributed around
// The total number of elements in test sequences (alphabet*states*traceQuantity) will be distributed around (random(pathLength)+1). The total size of PTA is a product of these two.
// For the purpose of generating long traces, we construct as many traces as there are states but these traces have to be rather long,
// that is, length of traces will be (random(pathLength)+1)*sequencesPerChunk/states and the number of traces generated will be the same as the number of states.
final int tracesToGenerate = makeEven(traceQuantity);
generator.generateRandomPosNeg(tracesToGenerate, 1, false, new RandomLengthGenerator() {
@Override
public int getLength() {
return 2*states*alphabet;
}
@Override
public int getPrefixLength(int len) {
return len;
}
});
if (onlyUsePositives)
pta.paths.augmentPTA(generator.getAllSequences(0).filter(new FilterPredicate() {
@Override
public boolean shouldBeReturned(Object name) {
return ((statechum.analysis.learning.rpnicore.RandomPathGenerator.StateName)name).accept;
}
}));
else
pta.paths.augmentPTA(generator.getAllSequences(0));// the PTA will have very few reject-states because we are generating few sequences and hence there will be few negative sequences.
// In order to approximate the behaviour of our case study, we need to compute which pairs are not allowed from a reference graph and use those as if-then automata to start the inference.
//pta.paths.augmentPTA(referenceGraph.wmethod.computeNewTestSet(referenceGraph.getInit(),1));
List<List<Label>> sPlus = generator.getAllSequences(0).getData(new FilterPredicate() {
@Override
public boolean shouldBeReturned(Object name) {
return ((statechum.analysis.learning.rpnicore.RandomPathGenerator.StateName)name).accept;
}
});
List<List<Label>> sMinus= generator.getAllSequences(0).getData(new FilterPredicate() {
@Override
public boolean shouldBeReturned(Object name) {
return !((statechum.analysis.learning.rpnicore.RandomPathGenerator.StateName)name).accept;
}
});