int alphabet = states/2;
MachineGenerator mg = new MachineGenerator(states, 40, states/10);
int mutationsPerStage = (states/2) / 2;
//System.out.print("\n"+states+": ");
TestGD.ProgressIndicator progress = new ProgressIndicator(""+states, mutationStages*experimentsPerMutationCategory);
for(int mutationStage = 0;mutationStage<mutationStages;mutationStage++)
{
for(int experiment=0;experiment<experimentsPerMutationCategory;experiment++)
{
ExperimentResult outcome = new ExperimentResult();
while(!outcome.experimentValid)
{
int mutations = mutationsPerStage * (mutationStage+1);
LearnerGraphND origGraph = mg.nextMachine(alphabet, experiment);
GraphMutator<List<CmpVertex>,LearnerGraphNDCachedData> mutator = new GraphMutator<List<CmpVertex>,LearnerGraphNDCachedData>(origGraph,r);
mutator.mutate(mutations);
LearnerGraphND origAfterRenaming = new LearnerGraphND(origGraph.config);
Map<CmpVertex,CmpVertex> origToNew = copyStatesAndTransitions(origGraph,origAfterRenaming);
LearnerGraphND mutated = (LearnerGraphND)mutator.getMutated();
Set<Transition> appliedMutations = new HashSet<Transition>();
for(Transition tr:mutator.getDiff())
{
CmpVertex renamedFrom = origToNew.get(tr.getFrom());if (renamedFrom == null) renamedFrom = tr.getFrom();
CmpVertex renamedTo = origToNew.get(tr.getTo());if (renamedTo == null) renamedTo = tr.getTo();
appliedMutations.add(new Transition(renamedFrom,renamedTo,tr.getLabel()));
}
final double perfectLowToHigh=0.7,perfectThreshold=0.5;
// These experiments are only run for the maximal number of states
if (graphComplexity == graphComplexityMax-1)
{
for(double k:new double[]{0,.2,.4,.6,.8,.95})
{
config.setAttenuationK(k);
config.setGdKeyPairThreshold(0.5);
config.setGdLowToHighRatio(perfectLowToHigh);
config.setGdPropagateDet(false);// this is to ensure that if we removed a transition 0 from to a state and then added one from that state to a different one, det-propagation will not force the two very different states into a key-pair relation.
linearDiff(origAfterRenaming,mutated, appliedMutations,outcome);
gr_Diff_k.add(k, outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
}
for(double threshold:new double[]{0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.95})
{
config.setGdKeyPairThreshold(threshold);
config.setGdLowToHighRatio(perfectLowToHigh);
config.setGdPropagateDet(false);// this is to ensure that if we removed a transition 0 from to a state and then added one from that state to a different one, det-propagation will not force the two very different states into a key-pair relation.
linearDiff(origAfterRenaming,mutated, appliedMutations,outcome);
gr_Diff_threshold.add(threshold, outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
}
for(double lowtohigh:new double[]{0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.95})
{
config.setGdKeyPairThreshold(perfectThreshold);
config.setGdLowToHighRatio(lowtohigh);
config.setGdPropagateDet(false);// this is to ensure that if we removed a transition 0 from to a state and then added one from that state to a different one, det-propagation will not force the two very different states into a key-pair relation.
linearDiff(origAfterRenaming,mutated, appliedMutations,outcome);
gr_Diff_lowtohigh.add(lowtohigh, outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
}
for(int i=0;i<pairThreshold.length;++i)
for(double ratio:lowToHigh)
{
config.setGdKeyPairThreshold(pairThreshold[i]);
config.setGdLowToHighRatio(ratio);
config.setGdPropagateDet(false);// this is to ensure that if we removed a transition 0 from to a state and then added one from that state to a different one, det-propagation will not force the two very different states into a key-pair relation.
linearDiff(origAfterRenaming,mutated, appliedMutations,outcome);
gr_Diff_thresholdslowhigh.add(new Pair<Double,Double>(ratio,pairThreshold[i]), outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
}
}
config.setAttenuationK(0.5);
config.setGdKeyPairThreshold(perfectThreshold);
config.setGdLowToHighRatio(perfectLowToHigh);
config.setGdPropagateDet(false);// this is to ensure that if we removed a transition 0 from to a state and then added one from that state to a different one, det-propagation will not force the two very different states into a key-pair relation.
linearDiff(origAfterRenaming,mutated, appliedMutations,outcome);
if (!skip)
{
LearnerGraph fromDet = null, toDet = null;
try {
fromDet = mergeAndDeterminize(origAfterRenaming);
toDet = mergeAndDeterminize(mutated);
} catch (IncompatibleStatesException e) {
Helper.throwUnchecked("failed to build a deterministic graph from a nondet one", e);
}
languageDiff(fromDet,toDet,states, graphComplexity,outcome);
}
outcome.experimentValid = true;
progress.next();
gr_Diff_States.add(states, outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));
gr_W_States.add(states,outcome.getValue(DOUBLE_V.ACCURACY_W));
Pair<Integer,Integer> mutations_states = new Pair<Integer,Integer>(mutationStage+1,states);
Pair<Integer,Integer> states_mutations = new Pair<Integer,Integer>(states,mutationStage+1);
gr_DiffGD_StatesLevel.add(mutations_states, outcome.getValue(DOUBLE_V.OBTAINED_TO_EXPECTED));