// Inference from a few traces
final int traceQuantityToUse = traceQuantity;
SquareBagPlot gr_StructuralDiff = new SquareBagPlot("Structural score, EDSM,>=2","Structural Score, EDSM-Markov learner",new File(branch+"_"+(traceQuantityToUse/2)+"_trace_structuraldiff.pdf"),0,1,true);
SquareBagPlot gr_BCR = new SquareBagPlot("BCR, EDSM,>=2","BCR, EDSM-Markov learner",new File(branch+"_"+(traceQuantityToUse/2)+"_trace_bcr.pdf"),0.5,1,true);
RBagPlot gr_BCR_singletons = new RBagPlot("%% states identified by singletons","BCR Score, EDSM-Markov learner",new File(branch+"_"+(traceQuantityToUse/2)+"_trace_bcr_singletons.pdf"));
RBagPlot gr_BCR_states = new RBagPlot("number of states in reference","BCR Score, EDSM-Markov learner",new File(branch+"_"+(traceQuantityToUse/2)+"_trace_bcr_numberofstates.pdf"));
ScatterPlot gr_ImprovementPerState = new ScatterPlot("State number", "BCR, improvement",new File(branch+"_"+(traceQuantityToUse/2)+"_bcr_statenumber.pdf"));
for(final boolean onlyPositives:new boolean[]{true})
for(final double alphabetMultiplier:new double[]{alphabetMultiplierMax})
{
final int totalTaskNumber = traceQuantityToUse;
try
{
int numberOfTasks = 0;
for(int states=minStateNumber;states < minStateNumber+rangeOfStateNumbers;states+=stateNumberIncrement)
for(int sample=0;sample<samplesPerFSM;++sample)
{
LearnerRunner learnerRunner = new LearnerRunner(states,sample,totalTaskNumber+numberOfTasks,traceQuantityToUse, config, converter);
learnerRunner.setOnlyUsePositives(onlyPositives);
learnerRunner.setAlphabetMultiplier(alphabetMultiplier);
learnerRunner.setTraceLengthMultiplier(traceLengthMultiplierMax);learnerRunner.setChunkLen(chunkSize);
learnerRunner.setSelectionID(branch+"_states"+states+"_sample"+sample);
runner.submit(learnerRunner);
++numberOfTasks;
}
ProgressIndicator progress = new ProgressIndicator(new Date()+" evaluating "+numberOfTasks+" tasks for learning whole graphs", numberOfTasks);
for(int count=0;count < numberOfTasks;++count)
{
ThreadResult result = runner.take().get();// this will throw an exception if any of the tasks failed.
for(SampleData sample:result.samples)
gr_StructuralDiff.add(sample.referenceLearner.differenceStructural.getValue(),sample.actualLearner.differenceStructural.getValue());
for(SampleData sample:result.samples)
{
gr_BCR.add(sample.referenceLearner.differenceBCR.getValue(),sample.actualLearner.differenceBCR.getValue());
gr_BCR_singletons.add((double)sample.fractionOfStatesIdentifiedBySingletons,sample.actualLearner.differenceBCR.getValue());
gr_BCR_states.add((double)sample.stateNumber,sample.actualLearner.differenceBCR.getValue());
if (sample.referenceLearner.differenceBCR.getValue() > 0)
gr_ImprovementPerState.add((double)sample.stateNumber,sample.actualLearner.differenceBCR.getValue()/sample.referenceLearner.differenceBCR.getValue());
}
progress.next();
}
gr_StructuralDiff.drawInteractive(gr);gr_BCR.drawInteractive(gr);gr_BCR_singletons.drawInteractive(gr);gr_BCR_states.drawInteractive(gr);gr_ImprovementPerState.drawInteractive(gr);
}
catch(Exception ex)
{
IllegalArgumentException e = new IllegalArgumentException("failed to compute, the problem is: "+ex);e.initCause(ex);
if (executorService != null) { executorService.shutdownNow();executorService = null; }
throw e;
}
}
if (gr_StructuralDiff != null) gr_StructuralDiff.drawPdf(gr);
if (gr_BCR != null) gr_BCR.drawPdf(gr);
if (gr_BCR_singletons != null) gr_BCR_singletons.drawPdf(gr);
if (gr_BCR_states != null) gr_BCR_states.drawPdf(gr);
if (gr_ImprovementPerState != null) gr_ImprovementPerState.drawPdf(gr);
final RBoxPlot<String> gr_BCRImprovementForDifferentAlphabetSize = new RBoxPlot<String>("alphabet multiplier","improvement, BCR",new File(branch+"BCR_vs_alphabet.pdf"));
final RBoxPlot<String> gr_BCRForDifferentAlphabetSize = new RBoxPlot<String>("alphabet multiplier","BCR",new File(branch+"BCR_absolute_vs_alphabet.pdf"));
final RBoxPlot<String> gr_StructuralImprovementForDifferentAlphabetSize = new RBoxPlot<String>("alphabet multiplier","improvement, structural",new File(branch+"structural_vs_alphabet.pdf"));