Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13748 for branches


Ignore:
Timestamp:
04/07/16 15:26:47 (9 years ago)
Author:
abeham
Message:

#2457: Added toolbar, fixed some bugs

Location:
branches/PerformanceComparison
Files:
2 added
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Common/3.3/KnowledgeCenter.cs

    r13722 r13748  
    107107
    108108    public KnowledgeCenter() {
    109       maximumEvaluations = new IntValue(0);
     109      maximumEvaluations = new IntValue(10000);
    110110      instanceRuns = new RunCollection();
     111      seededRuns = new RunCollection();
    111112      knowledgeBase = new RunCollection();
    112113      suggestedInstances = new ItemList<IAlgorithm>();
     
    122123
    123124    private void ProblemOnProblemChanged(object sender, EventArgs eventArgs) {
    124      
     125      // TODO: Potentially, knowledge base has to be re-downloaded
    125126    }
    126127
     
    337338      EventHandler exeStateChanged = (sender, e) => {
    338339        if (algorithmClone.ExecutionState == ExecutionState.Stopped) {
    339           foreach (var solution in algorithmClone.Results.Where(x => x.Name.ToLower().Contains("solution")).Select(x => x.Value).OfType<IScope>()) {
    340             Problem.Solutions.Add(new SingleObjectiveOKBSolution(Problem.ProblemId) {
    341               Quality = solution.Variables.ContainsKey(Problem.Problem.Evaluator.QualityParameter.ActualName) ? ((DoubleValue)solution.Variables[Problem.Problem.Evaluator.QualityParameter.ActualName].Value).Value : double.NaN,
    342               Solution = (IItem)solution.Clone()
    343             });
     340          lock (Problem.Solutions) {
     341            foreach (var solution in algorithmClone.Results.Where(x => x.Name.ToLower().Contains("solution")).Select(x => x.Value).OfType<IScope>()) {
     342              Problem.Solutions.Add(new SingleObjectiveOKBSolution(Problem.ProblemId) {
     343                Quality = solution.Variables.ContainsKey(Problem.Problem.Evaluator.QualityParameter.ActualName) ? ((DoubleValue)solution.Variables[Problem.Problem.Evaluator.QualityParameter.ActualName].Value).Value : double.NaN,
     344                Solution = (IItem)solution.Clone()
     345              });
     346            }
    344347          }
    345348          if (seedingStrategyLocal == SeedingStrategyTypes.NoSeeding) {
    346             InstanceRuns.Add(algorithmClone.Runs.Last());
    347           } else SeededRuns.Add(algorithmClone.Runs.Last());
     349            lock (InstanceRuns) {
     350              InstanceRuns.Add(algorithmClone.Runs.Last());
     351            }
     352          } else {
     353            lock (SeededRuns) {
     354              SeededRuns.Add(algorithmClone.Runs.Last());
     355            }
     356          }
    348357          waitHandle.Set();
    349358        }
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/HeuristicLab.OptimizationExpertSystem-3.3.csproj

    r13743 r13748  
    191191      <DependentUpon>AlgorithmControlForm.cs</DependentUpon>
    192192    </Compile>
     193    <Compile Include="Toolbar\DownloadFromOKBToolbarItem.cs" />
     194    <Compile Include="Toolbar\ToolbarItemBase.cs" />
    193195    <Compile Include="Views\KnowledgeCenterAllinOneView.cs">
    194196      <SubType>UserControl</SubType>
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Menu/0_Config/30_DownloadFromOkbMenuItem.cs

    r13720 r13748  
    2020#endregion
    2121
     22using HeuristicLab.Common;
    2223using HeuristicLab.Common.Resources;
     24using HeuristicLab.MainForm;
    2325using System;
    2426using System.Collections.Generic;
     
    4143    }
    4244
    43     public override string ToolTipText { get { return "Download relevant runs from the knowledge base."; } }
     45    public override string ToolTipText {
     46      get {
     47        return @"Download relevant runs, including algorithm instances
     48and problem instances from the OKB server.";
     49      }
     50    }
    4451
    4552    public override void Execute() {
     
    5158      ToolStripItem.Enabled = MainForm.ExpertSystem.Problem.ProblemId != -1;
    5259      MainForm.ExpertSystem.Problem.ProblemChanged += OnProblemChanged;
     60      MainForm.ExpertSystem.DownloadStarted += OnDownloadStarted;
    5361    }
    5462
     
    5664      ToolStripItem.Enabled = MainForm.ExpertSystem.Problem.ProblemId != -1;
    5765    }
     66
     67    private void OnDownloadStarted(object sender, EventArgs<IProgress> e) {
     68      ToolStripItem.Enabled = false;
     69      e.Value.ProgressStateChanged += DownloadProgressOnStateChanged;
     70    }
     71
     72    private void DownloadProgressOnStateChanged(object sender, EventArgs eventArgs) {
     73      var progress = (IProgress)sender;
     74      if (progress.ProgressState == ProgressState.Finished || progress.ProgressState == ProgressState.Canceled) {
     75        ToolStripItem.Enabled = true;
     76        progress.ProgressStateChanged -= DownloadProgressOnStateChanged;
     77      }
     78    }
    5879  }
    5980}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/OptimizationKnowledgeCenter.cs

    r13722 r13748  
    4242
    4343    private void ExpertSystemOnDownloadStarted(object sender, EventArgs<IProgress> e) {
     44      if (InvokeRequired) { Invoke((Action<object, EventArgs<IProgress>>)ExpertSystemOnDownloadStarted, sender, e); return; }
    4445      e.Value.ProgressStateChanged += OnProgressStateChanged;
    4546      e.Value.ProgressValueChanged += OnProgressValueChanged;
     
    5253
    5354    private void OnProgressStateChanged(object sender, EventArgs e) {
     55      if (InvokeRequired) { Invoke((Action<object, EventArgs>)OnProgressStateChanged, sender, e); return; }
    5456      var progress = (IProgress)sender;
    5557      if (progress.ProgressState == ProgressState.Canceled
     
    6466
    6567    private void OnProgressValueChanged(object sender, EventArgs e) {
     68      if (InvokeRequired) { Invoke((Action<object, EventArgs>)OnProgressValueChanged, sender, e); return; }
    6669      var progress = (IProgress)sender;
    6770      progressBar.Value = Math.Max(progressBar.Minimum, Math.Min(progressBar.Maximum, (int)(progress.ProgressValue * 100)));
     
    6972
    7073    private void OnProgressStatusChanged(object sender, EventArgs e) {
     74      if (InvokeRequired) { Invoke((Action<object, EventArgs>)OnProgressStatusChanged, sender, e); return; }
    7175      var progress = (IProgress)sender;
    7276      progressLabel.Text = progress.Status.Replace(Environment.NewLine, "   ");
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Toolbar/ToolbarItemBase.cs

    r13739 r13748  
    2222using HeuristicLab.MainForm.WindowsForms;
    2323
    24 namespace HeuristicLab.OptimizationExpertSystem.Menu {
    25   internal abstract class MenuItemBase : MenuItem, IOptimizationKnowledgeCenterUi {
     24namespace HeuristicLab.OptimizationExpertSystem.Toolbar {
     25  internal abstract class ToolbarItemBase : ToolBarItem, IOptimizationKnowledgeCenterUi {
    2626    public OptimizationKnowledgeCenter MainForm {
    2727      get { return (OptimizationKnowledgeCenter)HeuristicLab.MainForm.MainFormManager.MainForm; }
Note: See TracChangeset for help on using the changeset viewer.