public override bool KeepProgram(WExpr candidate) { Automata.TMCB <int, int> M = candidate.ToTMCB(-1); int numTapes = candidate.GetNumVariables(); int inputsPerTape = (int)Math.Pow(numTestInputs, (double)1 / numTapes); bool dummy; int count = 0; //counts inputs for which the TM times out int total = 0; foreach (int[][] input in WhileUtilities.NonNegIntTestInputs(numTapes, inputsPerTape, candidate.GetUselessVariables().ToArray())) { M.Run(input, out dummy); if (M.Timeout) { ++count; } ++total; } return(decideByPercentage(count, total)); }
public override bool KeepProgram(WExpr candidate) { Automata.TMCB <int, int> M = candidate.ToTMCB(-1); int numTapes = candidate.GetNumVariables(); int inputsPerTape = (int)Math.Pow(numTestInputs, (double)1 / numTapes); bool dummy; int[][] output; int count = 0; //counts inputs that get modified by a run of the TM int total = 0; foreach (int[][] input in WhileUtilities.NonNegIntTestInputs(numTapes, inputsPerTape, candidate.GetUselessVariables().ToArray())) { output = M.Run(input, out dummy); if (!WhileUtilities.TapesEqual(Array.ConvertAll(input, tape => WhileUtilities.TapeToString(tape, M.blank, null)), Array.ConvertAll(output, tape => WhileUtilities.TapeToString(tape, M.blank, null)))) { ++count; } ++total; } return(decideByPercentage(count, total)); }