Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12803 for branches


Ignore:
Timestamp:
07/24/15 15:31:54 (9 years ago)
Author:
abeham
Message:

#2431: worked on RLD analysis

  • started implementation of IRRRun
  • renamed view from ECDF to RLD
  • reverted algorithms (execution time)
  • changed per clock analyzer
Location:
branches/PerformanceComparison
Files:
1 added
4 edited
1 copied
2 moved

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Analysis/3.3/Optimizers/IRRRun.cs

    r12764 r12803  
    2525using System.Drawing;
    2626using System.Linq;
    27 using System.Threading.Tasks;
    28 using HeuristicLab.Collections;
    2927using HeuristicLab.Common;
    3028using HeuristicLab.Common.Resources;
    3129using HeuristicLab.Core;
     30using HeuristicLab.Data;
     31using HeuristicLab.Optimization;
    3232using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3333
    34 namespace HeuristicLab.Optimization {
     34namespace HeuristicLab.Analysis {
     35  public enum TerminationCriterium { OnlyByTime, OnlyByEvaluations, OnlyByTarget, ByTargetAndTime, ByTargetAndEvaluations, WhicheverHitsFirst, WhicheverHitsLast }
    3536  /// <summary>
    3637  /// A run in which an algorithm is executed for a certain maximum time only.
    3738  /// </summary>
    38   [Item("Timelimit Run", "A run in which an optimizer is executed a certain maximum time.")]
    39   [Creatable(CreatableAttribute.Categories.TestingAndAnalysis, Priority = 115)]
     39  [Item("Independent Random Restart Run", "A run in which an optimizer is repeated until either a certain target value is reached or a maximum budget is exceeded.")]
     40  [Creatable(CreatableAttribute.Categories.TestingAndAnalysis, Priority = 117)]
    4041  [StorableClass]
    41   public sealed class TimeLimitRun : NamedItem, IOptimizer, IStorableContent, INotifyPropertyChanged {
     42  public sealed class IndepdentRandomRestartRun : NamedItem, IOptimizer, IStorableContent, INotifyPropertyChanged {
    4243    public string Filename { get; set; }
    4344
     
    5152    #endregion
    5253
    53     private bool pausedForSnapshot = false;
    54     private bool pausedForTermination = false;
     54    [Storable]
     55    private TerminationCriterium terminationCriterium;
     56    public TerminationCriterium TerminationCriterium {
     57      get { return terminationCriterium; }
     58      set {
     59        if (terminationCriterium == value) return;
     60        terminationCriterium = value;
     61        OnPropertyChanged("TerminationCriterium");
     62      }
     63    }
    5564
    5665    [Storable]
     
    6675
    6776    [Storable]
    68     private int snapshotTimesIndex;
    69     [Storable]
    70     private ObservableList<TimeSpan> snapshotTimes;
    71     public ObservableList<TimeSpan> SnapshotTimes {
    72       get { return snapshotTimes; }
    73       set {
    74         if (snapshotTimes == value) return;
    75         snapshotTimes = value;
    76         snapshotTimes.Sort();
    77         FindNextSnapshotTimeIndex(ExecutionTime);
    78         OnPropertyChanged("SnapshotTimes");
    79       }
    80     }
    81 
    82     [Storable]
    83     private bool storeAlgorithmInEachSnapshot;
    84     [Storable]
    85     public bool StoreAlgorithmInEachSnapshot {
    86       get { return storeAlgorithmInEachSnapshot; }
    87       set {
    88         if (storeAlgorithmInEachSnapshot == value) return;
    89         storeAlgorithmInEachSnapshot = value;
    90         OnPropertyChanged("StoreAlgorithmInEachSnapshot");
    91       }
    92     }
    93 
    94     [Storable]
    95     private RunCollection snapshots;
    96     public RunCollection Snapshots {
    97       get { return snapshots; }
    98       set {
    99         if (snapshots == value) return;
    100         snapshots = value;
    101         OnPropertyChanged("Snapshots");
    102       }
    103     }
    104 
    105     #region Inherited Properties
     77    private int maximumEvaluations;
     78    public int MaximumEvaluations {
     79      get { return maximumEvaluations; }
     80      set {
     81        if (maximumEvaluations == value) return;
     82        maximumEvaluations = value;
     83        OnPropertyChanged("MaximumEvaluations");
     84      }
     85    }
     86
     87    [Storable]
     88    private double targetValue;
     89    public double TargetValue {
     90      get { return targetValue; }
     91      set {
     92        if (targetValue == value) return;
     93        targetValue = value;
     94        OnPropertyChanged("TargetValue");
     95      }
     96    }
     97
     98    [Storable]
     99    private bool maximization;
     100    public bool Maximization {
     101      get { return maximization; }
     102      private set {
     103        if (maximization == value) return;
     104        maximization = value;
     105        OnPropertyChanged("Maximization");
     106      }
     107    }
     108
     109    [Storable]
     110    private double moveCostPerSolution;
     111    public double MoveCostPerSolution {
     112      get { return moveCostPerSolution; }
     113      set {
     114        if (moveCostPerSolution == value) return;
     115        moveCostPerSolution = value;
     116        OnPropertyChanged("MoveCostPerSolution");
     117      }
     118    }
     119
     120
    106121    public ExecutionState ExecutionState {
    107122      get { return (Algorithm != null) ? Algorithm.ExecutionState : ExecutionState.Stopped; }
    108123    }
    109124
     125    private TimeSpan lastAlgorithmExecutionTime;
     126    [Storable]
     127    private TimeSpan executionTime;
    110128    public TimeSpan ExecutionTime {
    111       get { return (Algorithm != null) ? Algorithm.ExecutionTime : TimeSpan.FromSeconds(0); }
     129      get { return executionTime; }
     130      set {
     131        if (executionTime == value) return;
     132        executionTime = value;
     133        OnPropertyChanged("ExecutionTime");
     134        OnExecutionTimeChanged();
     135      }
     136    }
     137
     138    private int lastAlgorithmEvaluatedSolutions;
     139    private int lastAlgorithmEvaluatedMoves;
     140    [Storable]
     141    private double evaluations;
     142    public double Evaluations {
     143      get { return evaluations; }
     144      set {
     145        if (evaluations == value) return;
     146        evaluations = value;
     147        OnPropertyChanged("Evaluations");
     148      }
     149    }
     150
     151    [Storable]
     152    private double bestSoFar;
     153    public double BestSoFar {
     154      get { return bestSoFar; }
     155      set {
     156        if (bestSoFar == value) return;
     157        bestSoFar = value;
     158        OnPropertyChanged("BestSoFar");
     159      }
     160    }
     161
     162    [Storable]
     163    private IRun currentRun;
     164    public IRun CurrentRun {
     165      get { return currentRun; }
     166      private set {
     167        if (currentRun == value) return;
     168        currentRun = value;
     169        OnPropertyChanged("CurrentRun");
     170      }
    112171    }
    113172
     
    148207      }
    149208    }
    150     #endregion
     209
     210    private bool IsFinished {
     211      get {
     212        var timeHit = ExecutionTime >= MaximumExecutionTime;
     213        var evalHit = Evaluations >= MaximumEvaluations;
     214        var targetHit = (Maximization && BestSoFar >= TargetValue || !Maximization && BestSoFar <= TargetValue);
     215
     216        return timeHit && evalHit && targetHit
     217          || timeHit && (TerminationCriterium == TerminationCriterium.OnlyByTime
     218                      || TerminationCriterium == TerminationCriterium.ByTargetAndTime
     219                      || TerminationCriterium == TerminationCriterium.WhicheverHitsFirst)
     220          || evalHit && (TerminationCriterium == TerminationCriterium.OnlyByEvaluations
     221                      || TerminationCriterium == TerminationCriterium.ByTargetAndEvaluations
     222                      || TerminationCriterium == TerminationCriterium.WhicheverHitsFirst)
     223          || targetHit && (TerminationCriterium == TerminationCriterium.OnlyByTarget
     224                        || TerminationCriterium == TerminationCriterium.WhicheverHitsFirst
     225                        || TerminationCriterium == TerminationCriterium.ByTargetAndTime
     226                        || TerminationCriterium == TerminationCriterium.ByTargetAndEvaluations);
     227      }
     228    }
    151229
    152230    [StorableConstructor]
    153     private TimeLimitRun(bool deserializing) : base(deserializing) { }
    154     private TimeLimitRun(TimeLimitRun original, Cloner cloner)
     231    private IndepdentRandomRestartRun(bool deserializing) : base(deserializing) { }
     232    private IndepdentRandomRestartRun(IndepdentRandomRestartRun original, Cloner cloner)
    155233      : base(original, cloner) {
     234      terminationCriterium = original.terminationCriterium;
    156235      maximumExecutionTime = original.maximumExecutionTime;
    157       snapshotTimes = new ObservableList<TimeSpan>(original.snapshotTimes);
    158       snapshotTimesIndex = original.snapshotTimesIndex;
    159       snapshots = cloner.Clone(original.snapshots);
    160       storeAlgorithmInEachSnapshot = original.storeAlgorithmInEachSnapshot;
     236      maximumEvaluations = original.maximumEvaluations;
     237      targetValue = original.targetValue;
     238      executionTime = original.executionTime;
     239      evaluations = original.evaluations;
     240      bestSoFar = original.bestSoFar;
     241      lastAlgorithmExecutionTime = original.lastAlgorithmExecutionTime;
     242      lastAlgorithmEvaluatedSolutions = original.lastAlgorithmEvaluatedSolutions;
     243      lastAlgorithmEvaluatedMoves = original.lastAlgorithmEvaluatedMoves;
     244
    161245      algorithm = cloner.Clone(original.algorithm);
    162246      runs = cloner.Clone(original.runs);
     
    164248      Initialize();
    165249    }
    166     public TimeLimitRun()
     250    public IndepdentRandomRestartRun()
    167251      : base() {
    168252      name = ItemName;
    169253      description = ItemDescription;
    170       maximumExecutionTime = TimeSpan.FromMinutes(.5);
    171       snapshotTimes = new ObservableList<TimeSpan>(new[] {
    172           TimeSpan.FromSeconds(5),
    173           TimeSpan.FromSeconds(10),
    174           TimeSpan.FromSeconds(15) });
    175       snapshotTimesIndex = 0;
    176       snapshots = new RunCollection();
     254      terminationCriterium = TerminationCriterium.OnlyByEvaluations;
     255      maximumExecutionTime = TimeSpan.FromMinutes(1);
     256      maximumEvaluations = 10000000; // 10 mio
     257      targetValue = 0;
     258      executionTime = TimeSpan.Zero;
     259      evaluations = 0;
     260      bestSoFar = double.NaN;
     261      lastAlgorithmExecutionTime = TimeSpan.Zero;
     262      lastAlgorithmEvaluatedSolutions = 0;
     263      lastAlgorithmEvaluatedMoves = 0;
     264
    177265      Runs = new RunCollection { OptimizerName = Name };
    178266      Initialize();
    179267    }
    180     public TimeLimitRun(string name)
     268    public IndepdentRandomRestartRun(string name)
    181269      : base(name) {
    182270      description = ItemDescription;
    183       maximumExecutionTime = TimeSpan.FromMinutes(.5);
    184       snapshotTimes = new ObservableList<TimeSpan>(new[] {
    185           TimeSpan.FromSeconds(5),
    186           TimeSpan.FromSeconds(10),
    187           TimeSpan.FromSeconds(15) });
    188       snapshotTimesIndex = 0;
     271      terminationCriterium = TerminationCriterium.OnlyByEvaluations;
     272      maximumExecutionTime = TimeSpan.FromMinutes(1);
     273      maximumEvaluations = 10000000; // 10 mio
     274      targetValue = 0;
     275      executionTime = TimeSpan.Zero;
     276      evaluations = 0;
     277      bestSoFar = double.NaN;
     278      lastAlgorithmExecutionTime = TimeSpan.Zero;
     279      lastAlgorithmEvaluatedSolutions = 0;
     280      lastAlgorithmEvaluatedMoves = 0;
     281
    189282      Runs = new RunCollection { OptimizerName = Name };
    190283      Initialize();
    191284    }
    192     public TimeLimitRun(string name, string description)
     285    public IndepdentRandomRestartRun(string name, string description)
    193286      : base(name, description) {
    194       maximumExecutionTime = TimeSpan.FromMinutes(.5);
    195       snapshotTimes = new ObservableList<TimeSpan>(new[] {
    196           TimeSpan.FromSeconds(5),
    197           TimeSpan.FromSeconds(10),
    198           TimeSpan.FromSeconds(15) });
    199       snapshotTimesIndex = 0;
     287      terminationCriterium = TerminationCriterium.OnlyByEvaluations;
     288      maximumExecutionTime = TimeSpan.FromMinutes(1);
     289      maximumEvaluations = 10000000; // 10 mio
     290      targetValue = 0;
     291      executionTime = TimeSpan.Zero;
     292      evaluations = 0;
     293      bestSoFar = double.NaN;
     294      lastAlgorithmExecutionTime = TimeSpan.Zero;
     295      lastAlgorithmEvaluatedSolutions = 0;
     296      lastAlgorithmEvaluatedMoves = 0;
     297
    200298      Runs = new RunCollection { OptimizerName = Name };
    201299      Initialize();
     
    204302    public override IDeepCloneable Clone(Cloner cloner) {
    205303      if (ExecutionState == ExecutionState.Started) throw new InvalidOperationException(string.Format("Clone not allowed in execution state \"{0}\".", ExecutionState));
    206       return new TimeLimitRun(this, cloner);
     304      return new IndepdentRandomRestartRun(this, cloner);
    207305    }
    208306
     
    214312    private void Initialize() {
    215313      if (algorithm != null) RegisterAlgorithmEvents();
    216       snapshotTimes.ItemsAdded += snapshotTimes_Changed;
    217       snapshotTimes.ItemsMoved += snapshotTimes_Changed;
    218       snapshotTimes.ItemsRemoved += snapshotTimes_Changed;
    219       snapshotTimes.ItemsReplaced += snapshotTimes_Changed;
    220       snapshotTimes.CollectionReset += snapshotTimes_Changed;
    221     }
    222 
    223     private void snapshotTimes_Changed(object sender, CollectionItemsChangedEventArgs<IndexedItem<TimeSpan>> e) {
    224       if (e.Items.Any()) snapshotTimes.Sort();
    225       FindNextSnapshotTimeIndex(ExecutionTime);
    226     }
    227 
    228     public void Snapshot() {
    229       if (Algorithm == null || Algorithm.ExecutionState != ExecutionState.Paused) throw new InvalidOperationException("Snapshot not allowed in execution states other than Paused");
    230       Task.Factory.StartNew(MakeSnapshot);
    231314    }
    232315
     
    235318    }
    236319    public void Prepare(bool clearRuns) {
     320      executionTime = TimeSpan.Zero;
     321      evaluations = 0;
     322      lastAlgorithmExecutionTime = TimeSpan.Zero;
     323      lastAlgorithmEvaluatedSolutions = 0;
     324
    237325      Algorithm.Prepare(clearRuns);
    238326    }
    239327    public void Start() {
     328      if (ExecutionState == ExecutionState.Prepared) {
     329        currentRun = new Run(Algorithm) {
     330          Name = Algorithm.Name + " IRRRun" + Runs.Count
     331        };
     332      }
    240333      Algorithm.Start();
    241334    }
     
    306399      algorithm.Started += Algorithm_Started;
    307400      algorithm.Stopped += Algorithm_Stopped;
     401      algorithm.ProblemChanged += Algorithm_ProblemChanged;
    308402    }
    309403    private void DeregisterAlgorithmEvents() {
     
    315409      algorithm.Started -= Algorithm_Started;
    316410      algorithm.Stopped -= Algorithm_Stopped;
     411      algorithm.ProblemChanged -= Algorithm_ProblemChanged;
    317412    }
    318413    private void Algorithm_ExceptionOccurred(object sender, EventArgs<Exception> e) {
     
    320415    }
    321416    private void Algorithm_ExecutionTimeChanged(object sender, EventArgs e) {
    322       if (snapshotTimesIndex < SnapshotTimes.Count && ExecutionTime >= SnapshotTimes[snapshotTimesIndex]
    323         && !pausedForSnapshot) {
    324         pausedForSnapshot = true;
    325         Algorithm.Pause();
    326       }
    327       if (ExecutionTime >= MaximumExecutionTime && !pausedForTermination) {
    328         pausedForTermination = true;
    329         if (!pausedForSnapshot) Algorithm.Pause();
     417      ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime;
     418      lastAlgorithmExecutionTime = Algorithm.ExecutionTime;
     419
     420      UpdateAlgorithmResults();
     421
     422      if (IsFinished) {
     423        Algorithm.Stop();
    330424      }
    331425      OnExecutionTimeChanged();
    332426    }
     427
    333428    private void Algorithm_ExecutionStateChanged(object sender, EventArgs e) {
    334429      OnExecutionStateChanged();
    335430    }
    336431    private void Algorithm_Paused(object sender, EventArgs e) {
    337       var action = pausedForTermination ? ExecutionState.Stopped : (pausedForSnapshot ? ExecutionState.Started : ExecutionState.Paused);
    338       if (pausedForSnapshot || pausedForTermination) {
    339         pausedForSnapshot = pausedForTermination = false;
    340         MakeSnapshot();
    341         FindNextSnapshotTimeIndex(ExecutionTime);
    342       }
     432      ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime;
     433      lastAlgorithmExecutionTime = Algorithm.ExecutionTime;
     434
     435      UpdateAlgorithmResults();
    343436      OnPaused();
    344       if (action == ExecutionState.Started) Algorithm.Start();
    345       else if (action == ExecutionState.Stopped) Algorithm.Stop();
    346437    }
    347438    private void Algorithm_Prepared(object sender, EventArgs e) {
    348       snapshotTimesIndex = 0;
    349       snapshots.Clear();
    350439      OnPrepared();
    351440    }
     
    354443    }
    355444    private void Algorithm_Stopped(object sender, EventArgs e) {
     445      ExecutionTime += Algorithm.ExecutionTime - lastAlgorithmExecutionTime;
     446      lastAlgorithmExecutionTime = Algorithm.ExecutionTime;
     447
     448      var bestQuality = UpdateAlgorithmResults();
     449
     450      foreach (var result in Algorithm.Results) {
     451        if (result.Name == "QualityPerClock") {
     452          if (!currentRun.Results.ContainsKey(result.Name))
     453            currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     454          else {
     455            var dt = (IndexedDataTable<double>)currentRun.Results[result.Name];
     456            var execTime = ((TimeSpanValue)currentRun.Results["ExecutionTime"]).Value.TotalSeconds;
     457            var best = dt.Rows.First().Values.Last().Item2;
     458            var resultDt = (IndexedDataTable<double>)result.Value;
     459            foreach (var tupl in resultDt.Rows.First().Values) {
     460              if (Maximization && tupl.Item2 > best || !Maximization && tupl.Item2 < best) {
     461                dt.Rows.First().Values.Add(Tuple.Create(execTime + tupl.Item1, tupl.Item2));
     462                best = tupl.Item2;
     463              }
     464            }
     465          }
     466        } else if (result.Name == "QualityPerEvaluations") {
     467          if (!currentRun.Results.ContainsKey(result.Name))
     468            currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     469          else {
     470            var dt = (IndexedDataTable<double>)currentRun.Results[result.Name];
     471            var evalSols = ((DoubleValue)currentRun.Results["EvaluatedSolutions"]).Value;
     472            var evalMoves = ((DoubleValue)currentRun.Results["EvaluatedMoves"]).Value;
     473            var best = dt.Rows.First().Values.Last().Item2;
     474            var resultDt = (IndexedDataTable<double>)result.Value;
     475            foreach (var tupl in resultDt.Rows.First().Values) {
     476              if (Maximization && tupl.Item2 > best || !Maximization && tupl.Item2 < best) {
     477                dt.Rows.First().Values.Add(Tuple.Create(evalSols + moveCostPerSolution * evalMoves + tupl.Item1, tupl.Item2));
     478                best = tupl.Item2;
     479              }
     480            }
     481          }
     482        } else if (result.Name == "EvaluatedSolutions") {
     483          currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     484        } else if (result.Name == "EvaluatedMoves") {
     485          currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     486        } else if (result.Name == "ExecutionTime") {
     487          currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     488        } else if (result.Name == "BestQuality") {
     489          currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     490        } else if (result.Name.ToLower().EndsWith("solution") && BestSoFar == bestQuality) {
     491          currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     492        }
     493      }
     494      foreach (var result in Algorithm.Results) {
     495        if (result.Name == "QualityPerClock") {
     496
     497        } else if (result.Name == "QualityPerEvaluations") {
     498        } else if (result.Name == "EvaluatedSolutions") {
     499          currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     500        } else if (result.Name == "EvaluatedMoves") {
     501          currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     502        } else if (result.Name == "ExecutionTime") {
     503          currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     504        } else if (result.Name == "BestQuality") {
     505          currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     506        } else if (result.Name.ToLower().EndsWith("solution") && BestSoFar == bestQuality) {
     507          currentRun.Results.Add(result.Name, (IItem)result.Value.Clone());
     508        }
     509      }
     510
     511
     512      if (IsFinished) {
     513
     514      }
     515
     516      // TODO
    356517      var cloner = new Cloner();
    357518      var algRun = cloner.Clone(Algorithm.Runs.Last());
    358       var clonedSnapshots = cloner.Clone(snapshots);
    359       algRun.Results.Add("TimeLimitRunSnapshots", clonedSnapshots);
    360519      Runs.Add(algRun);
    361520      Algorithm.Runs.Clear();
    362521      OnStopped();
    363522    }
     523
     524    private double UpdateAlgorithmResults() {
     525      IResult evaluationsResult;
     526      if (Algorithm.Results.TryGetValue("EvaluatedSolutions", out evaluationsResult)) {
     527        var evals = ((IntValue)evaluationsResult.Value).Value;
     528        Evaluations += evals - lastAlgorithmEvaluatedSolutions;
     529        lastAlgorithmEvaluatedSolutions = evals;
     530      }
     531      if (Algorithm.Results.TryGetValue("EvaluatedMoves", out evaluationsResult)) {
     532        var evals = ((IntValue)evaluationsResult.Value).Value;
     533        Evaluations += moveCostPerSolution * (evals - lastAlgorithmEvaluatedMoves);
     534        lastAlgorithmEvaluatedMoves = evals;
     535      }
     536      if (Algorithm.Results.TryGetValue("BestQuality", out evaluationsResult)) {
     537        var bestQuality = ((DoubleValue)evaluationsResult).Value;
     538        if (double.IsNaN(BestSoFar)
     539            || Maximization && bestQuality > BestSoFar
     540            || !Maximization && bestQuality < BestSoFar)
     541          BestSoFar = bestQuality;
     542        return bestQuality;
     543      }
     544      return double.NaN;
     545    }
     546
     547    private void Algorithm_ProblemChanged(object sender, EventArgs e) {
     548      var soProblem = Algorithm.Problem as ISingleObjectiveHeuristicOptimizationProblem;
     549      if (soProblem == null) return;
     550      var maxParam = soProblem.MaximizationParameter as IValueParameter<BoolValue>;
     551      if (maxParam != null)
     552        Maximization = maxParam.Value.Value;
     553      var bkParam = soProblem.BestKnownQualityParameter as IValueParameter<DoubleValue>;
     554      if (bkParam != null && bkParam.Value != null)
     555        TargetValue = bkParam.Value.Value;
     556    }
    364557    #endregion
    365558    #endregion
    366 
    367     private void FindNextSnapshotTimeIndex(TimeSpan reference) {
    368       var index = 0;
    369       while (index < snapshotTimes.Count && snapshotTimes[index] <= reference) {
    370         index++;
    371       };
    372       snapshotTimesIndex = index;
    373     }
    374 
    375     private void MakeSnapshot() {
    376       string time = Math.Round(ExecutionTime.TotalSeconds, 1).ToString("0.0");
    377       string runName = "Snapshot " + time + "s " + algorithm.Name;
    378       var changed = false;
    379       if (StoreAlgorithmInEachSnapshot && !Algorithm.StoreAlgorithmInEachRun) {
    380         Algorithm.StoreAlgorithmInEachRun = true;
    381         changed = true;
    382       } else if (!StoreAlgorithmInEachSnapshot && Algorithm.StoreAlgorithmInEachRun) {
    383         Algorithm.StoreAlgorithmInEachRun = false;
    384         changed = true;
    385       }
    386       var run = new Run(runName, Algorithm);
    387       if (changed)
    388         Algorithm.StoreAlgorithmInEachRun = !Algorithm.StoreAlgorithmInEachRun;
    389 
    390       snapshots.Add(run);
    391     }
    392559  }
    393560}
  • branches/PerformanceComparison/HeuristicLab.Analysis/3.3/QualityAnalysis/QualityPerClockAnalyzer.cs

    r12774 r12803  
    4242    }
    4343
    44     public IResultParameter<TimeSpanValue> ExecutionTimeParameter {
    45       get { return (IResultParameter<TimeSpanValue>)Parameters["Execution Time"]; }
     44    public ILookupParameter<DateTimeValue> LastUpdateTimeParameter {
     45      get { return (ILookupParameter<DateTimeValue>)Parameters["LastUpdateTime"]; }
    4646    }
    4747
     
    5656      : base() {
    5757      Parameters.Add(new LookupParameter<DoubleValue>("BestQuality", "The quality value that should be compared."));
    58       Parameters.Add(new ResultParameter<TimeSpanValue>("Execution Time", "The execution time."));
     58      Parameters.Add(new LookupParameter<DateTimeValue>("LastUpdateTime", "The time the analyzer was last run."));
    5959      Parameters.Add(new ResultParameter<IndexedDataTable<double>>("QualityPerClock", "Data table containing the first hitting graph with elapsed wall clock time (in seconds) as the x-axis."));
    6060      QualityPerClockParameter.DefaultValue = new IndexedDataTable<double>("Quality per Clock") {
     
    7575
    7676    public override IOperation Apply() {
    77       var executionTime = Math.Max(ExecutionTimeParameter.ResultValue.Value.TotalSeconds, 0.2);
     77      var lastUpdateTime = LastUpdateTimeParameter.ActualValue;
     78      if (lastUpdateTime == null) {
     79        lastUpdateTime = new DateTimeValue(DateTime.UtcNow.AddMilliseconds(-1));
     80        LastUpdateTimeParameter.ActualValue = lastUpdateTime;
     81      }
     82      var now = DateTime.UtcNow;
     83
    7884      var bestQuality = BestQualityParameter.ActualValue.Value;
    7985
     
    8187      var values = dataTable.Rows["First-hit Graph"].Values;
    8288      if (values.Count == 0 || values.Last().Item2 != bestQuality)
    83         dataTable.Rows["First-hit Graph"].Values.Add(Tuple.Create(executionTime, bestQuality));
     89        dataTable.Rows["First-hit Graph"].Values.Add(Tuple.Create((now - lastUpdateTime.Value).TotalSeconds, bestQuality));
    8490
     91      lastUpdateTime.Value = now;
    8592      return base.Apply();
    8693    }
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/HeuristicLab.Optimization.Views-3.3.csproj

    r12771 r12803  
    338338      <DependentUpon>RunCollectionEqualityConstraintView.cs</DependentUpon>
    339339    </Compile>
    340     <Compile Include="RunCollectionViews\RunCollectionECDFView.cs">
    341       <SubType>UserControl</SubType>
    342     </Compile>
    343     <Compile Include="RunCollectionViews\RunCollectionECDFView.Designer.cs">
    344       <DependentUpon>RunCollectionECDFView.cs</DependentUpon>
     340    <Compile Include="RunCollectionViews\RunCollectionRLDView.cs">
     341      <SubType>UserControl</SubType>
     342    </Compile>
     343    <Compile Include="RunCollectionViews\RunCollectionRLDView.Designer.cs">
     344      <DependentUpon>RunCollectionRLDView.cs</DependentUpon>
    345345    </Compile>
    346346    <Compile Include="RunCollectionViews\RunCollectionTableView.cs">
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.Designer.cs

    r12771 r12803  
    2020#endregion
    2121namespace HeuristicLab.Optimization.Views {
    22   partial class RunCollectionECDFView {
     22  partial class RunCollectionRLDView {
    2323    /// <summary>
    2424    /// Required designer variable.
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs

    r12774 r12803  
    3232
    3333namespace HeuristicLab.Optimization.Views {
    34   [View("ECDF Performance Comparison")]
     34  [View("Run-length Distribution View")]
    3535  [Content(typeof(RunCollection), false)]
    36   public partial class RunCollectionECDFView : ItemView {
     36  public partial class RunCollectionRLDView : ItemView {
    3737    private const string AllRuns = "All Runs";
    3838
     
    4848    }
    4949
    50     public RunCollectionECDFView() {
     50    public RunCollectionRLDView() {
    5151      InitializeComponent();
    5252      combinedDataTable = new IndexedDataTable<double>("Combined DataTable", "A data table containing the ECDF of each of a number of groups.") {
     
    253253
    254254    private void UpdateCaption() {
    255       Caption = Content != null ? Content.OptimizerName + " ECDF Comparison" : ViewAttribute.GetViewName(GetType());
     255      Caption = Content != null ? Content.OptimizerName + " RLD View" : ViewAttribute.GetViewName(GetType());
    256256    }
    257257
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/Algorithms/BasicAlgorithm.cs

    r12771 r12803  
    2424using System.Threading.Tasks;
    2525using HeuristicLab.Common;
    26 using HeuristicLab.Data;
    2726using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827
     
    3635    public override ResultCollection Results {
    3736      get { return results; }
    38     }
    39 
    40     protected override void OnExecutionTimeChanged() {
    41       base.OnExecutionTimeChanged();
    42       IResult result;
    43       if (!Results.TryGetValue("Execution Time", out result))
    44         Results.Add(new Result("Execution Time", new TimeSpanValue(ExecutionTime)));
    45       else ((TimeSpanValue)result.Value).Value = ExecutionTime;
    4637    }
    4738
  • branches/PerformanceComparison/HeuristicLab.Optimization/3.3/Algorithms/EngineAlgorithm.cs

    r12771 r12803  
    2222using System;
    2323using System.Linq;
    24 using System.Reflection;
    2524using HeuristicLab.Common;
    2625using HeuristicLab.Core;
    27 using HeuristicLab.Data;
    2826using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2927using HeuristicLab.PluginInfrastructure;
     
    7371    }
    7472
    75     protected override void OnExecutionTimeChanged() {
    76       base.OnExecutionTimeChanged();
    77       IResult result;
    78       if (!Results.TryGetValue("Execution Time", out result))
    79         Results.Add(new Result("Execution Time", new TimeSpanValue(ExecutionTime)));
    80       else ((TimeSpanValue)result.Value).Value = ExecutionTime;
    81     }
    82 
    8373    public override ResultCollection Results {
    8474      get {
Note: See TracChangeset for help on using the changeset viewer.