Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/28/17 16:47:42 (7 years ago)
Author:
jkarder
Message:

#2258: merged r15287 into stable

Location:
stable
Files:
1 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Tests

  • stable/HeuristicLab.Tests/HeuristicLab-3.3/CollectObjectGraphTest.cs

    r14186 r15292  
    2424using System.Diagnostics;
    2525using System.Linq;
    26 using System.Threading;
    2726using System.Threading.Tasks;
    2827using HeuristicLab.Algorithms.GeneticAlgorithm;
     
    125124        algs.Add(ga);
    126125
    127         var cancellationTokenSource = new CancellationTokenSource();
    128         ga.StartSync(cancellationTokenSource.Token);
     126        ga.Start();
    129127        sw.Stop();
    130128        TestContext.WriteLine("{0}: {1} ", i, sw.Elapsed);
     
    157155          var sw = new Stopwatch();
    158156          sw.Start();
    159           ga.StartSync(new CancellationToken());
     157          ga.Start();
    160158          sw.Stop();
    161159          Console.WriteLine("{0}; Objects after execution: {1}", ga.Name, ga.GetObjectGraphObjects().Count());
  • stable/HeuristicLab.Tests/HeuristicLab-3.3/GeneticAlgorithmTest.cs

    r14186 r15292  
    2121
    2222using System;
    23 using System.Threading;
    2423using HeuristicLab.Algorithms.GeneticAlgorithm;
    2524using HeuristicLab.Common;
     
    3938    }
    4039
    41     private EventWaitHandle trigger = new AutoResetEvent(false);
    4240    private Exception ex;
    4341
     
    4947      GeneticAlgorithm ga = (GeneticAlgorithm)XmlParser.Deserialize(@"Test Resources\GA_TSP.hl");
    5048      ga.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(ga_ExceptionOccurred);
    51       ga.Stopped += new EventHandler(ga_Stopped);
    5249      ga.SetSeedRandomly.Value = false;
    5350      ga.Seed.Value = 0;
     
    5552      ga.Prepare();
    5653      ga.Start();
    57       trigger.WaitOne();
    5854      if (ex != null) throw ex;
    5955
     
    8076      ex = e.Value;
    8177    }
    82 
    83     private void ga_Stopped(object sender, EventArgs e) {
    84       trigger.Set();
    85     }
    8678  }
    8779}
  • stable/HeuristicLab.Tests/HeuristicLab-3.3/Samples/SamplesUtils.cs

    r13296 r15292  
    11using System;
    22using System.Linq;
    3 using System.Threading;
    43using HeuristicLab.Algorithms.ALPS;
    54using HeuristicLab.Algorithms.EvolutionStrategy;
     
    1817
    1918    public static void RunAlgorithm(IAlgorithm a) {
    20       var trigger = new EventWaitHandle(false, EventResetMode.ManualReset);
    2119      Exception ex = null;
    22       a.Stopped += (src, e) => { trigger.Set(); };
    23       a.ExceptionOccurred += (src, e) => { ex = e.Value; trigger.Set(); };
     20      a.ExceptionOccurred += (sender, e) => { ex = e.Value; };
    2421      a.Prepare();
    2522      a.Start();
    26       trigger.WaitOne();
    27 
    28       Assert.AreEqual(ex, null);
     23      Assert.IsNull(ex);
    2924    }
    3025
  • stable/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GaussianProcessRegressionTest.cs

    r14186 r15292  
    2222using System;
    2323using System.Linq;
    24 using System.Threading;
    2524using HeuristicLab.Common;
    2625using HeuristicLab.Problems.DataAnalysis;
     
    3938    }
    4039
    41     private EventWaitHandle trigger = new AutoResetEvent(false);
    4240    private Exception ex;
    4341
     
    6664
    6765      alg.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(cv_ExceptionOccurred);
    68       alg.Stopped += new EventHandler(cv_Stopped);
    6966
    7067      alg.Prepare();
    7168      alg.Start();
    72       trigger.WaitOne();
    7369      if (ex != null) throw ex;
    7470
     
    7975      ex = e.Value;
    8076    }
    81 
    82     private void cv_Stopped(object sender, EventArgs e) {
    83       trigger.Set();
    84     }
    8577  }
    8678}
  • stable/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/GradientBoostingTest.cs

    r14023 r15292  
    33using System.IO;
    44using System.Linq;
    5 using System.Threading;
    65using HeuristicLab.Data;
    7 using HeuristicLab.Optimization;
    86using HeuristicLab.Problems.DataAnalysis;
    97using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    242240      #endregion
    243241
    244       RunAlgorithm(gbt);
     242      gbt.Start();
    245243
    246244      Console.WriteLine(gbt.ExecutionTime);
     
    270268      #endregion
    271269
    272       RunAlgorithm(gbt);
     270      gbt.Start();
    273271
    274272      Console.WriteLine(gbt.ExecutionTime);
     
    298296      #endregion
    299297
    300       RunAlgorithm(gbt);
     298      gbt.Start();
    301299
    302300      Console.WriteLine(gbt.ExecutionTime);
    303301      Assert.AreEqual(0.061954221604374943, ((DoubleValue)gbt.Results["Loss (train)"].Value).Value, 1E-6);
    304302      Assert.AreEqual(0.06316303473499961, ((DoubleValue)gbt.Results["Loss (test)"].Value).Value, 1E-6);
    305     }
    306 
    307     // same as in SamplesUtil
    308     private void RunAlgorithm(IAlgorithm a) {
    309       var trigger = new EventWaitHandle(false, EventResetMode.ManualReset);
    310       Exception ex = null;
    311       a.Stopped += (src, e) => { trigger.Set(); };
    312       a.ExceptionOccurred += (src, e) => { ex = e.Value; trigger.Set(); };
    313       a.Prepare();
    314       a.Start();
    315       trigger.WaitOne();
    316 
    317       Assert.AreEqual(ex, null);
    318303    }
    319304
  • stable/HeuristicLab.Tests/HeuristicLab.Algorithms.DataAnalysis-3.4/SupportVectorMachineTest.cs

    r14186 r15292  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using System.Threading;
    2625using HeuristicLab.Algorithms.DataAnalysis;
    2726using HeuristicLab.Common;
     
    5049    }
    5150
    52     private EventWaitHandle trigger = new AutoResetEvent(false);
    5351    private Exception ex;
    5452
     
    7169
    7270      cv.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(cv_ExceptionOccurred);
    73       cv.Stopped += new EventHandler(cv_Stopped);
    7471
    7572      cv.Prepare();
    7673      cv.Start();
    77       trigger.WaitOne();
    7874      if (ex != null) throw ex;
    7975
     
    10298      ex = e.Value;
    10399    }
    104 
    105     private void cv_Stopped(object sender, EventArgs e) {
    106       trigger.Set();
    107     }
    108100  }
    109101}
  • stable/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/Script Sources/GUIAutomationScriptSource.cs

    r11789 r15292  
    1 using System;
    2 using System.Linq;
    3 using System.Threading;
     1using System.Linq;
    42using System.Windows.Forms;
    53
    64using HeuristicLab.Algorithms.GeneticAlgorithm;
    7 using HeuristicLab.Core;
    85using HeuristicLab.MainForm;
    96using HeuristicLab.MainForm.WindowsForms;
     
    1310
    1411public class GUIAutomationScript : HeuristicLab.Scripting.CSharpScriptBase {
    15   readonly ManualResetEvent mutex = new ManualResetEvent(false);
    16 
    1712  public override void Main() {
    1813    var ga = new GeneticAlgorithm {
     
    2722      ga.PopulationSize.Value *= 2;
    2823    }
    29 
    30     experiment.ExecutionStateChanged += OnExecutionStateChanged;
    3124    experiment.Start();
    32     mutex.WaitOne();
    3325
    3426    vars.experiment = experiment;
     
    3931    bubbleChart.Controls.OfType<ComboBox>().Single(x => x.Name == "xAxisComboBox").SelectedItem = "PopulationSize";
    4032  }
    41 
    42   private void OnExecutionStateChanged(object sender, EventArgs e) {
    43     if (((IExecutable)sender).ExecutionState == ExecutionState.Stopped)
    44       mutex.Set();
    45   }
    4633}
  • stable/HeuristicLab.Tests/HeuristicLab.Scripting-3.3/ScriptingUtils.cs

    r14186 r15292  
    2121
    2222using System;
    23 using System.Threading;
    2423using HeuristicLab.Scripting;
    2524using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3332
    3433    public static void RunScript(CSharpScript s) {
    35       var trigger = new EventWaitHandle(false, EventResetMode.ManualReset);
    3634      Exception ex = null;
    37 
    38       s.ScriptExecutionFinished += (sender, e) => { ex = e.Value; trigger.Set(); };
    39       s.ExecuteAsync();
    40       trigger.WaitOne();
    41 
     35      s.ScriptExecutionFinished += (sender, e) => { ex = e.Value; };
     36      s.Execute();
    4237      Assert.IsNull(ex);
    4338    }
  • stable/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r15277 r15292  
    446446  <ItemGroup>
    447447    <Compile Include="AssemblyInitializer.cs" />
    448     <Compile Include="HeuristicLab-3.3\AlgorithmExtensions.cs" />
    449448    <Compile Include="HeuristicLab-3.3\CloningConstructorTest.cs" />
    450449    <Compile Include="HeuristicLab-3.3\CollectObjectGraphTest.cs" />
Note: See TracChangeset for help on using the changeset viewer.