Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5300


Ignore:
Timestamp:
01/15/11 02:34:08 (14 years ago)
Author:
swagner
Message:

Enabled batch runs to deal with optimizers (#1378)

Location:
trunk/sources
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.Designer.cs

    r5287 r5300  
    3535    private void InitializeComponent() {
    3636      this.tabControl = new System.Windows.Forms.TabControl();
    37       this.algorithmTabPage = new System.Windows.Forms.TabPage();
    38       this.algorithmViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    39       this.openAlgorithmButton = new System.Windows.Forms.Button();
    40       this.newAlgorithmButton = new System.Windows.Forms.Button();
     37      this.optimizerTabPage = new System.Windows.Forms.TabPage();
     38      this.optimizerViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     39      this.openOptimizerButton = new System.Windows.Forms.Button();
     40      this.newOptimizerButton = new System.Windows.Forms.Button();
    4141      this.runsTabPage = new System.Windows.Forms.TabPage();
    4242      this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();
     
    5252      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5353      this.tabControl.SuspendLayout();
    54       this.algorithmTabPage.SuspendLayout();
     54      this.optimizerTabPage.SuspendLayout();
    5555      this.runsTabPage.SuspendLayout();
    5656      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
     
    7272                  | System.Windows.Forms.AnchorStyles.Left)
    7373                  | System.Windows.Forms.AnchorStyles.Right)));
    74       this.tabControl.Controls.Add(this.algorithmTabPage);
     74      this.tabControl.Controls.Add(this.optimizerTabPage);
    7575      this.tabControl.Controls.Add(this.runsTabPage);
    7676      this.tabControl.Location = new System.Drawing.Point(0, 78);
     
    8080      this.tabControl.TabIndex = 6;
    8181      //
    82       // algorithmTabPage
    83       //
    84       this.algorithmTabPage.AllowDrop = true;
    85       this.algorithmTabPage.Controls.Add(this.algorithmViewHost);
    86       this.algorithmTabPage.Controls.Add(this.openAlgorithmButton);
    87       this.algorithmTabPage.Controls.Add(this.newAlgorithmButton);
    88       this.algorithmTabPage.Location = new System.Drawing.Point(4, 22);
    89       this.algorithmTabPage.Name = "algorithmTabPage";
    90       this.algorithmTabPage.Padding = new System.Windows.Forms.Padding(3);
    91       this.algorithmTabPage.Size = new System.Drawing.Size(671, 348);
    92       this.algorithmTabPage.TabIndex = 1;
    93       this.algorithmTabPage.Text = "Algorithm";
    94       this.algorithmTabPage.UseVisualStyleBackColor = true;
    95       this.algorithmTabPage.DragOver += new System.Windows.Forms.DragEventHandler(this.algorithmTabPage_DragEnterOver);
    96       this.algorithmTabPage.DragDrop += new System.Windows.Forms.DragEventHandler(this.algorithmTabPage_DragDrop);
    97       this.algorithmTabPage.DragEnter += new System.Windows.Forms.DragEventHandler(this.algorithmTabPage_DragEnterOver);
    98       //
    99       // algorithmViewHost
    100       //
    101       this.algorithmViewHost.Content = null;
    102       this.algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     82      // optimizerTabPage
     83      //
     84      this.optimizerTabPage.AllowDrop = true;
     85      this.optimizerTabPage.Controls.Add(this.optimizerViewHost);
     86      this.optimizerTabPage.Controls.Add(this.openOptimizerButton);
     87      this.optimizerTabPage.Controls.Add(this.newOptimizerButton);
     88      this.optimizerTabPage.Location = new System.Drawing.Point(4, 22);
     89      this.optimizerTabPage.Name = "optimizerTabPage";
     90      this.optimizerTabPage.Padding = new System.Windows.Forms.Padding(3);
     91      this.optimizerTabPage.Size = new System.Drawing.Size(671, 348);
     92      this.optimizerTabPage.TabIndex = 1;
     93      this.optimizerTabPage.Text = "Optimizer";
     94      this.optimizerTabPage.UseVisualStyleBackColor = true;
     95      this.optimizerTabPage.DragOver += new System.Windows.Forms.DragEventHandler(this.optimizerTabPage_DragEnterOver);
     96      this.optimizerTabPage.DragDrop += new System.Windows.Forms.DragEventHandler(this.optimizerTabPage_DragDrop);
     97      this.optimizerTabPage.DragEnter += new System.Windows.Forms.DragEventHandler(this.optimizerTabPage_DragEnterOver);
     98      //
     99      // optimizerViewHost
     100      //
     101      this.optimizerViewHost.Content = null;
     102      this.optimizerViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    103103                  | System.Windows.Forms.AnchorStyles.Left)
    104104                  | System.Windows.Forms.AnchorStyles.Right)));
    105       this.algorithmViewHost.Location = new System.Drawing.Point(6, 36);
    106       this.algorithmViewHost.Name = "algorithmViewHost";
    107       this.algorithmViewHost.Size = new System.Drawing.Size(659, 306);
    108       this.algorithmViewHost.TabIndex = 3;
    109       this.algorithmViewHost.ViewType = null;
    110       //
    111       // openAlgorithmButton
    112       //
    113       this.openAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
    114       this.openAlgorithmButton.Location = new System.Drawing.Point(36, 6);
    115       this.openAlgorithmButton.Name = "openAlgorithmButton";
    116       this.openAlgorithmButton.Size = new System.Drawing.Size(24, 24);
    117       this.openAlgorithmButton.TabIndex = 1;
    118       this.toolTip.SetToolTip(this.openAlgorithmButton, "Open Algorithm");
    119       this.openAlgorithmButton.UseVisualStyleBackColor = true;
    120       this.openAlgorithmButton.Click += new System.EventHandler(this.openAlgorithmButton_Click);
    121       //
    122       // newAlgorithmButton
    123       //
    124       this.newAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;
    125       this.newAlgorithmButton.Location = new System.Drawing.Point(6, 6);
    126       this.newAlgorithmButton.Name = "newAlgorithmButton";
    127       this.newAlgorithmButton.Size = new System.Drawing.Size(24, 24);
    128       this.newAlgorithmButton.TabIndex = 0;
    129       this.toolTip.SetToolTip(this.newAlgorithmButton, "New Algorithm");
    130       this.newAlgorithmButton.UseVisualStyleBackColor = true;
    131       this.newAlgorithmButton.Click += new System.EventHandler(this.newAlgorithmButton_Click);
     105      this.optimizerViewHost.Location = new System.Drawing.Point(6, 36);
     106      this.optimizerViewHost.Name = "optimizerViewHost";
     107      this.optimizerViewHost.Size = new System.Drawing.Size(659, 306);
     108      this.optimizerViewHost.TabIndex = 3;
     109      this.optimizerViewHost.ViewType = null;
     110      //
     111      // openOptimizerButton
     112      //
     113      this.openOptimizerButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
     114      this.openOptimizerButton.Location = new System.Drawing.Point(36, 6);
     115      this.openOptimizerButton.Name = "openOptimizerButton";
     116      this.openOptimizerButton.Size = new System.Drawing.Size(24, 24);
     117      this.openOptimizerButton.TabIndex = 1;
     118      this.toolTip.SetToolTip(this.openOptimizerButton, "Open Optimizer");
     119      this.openOptimizerButton.UseVisualStyleBackColor = true;
     120      this.openOptimizerButton.Click += new System.EventHandler(this.openOptimizerButton_Click);
     121      //
     122      // newOptimizerButton
     123      //
     124      this.newOptimizerButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;
     125      this.newOptimizerButton.Location = new System.Drawing.Point(6, 6);
     126      this.newOptimizerButton.Name = "newOptimizerButton";
     127      this.newOptimizerButton.Size = new System.Drawing.Size(24, 24);
     128      this.newOptimizerButton.TabIndex = 0;
     129      this.toolTip.SetToolTip(this.newOptimizerButton, "New Optimizer");
     130      this.newOptimizerButton.UseVisualStyleBackColor = true;
     131      this.newOptimizerButton.Click += new System.EventHandler(this.newOptimizerButton_Click);
    132132      //
    133133      // runsTabPage
     
    211211      //
    212212      this.openFileDialog.DefaultExt = "hl";
    213       this.openFileDialog.FileName = "Algorithm";
     213      this.openFileDialog.FileName = "Optimizer";
    214214      this.openFileDialog.Filter = "HeuristicLab Files|*.hl|All Files|*.*";
    215       this.openFileDialog.Title = "Open Algorithm";
     215      this.openFileDialog.Title = "Open Optimizer";
    216216      //
    217217      // repetitionsLabel
     
    293293      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    294294      this.tabControl.ResumeLayout(false);
    295       this.algorithmTabPage.ResumeLayout(false);
     295      this.optimizerTabPage.ResumeLayout(false);
    296296      this.runsTabPage.ResumeLayout(false);
    297297      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).EndInit();
     
    303303
    304304    private System.Windows.Forms.TabControl tabControl;
    305     private System.Windows.Forms.TabPage algorithmTabPage;
    306     private HeuristicLab.MainForm.WindowsForms.ViewHost algorithmViewHost;
    307     private System.Windows.Forms.Button newAlgorithmButton;
    308     private System.Windows.Forms.Button openAlgorithmButton;
     305    private System.Windows.Forms.TabPage optimizerTabPage;
     306    private HeuristicLab.MainForm.WindowsForms.ViewHost optimizerViewHost;
     307    private System.Windows.Forms.Button newOptimizerButton;
     308    private System.Windows.Forms.Button openOptimizerButton;
    309309    private System.Windows.Forms.Button startButton;
    310310    private System.Windows.Forms.Button stopButton;
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs

    r5237 r5300  
    3535  [Content(typeof(BatchRun), true)]
    3636  public sealed partial class BatchRunView : NamedItemView {
    37     private TypeSelectorDialog algorithmTypeSelectorDialog;
     37    private TypeSelectorDialog optimizerTypeSelectorDialog;
    3838
    3939    public new BatchRun Content {
     
    5151    protected override void Dispose(bool disposing) {
    5252      if (disposing) {
    53         if (algorithmTypeSelectorDialog != null) algorithmTypeSelectorDialog.Dispose();
     53        if (optimizerTypeSelectorDialog != null) optimizerTypeSelectorDialog.Dispose();
    5454        if (components != null) components.Dispose();
    5555      }
     
    5858
    5959    protected override void DeregisterContentEvents() {
    60       Content.AlgorithmChanged -= new EventHandler(Content_AlgorithmChanged);
     60      Content.OptimizerChanged -= new EventHandler(Content_OptimizerChanged);
    6161      Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    6262      Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
     
    7171    protected override void RegisterContentEvents() {
    7272      base.RegisterContentEvents();
    73       Content.AlgorithmChanged += new EventHandler(Content_AlgorithmChanged);
     73      Content.OptimizerChanged += new EventHandler(Content_OptimizerChanged);
    7474      Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    7575      Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
     
    8686      if (Content == null) {
    8787        repetitionsNumericUpDown.Value = 1;
    88         algorithmViewHost.Content = null;
     88        optimizerViewHost.Content = null;
    8989        runsView.Content = null;
    9090        executionTimeTextBox.Text = "-";
     
    9292        Locked = ReadOnly = Content.ExecutionState == ExecutionState.Started;
    9393        repetitionsNumericUpDown.Value = Content.Repetitions;
    94         algorithmViewHost.Content = Content.Algorithm;
     94        optimizerViewHost.Content = Content.Optimizer;
    9595        runsView.Content = Content.Runs;
    9696        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
     
    100100      base.SetEnabledStateOfControls();
    101101      repetitionsNumericUpDown.Enabled = Content != null && !ReadOnly;
    102       newAlgorithmButton.Enabled = Content != null && !ReadOnly;
    103       openAlgorithmButton.Enabled = Content != null && !ReadOnly;
    104       algorithmViewHost.Enabled = Content != null;
     102      newOptimizerButton.Enabled = Content != null && !ReadOnly;
     103      openOptimizerButton.Enabled = Content != null && !ReadOnly;
     104      optimizerViewHost.Enabled = Content != null;
    105105      runsView.Enabled = Content != null;
    106106      executionTimeTextBox.Enabled = Content != null;
     
    164164        ErrorHandling.ShowErrorDialog(this, e.Value);
    165165    }
    166     private void Content_AlgorithmChanged(object sender, EventArgs e) {
    167       if (InvokeRequired)
    168         Invoke(new EventHandler(Content_AlgorithmChanged), sender, e);
    169       else {
    170         algorithmViewHost.Content = Content.Algorithm;
     166    private void Content_OptimizerChanged(object sender, EventArgs e) {
     167      if (InvokeRequired)
     168        Invoke(new EventHandler(Content_OptimizerChanged), sender, e);
     169      else {
     170        optimizerViewHost.Content = Content.Optimizer;
    171171      }
    172172    }
     
    188188        Content.Repetitions = (int)repetitionsNumericUpDown.Value;
    189189    }
    190     private void newAlgorithmButton_Click(object sender, EventArgs e) {
    191       if (algorithmTypeSelectorDialog == null) {
    192         algorithmTypeSelectorDialog = new TypeSelectorDialog();
    193         algorithmTypeSelectorDialog.Caption = "Select Algorithm";
    194         algorithmTypeSelectorDialog.TypeSelector.Caption = "Available Algorithms";
    195         algorithmTypeSelectorDialog.TypeSelector.Configure(typeof(IAlgorithm), false, true);
    196       }
    197       if (algorithmTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     190    private void newOptimizerButton_Click(object sender, EventArgs e) {
     191      if (optimizerTypeSelectorDialog == null) {
     192        optimizerTypeSelectorDialog = new TypeSelectorDialog();
     193        optimizerTypeSelectorDialog.Caption = "Select Optimizer";
     194        optimizerTypeSelectorDialog.TypeSelector.Caption = "Available Optimizers";
     195        optimizerTypeSelectorDialog.TypeSelector.Configure(typeof(IOptimizer), false, true);
     196      }
     197      if (optimizerTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    198198        try {
    199           Content.Algorithm = (IAlgorithm)algorithmTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
     199          Content.Optimizer = (IOptimizer)optimizerTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
    200200        }
    201201        catch (Exception ex) {
     
    204204      }
    205205    }
    206     private void openAlgorithmButton_Click(object sender, EventArgs e) {
    207       openFileDialog.Title = "Open Algorithm";
     206    private void openOptimizerButton_Click(object sender, EventArgs e) {
     207      openFileDialog.Title = "Open Optimizer";
    208208      if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
    209         newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = false;
    210         algorithmViewHost.Enabled = false;
     209        newOptimizerButton.Enabled = openOptimizerButton.Enabled = false;
     210        optimizerViewHost.Enabled = false;
    211211
    212212        ContentManager.LoadAsync(openFileDialog.FileName, delegate(IStorableContent content, Exception error) {
    213213          try {
    214214            if (error != null) throw error;
    215             IAlgorithm algorithm = content as IAlgorithm;
    216             if (algorithm == null)
    217               MessageBox.Show(this, "The selected file does not contain an algorithm.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error);
     215            IOptimizer optimizer = content as IOptimizer;
     216            if (optimizer == null)
     217              MessageBox.Show(this, "The selected file does not contain an optimizer.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error);
    218218            else
    219               Content.Algorithm = algorithm;
     219              Content.Optimizer = optimizer;
    220220          }
    221221          catch (Exception ex) {
     
    224224          finally {
    225225            Invoke(new Action(delegate() {
    226               algorithmViewHost.Enabled = true;
    227               newAlgorithmButton.Enabled = openAlgorithmButton.Enabled = true;
     226              optimizerViewHost.Enabled = true;
     227              newOptimizerButton.Enabled = openOptimizerButton.Enabled = true;
    228228            }));
    229229          }
     
    243243      Content.Prepare(false);
    244244    }
    245     private void algorithmTabPage_DragEnterOver(object sender, DragEventArgs e) {
     245    private void optimizerTabPage_DragEnterOver(object sender, DragEventArgs e) {
    246246      e.Effect = DragDropEffects.None;
    247247      if (ReadOnly)
    248248        return;
    249249      Type type = e.Data.GetData("Type") as Type;
    250       if ((type != null) && (typeof(IAlgorithm).IsAssignableFrom(type))) {
     250      if ((type != null) && (typeof(IOptimizer).IsAssignableFrom(type))) {
    251251        if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
    252252        else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
     
    256256      }
    257257    }
    258     private void algorithmTabPage_DragDrop(object sender, DragEventArgs e) {
     258    private void optimizerTabPage_DragDrop(object sender, DragEventArgs e) {
    259259      if (e.Effect != DragDropEffects.None) {
    260         IAlgorithm algorithm = e.Data.GetData("Value") as IAlgorithm;
    261         if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) algorithm = (IAlgorithm)algorithm.Clone();
    262         Content.Algorithm = algorithm;
     260        IOptimizer optimizer = e.Data.GetData("Value") as IOptimizer;
     261        if ((e.Effect & DragDropEffects.Copy) == DragDropEffects.Copy) optimizer = (IOptimizer)optimizer.Clone();
     262        Content.Optimizer = optimizer;
    263263      }
    264264    }
  • trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs

    r5287 r5300  
    3131namespace HeuristicLab.Optimization {
    3232  /// <summary>
    33   /// A run in which an algorithm is executed a given number of times.
     33  /// A run in which an optimizer is executed a given number of times.
    3434  /// </summary>
    35   [Item("Batch Run", "A run in which an algorithm is executed a given number of times.")]
     35  [Item("Batch Run", "A run in which an optimizer is executed a given number of times.")]
    3636  [Creatable("Testing & Analysis")]
    3737  [StorableClass]
     
    6666    public TimeSpan ExecutionTime {
    6767      get {
    68         if ((Algorithm != null) && (Algorithm.ExecutionState != ExecutionState.Stopped))
    69           return executionTime + Algorithm.ExecutionTime;
     68        if ((Optimizer != null) && (Optimizer.ExecutionState != ExecutionState.Stopped))
     69          return executionTime + Optimizer.ExecutionTime;
    7070        else
    7171          return executionTime;
     
    7878
    7979    [Storable]
    80     private IAlgorithm algorithm;
    81     public IAlgorithm Algorithm {
    82       get { return algorithm; }
     80    private IOptimizer optimizer;
     81    public IOptimizer Optimizer {
     82      get { return optimizer; }
    8383      set {
    84         if (algorithm != value) {
    85           if (algorithm != null) {
    86             DeregisterAlgorithmEvents();
    87             IEnumerable<IRun> runs = algorithm.Runs;
    88             algorithm = null; //necessary to avoid removing the runs from the old algorithm
     84        if (optimizer != value) {
     85          if (optimizer != null) {
     86            DeregisterOptimizerEvents();
     87            IEnumerable<IRun> runs = optimizer.Runs;
     88            optimizer = null; //necessary to avoid removing the runs from the old optimizer
    8989            Runs.RemoveRange(runs);
    9090          }
    91           algorithm = value;
    92           if (algorithm != null) {
    93             RegisterAlgorithmEvents();
    94             Runs.AddRange(algorithm.Runs);
     91          optimizer = value;
     92          if (optimizer != null) {
     93            RegisterOptimizerEvents();
     94            Runs.AddRange(optimizer.Runs);
    9595          }
    96           OnAlgorithmChanged();
     96          OnOptimizerChanged();
    9797          Prepare();
    9898        }
    9999      }
    100100    }
     101    // BackwardsCompatibility3.3
     102    #region Backwards compatible code (remove with 3.4)
     103    [Storable]
     104    private IAlgorithm algorithm {
     105      get { return null; }
     106      set { optimizer = value; }
     107    }
     108    #endregion
    101109
    102110    [Storable]
     
    108116          repetitions = value;
    109117          OnRepetitionsChanged();
    110           if ((Algorithm != null) && (Algorithm.ExecutionState == ExecutionState.Stopped))
     118          if ((Optimizer != null) && (Optimizer.ExecutionState == ExecutionState.Stopped))
    111119            Prepare();
    112120        }
     
    176184      executionState = original.executionState;
    177185      executionTime = original.executionTime;
    178       algorithm = cloner.Clone(original.algorithm);
     186      optimizer = cloner.Clone(original.optimizer);
    179187      repetitions = original.repetitions;
    180188      repetitionsCounter = original.repetitionsCounter;
     
    189197
    190198    private void Initialize() {
    191       if (algorithm != null) RegisterAlgorithmEvents();
     199      if (optimizer != null) RegisterOptimizerEvents();
    192200      if (runs != null) RegisterRunsEvents();
    193201    }
     
    199207      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped))
    200208        throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState));
    201       if (Algorithm != null) {
     209      if (Optimizer != null) {
    202210        repetitionsCounter = 0;
    203211        if (clearRuns) runs.Clear();
    204         Algorithm.Prepare(clearRuns);
     212        Optimizer.Prepare(clearRuns);
    205213      }
    206214    }
     
    208216      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused))
    209217        throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState));
    210       if (Algorithm != null) Algorithm.Start();
     218      if (Optimizer != null) Optimizer.Start();
    211219    }
    212220    public void Pause() {
    213221      if (ExecutionState != ExecutionState.Started)
    214222        throw new InvalidOperationException(string.Format("Pause not allowed in execution state \"{0}\".", ExecutionState));
    215       if ((Algorithm != null) && (Algorithm.ExecutionState == ExecutionState.Started))
    216         Algorithm.Pause();
     223      if ((Optimizer != null) && (Optimizer.ExecutionState == ExecutionState.Started))
     224        Optimizer.Pause();
    217225    }
    218226    public void Stop() {
     
    220228        throw new InvalidOperationException(string.Format("Stop not allowed in execution state \"{0}\".", ExecutionState));
    221229      stopPending = true;
    222       if ((Algorithm != null) &&
    223           ((Algorithm.ExecutionState == ExecutionState.Started) || (Algorithm.ExecutionState == ExecutionState.Paused)))
    224         Algorithm.Stop();
     230      if ((Optimizer != null) &&
     231          ((Optimizer.ExecutionState == ExecutionState.Started) || (Optimizer.ExecutionState == ExecutionState.Paused)))
     232        Optimizer.Stop();
    225233    }
    226234
     
    236244      if (handler != null) handler(this, EventArgs.Empty);
    237245    }
    238     public event EventHandler AlgorithmChanged;
    239     private void OnAlgorithmChanged() {
    240       EventHandler handler = AlgorithmChanged;
     246    public event EventHandler OptimizerChanged;
     247    private void OnOptimizerChanged() {
     248      EventHandler handler = OptimizerChanged;
    241249      if (handler != null) handler(this, EventArgs.Empty);
    242250    }
     
    276284    }
    277285
    278     private void RegisterAlgorithmEvents() {
    279       algorithm.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Algorithm_ExceptionOccurred);
    280       algorithm.ExecutionTimeChanged += new EventHandler(Algorithm_ExecutionTimeChanged);
    281       algorithm.Paused += new EventHandler(Algorithm_Paused);
    282       algorithm.Prepared += new EventHandler(Algorithm_Prepared);
    283       algorithm.Started += new EventHandler(Algorithm_Started);
    284       algorithm.Stopped += new EventHandler(Algorithm_Stopped);
    285       algorithm.Runs.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_CollectionReset);
    286       algorithm.Runs.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_ItemsAdded);
    287       algorithm.Runs.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_ItemsRemoved);
    288     }
    289     private void DeregisterAlgorithmEvents() {
    290       algorithm.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Algorithm_ExceptionOccurred);
    291       algorithm.ExecutionTimeChanged -= new EventHandler(Algorithm_ExecutionTimeChanged);
    292       algorithm.Paused -= new EventHandler(Algorithm_Paused);
    293       algorithm.Prepared -= new EventHandler(Algorithm_Prepared);
    294       algorithm.Started -= new EventHandler(Algorithm_Started);
    295       algorithm.Stopped -= new EventHandler(Algorithm_Stopped);
    296       algorithm.Runs.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_CollectionReset);
    297       algorithm.Runs.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_ItemsAdded);
    298       algorithm.Runs.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Algorithm_Runs_ItemsRemoved);
    299     }
    300     private void Algorithm_ExceptionOccurred(object sender, EventArgs<Exception> e) {
     286    private void RegisterOptimizerEvents() {
     287      optimizer.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Optimizer_ExceptionOccurred);
     288      optimizer.ExecutionTimeChanged += new EventHandler(Optimizer_ExecutionTimeChanged);
     289      optimizer.Paused += new EventHandler(Optimizer_Paused);
     290      optimizer.Prepared += new EventHandler(Optimizer_Prepared);
     291      optimizer.Started += new EventHandler(Optimizer_Started);
     292      optimizer.Stopped += new EventHandler(Optimizer_Stopped);
     293      optimizer.Runs.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_CollectionReset);
     294      optimizer.Runs.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_ItemsAdded);
     295      optimizer.Runs.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_ItemsRemoved);
     296    }
     297    private void DeregisterOptimizerEvents() {
     298      optimizer.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Optimizer_ExceptionOccurred);
     299      optimizer.ExecutionTimeChanged -= new EventHandler(Optimizer_ExecutionTimeChanged);
     300      optimizer.Paused -= new EventHandler(Optimizer_Paused);
     301      optimizer.Prepared -= new EventHandler(Optimizer_Prepared);
     302      optimizer.Started -= new EventHandler(Optimizer_Started);
     303      optimizer.Stopped -= new EventHandler(Optimizer_Stopped);
     304      optimizer.Runs.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_CollectionReset);
     305      optimizer.Runs.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_ItemsAdded);
     306      optimizer.Runs.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Optimizer_Runs_ItemsRemoved);
     307    }
     308    private void Optimizer_ExceptionOccurred(object sender, EventArgs<Exception> e) {
    301309      OnExceptionOccurred(e.Value);
    302310    }
    303     private void Algorithm_ExecutionTimeChanged(object sender, EventArgs e) {
     311    private void Optimizer_ExecutionTimeChanged(object sender, EventArgs e) {
    304312      OnExecutionTimeChanged();
    305313    }
    306     private void Algorithm_Paused(object sender, EventArgs e) {
     314    private void Optimizer_Paused(object sender, EventArgs e) {
    307315      OnPaused();
    308316    }
    309     private void Algorithm_Prepared(object sender, EventArgs e) {
     317    private void Optimizer_Prepared(object sender, EventArgs e) {
    310318      if ((ExecutionState == ExecutionState.Paused) || (ExecutionState == ExecutionState.Stopped))
    311319        OnPrepared();
    312320    }
    313     private void Algorithm_Started(object sender, EventArgs e) {
     321    private void Optimizer_Started(object sender, EventArgs e) {
    314322      stopPending = false;
    315323      if (ExecutionState != ExecutionState.Started)
    316324        OnStarted();
    317325    }
    318     private void Algorithm_Stopped(object sender, EventArgs e) {
     326    private void Optimizer_Stopped(object sender, EventArgs e) {
    319327      repetitionsCounter++;
    320328
    321329      if (!stopPending && (repetitionsCounter < repetitions)) {
    322         Algorithm.Prepare();
    323         Algorithm.Start();
     330        Optimizer.Prepare();
     331        Optimizer.Start();
    324332      } else {
    325333        OnStopped();
    326334      }
    327335    }
    328     private void Algorithm_Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     336    private void Optimizer_Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    329337      Runs.RemoveRange(e.OldItems);
    330338      Runs.AddRange(e.Items);
    331339    }
    332     private void Algorithm_Runs_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     340    private void Optimizer_Runs_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    333341      Runs.AddRange(e.Items);
    334342    }
    335     private void Algorithm_Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
     343    private void Optimizer_Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
    336344      Runs.RemoveRange(e.Items);
    337345    }
     
    355363        if (executionTime != null) ExecutionTime -= executionTime.Value;
    356364      }
    357       if (Algorithm != null) Algorithm.Runs.RemoveRange(e.OldItems);
     365      if (Optimizer != null) Optimizer.Runs.RemoveRange(e.OldItems);
    358366      foreach (IRun run in e.Items) {
    359367        IItem item;
     
    378386        if (executionTime != null) ExecutionTime -= executionTime.Value;
    379387      }
    380       if (Algorithm != null) Algorithm.Runs.RemoveRange(e.Items);
     388      if (Optimizer != null) Optimizer.Runs.RemoveRange(e.Items);
    381389    }
    382390    #endregion
  • trunk/sources/HeuristicLab.Optimization/3.3/Experiment.cs

    r5287 r5300  
    3030namespace HeuristicLab.Optimization {
    3131  /// <summary>
    32   /// An experiment which contains multiple batch runs of algorithms.
     32  /// An experiment which contains multiple algorithms, batch runs or other experiments.
    3333  /// </summary>
    34   [Item("Experiment", "An experiment which contains multiple batch runs of algorithms.")]
     34  [Item("Experiment", "An experiment which contains multiple algorithms, batch runs or other experiments.")]
    3535  [Creatable("Testing & Analysis")]
    3636  [StorableClass]
  • trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.Designer.cs

    r4650 r5300  
    8989      this.createBatchRunCheckBox.Size = new System.Drawing.Size(15, 14);
    9090      this.createBatchRunCheckBox.TabIndex = 1;
    91       this.toolTip.SetToolTip(this.createBatchRunCheckBox, "Check to create a batch run for executing an algorithm multiple times.");
     91      this.toolTip.SetToolTip(this.createBatchRunCheckBox, "Check to create a batch run for executing an optimizer multiple times.");
    9292      this.createBatchRunCheckBox.UseVisualStyleBackColor = true;
    9393      this.createBatchRunCheckBox.CheckedChanged += new System.EventHandler(this.createBatchRunCheckBox_CheckedChanged);
  • trunk/sources/HeuristicLab.Optimizer/3.3/CreateExperimentDialog.cs

    r4722 r5300  
    2626namespace HeuristicLab.Optimizer {
    2727  public partial class CreateExperimentDialog : Form {
    28     private IAlgorithm algorithm;
    29     public IAlgorithm Algorithm {
    30       get { return algorithm; }
     28    private IOptimizer optimizer;
     29    public IOptimizer Optimizer {
     30      get { return optimizer; }
    3131      set {
    32         algorithm = value;
     32        optimizer = value;
    3333        experiment = null;
    34         okButton.Enabled = algorithm != null;
     34        okButton.Enabled = optimizer != null;
    3535      }
    3636    }
    37    
     37
    3838    private Experiment experiment;
    3939    public Experiment Experiment {
     
    4343    public CreateExperimentDialog() {
    4444      experiment = null;
    45       algorithm = null;
     45      optimizer = null;
    4646      InitializeComponent();
    4747    }
    48     public CreateExperimentDialog(IAlgorithm algorithm) : this() {
    49       Algorithm = algorithm;
     48    public CreateExperimentDialog(IOptimizer optimizer)
     49      : this() {
     50      Optimizer = optimizer;
    5051    }
    5152
     
    5859    }
    5960    private void okButton_Click(object sender, EventArgs e) {
    60       experiment = new Experiment(Algorithm.Name);
     61      experiment = new Experiment(Optimizer.Name);
    6162      if (createBatchRunCheckBox.Checked) {
    62         BatchRun batchRun = new BatchRun(Algorithm.Name);
     63        BatchRun batchRun = new BatchRun(Optimizer.Name);
    6364        batchRun.Repetitions = (int)repetitionsNumericUpDown.Value;
    64         batchRun.Algorithm = (IAlgorithm)Algorithm.Clone();
     65        batchRun.Optimizer = (IOptimizer)Optimizer.Clone();
    6566        Experiment.Optimizers.Add(batchRun);
    6667      } else {
    67         Experiment.Optimizers.Add((IAlgorithm)Algorithm.Clone());
     68        Experiment.Optimizers.Add((IOptimizer)Optimizer.Clone());
    6869      }
    6970      Experiment.Prepare(true);
  • trunk/sources/HeuristicLab.Optimizer/3.3/MenuItems/CreateExperimentMenuItem.cs

    r4650 r5300  
    3838    }
    3939    public override string ToolTipText {
    40       get { return "Create an experiment for the shown algorithm"; }
     40      get { return "Create an experiment for the shown optimizer"; }
    4141    }
    4242
     
    4646    protected override void OnActiveViewChanged(object sender, EventArgs e) {
    4747      IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
    48       ToolStripItem.Enabled = (activeView != null) && (activeView.Content != null) && (activeView.Content is IAlgorithm) && !activeView.Locked;
     48      ToolStripItem.Enabled = (activeView != null) && (activeView.Content != null) && (activeView.Content is IOptimizer) && !activeView.Locked;
    4949    }
    5050
    5151    public override void Execute() {
    5252      IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
    53       if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IAlgorithm) && !activeView.Locked) {
    54         using (CreateExperimentDialog dialog = new CreateExperimentDialog((IAlgorithm)activeView.Content)) {
     53      if ((activeView != null) && (activeView.Content != null) && (activeView.Content is IOptimizer) && !activeView.Locked) {
     54        using (CreateExperimentDialog dialog = new CreateExperimentDialog((IOptimizer)activeView.Content)) {
    5555          if (dialog.ShowDialog() == DialogResult.OK) MainFormManager.MainForm.ShowContent(dialog.Experiment);
    5656        }
Note: See TracChangeset for help on using the changeset viewer.