/// <summary> /// To test the Clone() method /// </summary> /// <param name="args"></param> static void Main3(string[] args) { NodeTypeFrequencyProfile p = NodeTypeFrequencyProfile.createProfile(new List <SolutionProgram> { getProgram0(), getProgram1(), getProgram2() }, true); for (int i = 0; i < 50; i++) { Console.WriteLine("New random program:"); SolutionProgram pr = new SolutionProgram((DirectiveNode)SearchMethodsSupport.createRandomTree(NodeClass.directive, p, 10)); Console.WriteLine(pr.ToString()); new GraphVisualizer().visualizeDialog(ProgramTreeDrawer.createGraph(pr)); Console.WriteLine(); Console.WriteLine("CLONE:"); SolutionProgram clon = (SolutionProgram)pr.Clone(); Console.WriteLine(clon.ToString()); new GraphVisualizer().visualizeDialog(ProgramTreeDrawer.createGraph(clon)); Console.WriteLine(); } }
public static NodeTypeRelativizedFrequencyProfile createProfile(List <SolutionProgram> programs) { int minPrograms = 100; int repeat = programs.Count < minPrograms ? minPrograms - programs.Count : 1; NodeTypeRelativizedFrequencyProfile result = new NodeTypeRelativizedFrequencyProfile(); result.simpleProfile = createProfile(programs, atLeastOneOfEach: true); foreach (var program in programs) { foreach (var node in program.getAllNodes()) { if (!result.relativizedProfiles.ContainsKey(node.type)) { NodeTypeFrequencyProfile p = NodeTypeFrequencyProfile.createProfile(enumarateAllNodesThatAreSuccessorsOfType(node.type, programs, repeat), atLeastOneOfEach: true); result.relativizedProfiles.Add(node.type, p); } } } return(result); }