Changeset 15223


Ignore:
Timestamp:
07/13/17 10:21:43 (2 months ago)
Author:
abeham
Message:

#2797: Updated sample to change from Schwefel to Rastrigin (in the hope that it's numerically more stable)

Location:
trunk/sources
Files:
1 added
1 deleted
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimizer/3.3/HeuristicLab.Optimizer-3.3.csproj

    r15003 r15223  
    129129    <EmbeddedResource Include="Documents\SGP_SymbReg.hl" />
    130130    <EmbeddedResource Include="Documents\VNS_TSP.hl" />
    131     <EmbeddedResource Include="Documents\PSO_Schwefel.hl" />
    132131    <EmbeddedResource Include="Documents\SS_VRP.hl" />
    133132    <EmbeddedResource Include="Documents\RAPGA_JSSP.hl" />
     
    152151    <EmbeddedResource Include="Documents\OSES_Griewank.hl" />
    153152    <EmbeddedResource Include="Documents\SGP_Robocode.hl" />
     153    <EmbeddedResource Include="Documents\PSO_Rastrigin.hl" />
    154154    <None Include="Plugin.cs.frame" />
    155155    <Compile Include="ChangeNestingLevelDialog.cs">
  • trunk/sources/HeuristicLab.Optimizer/3.3/StartPage.cs

    r14204 r15223  
    134134    private void FillGroupLookup() {
    135135      var standardProblems = new List<string> { "ALPSGA_TSP", "ES_Griewank", "OSES_Griewank", "GA_Grouping", "GA_TSP", "GA_VRP", "GE_ArtificialAnt",
    136                 "IslandGA_TSP", "LS_Knapsack", "PSO_Schwefel", "RAPGA_JSSP",
     136                "IslandGA_TSP", "LS_Knapsack", "PSO_Rastrigin", "RAPGA_JSSP",
    137137                "SA_Rastrigin", "SGP_SantaFe", "GP_Multiplexer", "SGP_Robocode", "SS_VRP", "TS_TSP", "TS_VRP", "VNS_OP", "VNS_TSP", "GA_BPP"
    138138        };
  • trunk/sources/HeuristicLab.Tests/HeuristicLab-3.3/Samples/PsoRastriginSampleTest.cs

    r15222 r15223  
    2424using System.Linq;
    2525using HeuristicLab.Algorithms.ParticleSwarmOptimization;
    26 using HeuristicLab.Data;
    2726using HeuristicLab.Encodings.RealVectorEncoding;
    2827using HeuristicLab.Persistence.Default.Xml;
     
    3332  [TestClass]
    3433  public class PsoSchwefelSampleTest {
    35     private const string SampleFileName = "PSO_Schwefel";
     34    private const string SampleFileName = "PSO_Rastrigin";
    3635
    3736    [TestMethod]
    3837    [TestCategory("Samples.Create")]
    3938    [TestProperty("Time", "medium")]
    40     public void CreatePsoSchwefelSampleTest() {
    41       var pso = CreatePsoSchwefelSample();
     39    public void CreatePsoRastriginSampleTest() {
     40      var pso = CreatePsoRastriginSample();
    4241      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
    4342      XmlGenerator.Serialize(pso, path);
     
    4645    [TestCategory("Samples.Execute")]
    4746    [TestProperty("Time", "medium")]
    48     public void RunPsoSchwefelSampleTest() {
    49       var pso = CreatePsoSchwefelSample();
     47    public void RunPsoRastriginSampleTest() {
     48      var pso = CreatePsoRastriginSample();
    5049      pso.SetSeedRandomly.Value = false;
    5150      SamplesUtils.RunAlgorithm(pso);
    5251      if (Environment.Is64BitProcess) {
    53         Assert.AreEqual(-1.4779288903810084E-12, SamplesUtils.GetDoubleResult(pso, "BestQuality"));
    54         Assert.AreEqual(189.28837949705971, SamplesUtils.GetDoubleResult(pso, "CurrentAverageQuality"));
    55         Assert.AreEqual(1195.4166822158872, SamplesUtils.GetDoubleResult(pso, "CurrentWorstQuality"));
     52        Assert.AreEqual(0, SamplesUtils.GetDoubleResult(pso, "BestQuality"));
     53        Assert.AreEqual(3.9649516110677525, SamplesUtils.GetDoubleResult(pso, "CurrentAverageQuality"));
     54        Assert.AreEqual(25.566430359483757, SamplesUtils.GetDoubleResult(pso, "CurrentWorstQuality"));
    5655        Assert.AreEqual(200, SamplesUtils.GetIntResult(pso, "Iterations"));
    5756      } else {
    58         Assert.AreEqual(-1.4779288903810084E-12, SamplesUtils.GetDoubleResult(pso, "BestQuality"));
    59         Assert.AreEqual(189.28837949705971, SamplesUtils.GetDoubleResult(pso, "CurrentAverageQuality"));
    60         Assert.AreEqual(1195.4166822158873, SamplesUtils.GetDoubleResult(pso, "CurrentWorstQuality"));
     57        Assert.AreEqual(0, SamplesUtils.GetDoubleResult(pso, "BestQuality"));
     58        Assert.AreEqual(3.3957460831564048, SamplesUtils.GetDoubleResult(pso, "CurrentAverageQuality"));
     59        Assert.AreEqual(34.412788077766145, SamplesUtils.GetDoubleResult(pso, "CurrentWorstQuality"));
    6160        Assert.AreEqual(200, SamplesUtils.GetIntResult(pso, "Iterations"));
    6261      }
    6362    }
    6463
    65     private ParticleSwarmOptimization CreatePsoSchwefelSample() {
     64    private ParticleSwarmOptimization CreatePsoRastriginSample() {
    6665      ParticleSwarmOptimization pso = new ParticleSwarmOptimization();
    6766      #region Problem Configuration
    6867      var problem = new SingleObjectiveTestFunctionProblem();
    69       problem.BestKnownQuality.Value = 0.0;
    70       problem.BestKnownSolutionParameter.Value = new RealVector(new double[] { 420.968746, 420.968746 });
    71       problem.Bounds = new DoubleMatrix(new double[,] { { -500, 500 } });
    72       problem.EvaluatorParameter.Value = new SchwefelEvaluator();
    73       problem.Maximization.Value = false;
    74       problem.ProblemSize.Value = 2;
     68      var provider = new SOTFInstanceProvider();
     69      problem.Load(provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name == "Rastrigin Function")));
    7570      problem.SolutionCreatorParameter.Value = new UniformRandomRealVectorCreator();
    7671      #endregion
    7772      #region Algorithm Configuration
    78       pso.Name = "Particle Swarm Optimization - Schwefel";
    79       pso.Description = "A particle swarm optimization algorithm which solves the 2-dimensional Schwefel test function (based on the description in Pedersen, M.E.H. (2010). PhD thesis. University of Southampton)";
     73      pso.Name = "Particle Swarm Optimization - Rastrigin";
     74      pso.Description = "A particle swarm optimization algorithm which solves the 2-dimensional Rastrigin test function.";
    8075      pso.Problem = problem;
    8176      pso.Inertia.Value = 0.721;
Note: See TracChangeset for help on using the changeset viewer.