Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8961


Ignore:
Timestamp:
11/28/12 11:03:38 (12 years ago)
Author:
abeham
Message:

#1985: added ability to edit snapshot times (changed representation to a list of timespan instead of a list of double)

Location:
branches/RuntimeOptimizer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/RuntimeOptimizer/HeuristicLab.Optimization.Views/3.3/TimeLimitRunView.Designer.cs

    r8956 r8961  
    3838      this.timeLimitTextBox = new System.Windows.Forms.TextBox();
    3939      this.label1 = new System.Windows.Forms.Label();
    40       this.snapShotsTextBox = new System.Windows.Forms.TextBox();
     40      this.snapshotsTextBox = new System.Windows.Forms.TextBox();
    4141      this.storeAlgorithmInEachSnapshotCheckBox = new System.Windows.Forms.CheckBox();
    4242      this.tabControl = new HeuristicLab.MainForm.WindowsForms.DragOverTabControl();
     
    6161      //
    6262      this.startButton.Location = new System.Drawing.Point(0, 440);
     63      this.startButton.TabIndex = 9;
    6364      this.toolTip.SetToolTip(this.startButton, "Start/Resume Optimizer");
    6465      //
    6566      // executionTimeTextBox
    6667      //
    67       this.executionTimeTextBox.Location = new System.Drawing.Point(295, 444);
     68      this.executionTimeTextBox.Location = new System.Drawing.Point(412, 444);
    6869      //
    6970      // executionTimeLabel
    7071      //
    71       this.executionTimeLabel.Location = new System.Drawing.Point(206, 447);
     72      this.executionTimeLabel.Location = new System.Drawing.Point(323, 447);
    7273      //
    7374      // pauseButton
    7475      //
    7576      this.pauseButton.Location = new System.Drawing.Point(30, 440);
     77      this.pauseButton.TabIndex = 10;
    7678      this.toolTip.SetToolTip(this.pauseButton, "Pause Optimizer");
    7779      //
     
    7981      //
    8082      this.stopButton.Location = new System.Drawing.Point(60, 440);
     83      this.stopButton.TabIndex = 11;
    8184      this.toolTip.SetToolTip(this.stopButton, "Stop Optimizer");
    8285      //
     
    8487      //
    8588      this.resetButton.Location = new System.Drawing.Point(90, 440);
     89      this.resetButton.TabIndex = 12;
    8690      this.toolTip.SetToolTip(this.resetButton, "Reset Optimizer");
    8791      //
     
    9195      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    9296      this.nameTextBox.Location = new System.Drawing.Point(69, 0);
    93       this.nameTextBox.Size = new System.Drawing.Size(338, 20);
     97      this.nameTextBox.Size = new System.Drawing.Size(455, 20);
     98      //
     99      // infoLabel
     100      //
     101      this.infoLabel.Location = new System.Drawing.Point(530, 3);
    94102      //
    95103      // timeLimitLabel
     
    99107      this.timeLimitLabel.Name = "timeLimitLabel";
    100108      this.timeLimitLabel.Size = new System.Drawing.Size(53, 13);
    101       this.timeLimitLabel.TabIndex = 16;
     109      this.timeLimitLabel.TabIndex = 3;
    102110      this.timeLimitLabel.Text = "Time limit:";
    103111      //
    104112      // timeLimitTextBox
    105113      //
    106       this.timeLimitTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     114      this.timeLimitTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    107115            | System.Windows.Forms.AnchorStyles.Right)));
    108116      this.timeLimitTextBox.Location = new System.Drawing.Point(69, 26);
    109117      this.timeLimitTextBox.Name = "timeLimitTextBox";
    110       this.timeLimitTextBox.Size = new System.Drawing.Size(338, 20);
    111       this.timeLimitTextBox.TabIndex = 17;
     118      this.timeLimitTextBox.Size = new System.Drawing.Size(455, 20);
     119      this.timeLimitTextBox.TabIndex = 4;
    112120      this.timeLimitTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.timeLimitTextBox_Validating);
    113121      //
     
    118126      this.label1.Name = "label1";
    119127      this.label1.Size = new System.Drawing.Size(60, 13);
    120       this.label1.TabIndex = 16;
     128      this.label1.TabIndex = 5;
    121129      this.label1.Text = "Snapshots:";
    122130      //
    123       // snapShotsTextBox
    124       //
    125       this.snapShotsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    126             | System.Windows.Forms.AnchorStyles.Right)));
    127       this.snapShotsTextBox.Location = new System.Drawing.Point(69, 52);
    128       this.snapShotsTextBox.Name = "snapShotsTextBox";
    129       this.snapShotsTextBox.Size = new System.Drawing.Size(142, 20);
    130       this.snapShotsTextBox.TabIndex = 17;
     131      // snapshotsTextBox
     132      //
     133      this.snapshotsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     134            | System.Windows.Forms.AnchorStyles.Right)));
     135      this.snapshotsTextBox.Location = new System.Drawing.Point(69, 52);
     136      this.snapshotsTextBox.Name = "snapshotsTextBox";
     137      this.snapshotsTextBox.Size = new System.Drawing.Size(259, 20);
     138      this.snapshotsTextBox.TabIndex = 6;
     139      this.snapshotsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.snapshotsTextBox_Validating);
    131140      //
    132141      // storeAlgorithmInEachSnapshotCheckBox
     
    134143      this.storeAlgorithmInEachSnapshotCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    135144      this.storeAlgorithmInEachSnapshotCheckBox.AutoSize = true;
    136       this.storeAlgorithmInEachSnapshotCheckBox.Location = new System.Drawing.Point(223, 54);
     145      this.storeAlgorithmInEachSnapshotCheckBox.Location = new System.Drawing.Point(340, 54);
    137146      this.storeAlgorithmInEachSnapshotCheckBox.Name = "storeAlgorithmInEachSnapshotCheckBox";
    138147      this.storeAlgorithmInEachSnapshotCheckBox.Size = new System.Drawing.Size(184, 17);
    139       this.storeAlgorithmInEachSnapshotCheckBox.TabIndex = 18;
     148      this.storeAlgorithmInEachSnapshotCheckBox.TabIndex = 7;
    140149      this.storeAlgorithmInEachSnapshotCheckBox.Text = "Store Algorithm in Each Snapshot";
    141150      this.storeAlgorithmInEachSnapshotCheckBox.UseVisualStyleBackColor = true;
     
    145154      //
    146155      this.tabControl.AllowDrop = true;
    147       this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    148             | System.Windows.Forms.AnchorStyles.Left) 
     156      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     157            | System.Windows.Forms.AnchorStyles.Left)
    149158            | System.Windows.Forms.AnchorStyles.Right)));
    150159      this.tabControl.Controls.Add(this.algorithmTabPage);
     
    154163      this.tabControl.Name = "tabControl";
    155164      this.tabControl.SelectedIndex = 0;
    156       this.tabControl.Size = new System.Drawing.Size(429, 356);
    157       this.tabControl.TabIndex = 19;
     165      this.tabControl.Size = new System.Drawing.Size(546, 356);
     166      this.tabControl.TabIndex = 8;
    158167      //
    159168      // algorithmTabPage
     
    166175      this.algorithmTabPage.Name = "algorithmTabPage";
    167176      this.algorithmTabPage.Padding = new System.Windows.Forms.Padding(3);
    168       this.algorithmTabPage.Size = new System.Drawing.Size(421, 330);
     177      this.algorithmTabPage.Size = new System.Drawing.Size(538, 330);
    169178      this.algorithmTabPage.TabIndex = 1;
    170179      this.algorithmTabPage.Text = "Algorithm";
     
    176185      // algorithmViewHost
    177186      //
    178       this.algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    179             | System.Windows.Forms.AnchorStyles.Left) 
     187      this.algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     188            | System.Windows.Forms.AnchorStyles.Left)
    180189            | System.Windows.Forms.AnchorStyles.Right)));
    181190      this.algorithmViewHost.Caption = "View";
     
    185194      this.algorithmViewHost.Name = "algorithmViewHost";
    186195      this.algorithmViewHost.ReadOnly = false;
    187       this.algorithmViewHost.Size = new System.Drawing.Size(409, 288);
    188       this.algorithmViewHost.TabIndex = 3;
     196      this.algorithmViewHost.Size = new System.Drawing.Size(526, 288);
     197      this.algorithmViewHost.TabIndex = 2;
    189198      this.algorithmViewHost.ViewsLabelVisible = true;
    190199      this.algorithmViewHost.ViewType = null;
     
    192201      // openAlgorithmButton
    193202      //
    194       this.openAlgorithmButton.Image = ((System.Drawing.Image)(resources.GetObject("openAlgorithmButton.Image")));
     203      this.openAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
    195204      this.openAlgorithmButton.Location = new System.Drawing.Point(36, 6);
    196205      this.openAlgorithmButton.Name = "openAlgorithmButton";
     
    203212      // newAlgorithmButton
    204213      //
    205       this.newAlgorithmButton.Image = ((System.Drawing.Image)(resources.GetObject("newAlgorithmButton.Image")));
     214      this.newAlgorithmButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument;
    206215      this.newAlgorithmButton.Location = new System.Drawing.Point(6, 6);
    207216      this.newAlgorithmButton.Name = "newAlgorithmButton";
     
    218227      this.snapshotsTabPage.Name = "snapshotsTabPage";
    219228      this.snapshotsTabPage.Padding = new System.Windows.Forms.Padding(3);
    220       this.snapshotsTabPage.Size = new System.Drawing.Size(421, 330);
     229      this.snapshotsTabPage.Size = new System.Drawing.Size(538, 330);
    221230      this.snapshotsTabPage.TabIndex = 2;
    222231      this.snapshotsTabPage.Text = "Snapshots";
     
    225234      // snapshotsView
    226235      //
    227       this.snapshotsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    228             | System.Windows.Forms.AnchorStyles.Left) 
     236      this.snapshotsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     237            | System.Windows.Forms.AnchorStyles.Left)
    229238            | System.Windows.Forms.AnchorStyles.Right)));
    230239      this.snapshotsView.Caption = "RunCollection View";
     
    233242      this.snapshotsView.Name = "snapshotsView";
    234243      this.snapshotsView.ReadOnly = false;
    235       this.snapshotsView.Size = new System.Drawing.Size(409, 317);
     244      this.snapshotsView.Size = new System.Drawing.Size(526, 317);
    236245      this.snapshotsView.TabIndex = 0;
    237246      //
     
    241250      this.runsTabPage.Location = new System.Drawing.Point(4, 22);
    242251      this.runsTabPage.Name = "runsTabPage";
    243       this.runsTabPage.Size = new System.Drawing.Size(421, 330);
     252      this.runsTabPage.Size = new System.Drawing.Size(538, 330);
    244253      this.runsTabPage.TabIndex = 3;
    245254      this.runsTabPage.Text = "Runs";
     
    248257      // runsView
    249258      //
    250       this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    251             | System.Windows.Forms.AnchorStyles.Left) 
     259      this.runsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     260            | System.Windows.Forms.AnchorStyles.Left)
    252261            | System.Windows.Forms.AnchorStyles.Right)));
    253262      this.runsView.Caption = "RunCollection View";
     
    256265      this.runsView.Name = "runsView";
    257266      this.runsView.ReadOnly = false;
    258       this.runsView.Size = new System.Drawing.Size(409, 317);
     267      this.runsView.Size = new System.Drawing.Size(526, 317);
    259268      this.runsView.TabIndex = 1;
    260269      //
     
    272281      this.snapshotButton.Name = "snapshotButton";
    273282      this.snapshotButton.Size = new System.Drawing.Size(24, 24);
    274       this.snapshotButton.TabIndex = 20;
     283      this.snapshotButton.TabIndex = 13;
    275284      this.snapshotButton.Text = "Snapshot";
    276285      this.snapshotButton.UseVisualStyleBackColor = true;
     
    285294      this.Controls.Add(this.timeLimitLabel);
    286295      this.Controls.Add(this.label1);
    287       this.Controls.Add(this.snapShotsTextBox);
     296      this.Controls.Add(this.snapshotsTextBox);
    288297      this.Controls.Add(this.storeAlgorithmInEachSnapshotCheckBox);
    289298      this.Name = "TimeLimitRunView";
    290       this.Size = new System.Drawing.Size(432, 464);
     299      this.Size = new System.Drawing.Size(549, 464);
    291300      this.Controls.SetChildIndex(this.storeAlgorithmInEachSnapshotCheckBox, 0);
    292       this.Controls.SetChildIndex(this.snapShotsTextBox, 0);
     301      this.Controls.SetChildIndex(this.snapshotsTextBox, 0);
    293302      this.Controls.SetChildIndex(this.label1, 0);
    294303      this.Controls.SetChildIndex(this.timeLimitLabel, 0);
     
    320329    private System.Windows.Forms.TextBox timeLimitTextBox;
    321330    private System.Windows.Forms.Label label1;
    322     private System.Windows.Forms.TextBox snapShotsTextBox;
     331    private System.Windows.Forms.TextBox snapshotsTextBox;
    323332    private System.Windows.Forms.CheckBox storeAlgorithmInEachSnapshotCheckBox;
    324333    private MainForm.WindowsForms.DragOverTabControl tabControl;
  • branches/RuntimeOptimizer/HeuristicLab.Optimization.Views/3.3/TimeLimitRunView.cs

    r8956 r8961  
    2424using System.Linq;
    2525using System.Windows.Forms;
     26using HeuristicLab.Collections;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Common.Resources;
     
    6061    protected override void DeregisterContentEvents() {
    6162      Content.PropertyChanged -= Content_PropertyChanged;
     63      Content.SnapshotTimes.ItemsAdded -= Content_SnapshotTimes_Changed;
     64      Content.SnapshotTimes.ItemsMoved -= Content_SnapshotTimes_Changed;
     65      Content.SnapshotTimes.ItemsRemoved -= Content_SnapshotTimes_Changed;
     66      Content.SnapshotTimes.ItemsReplaced -= Content_SnapshotTimes_Changed;
     67      Content.SnapshotTimes.CollectionReset -= Content_SnapshotTimes_Changed;
    6268      base.DeregisterContentEvents();
    6369    }
     
    6571      base.RegisterContentEvents();
    6672      Content.PropertyChanged += Content_PropertyChanged;
     73      Content.SnapshotTimes.ItemsAdded += Content_SnapshotTimes_Changed;
     74      Content.SnapshotTimes.ItemsMoved += Content_SnapshotTimes_Changed;
     75      Content.SnapshotTimes.ItemsRemoved += Content_SnapshotTimes_Changed;
     76      Content.SnapshotTimes.ItemsReplaced += Content_SnapshotTimes_Changed;
     77      Content.SnapshotTimes.CollectionReset += Content_SnapshotTimes_Changed;
    6778    }
    6879
     
    7384        if (Content == null) {
    7485          timeLimitTextBox.Text = FormatTimeSpan(TimeSpan.FromSeconds(60));
    75           snapShotsTextBox.Text = String.Empty;
     86          snapshotsTextBox.Text = String.Empty;
    7687          storeAlgorithmInEachSnapshotCheckBox.Checked = false;
    7788          algorithmViewHost.Content = null;
     
    8091        } else {
    8192          timeLimitTextBox.Text = FormatTimeSpan(Content.MaximumExecutionTime);
    82           snapShotsTextBox.Text = String.Join(" ; ", Content.SnapshotTimes);
     93          snapshotsTextBox.Text = String.Join(" ; ", Content.SnapshotTimes.Select(x => FormatTimeSpan(x, true)));
    8394          storeAlgorithmInEachSnapshotCheckBox.Checked = Content.StoreAlgorithmInEachSnapshot;
    8495          algorithmViewHost.Content = Content.Algorithm;
     
    92103      base.SetEnabledStateOfControls();
    93104      timeLimitTextBox.Enabled = Content != null && !ReadOnly;
    94       snapShotsTextBox.Enabled = Content != null && !ReadOnly;
     105      snapshotsTextBox.Enabled = Content != null && !ReadOnly;
    95106      storeAlgorithmInEachSnapshotCheckBox.Enabled = Content != null && !ReadOnly;
    96107      newAlgorithmButton.Enabled = Content != null && !ReadOnly;
     
    128139          } finally { SuppressEvents = false; }
    129140          break;
    130         case "SnapshotTimes": break;
     141        case "SnapshotTimes":
     142          SuppressEvents = true;
     143          try {
     144            snapshotsTextBox.Text = string.Join(" ; ", Content.SnapshotTimes.Select(x => FormatTimeSpan(x, true)));
     145            Content.SnapshotTimes.ItemsAdded += Content_SnapshotTimes_Changed;
     146            Content.SnapshotTimes.ItemsMoved += Content_SnapshotTimes_Changed;
     147            Content.SnapshotTimes.ItemsRemoved += Content_SnapshotTimes_Changed;
     148            Content.SnapshotTimes.ItemsReplaced += Content_SnapshotTimes_Changed;
     149            Content.SnapshotTimes.CollectionReset += Content_SnapshotTimes_Changed;
     150          } finally { SuppressEvents = false; }
     151          break;
    131152        case "StoreAlgorithmInEachSnapshot":
    132153          SuppressEvents = true;
     
    154175          break;
    155176      }
     177    }
     178
     179    private void Content_SnapshotTimes_Changed(object sender, EventArgs e) {
     180      SuppressEvents = true;
     181      try {
     182        snapshotsTextBox.Text = string.Join(" ; ", Content.SnapshotTimes.Select(x => FormatTimeSpan(x, true)));
     183      } finally { SuppressEvents = false; }
    156184    }
    157185    #endregion
     
    160188    private void timeLimitTextBox_Validating(object sender, CancelEventArgs e) {
    161189      if (SuppressEvents) return;
    162       double value;
    163       var text = timeLimitTextBox.Text.Trim();
    164       var length = text.Length;
    165       while (!double.TryParse(text.Substring(0, length), out value)) {
    166         length--;
    167         if (length <= 0) {
    168           value = double.NaN;
    169           break;
    170         }
    171       }
    172       if (double.IsNaN(value)) {
     190      TimeSpan ts;
     191      if (!TryGetTimeSpanFromFormat(timeLimitTextBox.Text, out ts)) {
    173192        e.Cancel = true;
    174193        errorProvider.SetError(timeLimitTextBox, "Please enter a valid time span, e.g. 60, 20s, 45 seconds, 3h, 1 hour, 4 d, 2 days");
    175194      } else {
    176         TimeSpan ts;
    177         if (length < text.Length) {
    178           ts = GetTimeSpanFromFormat(value, text.Substring(length - 1, text.Length - (length - 1)).TrimStart());
    179         } else ts = TimeSpan.FromSeconds(value);
    180195        Content.MaximumExecutionTime = ts;
    181196        e.Cancel = false;
    182197        errorProvider.SetError(timeLimitTextBox, String.Empty);
    183198      }
     199    }
     200
     201    private void snapshotsTextBox_Validating(object sender, CancelEventArgs e) {
     202      if (SuppressEvents) return;
     203      e.Cancel = false;
     204      errorProvider.SetError(timeLimitTextBox, String.Empty);
     205
     206      var tokens = snapshotsTextBox.Text.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
     207
     208      var snapshotTimes = new ObservableList<TimeSpan>();
     209      foreach (var t in tokens) {
     210        TimeSpan value;
     211        if (!TryGetTimeSpanFromFormat(t, out value)) {
     212          e.Cancel = true;
     213          errorProvider.SetError(snapshotsTextBox, "Error parsing " + t + ", please provide a valid time span, e.g. 60, 20s, 45 seconds, 3h, 1 hour, 4 d, 2 days");
     214          return;
     215        } else {
     216          snapshotTimes.Add(value);
     217        }
     218      }
     219      Content.SnapshotTimes = snapshotTimes;
    184220    }
    185221
     
    258294    #endregion
    259295
    260     private string FormatTimeSpan(TimeSpan ts) {
    261       if (ts.TotalSeconds < 180) return ts.TotalSeconds + " seconds";
    262       if (ts.TotalMinutes < 180) return ts.TotalMinutes + " minutes";
    263       if (ts.TotalHours < 96) return ts.TotalHours + " hours";
    264       return ts.TotalDays + " days";
    265     }
    266 
    267     private TimeSpan GetTimeSpanFromFormat(double value, string text) {
    268       switch (text) {
    269         case "d":
    270         case "day":
    271         case "days": return TimeSpan.FromDays(value);
    272         case "h":
    273         case "hour":
    274         case "hours": return TimeSpan.FromHours(value);
    275         case "min":
    276         case "minute":
    277         case "minutes": return TimeSpan.FromMinutes(value);
    278         default: return TimeSpan.FromSeconds(value);
     296    private string FormatTimeSpan(TimeSpan ts, bool abbrevUnit = false) {
     297      if (ts.TotalSeconds < 180) return ts.TotalSeconds + (abbrevUnit ? "s" : " seconds");
     298      if (ts.TotalMinutes < 180) return ts.TotalMinutes + (abbrevUnit ? "min" : " minutes");
     299      if (ts.TotalHours < 96) return ts.TotalHours + (abbrevUnit ? "h" : " hours");
     300      return ts.TotalDays + (abbrevUnit ? "d" : " days");
     301    }
     302
     303    private bool TryGetTimeSpanFromFormat(string text, out TimeSpan result) {
     304      double value;
     305      text = text.Trim();
     306      var length = text.Length;
     307      while (!double.TryParse(text.Substring(0, length), out value)) {
     308        length--;
     309        if (length <= 0) {
     310          value = double.NaN;
     311          break;
     312        }
     313      }
     314      if (double.IsNaN(value)) {
     315        result = TimeSpan.Zero;
     316        return false;
     317      } else {
     318        var remaining = String.Empty;
     319        if (length < text.Length) remaining = text.Substring(length, text.Length - length);
     320        switch (remaining.Trim()) {
     321          case "d":
     322          case "day":
     323          case "days": result = TimeSpan.FromDays(value); break;
     324          case "h":
     325          case "hour":
     326          case "hours": result = TimeSpan.FromHours(value); break;
     327          case "min":
     328          case "minute":
     329          case "minutes": result = TimeSpan.FromMinutes(value); break;
     330          default: result = TimeSpan.FromSeconds(value); break;
     331        }
     332        return true;
    279333      }
    280334    }
  • branches/RuntimeOptimizer/HeuristicLab.Optimization/3.3/MetaOptimizers/TimeLimitRun.cs

    r8956 r8961  
    7878    private int snapshotTimesIndex;
    7979    [Storable]
    80     private ObservableList<double> snapshotTimes;
    81     public ObservableList<double> SnapshotTimes {
     80    private ObservableList<TimeSpan> snapshotTimes;
     81    public ObservableList<TimeSpan> SnapshotTimes {
    8282      get { return snapshotTimes; }
    8383      set {
     
    170170      : base(original, cloner) {
    171171      maximumExecutionTime = original.maximumExecutionTime;
    172       snapshotTimes = new ObservableList<double>(original.snapshotTimes);
     172      snapshotTimes = new ObservableList<TimeSpan>(original.snapshotTimes);
    173173      snapshotTimesIndex = original.snapshotTimesIndex;
    174174      snapshots = cloner.Clone(original.snapshots);
     
    200200      description = ItemDescription;
    201201      maximumExecutionTime = TimeSpan.FromMinutes(1);
    202       snapshotTimes = new ObservableList<double>(new[] {
    203           TimeSpan.FromSeconds(5).TotalMilliseconds,
    204           TimeSpan.FromSeconds(10).TotalMilliseconds,
    205           TimeSpan.FromSeconds(30).TotalMilliseconds });
     202      snapshotTimes = new ObservableList<TimeSpan>(new[] {
     203          TimeSpan.FromSeconds(5),
     204          TimeSpan.FromSeconds(10),
     205          TimeSpan.FromSeconds(30) });
    206206      snapshotTimesIndex = 0;
    207207      snapTimer = new Timer() {
     
    223223      description = ItemDescription;
    224224      maximumExecutionTime = TimeSpan.FromMinutes(1);
    225       snapshotTimes = new ObservableList<double>(new[] {
    226           TimeSpan.FromSeconds(5).TotalMilliseconds,
    227           TimeSpan.FromSeconds(10).TotalMilliseconds,
    228           TimeSpan.FromSeconds(30).TotalMilliseconds });
     225      snapshotTimes = new ObservableList<TimeSpan>(new[] {
     226          TimeSpan.FromSeconds(5),
     227          TimeSpan.FromSeconds(10),
     228          TimeSpan.FromSeconds(30) });
    229229      snapshotTimesIndex = 0;
    230230      snapTimer = new Timer() {
     
    245245      : base(name, description) {
    246246      maximumExecutionTime = TimeSpan.FromMinutes(1);
    247       snapshotTimes = new ObservableList<double>(new[] {
    248           TimeSpan.FromSeconds(5).TotalMilliseconds,
    249           TimeSpan.FromSeconds(10).TotalMilliseconds,
    250           TimeSpan.FromSeconds(30).TotalMilliseconds });
     247      snapshotTimes = new ObservableList<TimeSpan>(new[] {
     248          TimeSpan.FromSeconds(5),
     249          TimeSpan.FromSeconds(10),
     250          TimeSpan.FromSeconds(30) });
    251251      snapshotTimesIndex = 0;
    252252      snapTimer = new Timer() {
     
    320320          var execTime = ExecutionTime;
    321321          if (snapshotTimesIndex < SnapshotTimes.Count &&
    322               SnapshotTimes[snapshotTimesIndex] <= execTime.TotalMilliseconds) {
     322              SnapshotTimes[snapshotTimesIndex] <= execTime) {
    323323            DoSnapshot();
    324324            snapshotTimesIndex++;
     
    345345    private void FindNextSnapshotTimeIndex(TimeSpan reference) {
    346346      var index = 0;
    347       while (index < snapshotTimes.Count && (snapshotTimes[index] - reference.TotalMilliseconds) <= 0) {
     347      while (index < snapshotTimes.Count && snapshotTimes[index] <= reference) {
    348348        index++;
    349349      };
Note: See TracChangeset for help on using the changeset viewer.