Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4102


Ignore:
Timestamp:
07/25/10 02:57:07 (14 years ago)
Author:
swagner
Message:

Enabled users to choose whether runs should contain a copy of their algorithm or not (#1105)

Location:
trunk/sources
Files:
7 edited

Legend:

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

    r4011 r4102  
    4747    private void InitializeComponent() {
    4848      this.tabControl = new System.Windows.Forms.TabControl();
    49       this.parametersTabPage = new System.Windows.Forms.TabPage();
    50       this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
    5149      this.problemTabPage = new System.Windows.Forms.TabPage();
    5250      this.problemViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    5351      this.openProblemButton = new System.Windows.Forms.Button();
    5452      this.newProblemButton = new System.Windows.Forms.Button();
     53      this.parametersTabPage = new System.Windows.Forms.TabPage();
     54      this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
    5555      this.resultsTabPage = new System.Windows.Forms.TabPage();
    5656      this.resultsView = new HeuristicLab.Optimization.Views.ResultCollectionView();
     
    6464      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
    6565      this.stopButton = new System.Windows.Forms.Button();
     66      this.storeAlgorithmInEachRunCheckBox = new System.Windows.Forms.CheckBox();
    6667      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6768      this.tabControl.SuspendLayout();
     69      this.problemTabPage.SuspendLayout();
    6870      this.parametersTabPage.SuspendLayout();
    69       this.problemTabPage.SuspendLayout();
    7071      this.resultsTabPage.SuspendLayout();
    7172      this.runsTabPage.SuspendLayout();
     
    9697      this.tabControl.Size = new System.Drawing.Size(679, 400);
    9798      this.tabControl.TabIndex = 4;
    98       //
    99       // parametersTabPage
    100       //
    101       this.parametersTabPage.Controls.Add(this.parameterCollectionView);
    102       this.parametersTabPage.Location = new System.Drawing.Point(4, 22);
    103       this.parametersTabPage.Name = "parametersTabPage";
    104       this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3);
    105       this.parametersTabPage.Size = new System.Drawing.Size(671, 374);
    106       this.parametersTabPage.TabIndex = 1;
    107       this.parametersTabPage.Text = "Parameters";
    108       this.parametersTabPage.UseVisualStyleBackColor = true;
    109       //
    110       // parameterCollectionView
    111       //
    112       this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    113                   | System.Windows.Forms.AnchorStyles.Left)
    114                   | System.Windows.Forms.AnchorStyles.Right)));
    115       this.parameterCollectionView.Content = null;
    116       this.parameterCollectionView.Location = new System.Drawing.Point(6, 6);
    117       this.parameterCollectionView.Name = "parameterCollectionView";
    118       this.parameterCollectionView.Size = new System.Drawing.Size(659, 362);
    119       this.parameterCollectionView.TabIndex = 0;
    12099      //
    121100      // problemTabPage
     
    135114      //
    136115      this.problemViewHost.AllowDrop = true;
     116      this.problemViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     117                  | System.Windows.Forms.AnchorStyles.Left)
     118                  | System.Windows.Forms.AnchorStyles.Right)));
     119      this.problemViewHost.Caption = "View";
    137120      this.problemViewHost.Content = null;
    138       this.problemViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    139                   | System.Windows.Forms.AnchorStyles.Left)
    140                   | System.Windows.Forms.AnchorStyles.Right)));
    141121      this.problemViewHost.Location = new System.Drawing.Point(6, 36);
    142122      this.problemViewHost.Name = "problemViewHost";
     123      this.problemViewHost.ReadOnly = false;
    143124      this.problemViewHost.Size = new System.Drawing.Size(659, 332);
    144125      this.problemViewHost.TabIndex = 3;
    145126      this.problemViewHost.ViewType = null;
    146       this.problemViewHost.DragOver += new System.Windows.Forms.DragEventHandler(this.problemViewHost_DragEnterOver);
    147127      this.problemViewHost.DragDrop += new System.Windows.Forms.DragEventHandler(this.problemViewHost_DragDrop);
    148128      this.problemViewHost.DragEnter += new System.Windows.Forms.DragEventHandler(this.problemViewHost_DragEnterOver);
     129      this.problemViewHost.DragOver += new System.Windows.Forms.DragEventHandler(this.problemViewHost_DragEnterOver);
    149130      //
    150131      // openProblemButton
     
    170151      this.newProblemButton.Click += new System.EventHandler(this.newProblemButton_Click);
    171152      //
     153      // parametersTabPage
     154      //
     155      this.parametersTabPage.Controls.Add(this.parameterCollectionView);
     156      this.parametersTabPage.Location = new System.Drawing.Point(4, 22);
     157      this.parametersTabPage.Name = "parametersTabPage";
     158      this.parametersTabPage.Padding = new System.Windows.Forms.Padding(3);
     159      this.parametersTabPage.Size = new System.Drawing.Size(671, 374);
     160      this.parametersTabPage.TabIndex = 1;
     161      this.parametersTabPage.Text = "Parameters";
     162      this.parametersTabPage.UseVisualStyleBackColor = true;
     163      //
     164      // parameterCollectionView
     165      //
     166      this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     167                  | System.Windows.Forms.AnchorStyles.Left)
     168                  | System.Windows.Forms.AnchorStyles.Right)));
     169      this.parameterCollectionView.Caption = "ParameterCollection View";
     170      this.parameterCollectionView.Content = null;
     171      this.parameterCollectionView.Location = new System.Drawing.Point(6, 6);
     172      this.parameterCollectionView.Name = "parameterCollectionView";
     173      this.parameterCollectionView.ReadOnly = false;
     174      this.parameterCollectionView.Size = new System.Drawing.Size(659, 362);
     175      this.parameterCollectionView.TabIndex = 0;
     176      //
    172177      // resultsTabPage
    173178      //
     
    186191                  | System.Windows.Forms.AnchorStyles.Left)
    187192                  | System.Windows.Forms.AnchorStyles.Right)));
     193      this.resultsView.Caption = "ResultCollection View";
    188194      this.resultsView.Content = null;
    189195      this.resultsView.Location = new System.Drawing.Point(6, 6);
    190196      this.resultsView.Name = "resultsView";
     197      this.resultsView.ReadOnly = true;
    191198      this.resultsView.Size = new System.Drawing.Size(659, 362);
    192199      this.resultsView.TabIndex = 0;
     
    194201      // runsTabPage
    195202      //
     203      this.runsTabPage.Controls.Add(this.storeAlgorithmInEachRunCheckBox);
    196204      this.runsTabPage.Controls.Add(this.runsView);
    197205      this.runsTabPage.Location = new System.Drawing.Point(4, 22);
     
    208216                  | System.Windows.Forms.AnchorStyles.Left)
    209217                  | System.Windows.Forms.AnchorStyles.Right)));
     218      this.runsView.Caption = "RunCollection View";
    210219      this.runsView.Content = null;
    211220      this.runsView.Location = new System.Drawing.Point(6, 6);
    212221      this.runsView.Name = "runsView";
     222      this.runsView.ReadOnly = false;
    213223      this.runsView.Size = new System.Drawing.Size(659, 362);
    214224      this.runsView.TabIndex = 0;
     
    287297      this.stopButton.UseVisualStyleBackColor = true;
    288298      this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
     299      //
     300      // storeAlgorithmInEachRunCheckBox
     301      //
     302      this.storeAlgorithmInEachRunCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     303      this.storeAlgorithmInEachRunCheckBox.AutoSize = true;
     304      this.storeAlgorithmInEachRunCheckBox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
     305      this.storeAlgorithmInEachRunCheckBox.Checked = true;
     306      this.storeAlgorithmInEachRunCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
     307      this.storeAlgorithmInEachRunCheckBox.Location = new System.Drawing.Point(503, 6);
     308      this.storeAlgorithmInEachRunCheckBox.Name = "storeAlgorithmInEachRunCheckBox";
     309      this.storeAlgorithmInEachRunCheckBox.Size = new System.Drawing.Size(161, 17);
     310      this.storeAlgorithmInEachRunCheckBox.TabIndex = 1;
     311      this.storeAlgorithmInEachRunCheckBox.Text = "&Store Algorithm in each Run:";
     312      this.toolTip.SetToolTip(this.storeAlgorithmInEachRunCheckBox, "Check to store a copy of the algorithm in each run.");
     313      this.storeAlgorithmInEachRunCheckBox.UseVisualStyleBackColor = true;
     314      this.storeAlgorithmInEachRunCheckBox.CheckedChanged += new System.EventHandler(this.storeAlgorithmInEachRunCheckBox_CheckedChanged);
    289315      //
    290316      // AlgorithmView
     
    314340      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    315341      this.tabControl.ResumeLayout(false);
     342      this.problemTabPage.ResumeLayout(false);
    316343      this.parametersTabPage.ResumeLayout(false);
    317       this.problemTabPage.ResumeLayout(false);
    318344      this.resultsTabPage.ResumeLayout(false);
    319345      this.runsTabPage.ResumeLayout(false);
     346      this.runsTabPage.PerformLayout();
    320347      this.ResumeLayout(false);
    321348      this.PerformLayout();
     
    343370    protected System.Windows.Forms.TabPage runsTabPage;
    344371    protected RunCollectionView runsView;
     372    protected System.Windows.Forms.CheckBox storeAlgorithmInEachRunCheckBox;
    345373  }
    346374}
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/AlgorithmView.cs

    r4070 r4102  
    7474      Content.Stopped -= new EventHandler(Content_Stopped);
    7575      Content.ProblemChanged -= new EventHandler(Content_ProblemChanged);
     76      Content.StoreAlgorithmInEachRunChanged -= new EventHandler(Content_StoreAlgorithmInEachRunChanged);
    7677      base.DeregisterContentEvents();
    7778    }
     
    8687      Content.Stopped += new EventHandler(Content_Stopped);
    8788      Content.ProblemChanged += new EventHandler(Content_ProblemChanged);
     89      Content.StoreAlgorithmInEachRunChanged += new EventHandler(Content_StoreAlgorithmInEachRunChanged);
    8890    }
    8991
     
    9597        resultsView.Content = null;
    9698        runsView.Content = null;
     99        storeAlgorithmInEachRunCheckBox.Checked = true;
    97100        executionTimeTextBox.Text = "-";
    98101      } else {
     
    102105        resultsView.Content = Content.Results.AsReadOnly();
    103106        runsView.Content = Content.Runs;
     107        storeAlgorithmInEachRunCheckBox.Checked = Content.StoreAlgorithmInEachRun;
    104108        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    105109      }
     
    114118      resultsView.Enabled = Content != null;
    115119      runsView.Enabled = Content != null;
     120      storeAlgorithmInEachRunCheckBox.Enabled = Content != null && !ReadOnly;
    116121      executionTimeTextBox.Enabled = Content != null;
    117122      SetEnabledStateOfExecutableButtons();
     
    138143        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
    139144    }
     145    protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) {
     146      if (InvokeRequired)
     147        Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
     148      else
     149        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
     150    }
     151    protected virtual void Content_StoreAlgorithmInEachRunChanged(object sender, EventArgs e) {
     152      if (InvokeRequired)
     153        Invoke(new EventHandler(Content_StoreAlgorithmInEachRunChanged), sender, e);
     154      else
     155        storeAlgorithmInEachRunCheckBox.Checked = Content.StoreAlgorithmInEachRun;
     156    }
    140157    protected virtual void Content_Prepared(object sender, EventArgs e) {
    141158      if (InvokeRequired)
     
    170187        SetEnabledStateOfExecutableButtons();
    171188      }
    172     }
    173     protected virtual void Content_ExecutionTimeChanged(object sender, EventArgs e) {
    174       if (InvokeRequired)
    175         Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
    176       else
    177         executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    178189    }
    179190    protected virtual void Content_ExceptionOccurred(object sender, EventArgs<Exception> e) {
     
    233244      }
    234245    }
     246    protected virtual void storeAlgorithmInEachRunCheckBox_CheckedChanged(object sender, EventArgs e) {
     247      if (Content != null) Content.StoreAlgorithmInEachRun = storeAlgorithmInEachRunCheckBox.Checked;
     248    }
    235249    protected virtual void startButton_Click(object sender, EventArgs e) {
    236250      Content.Start();
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/EngineAlgorithmView.Designer.cs

    r4011 r4102  
    117117      //
    118118      this.executionTimeLabel.Location = new System.Drawing.Point(487, 532);
    119       this.executionTimeLabel.TabIndex = 9;
    120119      //
    121120      // executionTimeTextBox
    122121      //
    123122      this.executionTimeTextBox.Location = new System.Drawing.Point(576, 529);
    124       this.executionTimeTextBox.TabIndex = 10;
    125123      //
    126124      // resultsTabPage
     
    145143      this.runsView.Size = new System.Drawing.Size(693, 429);
    146144      //
    147       // problemPanel
    148       //
    149       this.problemViewHost.Size = new System.Drawing.Size(693, 399);
     145      // storeAlgorithmInEachRunCheckBox
     146      //
     147      this.storeAlgorithmInEachRunCheckBox.Location = new System.Drawing.Point(530, 6);
    150148      //
    151149      // nameTextBox
     
    198196                  | System.Windows.Forms.AnchorStyles.Left)
    199197                  | System.Windows.Forms.AnchorStyles.Right)));
     198      this.engineViewHost.Caption = "View";
    200199      this.engineViewHost.Content = null;
    201200      this.engineViewHost.Location = new System.Drawing.Point(6, 33);
     
    245244                  | System.Windows.Forms.AnchorStyles.Left)
    246245                  | System.Windows.Forms.AnchorStyles.Right)));
     246      this.operatorGraphViewHost.Caption = "View";
    247247      this.operatorGraphViewHost.Content = null;
    248248      this.operatorGraphViewHost.Location = new System.Drawing.Point(3, 33);
     
    259259      this.Name = "EngineAlgorithmView";
    260260      this.Size = new System.Drawing.Size(713, 549);
    261       this.Controls.SetChildIndex(this.stopButton, 0);
    262       this.Controls.SetChildIndex(this.resetButton, 0);
    263       this.Controls.SetChildIndex(this.pauseButton, 0);
    264       this.Controls.SetChildIndex(this.executionTimeLabel, 0);
    265       this.Controls.SetChildIndex(this.executionTimeTextBox, 0);
    266       this.Controls.SetChildIndex(this.startButton, 0);
    267       this.Controls.SetChildIndex(this.tabControl, 0);
    268       this.Controls.SetChildIndex(this.nameLabel, 0);
    269       this.Controls.SetChildIndex(this.descriptionLabel, 0);
    270       this.Controls.SetChildIndex(this.nameTextBox, 0);
    271       this.Controls.SetChildIndex(this.descriptionTextBox, 0);
    272261      this.tabControl.ResumeLayout(false);
    273262      this.parametersTabPage.ResumeLayout(false);
     
    275264      this.resultsTabPage.ResumeLayout(false);
    276265      this.runsTabPage.ResumeLayout(false);
     266      this.runsTabPage.PerformLayout();
    277267      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    278268      this.engineTabPage.ResumeLayout(false);
  • trunk/sources/HeuristicLab.Optimization.Views/3.3/RunView.cs

    r4099 r4102  
    8080      viewHost.Enabled = Content != null;
    8181      changeColorButton.Enabled = Content != null;
    82       showAlgorithmButton.Enabled = Content != null && !Locked;
     82      showAlgorithmButton.Enabled = Content != null && Content.Algorithm != null && !Locked;
    8383    }
    8484
  • trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs

    r3785 r4102  
    9292
    9393    [Storable]
     94    private bool storeAlgorithmInEachRun;
     95    public bool StoreAlgorithmInEachRun {
     96      get { return storeAlgorithmInEachRun; }
     97      set {
     98        if (storeAlgorithmInEachRun != value) {
     99          storeAlgorithmInEachRun = value;
     100          OnStoreAlgorithmInEachRunChanged();
     101        }
     102      }
     103    }
     104
     105    [Storable]
    94106    protected int runsCounter;
    95107
     
    112124      executionState = ExecutionState.Stopped;
    113125      executionTime = TimeSpan.Zero;
     126      storeAlgorithmInEachRun = true;
    114127      runsCounter = 0;
    115128      Runs = new RunCollection();
     
    119132      executionState = ExecutionState.Stopped;
    120133      executionTime = TimeSpan.Zero;
     134      storeAlgorithmInEachRun = true;
    121135      runsCounter = 0;
    122136      Runs = new RunCollection();
     
    126140      executionState = ExecutionState.Stopped;
    127141      executionTime = TimeSpan.Zero;
     142      storeAlgorithmInEachRun = true;
    128143      runsCounter = 0;
    129144      Runs = new RunCollection();
     
    133148      executionState = ExecutionState.Stopped;
    134149      executionTime = TimeSpan.Zero;
     150      storeAlgorithmInEachRun = true;
    135151      runsCounter = 0;
    136152      Runs = new RunCollection();
     
    140156      executionState = ExecutionState.Stopped;
    141157      executionTime = TimeSpan.Zero;
     158      storeAlgorithmInEachRun = true;
    142159      runsCounter = 0;
    143160      Runs = new RunCollection();
    144161    }
    145162    [StorableConstructor]
    146     protected Algorithm(bool deserializing) : base(deserializing) { }
     163    protected Algorithm(bool deserializing)
     164      : base(deserializing) {
     165      storeAlgorithmInEachRun = true;
     166    }
    147167
    148168    [StorableHook(HookType.AfterDeserialization)]
     
    158178      clone.executionTime = executionTime;
    159179      clone.problem = (IProblem)cloner.Clone(problem);
     180      clone.storeAlgorithmInEachRun = storeAlgorithmInEachRun;
    160181      clone.runsCounter = runsCounter;
    161182      clone.runs = (RunCollection)cloner.Clone(runs);
     
    173194        algorithm.executionTime = executionTime;
    174195        algorithm.problem = (IProblem)cloner.Clone(problem);
     196        algorithm.storeAlgorithmInEachRun = storeAlgorithmInEachRun;
    175197        algorithm.runsCounter = runsCounter;
    176198        algorithm.runs = (RunCollection)cloner.Clone(runs);
     
    234256      if (handler != null) handler(this, EventArgs.Empty);
    235257    }
     258    public event EventHandler StoreAlgorithmInEachRunChanged;
     259    protected virtual void OnStoreAlgorithmInEachRunChanged() {
     260      EventHandler handler = StoreAlgorithmInEachRunChanged;
     261      if (handler != null) handler(this, EventArgs.Empty);
     262    }
    236263    public event EventHandler Prepared;
    237264    protected virtual void OnPrepared() {
  • trunk/sources/HeuristicLab.Optimization/3.3/Interfaces/IAlgorithm.cs

    r4068 r4102  
    3232    IProblem Problem { get; set; }
    3333    ResultCollection Results { get; }
     34    bool StoreAlgorithmInEachRun { get; set; }
    3435
    3536    void CollectResultValues(IDictionary<string, IItem> values);
    3637
    3738    event EventHandler ProblemChanged;
     39    event EventHandler StoreAlgorithmInEachRunChanged;
    3840  }
    3941}
  • trunk/sources/HeuristicLab.Optimization/3.3/Run.cs

    r4068 r4102  
    9090      name = algorithm.Name + " Run (" + algorithm.ExecutionTime.ToString() + ")";
    9191      description = ItemDescription;
    92       Initialize((IAlgorithm)algorithm.Clone());
     92      Initialize(algorithm);
    9393    }
    9494    public Run(string name, IAlgorithm algorithm)
     
    9696      if (algorithm == null) throw new ArgumentNullException();
    9797      description = ItemDescription;
    98       Initialize((IAlgorithm)algorithm.Clone());
     98      Initialize(algorithm);
    9999    }
    100100    public Run(string name, string description, IAlgorithm algorithm)
    101101      : base(name, description) {
    102102      if (algorithm == null) throw new ArgumentNullException();
    103       Initialize((IAlgorithm)algorithm.Clone());
     103      Initialize(algorithm);
    104104    }
    105105
    106106    private void Initialize(IAlgorithm algorithm) {
    107       this.algorithm = algorithm;
     107      IAlgorithm clone = (IAlgorithm)algorithm.Clone();
    108108      parameters = new Dictionary<string, IItem>();
    109109      results = new Dictionary<string, IItem>();
    110       this.algorithm.CollectParameterValues(parameters);
    111       this.algorithm.CollectResultValues(results);
    112       this.algorithm.Prepare(true);
     110      clone.CollectParameterValues(parameters);
     111      clone.CollectResultValues(results);
     112      if (clone.StoreAlgorithmInEachRun) {
     113        clone.Prepare(true);
     114        this.algorithm = clone;
     115      }
    113116    }
    114117
Note: See TracChangeset for help on using the changeset viewer.