Changeset 3260


Ignore:
Timestamp:
04/03/10 06:04:49 (11 years ago)
Author:
swagner
Message:

Continued work on algorithm batch processing (#947).

Location:
trunk/sources
Files:
6 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/EngineView.cs

    r2917 r3260  
    103103      else {
    104104        UpdateExecutionTimeTextBox();
    105         logTextBox.Clear();
    106105        Log("Engine prepared");
    107106      }
     
    127126    protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) {
    128127      executionTimeCounter++;
    129       if ((executionTimeCounter == 100) || !Content.Running) {
     128      if ((executionTimeCounter >= 100) || !Content.Running) {
    130129        executionTimeCounter = 0;
    131130        UpdateExecutionTimeTextBox();
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IParameterizedItem.cs

    r2834 r3260  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HeuristicLab.Collections;
    2324
     
    2829  public interface IParameterizedItem : IItem {
    2930    IObservableKeyedCollection<string, IParameter> Parameters { get; }
     31
     32    void CollectParameterValues(IDictionary<string, IItem> values);
    3033  }
    3134}
  • trunk/sources/HeuristicLab.Core/3.3/ParameterizedNamedItem.cs

    r3017 r3260  
    2020#endregion
    2121
     22using System.Collections.Generic;
     23using System.Linq;
    2224using HeuristicLab.Collections;
    2325using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    8284      return clone;
    8385    }
     86
     87    public virtual void CollectParameterValues(IDictionary<string, IItem> values) {
     88      foreach (IValueParameter param in parameters.OfType<IValueParameter>()) {
     89        values.Add(param.Name, param.Value != null ? (IItem)param.Value.Clone() : null);
     90        if (param.Value is IParameterizedItem) {
     91          Dictionary<string, IItem> children = new Dictionary<string, IItem>();
     92          ((IParameterizedItem)param.Value).CollectParameterValues(children);
     93          foreach (string key in children.Keys)
     94            values.Add(param.Name + "." + key, children[key]);
     95        }
     96      }
     97    }
    8498  }
    8599}
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs

    r3226 r3260  
    174174    protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) {
    175175      executionTimeCounter++;
    176       if ((executionTimeCounter == 100) || !Content.Running) {
     176      if ((executionTimeCounter >= 100) || !Content.Running) {
    177177        executionTimeCounter = 0;
    178178        UpdateExecutionTimeTextBox();
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.Designer.cs

    r3246 r3260  
    5252      this.newAlgorithmButton = new System.Windows.Forms.Button();
    5353      this.algorithmViewHost = new HeuristicLab.Core.Views.ViewHost();
    54       this.resultsTabPage = new System.Windows.Forms.TabPage();
     54      this.runsTabPage = new System.Windows.Forms.TabPage();
    5555      this.startButton = new System.Windows.Forms.Button();
    5656      this.stopButton = new System.Windows.Forms.Button();
     
    6262      this.repetitionsLabel = new System.Windows.Forms.Label();
    6363      this.repetitionsNumericUpDown = new System.Windows.Forms.NumericUpDown();
    64       this.resultsView = new HeuristicLab.Optimization.Views.ResultCollectionView();
     64      this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();
    6565      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6666      this.tabControl.SuspendLayout();
    6767      this.algorithmTabPage.SuspendLayout();
    68       this.resultsTabPage.SuspendLayout();
     68      this.runsTabPage.SuspendLayout();
    6969      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).BeginInit();
    7070      this.SuspendLayout();
     
    8686                  | System.Windows.Forms.AnchorStyles.Right)));
    8787      this.tabControl.Controls.Add(this.algorithmTabPage);
    88       this.tabControl.Controls.Add(this.resultsTabPage);
     88      this.tabControl.Controls.Add(this.runsTabPage);
    8989      this.tabControl.Location = new System.Drawing.Point(0, 78);
    9090      this.tabControl.Name = "tabControl";
     
    152152      this.algorithmViewHost.ViewType = null;
    153153      //
    154       // resultsTabPage
    155       //
    156       this.resultsTabPage.Controls.Add(this.resultsView);
    157       this.resultsTabPage.Location = new System.Drawing.Point(4, 22);
    158       this.resultsTabPage.Name = "resultsTabPage";
    159       this.resultsTabPage.Padding = new System.Windows.Forms.Padding(3);
    160       this.resultsTabPage.Size = new System.Drawing.Size(671, 348);
    161       this.resultsTabPage.TabIndex = 2;
    162       this.resultsTabPage.Text = "Results";
    163       this.resultsTabPage.UseVisualStyleBackColor = true;
     154      // runsTabPage
     155      //
     156      this.runsTabPage.Controls.Add(this.runsView);
     157      this.runsTabPage.Location = new System.Drawing.Point(4, 22);
     158      this.runsTabPage.Name = "runsTabPage";
     159      this.runsTabPage.Padding = new System.Windows.Forms.Padding(3);
     160      this.runsTabPage.Size = new System.Drawing.Size(671, 348);
     161      this.runsTabPage.TabIndex = 2;
     162      this.runsTabPage.Text = "Runs";
     163      this.runsTabPage.UseVisualStyleBackColor = true;
    164164      //
    165165      // startButton
     
    268268      this.repetitionsNumericUpDown.ValueChanged += new System.EventHandler(this.repetitionsNumericUpDown_ValueChanged);
    269269      //
    270       // resultsView
    271       //
    272       this.resultsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     270      // runsView
     271      //
     272      this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    273273                  | System.Windows.Forms.AnchorStyles.Left)
    274274                  | System.Windows.Forms.AnchorStyles.Right)));
    275       this.resultsView.Caption = "ResultCollection";
    276       this.resultsView.Content = null;
    277       this.resultsView.Location = new System.Drawing.Point(6, 6);
    278       this.resultsView.Name = "resultsView";
    279       this.resultsView.Size = new System.Drawing.Size(659, 336);
    280       this.resultsView.TabIndex = 0;
     275      this.runsView.Caption = "RunCollection";
     276      this.runsView.Content = null;
     277      this.runsView.Location = new System.Drawing.Point(6, 6);
     278      this.runsView.Name = "runsView";
     279      this.runsView.Size = new System.Drawing.Size(659, 336);
     280      this.runsView.TabIndex = 0;
    281281      //
    282282      // BatchRunView
     
    309309      this.tabControl.ResumeLayout(false);
    310310      this.algorithmTabPage.ResumeLayout(false);
    311       this.resultsTabPage.ResumeLayout(false);
     311      this.runsTabPage.ResumeLayout(false);
    312312      ((System.ComponentModel.ISupportInitialize)(this.repetitionsNumericUpDown)).EndInit();
    313313      this.ResumeLayout(false);
     
    331331    private System.Windows.Forms.OpenFileDialog openFileDialog;
    332332    private System.Windows.Forms.SaveFileDialog saveFileDialog;
    333     private System.Windows.Forms.TabPage resultsTabPage;
     333    private System.Windows.Forms.TabPage runsTabPage;
    334334    private System.Windows.Forms.Label repetitionsLabel;
    335335    private System.Windows.Forms.NumericUpDown repetitionsNumericUpDown;
    336     private ResultCollectionView resultsView;
     336    private RunCollectionView runsView;
    337337
    338338  }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/BatchRunView.cs

    r3226 r3260  
    8585        repetitionsNumericUpDown.Enabled = false;
    8686        algorithmViewHost.Content = null;
    87         resultsView.Content = null;
     87        runsView.Content = null;
    8888        tabControl.Enabled = false;
    8989        startButton.Enabled = resetButton.Enabled = false;
     
    9696        algorithmViewHost.ViewType = null;
    9797        algorithmViewHost.Content = Content.Algorithm;
    98         resultsView.Content = Content.Results;
     98        runsView.Content = Content.Runs;
    9999        tabControl.Enabled = true;
    100100        startButton.Enabled = !Content.Finished;
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj

    r3246 r3260  
    9898      <DependentUpon>BatchRunView.cs</DependentUpon>
    9999    </Compile>
     100    <Compile Include="RunCollectionView.cs">
     101      <SubType>UserControl</SubType>
     102    </Compile>
     103    <Compile Include="RunCollectionView.Designer.cs">
     104      <DependentUpon>RunCollectionView.cs</DependentUpon>
     105    </Compile>
     106    <Compile Include="RunView.cs">
     107      <SubType>UserControl</SubType>
     108    </Compile>
     109    <Compile Include="RunView.Designer.cs">
     110      <DependentUpon>RunView.cs</DependentUpon>
     111    </Compile>
    100112    <Compile Include="UserDefinedAlgorithmView.cs">
    101113      <SubType>UserControl</SubType>
  • trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs

    r3226 r3260  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Drawing;
    24 using HeuristicLab.Collections;
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     
    120120    }
    121121
     122    public override void CollectParameterValues(IDictionary<string, IItem> values) {
     123      base.CollectParameterValues(values);
     124      Problem.CollectParameterValues(values);
     125    }
     126    public virtual void CollectResultValues(IDictionary<string, IItem> values) {
     127      foreach (IResult result in Results)
     128        values.Add(result.Name, result.Value != null ? (IItem)result.Value.Clone() : null);
     129    }
     130
    122131    #region Events
    123132    public event EventHandler ProblemChanged;
  • trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs

    r3246 r3260  
    2222using System;
    2323using System.Drawing;
    24 using HeuristicLab.Collections;
    2524using HeuristicLab.Core;
    2625using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    7473
    7574    [Storable]
    76     private ResultCollection results;
    77     public ResultCollection Results {
    78       get { return results; }
     75    private RunCollection runs;
     76    public RunCollection Runs {
     77      get { return runs; }
    7978    }
    8079
     
    103102
    104103    public bool Finished {
    105       get { return ((Algorithm == null) || (Algorithm.Finished && (results.Count >= repetitions))); }
     104      get { return ((Algorithm == null) || (Algorithm.Finished && (runs.Count >= repetitions))); }
    106105    }
    107106
     
    111110      : base() {
    112111      repetitions = 10;
    113       results = new ResultCollection();
     112      runs = new RunCollection();
    114113      executionTime = TimeSpan.Zero;
    115114    }
    116115    public BatchRun(string name) : base(name) {
    117116      repetitions = 10;
    118       results = new ResultCollection();
     117      runs = new RunCollection();
    119118      executionTime = TimeSpan.Zero;
    120119    }
    121120    public BatchRun(string name, string description) : base(name, description) {
    122121      repetitions = 10;
    123       results = new ResultCollection();
     122      runs = new RunCollection();
    124123      executionTime = TimeSpan.Zero;
    125124    }
     
    129128      clone.Algorithm = (IAlgorithm)cloner.Clone(algorithm);
    130129      clone.repetitions = repetitions;
    131       clone.results = (ResultCollection)cloner.Clone(results);
     130      clone.runs = (RunCollection)cloner.Clone(runs);
    132131      clone.executionTime = executionTime;
    133132      clone.running = running;
     
    137136
    138137    public void Prepare() {
    139       results.Clear();
     138      executionTime = TimeSpan.Zero;
     139      runs.Clear();
    140140      if (Algorithm != null) Algorithm.Prepare();
    141141      OnPrepared();
     
    196196
    197197    private void DeregisterAlgorithmEvents() {
    198       algorithm.Prepared -= new EventHandler(Algorithm_Prepared);
    199198      algorithm.RunningChanged -= new EventHandler(Algorithm_RunningChanged);
    200199      algorithm.ExceptionOccurred -= new EventHandler<HeuristicLab.Common.EventArgs<Exception>>(Algorithm_ExceptionOccurred);
     
    202201
    203202    private void RegisterAlgorithmEvents() {
    204       algorithm.Prepared += new EventHandler(Algorithm_Prepared);
    205203      algorithm.RunningChanged += new EventHandler(Algorithm_RunningChanged);
    206204      algorithm.ExceptionOccurred += new EventHandler<HeuristicLab.Common.EventArgs<Exception>>(Algorithm_ExceptionOccurred);
    207205    }
    208206
    209     private void Algorithm_Prepared(object sender, EventArgs e) {
    210       results.Add(new Result("Run " + DateTime.Now.ToString(), Algorithm.Results));
    211     }
    212207    private void Algorithm_RunningChanged(object sender, EventArgs e) {
    213208      if (Algorithm.Running) {
     
    215210        OnStarted();
    216211      } else {
    217         if (!canceled && (results.Count < repetitions)) {
     212        if (!canceled) {
    218213          ExecutionTime += Algorithm.ExecutionTime;
     214          runs.Add(new Run("Run " + Algorithm.ExecutionTime.ToString(), Algorithm));
    219215          Algorithm.Prepare();
    220           Algorithm.Start();
     216          if (runs.Count < repetitions) Algorithm.Start();
     217          else OnStopped();
    221218        } else {
    222           if (Algorithm.Finished) ExecutionTime += Algorithm.ExecutionTime;
    223219          OnStopped();
    224220        }
  • trunk/sources/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs

    r3226 r3260  
    216216      Engine.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred);
    217217      Engine.ExecutionTimeChanged += new EventHandler(Engine_ExecutionTimeChanged);
    218       Engine.Stopped += new EventHandler(Engine_Stopped);
     218      Engine.RunningChanged += new EventHandler(Engine_RunningChanged);
    219219    }
    220220    private void DeregisterEngineEvents() {
    221221      Engine.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred);
    222222      Engine.ExecutionTimeChanged -= new EventHandler(Engine_ExecutionTimeChanged);
    223       Engine.Stopped -= new EventHandler(Engine_Stopped);
     223      Engine.RunningChanged -= new EventHandler(Engine_RunningChanged);
    224224    }
    225225
     
    230230      OnExecutionTimeChanged();
    231231    }
    232     private void Engine_Stopped(object sender, EventArgs e) {
    233       OnStopped();
     232    private void Engine_RunningChanged(object sender, EventArgs e) {
     233      if (!Engine.Running) OnStopped();
    234234    }
    235235  }
  • trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r3246 r3260  
    8787    <Compile Include="Algorithm.cs" />
    8888    <Compile Include="BatchRun.cs" />
     89    <Compile Include="RunCollection.cs" />
     90    <Compile Include="Run.cs" />
    8991    <Compile Include="Interfaces\IMultiObjectiveSolutionsVisualizer.cs" />
    9092    <Compile Include="Interfaces\IResult.cs" />
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IAlgorithm.cs

    r3226 r3260  
    2121
    2222using System;
    23 using HeuristicLab.Collections;
     23using System.Collections.Generic;
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Core;
     
    4141    void Stop();
    4242
     43    void CollectResultValues(IDictionary<string, IItem> values);
     44
    4345    event EventHandler ProblemChanged;
    4446    event EventHandler ExecutionTimeChanged;
Note: See TracChangeset for help on using the changeset viewer.