Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/29/19 15:57:35 (5 years ago)
Author:
mkommend
Message:

#2521: Merged trunk changes into problem refactoring branch.

Location:
branches/2521_ProblemRefactoring
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring

  • branches/2521_ProblemRefactoring/HeuristicLab.Tests

  • branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/Samples/GABppSampleTest.cs

    r16723 r17226  
    1 #region License Information
    2 /* HeuristicLab
    3  * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    4  *
    5  * This file is part of HeuristicLab.
    6  *
    7  * HeuristicLab is free software: you can redistribute it and/or modify
    8  * it under the terms of the GNU General Public License as published by
    9  * the Free Software Foundation, either version 3 of the License, or
    10  * (at your option) any later version.
    11  *
    12  * HeuristicLab is distributed in the hope that it will be useful,
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  * GNU General Public License for more details.
    16  *
    17  * You should have received a copy of the GNU General Public License
    18  * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
    19  */
    20 #endregion
     1//#region License Information
     2///* HeuristicLab
     3// * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4// *
     5// * This file is part of HeuristicLab.
     6// *
     7// * HeuristicLab is free software: you can redistribute it and/or modify
     8// * it under the terms of the GNU General Public License as published by
     9// * the Free Software Foundation, either version 3 of the License, or
     10// * (at your option) any later version.
     11// *
     12// * HeuristicLab is distributed in the hope that it will be useful,
     13// * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15// * GNU General Public License for more details.
     16// *
     17// * You should have received a copy of the GNU General Public License
     18// * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19// */
     20//#endregion
    2121
    22 using System.IO;
    23 using System.Linq;
    24 using HeuristicLab.Algorithms.GeneticAlgorithm;
    25 using HeuristicLab.Encodings.PermutationEncoding;
    26 using HeuristicLab.Persistence.Default.Xml;
    27 using HeuristicLab.Problems.BinPacking3D;
    28 using HeuristicLab.Selection;
    29 using Microsoft.VisualStudio.TestTools.UnitTesting;
     22//using System.IO;
     23//using HEAL.Attic;
     24//using HeuristicLab.Algorithms.GeneticAlgorithm;
     25//using HeuristicLab.Encodings.PermutationEncoding;
     26//using HeuristicLab.Problems.BinPacking3D;
     27//using HeuristicLab.Selection;
     28//using Microsoft.VisualStudio.TestTools.UnitTesting;
    3029
    31 namespace HeuristicLab.Tests {
    32   [TestClass]
    33   public class GABppSampleTest {
    34     private const string SampleFileName = "GA_BPP";
     30//namespace HeuristicLab.Tests {
     31//  [TestClass]
     32//  public class GABppSampleTest {
     33//    private const string SampleFileName = "GA_BPP";
    3534
    36     [TestMethod]
    37     [TestCategory("Samples.Create")]
    38     [TestProperty("Time", "medium")]
    39     public void CreateGaBppSampleTest() {
    40       var ga = CreateGaBppSample();
    41       string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
    42       XmlGenerator.Serialize(ga, path);
    43     }
     35//    private static readonly ProtoBufSerializer serializer = new ProtoBufSerializer();
    4436
    45     [TestMethod]
    46     [TestCategory("Samples.Execute")]
    47     [TestProperty("Time", "long")]
    48     public void RunGaBppSampleTest() {
    49       var ga = CreateGaBppSample();
    50       ga.SetSeedRandomly.Value = false;
    51       SamplesUtils.RunAlgorithm(ga);
    52       Assert.AreEqual(0.59369488300408157, SamplesUtils.GetDoubleResult(ga, "BestQuality"), 1E-6);
    53       Assert.AreEqual(0.51834350243004124, SamplesUtils.GetDoubleResult(ga, "CurrentAverageQuality"),1E-6);
    54       Assert.AreEqual(0.36227753691428577, SamplesUtils.GetDoubleResult(ga, "CurrentWorstQuality"),1E-6);
    55       Assert.AreEqual(15250, SamplesUtils.GetIntResult(ga, "EvaluatedSolutions"));
    56     }
     37//    [TestMethod]
     38//    [TestCategory("Samples.Create")]
     39//    [TestProperty("Time", "medium")]
     40//    public void CreateGaBppSampleTest() {
     41//      var ga = CreateGaBppSample();
     42//      string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);
     43//      serializer.Serialize(ga, path);
     44//    }
    5745
    58     private GeneticAlgorithm CreateGaBppSample() {
    59       GeneticAlgorithm ga = new GeneticAlgorithm();
     46//    [TestMethod]
     47//    [TestCategory("Samples.Execute")]
     48//    [TestProperty("Time", "long")]
     49//    public void RunGaBppSampleTest() {
     50//      var ga = CreateGaBppSample();
     51//      ga.SetSeedRandomly.Value = false;
     52//      SamplesUtils.RunAlgorithm(ga);
     53//      Assert.AreEqual(0.59369488300408157, SamplesUtils.GetDoubleResult(ga, "BestQuality"), 1E-6);
     54//      Assert.AreEqual(0.51834350243004124, SamplesUtils.GetDoubleResult(ga, "CurrentAverageQuality"),1E-6);
     55//      Assert.AreEqual(0.36227753691428577, SamplesUtils.GetDoubleResult(ga, "CurrentWorstQuality"),1E-6);
     56//      Assert.AreEqual(15250, SamplesUtils.GetIntResult(ga, "EvaluatedSolutions"));
     57//    }
    6058
    61       #region Problem Configuration
    62       var bpp = new PermutationProblem();
    63       #endregion
    64       #region Algorithm Configuration
    65       ga.Name = "Genetic Algorithm - Bin Packing Problem (3D)";
    66       ga.Description = "A genetic algorithm which solves the a 3d bin packing problem instance";
    67       ga.Problem = bpp;
    68       SamplesUtils.ConfigureGeneticAlgorithmParameters<TournamentSelector, PartiallyMatchedCrossover, Swap2Manipulator>(
    69         ga, 300, 1, 50, 0.05, 3);
    70       #endregion
     59//    private GeneticAlgorithm CreateGaBppSample() {
     60//      GeneticAlgorithm ga = new GeneticAlgorithm();
    7161
    72       return ga;
    73     }
    74   }
    75 }
     62//      #region Problem Configuration
     63//      var bpp = new PermutationProblem();
     64//      #endregion
     65//      #region Algorithm Configuration
     66//      ga.Name = "Genetic Algorithm - Bin Packing Problem (3D)";
     67//      ga.Description = "A genetic algorithm which solves the a 3d bin packing problem instance";
     68//      ga.Problem = bpp;
     69//      SamplesUtils.ConfigureGeneticAlgorithmParameters<TournamentSelector, PartiallyMatchedCrossover, Swap2Manipulator>(
     70//        ga, 300, 1, 50, 0.05, 3);
     71//      #endregion
     72
     73//      return ga;
     74//    }
     75//  }
     76//}
Note: See TracChangeset for help on using the changeset viewer.