Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3275 for trunk


Ignore:
Timestamp:
04/06/10 03:37:29 (15 years ago)
Author:
swagner
Message:

Continued work on algorithm batch processing (#947).

Location:
trunk/sources
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs

    r3274 r3275  
    179179    }
    180180
    181     public override void Prepare(bool clearResults) {
    182       if (Problem != null) base.Prepare(clearResults);
     181    public override void Prepare() {
     182      if (Problem != null) base.Prepare();
    183183    }
    184184
  • trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs

    r3274 r3275  
    154154    }
    155155
    156     public override void Prepare(bool clearResults) {
     156    public override void Prepare() {
    157157      if (Problem != null && MoveGenerator != null && MoveMaker != null && MoveEvaluator != null)
    158         base.Prepare(clearResults);
     158        base.Prepare();
    159159    }
    160160
  • trunk/sources/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealing.cs

    r3274 r3275  
    182182    }
    183183
    184     public override void Prepare(bool clearResults) {
     184    public override void Prepare() {
    185185      if (Problem != null && MoveGenerator != null && MoveMaker != null && MoveEvaluator != null)
    186         base.Prepare(clearResults);
     186        base.Prepare();
    187187    }
    188188
  • trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs

    r3274 r3275  
    176176    }
    177177
    178     public override void Prepare(bool clearResults) {
     178    public override void Prepare() {
    179179      if (Problem != null && MoveGenerator != null && MoveMaker != null && MoveEvaluator != null &&
    180180          TabuMoveEvaluator != null && TabuMoveMaker != null)
    181         base.Prepare(clearResults);
     181        base.Prepare();
    182182    }
    183183
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.Designer.cs

    r3262 r3275  
    6464      this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
    6565      this.stopButton = new System.Windows.Forms.Button();
     66      this.runsTabPage = new System.Windows.Forms.TabPage();
     67      this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();
    6668      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6769      this.tabControl.SuspendLayout();
     
    6971      this.problemTabPage.SuspendLayout();
    7072      this.resultsTabPage.SuspendLayout();
     73      this.runsTabPage.SuspendLayout();
    7174      this.SuspendLayout();
    7275      //
     
    8992      this.tabControl.Controls.Add(this.problemTabPage);
    9093      this.tabControl.Controls.Add(this.resultsTabPage);
     94      this.tabControl.Controls.Add(this.runsTabPage);
    9195      this.tabControl.Location = new System.Drawing.Point(0, 52);
    9296      this.tabControl.Name = "tabControl";
     
    281285      this.stopButton.UseVisualStyleBackColor = true;
    282286      this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
     287      //
     288      // runsTabPage
     289      //
     290      this.runsTabPage.Controls.Add(this.runsView);
     291      this.runsTabPage.Location = new System.Drawing.Point(4, 22);
     292      this.runsTabPage.Name = "runsTabPage";
     293      this.runsTabPage.Padding = new System.Windows.Forms.Padding(3);
     294      this.runsTabPage.Size = new System.Drawing.Size(671, 374);
     295      this.runsTabPage.TabIndex = 3;
     296      this.runsTabPage.Text = "Runs";
     297      this.runsTabPage.UseVisualStyleBackColor = true;
     298      //
     299      // runsView
     300      //
     301      this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     302                  | System.Windows.Forms.AnchorStyles.Left)
     303                  | System.Windows.Forms.AnchorStyles.Right)));
     304      this.runsView.Caption = "RunCollection";
     305      this.runsView.Content = null;
     306      this.runsView.Location = new System.Drawing.Point(6, 6);
     307      this.runsView.Name = "runsView";
     308      this.runsView.Size = new System.Drawing.Size(659, 362);
     309      this.runsView.TabIndex = 0;
    283310      //
    284311      // AlgorithmView
     
    311338      this.problemTabPage.ResumeLayout(false);
    312339      this.resultsTabPage.ResumeLayout(false);
     340      this.runsTabPage.ResumeLayout(false);
    313341      this.ResumeLayout(false);
    314342      this.PerformLayout();
     
    336364    protected HeuristicLab.Optimization.Views.ResultCollectionView resultsView;
    337365    protected System.Windows.Forms.Button stopButton;
     366    protected System.Windows.Forms.TabPage runsTabPage;
     367    protected RunCollectionView runsView;
    338368
    339369  }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs

    r3274 r3275  
    9696        problemViewHost.Content = null;
    9797        resultsView.Content = null;
     98        runsView.Content = null;
    9899        tabControl.Enabled = false;
    99100        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
     
    106107        problemViewHost.Content = Content.Problem;
    107108        resultsView.Content = Content.Results.AsReadOnly();
     109        runsView.Content = Content.Runs;
    108110        tabControl.Enabled = true;
    109111        EnableDisableButtons();
     
    144146        newProblemButton.Enabled = openProblemButton.Enabled = saveProblemButton.Enabled = Content.ExecutionState != ExecutionState.Started;
    145147        problemViewHost.Enabled = Content.ExecutionState != ExecutionState.Started;
    146         resultsView.Enabled = Content.ExecutionState != ExecutionState.Started;
    147148        EnableDisableButtons();
    148149      }
     
    237238    }
    238239    protected virtual void resetButton_Click(object sender, EventArgs e) {
    239       if (Content.Results.Count > 0) {
    240         if (MessageBox.Show(this, "Clear all results of this run?", "Clear All Results?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
     240      if (Content.Runs.Count > 0) {
     241        if (MessageBox.Show(this, "Clear all runs executed so far?", "Clear All Runs?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
    241242          Content.Prepare(true);
    242243        else
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentView.Designer.cs

    r3274 r3275  
    4747      this.tabControl = new System.Windows.Forms.TabControl();
    4848      this.optimizersTabPage = new System.Windows.Forms.TabPage();
     49      this.optimizerListView = new HeuristicLab.Optimization.Views.OptimizerListView();
    4950      this.startButton = new System.Windows.Forms.Button();
    5051      this.stopButton = new System.Windows.Forms.Button();
     
    5354      this.executionTimeTextBox = new System.Windows.Forms.TextBox();
    5455      this.pauseButton = new System.Windows.Forms.Button();
    55       this.optimizerListView = new HeuristicLab.Optimization.Views.OptimizerListView();
     56      this.runsTabPage = new System.Windows.Forms.TabPage();
     57      this.runsView = new HeuristicLab.Optimization.Views.RunCollectionView();
    5658      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5759      this.tabControl.SuspendLayout();
    5860      this.optimizersTabPage.SuspendLayout();
     61      this.runsTabPage.SuspendLayout();
    5962      this.SuspendLayout();
    6063      //
     
    7578                  | System.Windows.Forms.AnchorStyles.Right)));
    7679      this.tabControl.Controls.Add(this.optimizersTabPage);
     80      this.tabControl.Controls.Add(this.runsTabPage);
    7781      this.tabControl.Location = new System.Drawing.Point(0, 52);
    7882      this.tabControl.Name = "tabControl";
     
    9195      this.optimizersTabPage.Text = "Optimizers";
    9296      this.optimizersTabPage.UseVisualStyleBackColor = true;
     97      //
     98      // optimizerListView
     99      //
     100      this.optimizerListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     101                  | System.Windows.Forms.AnchorStyles.Left)
     102                  | System.Windows.Forms.AnchorStyles.Right)));
     103      this.optimizerListView.Caption = "OptimizerList";
     104      this.optimizerListView.Content = null;
     105      this.optimizerListView.Location = new System.Drawing.Point(6, 6);
     106      this.optimizerListView.Name = "optimizerListView";
     107      this.optimizerListView.Size = new System.Drawing.Size(659, 362);
     108      this.optimizerListView.TabIndex = 0;
    93109      //
    94110      // startButton
     
    159175      this.pauseButton.Click += new System.EventHandler(this.pauseButton_Click);
    160176      //
    161       // optimizerListView
    162       //
    163       this.optimizerListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     177      // runsTabPage
     178      //
     179      this.runsTabPage.Controls.Add(this.runsView);
     180      this.runsTabPage.Location = new System.Drawing.Point(4, 22);
     181      this.runsTabPage.Name = "runsTabPage";
     182      this.runsTabPage.Padding = new System.Windows.Forms.Padding(3);
     183      this.runsTabPage.Size = new System.Drawing.Size(671, 374);
     184      this.runsTabPage.TabIndex = 2;
     185      this.runsTabPage.Text = "Runs";
     186      this.runsTabPage.UseVisualStyleBackColor = true;
     187      //
     188      // runsView
     189      //
     190      this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    164191                  | System.Windows.Forms.AnchorStyles.Left)
    165192                  | System.Windows.Forms.AnchorStyles.Right)));
    166       this.optimizerListView.Caption = "OptimizerList";
    167       this.optimizerListView.Content = null;
    168       this.optimizerListView.Location = new System.Drawing.Point(6, 6);
    169       this.optimizerListView.Name = "optimizerListView";
    170       this.optimizerListView.Size = new System.Drawing.Size(659, 362);
    171       this.optimizerListView.TabIndex = 0;
     193      this.runsView.Caption = "RunCollection";
     194      this.runsView.Content = null;
     195      this.runsView.Location = new System.Drawing.Point(6, 6);
     196      this.runsView.Name = "runsView";
     197      this.runsView.Size = new System.Drawing.Size(659, 362);
     198      this.runsView.TabIndex = 0;
    172199      //
    173200      // ExperimentView
     
    198225      this.tabControl.ResumeLayout(false);
    199226      this.optimizersTabPage.ResumeLayout(false);
     227      this.runsTabPage.ResumeLayout(false);
    200228      this.ResumeLayout(false);
    201229      this.PerformLayout();
     
    213241    private System.Windows.Forms.Button pauseButton;
    214242    private OptimizerListView optimizerListView;
     243    private System.Windows.Forms.TabPage runsTabPage;
     244    private RunCollectionView runsView;
    215245
    216246  }
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/ExperimentView.cs

    r3274 r3275  
    7171      if (Content == null) {
    7272        optimizerListView.Content = null;
     73        runsView.Content = null;
    7374        tabControl.Enabled = false;
    7475        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
     
    7778      } else {
    7879        optimizerListView.Content = Content.Optimizers;
     80        runsView.Content = Content.Runs;
    7981        tabControl.Enabled = true;
    8082        EnableDisableButtons();
     
    125127    }
    126128    private void resetButton_Click(object sender, EventArgs e) {
    127       if (MessageBox.Show(this, "Clear all runs executed so far?", "Clear All Runs?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
    128         Content.Prepare(true);
    129       else
    130         Content.Prepare(false);
     129      if (Content.Runs.Count > 0) {
     130        if (MessageBox.Show(this, "Clear all runs executed so far?", "Clear All Runs?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
     131          Content.Prepare(true);
     132        else
     133          Content.Prepare(false);
     134      } else {
     135        Content.Prepare();
     136      }
    131137    }
    132138    #endregion
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/UserDefinedAlgorithmView.Designer.cs

    r3262 r3275  
    7676      this.tabControl.Controls.SetChildIndex(this.globalScopeTabPage, 0);
    7777      this.tabControl.Controls.SetChildIndex(this.operatorGraphTabPage, 0);
     78      this.tabControl.Controls.SetChildIndex(this.runsTabPage, 0);
    7879      this.tabControl.Controls.SetChildIndex(this.resultsTabPage, 0);
    7980      this.tabControl.Controls.SetChildIndex(this.engineTabPage, 0);
  • trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs

    r3274 r3275  
    9090    public abstract ResultCollection Results { get; }
    9191
     92    [Storable]
     93    private RunCollection runs;
     94    public RunCollection Runs {
     95      get { return runs; }
     96    }
     97
    9298    protected Algorithm()
    9399      : base() {
    94100      executionState = ExecutionState.Stopped;
    95101      executionTime = TimeSpan.Zero;
     102      runs = new RunCollection();
    96103    }
    97104    protected Algorithm(string name)
     
    99106      executionState = ExecutionState.Stopped;
    100107      executionTime = TimeSpan.Zero;
     108      runs = new RunCollection();
    101109    }
    102110    protected Algorithm(string name, ParameterCollection parameters)
     
    104112      executionState = ExecutionState.Stopped;
    105113      executionTime = TimeSpan.Zero;
     114      runs = new RunCollection();
    106115    }
    107116    protected Algorithm(string name, string description)
     
    109118      executionState = ExecutionState.Stopped;
    110119      executionTime = TimeSpan.Zero;
     120      runs = new RunCollection();
    111121    }
    112122    protected Algorithm(string name, string description, ParameterCollection parameters)
     
    114124      executionState = ExecutionState.Stopped;
    115125      executionTime = TimeSpan.Zero;
     126      runs = new RunCollection();
    116127    }
    117128
     
    121132      clone.executionTime = executionTime;
    122133      clone.Problem = (IProblem)cloner.Clone(problem);
     134      clone.runs = (RunCollection)cloner.Clone(runs);
    123135      return clone;
    124136    }
    125137
    126     public void Prepare() {
    127       Prepare(true);
    128     }
    129     public virtual void Prepare(bool clearResults) {
     138    public virtual void Prepare() {
    130139      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped))
    131140        throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState));
    132       ExecutionTime = TimeSpan.Zero;
     141    }
     142    public void Prepare(bool clearRuns) {
     143      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped))
     144        throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState));
     145      if (clearRuns) runs.Clear();
     146      Prepare();
    133147    }
    134148    public virtual void Start() {
     
    172186    public event EventHandler Prepared;
    173187    protected virtual void OnPrepared() {
     188      ExecutionTime = TimeSpan.Zero;
    174189      ExecutionState = ExecutionState.Prepared;
    175190      EventHandler handler = Prepared;
     
    190205    public event EventHandler Stopped;
    191206    protected virtual void OnStopped() {
     207      Run run = new Run("Run (" + ExecutionTime.ToString() + ")");
     208      CollectParameterValues(run.Parameters);
     209      CollectResultValues(run.Results);
     210      runs.Add(run);
    192211      ExecutionState = ExecutionState.Stopped;
    193212      EventHandler handler = Stopped;
  • trunk/sources/HeuristicLab.Optimization/3.3/BatchRun.cs

    r3274 r3275  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Collections;
    2728
    2829namespace HeuristicLab.Optimization {
     
    8384          if (algorithm != null) RegisterAlgorithmEvents();
    8485          OnAlgorithmChanged();
    85           Prepare();
     86          Prepare(true);
    8687        }
    8788      }
     
    9798          OnRepetitionsChanged();
    9899          if ((runs.Count < repetitions) && (Algorithm != null) && (Algorithm.ExecutionState == ExecutionState.Stopped))
    99             Prepare(false);
     100            Prepare();
    100101        }
    101102      }
     
    145146
    146147    public void Prepare() {
    147       Prepare(true);
    148     }
    149     public void Prepare(bool clearResults) {
     148      Prepare(false);
     149    }
     150    public void Prepare(bool clearRuns) {
    150151      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped))
    151152        throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState));
    152153      if (Algorithm != null) {
    153         if (clearResults) {
     154        if (clearRuns) {
    154155          ExecutionTime = TimeSpan.Zero;
    155156          runs.Clear();
    156157        }
    157         Algorithm.Prepare();
     158        Algorithm.Prepare(clearRuns);
    158159      }
    159160    }
     
    233234      algorithm.Started += new EventHandler(Algorithm_Started);
    234235      algorithm.Stopped += new EventHandler(Algorithm_Stopped);
     236      algorithm.Runs.CollectionReset += new CollectionItemsChangedEventHandler<Run>(Algorithm_Runs_CollectionReset);
     237      algorithm.Runs.ItemsAdded += new CollectionItemsChangedEventHandler<Run>(Algorithm_Runs_ItemsAdded);
     238      algorithm.Runs.ItemsRemoved += new CollectionItemsChangedEventHandler<Run>(Algorithm_Runs_ItemsRemoved);
    235239    }
    236240    private void DeregisterAlgorithmEvents() {
     
    241245      algorithm.Started -= new EventHandler(Algorithm_Started);
    242246      algorithm.Stopped -= new EventHandler(Algorithm_Stopped);
    243     }
    244 
     247      algorithm.Runs.CollectionReset -= new CollectionItemsChangedEventHandler<Run>(Algorithm_Runs_CollectionReset);
     248      algorithm.Runs.ItemsAdded -= new CollectionItemsChangedEventHandler<Run>(Algorithm_Runs_ItemsAdded);
     249      algorithm.Runs.ItemsRemoved -= new CollectionItemsChangedEventHandler<Run>(Algorithm_Runs_ItemsRemoved);
     250    }
    245251    private void Algorithm_ExceptionOccurred(object sender, EventArgs<Exception> e) {
    246252      OnExceptionOccurred(e.Value);
     
    261267    private void Algorithm_Stopped(object sender, EventArgs e) {
    262268      ExecutionTime += Algorithm.ExecutionTime;
    263       runs.Add(new Run("Run " + Algorithm.ExecutionTime.ToString(), Algorithm));
    264269      OnStopped();
    265270
     
    269274      }
    270275    }
     276    private void Algorithm_Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<Run> e) {
     277      Runs.RemoveRange(e.OldItems);
     278      Runs.AddRange(e.Items);
     279    }
     280    private void Algorithm_Runs_ItemsAdded(object sender, CollectionItemsChangedEventArgs<Run> e) {
     281      Runs.AddRange(e.Items);
     282    }
     283    private void Algorithm_Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<Run> e) {
     284      Runs.RemoveRange(e.Items);
     285    }
    271286    #endregion
    272287  }
  • trunk/sources/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs

    r3274 r3275  
    157157    }
    158158
    159     public override void Prepare(bool clearResults) {
    160       base.Prepare(clearResults);
    161 
    162       ResultCollection results = Results;
     159    public override void Prepare() {
     160      base.Prepare();
    163161      globalScope.Clear();
    164       if (clearResults)
    165         globalScope.Variables.Add(new Variable("Results", new ResultCollection()));
    166       else
    167         globalScope.Variables.Add(new Variable("Results", results));
     162      globalScope.Variables.Add(new Variable("Results", new ResultCollection()));
    168163
    169164      if (engine != null) {
  • trunk/sources/HeuristicLab.Optimization/3.3/Experiment.cs

    r3274 r3275  
    7777    }
    7878
     79    [Storable]
     80    private RunCollection runs;
     81    public RunCollection Runs {
     82      get { return runs; }
     83    }
     84
    7985    private bool stopPending;
    8086
     
    8490      executionTime = TimeSpan.Zero;
    8591      Optimizers = new OptimizerList();
     92      runs = new RunCollection();
    8693      stopPending = false;
    8794    }
     
    9097      executionTime = TimeSpan.Zero;
    9198      Optimizers = new OptimizerList();
     99      runs = new RunCollection();
    92100      stopPending = false;
    93101    }
     
    96104      executionTime = TimeSpan.Zero;
    97105      Optimizers = new OptimizerList();
     106      runs = new RunCollection();
    98107      stopPending = false;
    99108    }
     
    104113      clone.executionTime = executionTime;
    105114      clone.Optimizers = (OptimizerList)cloner.Clone(optimizers);
     115      clone.runs = (RunCollection)cloner.Clone(runs);
    106116      clone.stopPending = stopPending;
    107117      return clone;
     
    109119
    110120    public void Prepare() {
    111       Prepare(true);
    112     }
    113     public void Prepare(bool clearResults) {
     121      Prepare(false);
     122    }
     123    public void Prepare(bool clearRuns) {
    114124      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused) && (ExecutionState != ExecutionState.Stopped))
    115125        throw new InvalidOperationException(string.Format("Prepare not allowed in execution state \"{0}\".", ExecutionState));
    116126      if (Optimizers.Count > 0) {
     127        if (clearRuns) runs.Clear();
    117128        foreach (IOptimizer optimizer in Optimizers.Where(x => x.ExecutionState != ExecutionState.Started))
    118           optimizer.Prepare(clearResults);
     129          optimizer.Prepare(clearRuns);
    119130      }
    120131    }
     
    233244      optimizer.Started += new EventHandler(optimizer_Started);
    234245      optimizer.Stopped += new EventHandler(optimizer_Stopped);
    235     }
    236 
     246      optimizer.Runs.CollectionReset += new CollectionItemsChangedEventHandler<Run>(optimizer_Runs_CollectionReset);
     247      optimizer.Runs.ItemsAdded += new CollectionItemsChangedEventHandler<Run>(optimizer_Runs_ItemsAdded);
     248      optimizer.Runs.ItemsRemoved += new CollectionItemsChangedEventHandler<Run>(optimizer_Runs_ItemsRemoved);
     249    }
    237250    private void DeregisterOptimizerEvents(IOptimizer optimizer) {
    238251      optimizer.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(optimizer_ExceptionOccurred);
     
    242255      optimizer.Started -= new EventHandler(optimizer_Started);
    243256      optimizer.Stopped -= new EventHandler(optimizer_Stopped);
     257      optimizer.Runs.CollectionReset -= new CollectionItemsChangedEventHandler<Run>(optimizer_Runs_CollectionReset);
     258      optimizer.Runs.ItemsAdded -= new CollectionItemsChangedEventHandler<Run>(optimizer_Runs_ItemsAdded);
     259      optimizer.Runs.ItemsRemoved -= new CollectionItemsChangedEventHandler<Run>(optimizer_Runs_ItemsRemoved);
    244260    }
    245261    private void optimizer_ExceptionOccurred(object sender, EventArgs<Exception> e) {
     
    275291      }
    276292    }
     293    private void optimizer_Runs_CollectionReset(object sender, CollectionItemsChangedEventArgs<Run> e) {
     294      Runs.RemoveRange(e.OldItems);
     295      Runs.AddRange(e.Items);
     296    }
     297    private void optimizer_Runs_ItemsAdded(object sender, CollectionItemsChangedEventArgs<Run> e) {
     298      Runs.AddRange(e.Items);
     299    }
     300    private void optimizer_Runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<Run> e) {
     301      Runs.RemoveRange(e.Items);
     302    }
    277303    #endregion
    278304  }
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IOptimizer.cs

    r3274 r3275  
    2626  /// Interface to represent optimizers such as algorithms, batch runs, or experiments.
    2727  /// </summary>
    28   public interface IOptimizer : IExecutable {
    29     void Prepare(bool clearResults);
     28  public interface IOptimizer : INamedItem, IExecutable {
     29    RunCollection Runs { get; }
     30
     31    void Prepare(bool clearRuns);
    3032  }
    3133}
  • trunk/sources/HeuristicLab.Optimization/3.3/Run.cs

    r3260 r3275  
    5959      results = new Dictionary<string, IItem>();
    6060    }
    61     public Run(string name, IAlgorithm algorithm)
    62       : base(name) {
    63       parameters = new Dictionary<string, IItem>();
    64       results = new Dictionary<string, IItem>();
    65       algorithm.CollectParameterValues(parameters);
    66       algorithm.CollectResultValues(results);
    67     }
    6861    public Run(string name, string description)
    6962      : base(name, description) {
    7063      parameters = new Dictionary<string, IItem>();
    7164      results = new Dictionary<string, IItem>();
    72     }
    73     public Run(string name, string description, IAlgorithm algorithm)
    74       : base(name, description) {
    75       parameters = new Dictionary<string, IItem>();
    76       results = new Dictionary<string, IItem>();
    77       algorithm.CollectParameterValues(parameters);
    78       algorithm.CollectResultValues(results);
    7965    }
    8066
Note: See TracChangeset for help on using the changeset viewer.