From 215c5c8b907df16fbb53ce248458f5bb4ea75e07 Mon Sep 17 00:00:00 2001 From: hrntsm Date: Tue, 10 Jan 2023 23:17:01 +0900 Subject: [PATCH 1/2] Add eta display --- Tunny/Handler/ProgressState.cs | 2 ++ Tunny/Solver/Algorithm.cs | 5 ++++- Tunny/UI/OptimizationWindow.Designer.cs | 26 +++++++++++++++++------ Tunny/UI/OptimizeWindowTab/OptimizeTab.cs | 2 ++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Tunny/Handler/ProgressState.cs b/Tunny/Handler/ProgressState.cs index 85bcc723..5081d76f 100644 --- a/Tunny/Handler/ProgressState.cs +++ b/Tunny/Handler/ProgressState.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; namespace Tunny.Handler @@ -9,5 +10,6 @@ public class ProgressState public int ObjectiveNum { get; set; } public double[][] BestValues { get; set; } public double HypervolumeRatio { get; set; } + public TimeSpan EstimatedTimeRemaining { get; set; } } } diff --git a/Tunny/Solver/Algorithm.cs b/Tunny/Solver/Algorithm.cs index 8590a93c..5d375e76 100644 --- a/Tunny/Solver/Algorithm.cs +++ b/Tunny/Solver/Algorithm.cs @@ -208,7 +208,10 @@ private void RunOptimize(int nTrials, double timeout, dynamic study, Dictionary< ObjectiveNum = ObjNickName.Length, BestValues = bestValues, Values = xTest.Select(v => (decimal)v).ToList(), - HypervolumeRatio = trialNum == 0 ? 0 : trialNum == 1 || ObjNickName.Length == 1 ? 1 : Hypervolume.Compute2dHypervolumeRatio(study) + HypervolumeRatio = trialNum == 0 ? 0 : trialNum == 1 || ObjNickName.Length == 1 ? 1 : Hypervolume.Compute2dHypervolumeRatio(study), + EstimatedTimeRemaining = timeout == 0 + ? TimeSpan.FromSeconds((DateTime.Now - startTime).TotalSeconds * (nTrials - trialNum - 1) / (trialNum + 1)) + : TimeSpan.FromSeconds(timeout - (DateTime.Now - startTime).TotalSeconds) }; result = EvalFunc(pState, progress); diff --git a/Tunny/UI/OptimizationWindow.Designer.cs b/Tunny/UI/OptimizationWindow.Designer.cs index d4482102..4808f8cd 100644 --- a/Tunny/UI/OptimizationWindow.Designer.cs +++ b/Tunny/UI/OptimizationWindow.Designer.cs @@ -44,6 +44,7 @@ private void InitializeComponent() this.studyNameTextBox = new System.Windows.Forms.TextBox(); this.optimizeTabControl = new System.Windows.Forms.TabControl(); this.optimizeTabPage = new System.Windows.Forms.TabPage(); + this.EstimatedTimeRemainingLabel = new System.Windows.Forms.Label(); this.optimizeBestValueLabel = new System.Windows.Forms.Label(); this.optimizeTrialNumLabel = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); @@ -184,7 +185,7 @@ private void InitializeComponent() // // optimizeRunButton // - this.optimizeRunButton.Location = new System.Drawing.Point(48, 312); + this.optimizeRunButton.Location = new System.Drawing.Point(48, 295); this.optimizeRunButton.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.optimizeRunButton.Name = "optimizeRunButton"; this.optimizeRunButton.Size = new System.Drawing.Size(153, 34); @@ -196,7 +197,7 @@ private void InitializeComponent() // optimizeStopButton // this.optimizeStopButton.Enabled = false; - this.optimizeStopButton.Location = new System.Drawing.Point(246, 312); + this.optimizeStopButton.Location = new System.Drawing.Point(246, 295); this.optimizeStopButton.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.optimizeStopButton.Name = "optimizeStopButton"; this.optimizeStopButton.Size = new System.Drawing.Size(126, 34); @@ -248,10 +249,10 @@ private void InitializeComponent() // // optimizeProgressBar // - this.optimizeProgressBar.Location = new System.Drawing.Point(20, 358); + this.optimizeProgressBar.Location = new System.Drawing.Point(20, 341); this.optimizeProgressBar.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); this.optimizeProgressBar.Name = "optimizeProgressBar"; - this.optimizeProgressBar.Size = new System.Drawing.Size(388, 34); + this.optimizeProgressBar.Size = new System.Drawing.Size(388, 24); this.optimizeProgressBar.TabIndex = 6; // // samplerComboBox @@ -316,6 +317,7 @@ private void InitializeComponent() // // optimizeTabPage // + this.optimizeTabPage.Controls.Add(this.EstimatedTimeRemainingLabel); this.optimizeTabPage.Controls.Add(this.optimizeBestValueLabel); this.optimizeTabPage.Controls.Add(this.optimizeTrialNumLabel); this.optimizeTabPage.Controls.Add(this.groupBox2); @@ -337,10 +339,19 @@ private void InitializeComponent() this.optimizeTabPage.Text = "Optimize"; this.optimizeTabPage.UseVisualStyleBackColor = true; // + // EstimatedTimeRemainingLabel + // + this.EstimatedTimeRemainingLabel.AutoSize = true; + this.EstimatedTimeRemainingLabel.Location = new System.Drawing.Point(44, 411); + this.EstimatedTimeRemainingLabel.Name = "EstimatedTimeRemainingLabel"; + this.EstimatedTimeRemainingLabel.Size = new System.Drawing.Size(272, 23); + this.EstimatedTimeRemainingLabel.TabIndex = 16; + this.EstimatedTimeRemainingLabel.Text = "Estimated Time Remaining: #"; + // // optimizeBestValueLabel // this.optimizeBestValueLabel.AutoSize = true; - this.optimizeBestValueLabel.Location = new System.Drawing.Point(153, 398); + this.optimizeBestValueLabel.Location = new System.Drawing.Point(153, 380); this.optimizeBestValueLabel.Name = "optimizeBestValueLabel"; this.optimizeBestValueLabel.Size = new System.Drawing.Size(129, 23); this.optimizeBestValueLabel.TabIndex = 15; @@ -349,7 +360,7 @@ private void InitializeComponent() // optimizeTrialNumLabel // this.optimizeTrialNumLabel.AutoSize = true; - this.optimizeTrialNumLabel.Location = new System.Drawing.Point(44, 398); + this.optimizeTrialNumLabel.Location = new System.Drawing.Point(44, 380); this.optimizeTrialNumLabel.Name = "optimizeTrialNumLabel"; this.optimizeTrialNumLabel.Size = new System.Drawing.Size(80, 23); this.optimizeTrialNumLabel.TabIndex = 14; @@ -363,7 +374,7 @@ private void InitializeComponent() this.groupBox2.Controls.Add(this.studyNameLabel); this.groupBox2.Controls.Add(this.continueStudyCheckBox); this.groupBox2.Controls.Add(this.studyNameTextBox); - this.groupBox2.Location = new System.Drawing.Point(20, 150); + this.groupBox2.Location = new System.Drawing.Point(20, 133); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(390, 153); this.groupBox2.TabIndex = 13; @@ -1850,6 +1861,7 @@ private void InitializeComponent() private System.Windows.Forms.Label outputTargetStudyLabel; private System.Windows.Forms.ComboBox cmaEsWarmStartComboBox; private System.Windows.Forms.CheckBox cmaEsWarmStartCmaEsCheckBox; + private System.Windows.Forms.Label EstimatedTimeRemainingLabel; } } diff --git a/Tunny/UI/OptimizeWindowTab/OptimizeTab.cs b/Tunny/UI/OptimizeWindowTab/OptimizeTab.cs index ed5ad538..275de55f 100644 --- a/Tunny/UI/OptimizeWindowTab/OptimizeTab.cs +++ b/Tunny/UI/OptimizeWindowTab/OptimizeTab.cs @@ -250,6 +250,8 @@ private void OptimizeProgressChangedHandler(object sender, ProgressChangedEventA : $"Hypervolume Ratio: {pState.HypervolumeRatio:0.000}"; } + EstimatedTimeRemainingLabel.Text = $"Estimated Time Remaining: " + + (pState.EstimatedTimeRemaining.TotalSeconds != 0 ? new DateTime(0).Add(pState.EstimatedTimeRemaining).ToString("HH:mm:ss") : "00:00:00"); optimizeProgressBar.Value = e.ProgressPercentage; optimizeProgressBar.Update(); } From 70bc7c80b105606e9d67403b910db1db498fba4a Mon Sep 17 00:00:00 2001 From: hrntsm Date: Tue, 10 Jan 2023 23:19:24 +0900 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa6abe85..4e9fbdd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,29 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p Please see [here](https://github.com/hrntsm/Tunny/releases) for the data released for each version. +## [UNRELEASED] -20xx-xx-xx + + +### Added + +- Display of estimated remaining time during optimization run. + +### Changed + + +### Deprecated + + +### Removed + + +### Fixed + + +### Security + + + ## [v0.6.0] -2022-12-23 ### Added