Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ContextAlgorithms/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Script Sources/GUIAutomationScriptSource.cs @ 15624

Last change on this file since 15624 was 15287, checked in by jkarder, 7 years ago

#2258: merged Async branch into trunk

File size: 1.3 KB
Line 
1using System.Linq;
2using System.Windows.Forms;
3
4using HeuristicLab.Algorithms.GeneticAlgorithm;
5using HeuristicLab.MainForm;
6using HeuristicLab.MainForm.WindowsForms;
7using HeuristicLab.Optimization;
8using HeuristicLab.Optimization.Views;
9using HeuristicLab.Problems.TravelingSalesman;
10
11public class GUIAutomationScript : HeuristicLab.Scripting.CSharpScriptBase {
12  public override void Main() {
13    var ga = new GeneticAlgorithm {
14      MaximumGenerations = { Value = 50 },
15      PopulationSize = { Value = 10 },
16      Problem = new TravelingSalesmanProblem()
17    };
18
19    var experiment = new Experiment();
20    for (int i = 0; i < 5; i++) {
21      experiment.Optimizers.Add(new BatchRun() { Optimizer = (IOptimizer)ga.Clone(), Repetitions = 10 });
22      ga.PopulationSize.Value *= 2;
23    }
24    experiment.Start();
25
26    vars.experiment = experiment;
27    MainFormManager.MainForm.ShowContent(experiment);
28    var viewHost = (ViewHost)MainFormManager.MainForm.ShowContent(experiment.Runs, typeof(RunCollectionBubbleChartView));
29    var bubbleChart = (UserControl)(viewHost.ActiveView);
30    bubbleChart.Controls.OfType<ComboBox>().Single(x => x.Name == "yAxisComboBox").SelectedItem = "BestQuality";
31    bubbleChart.Controls.OfType<ComboBox>().Single(x => x.Name == "xAxisComboBox").SelectedItem = "PopulationSize";
32  }
33}
Note: See TracBrowser for help on using the repository browser.