Changeset 11205 for branches/HiveStatistics/sources/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3
- Timestamp:
- 07/18/14 13:44:53 (10 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources
- Property svn:ignore
-
old new 8 8 FxCopResults.txt 9 9 Google.ProtocolBuffers-0.9.1.dll 10 Google.ProtocolBuffers-2.4.1.473.dll 10 11 HeuristicLab 3.3.5.1.ReSharper.user 11 12 HeuristicLab 3.3.6.0.ReSharper.user 12 13 HeuristicLab.4.5.resharper.user 13 14 HeuristicLab.ExtLibs.6.0.ReSharper.user 15 HeuristicLab.Scripting.Development 14 16 HeuristicLab.resharper.user 15 17 ProtoGen.exe … … 17 19 _ReSharper.HeuristicLab 18 20 _ReSharper.HeuristicLab 3.3 21 _ReSharper.HeuristicLab 3.3 Tests 19 22 _ReSharper.HeuristicLab.ExtLibs 20 23 bin 21 24 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests23 Google.ProtocolBuffers-2.4.1.473.dll
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/HiveStatistics/sources/HeuristicLab.Tests
- Property svn:mergeinfo changed
-
branches/HiveStatistics/sources/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/DirectScheduleGTCrossoverTest.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System.Linq; 22 23 using HeuristicLab.Core; 23 using HeuristicLab.Encodings.ScheduleEncoding;24 24 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition; 25 25 using HeuristicLab.Encodings.ScheduleEncoding.ScheduleEncoding; … … 27 27 using Microsoft.VisualStudio.TestTools.UnitTesting; 28 28 29 namespace HeuristicLab.Encodings.ScheduleEncoding_33.Tests { 30 31 29 namespace HeuristicLab.Encodings.ScheduleEncoding.Tests { 32 30 /// <summary> 33 31 ///This is a test class for DirectScheduleGTCrossoverTest and is intended … … 36 34 [TestClass()] 37 35 public class DirectScheduleGTCrossoverTest { 38 39 40 private TestContext testContextInstance;41 42 /// <summary>43 ///Gets or sets the test context which provides44 ///information about and functionality for the current test run.45 ///</summary>46 public TestContext TestContext {47 get {48 return testContextInstance;49 }50 set {51 testContextInstance = value;52 }53 }54 55 #region Additional test attributes56 //57 //You can use the following additional attributes as you write your tests:58 //59 //Use ClassInitialize to run code before running the first test in the class60 //[ClassInitialize()]61 //public static void MyClassInitialize(TestContext testContext)62 //{63 //}64 //65 //Use ClassCleanup to run code after all tests in a class have run66 //[ClassCleanup()]67 //public static void MyClassCleanup()68 //{69 //}70 //71 //Use TestInitialize to run code before running each test72 //[TestInitialize()]73 //public void MyTestInitialize()74 //{75 //}76 //77 //Use TestCleanup to run code after each test has run78 //[TestCleanup()]79 //public void MyTestCleanup()80 //{81 //}82 //83 #endregion84 85 86 36 /// <summary> 87 37 ///A test for Apply 88 38 ///</summary> 89 [TestMethod()] 39 [TestMethod] 40 [TestCategory("Encodings.Schedule")] 41 [TestProperty("Time", "short")] 90 42 public void ApplyTest() { 91 IRandom random = new TestRandom(new int[] { 43 IRandom random = new TestRandom(new int[] { 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1 }, new double[] { 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9, 0.9 }); 92 44 Schedule parent1 = TestUtils.CreateTestSchedule1(); 93 45 Schedule parent2 = TestUtils.CreateTestSchedule2(); … … 97 49 actual = DirectScheduleGTCrossover.Apply(random, parent1, parent2, jobData, mutProp); 98 50 Schedule expected = DirectScheduleRandomCreator.Apply(3, 3, new PWREncoding(3, 3, new TestRandom(new int[] { 0, 2, 1, 1, 0, 2, 1, 2, 0 }, null)), TestUtils.CreateJobData()); 99 Assert.IsTrue( actual.Equals(expected));51 Assert.IsTrue(TestUtils.ScheduleEquals(actual, expected)); 100 52 } 53 101 54 } 102 55 } -
branches/HiveStatistics/sources/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/JSMJOXCrossoverTest.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 using Microsoft.VisualStudio.TestTools.UnitTesting; 27 27 28 namespace HeuristicLab.Encodings.ScheduleEncoding_33.Tests { 29 30 28 namespace HeuristicLab.Encodings.ScheduleEncoding.Tests { 31 29 /// <summary> 32 30 ///This is a test class for JSMJOXCrossoverTest and is intended … … 35 33 [TestClass()] 36 34 public class JSMJOXCrossoverTest { 37 38 39 private TestContext testContextInstance;40 41 /// <summary>42 ///Gets or sets the test context which provides43 ///information about and functionality for the current test run.44 ///</summary>45 public TestContext TestContext {46 get {47 return testContextInstance;48 }49 set {50 testContextInstance = value;51 }52 }53 54 #region Additional test attributes55 //56 //You can use the following additional attributes as you write your tests:57 //58 //Use ClassInitialize to run code before running the first test in the class59 //[ClassInitialize()]60 //public static void MyClassInitialize(TestContext testContext)61 //{62 //}63 //64 //Use ClassCleanup to run code after all tests in a class have run65 //[ClassCleanup()]66 //public static void MyClassCleanup()67 //{68 //}69 //70 //Use TestInitialize to run code before running each test71 //[TestInitialize()]72 //public void MyTestInitialize()73 //{74 //}75 //76 //Use TestCleanup to run code after each test has run77 //[TestCleanup()]78 //public void MyTestCleanup()79 //{80 //}81 //82 #endregion83 84 85 35 /// <summary> 86 36 ///A test for Apply 87 37 ///</summary> 88 [TestMethod()] 38 [TestMethod] 39 [TestCategory("Encodings.Schedule")] 40 [TestProperty("Time", "short")] 89 41 public void ApplyTest() { 90 42 IRandom random = new TestRandom(new int[] { 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1 }, null); … … 101 53 actual = JSMJOXCrossover.Apply(random, p1, p2); 102 54 103 Assert.IsTrue( expected.Equals(actual));55 Assert.IsTrue(TestUtils.JSMEncodingEquals(expected, actual)); 104 56 } 105 57 } -
branches/HiveStatistics/sources/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/JSMSXXCrossoverTest.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 using Microsoft.VisualStudio.TestTools.UnitTesting; 27 27 28 namespace HeuristicLab.Encodings.ScheduleEncoding_33.Tests { 29 30 28 namespace HeuristicLab.Encodings.ScheduleEncoding.Tests { 31 29 /// <summary> 32 30 ///This is a test class for JSMSXXCrossoverTest and is intended … … 35 33 [TestClass()] 36 34 public class JSMSXXCrossoverTest { 37 38 39 private TestContext testContextInstance;40 41 /// <summary>42 ///Gets or sets the test context which provides43 ///information about and functionality for the current test run.44 ///</summary>45 public TestContext TestContext {46 get {47 return testContextInstance;48 }49 set {50 testContextInstance = value;51 }52 }53 54 #region Additional test attributes55 //56 //You can use the following additional attributes as you write your tests:57 //58 //Use ClassInitialize to run code before running the first test in the class59 //[ClassInitialize()]60 //public static void MyClassInitialize(TestContext testContext)61 //{62 //}63 //64 //Use ClassCleanup to run code after all tests in a class have run65 //[ClassCleanup()]66 //public static void MyClassCleanup()67 //{68 //}69 //70 //Use TestInitialize to run code before running each test71 //[TestInitialize()]72 //public void MyTestInitialize()73 //{74 //}75 //76 //Use TestCleanup to run code after each test has run77 //[TestCleanup()]78 //public void MyTestCleanup()79 //{80 //}81 //82 #endregion83 84 85 35 /// <summary> 86 36 ///A test for Apply 87 37 ///</summary> 88 [TestMethod()] 38 [TestMethod] 39 [TestCategory("Encodings.Schedule")] 40 [TestProperty("Time", "short")] 89 41 public void ApplyTest() { 90 42 IRandom random = new TestRandom(new int[] { 3 }, null); … … 101 53 actual = JSMSXXCrossover.Apply(random, p1, p2); 102 54 103 Assert.IsTrue( expected.Equals(actual));55 Assert.IsTrue(TestUtils.JSMEncodingEquals(expected, actual)); 104 56 } 105 57 } -
branches/HiveStatistics/sources/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/JSMShiftChangeManipulatorTest.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 using Microsoft.VisualStudio.TestTools.UnitTesting; 27 27 28 namespace HeuristicLab.Encodings.ScheduleEncoding_33.Tests { 29 30 28 namespace HeuristicLab.Encodings.ScheduleEncoding.Tests { 31 29 /// <summary> 32 30 ///This is a test class for JSMShiftChangeManipulatorTest and is intended … … 35 33 [TestClass()] 36 34 public class JSMShiftChangeManipulatorTest { 37 38 39 private TestContext testContextInstance;40 41 /// <summary>42 ///Gets or sets the test context which provides43 ///information about and functionality for the current test run.44 ///</summary>45 public TestContext TestContext {46 get {47 return testContextInstance;48 }49 set {50 testContextInstance = value;51 }52 }53 54 #region Additional test attributes55 //56 //You can use the following additional attributes as you write your tests:57 //58 //Use ClassInitialize to run code before running the first test in the class59 //[ClassInitialize()]60 //public static void MyClassInitialize(TestContext testContext)61 //{62 //}63 //64 //Use ClassCleanup to run code after all tests in a class have run65 //[ClassCleanup()]66 //public static void MyClassCleanup()67 //{68 //}69 //70 //Use TestInitialize to run code before running each test71 //[TestInitialize()]72 //public void MyTestInitialize()73 //{74 //}75 //76 //Use TestCleanup to run code after each test has run77 //[TestCleanup()]78 //public void MyTestCleanup()79 //{80 //}81 //82 #endregion83 84 85 35 /// <summary> 86 36 ///A test for Apply 87 37 ///</summary> 88 [TestMethod()] 38 [TestMethod] 39 [TestCategory("Encodings.Schedule")] 40 [TestProperty("Time", "short")] 89 41 public void ApplyTest() { 90 42 IRandom random = new TestRandom(new int[] { 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2 }, null); … … 99 51 expected.JobSequenceMatrix = jsm; 100 52 101 Assert.IsTrue( individual.Equals(expected));53 Assert.IsTrue(TestUtils.JSMEncodingEquals(expected, individual)); 102 54 } 103 55 } -
branches/HiveStatistics/sources/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/PWRGOXCrossoverTest.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 using Microsoft.VisualStudio.TestTools.UnitTesting; 27 27 28 namespace HeuristicLab.Encodings.ScheduleEncoding_33.Tests { 29 30 28 namespace HeuristicLab.Encodings.ScheduleEncoding.Tests { 31 29 /// <summary> 32 30 ///This is a test class for PWRGOXCrossoverTest and is intended … … 35 33 [TestClass()] 36 34 public class PWRGOXCrossoverTest { 37 38 39 private TestContext testContextInstance;40 41 /// <summary>42 ///Gets or sets the test context which provides43 ///information about and functionality for the current test run.44 ///</summary>45 public TestContext TestContext {46 get {47 return testContextInstance;48 }49 set {50 testContextInstance = value;51 }52 }53 54 #region Additional test attributes55 //56 //You can use the following additional attributes as you write your tests:57 //58 //Use ClassInitialize to run code before running the first test in the class59 //[ClassInitialize()]60 //public static void MyClassInitialize(TestContext testContext)61 //{62 //}63 //64 //Use ClassCleanup to run code after all tests in a class have run65 //[ClassCleanup()]66 //public static void MyClassCleanup()67 //{68 //}69 //70 //Use TestInitialize to run code before running each test71 //[TestInitialize()]72 //public void MyTestInitialize()73 //{74 //}75 //76 //Use TestCleanup to run code after each test has run77 //[TestCleanup()]78 //public void MyTestCleanup()79 //{80 //}81 //82 #endregion83 84 85 35 /// <summary> 86 36 ///A test for Apply 87 37 ///</summary> 88 [TestMethod()] 38 [TestMethod] 39 [TestCategory("Encodings.Schedule")] 40 [TestProperty("Time", "short")] 89 41 public void ApplyTest() { 90 42 IRandom random = new TestRandom(new int[] { 3 }, null); … … 95 47 PWREncoding actual; 96 48 actual = PWRGOXCrossover.Apply(random, parent1, parent2); 97 Assert.IsTrue( actual.Equals(expected));49 Assert.IsTrue(TestUtils.PRWEncodingEquals(expected, actual)); 98 50 } 99 51 } -
branches/HiveStatistics/sources/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/PWRPPXCrossoverTest.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 26 26 using Microsoft.VisualStudio.TestTools.UnitTesting; 27 27 28 namespace HeuristicLab.Encodings.ScheduleEncoding_33.Tests { 29 30 28 namespace HeuristicLab.Encodings.ScheduleEncoding.Tests { 31 29 /// <summary> 32 30 ///This is a test class for PWRPPXCrossoverTest and is intended … … 35 33 [TestClass()] 36 34 public class PWRPPXCrossoverTest { 37 38 39 private TestContext testContextInstance;40 41 /// <summary>42 ///Gets or sets the test context which provides43 ///information about and functionality for the current test run.44 ///</summary>45 public TestContext TestContext {46 get {47 return testContextInstance;48 }49 set {50 testContextInstance = value;51 }52 }53 54 #region Additional test attributes55 //56 //You can use the following additional attributes as you write your tests:57 //58 //Use ClassInitialize to run code before running the first test in the class59 //[ClassInitialize()]60 //public static void MyClassInitialize(TestContext testContext)61 //{62 //}63 //64 //Use ClassCleanup to run code after all tests in a class have run65 //[ClassCleanup()]66 //public static void MyClassCleanup()67 //{68 //}69 //70 //Use TestInitialize to run code before running each test71 //[TestInitialize()]72 //public void MyTestInitialize()73 //{74 //}75 //76 //Use TestCleanup to run code after each test has run77 //[TestCleanup()]78 //public void MyTestCleanup()79 //{80 //}81 //82 #endregion83 84 85 35 /// <summary> 86 36 ///A test for Apply 87 37 ///</summary> 88 [TestMethod()] 38 [TestMethod] 39 [TestCategory("Encodings.Schedule")] 40 [TestProperty("Time", "short")] 89 41 public void ApplyTest() { 90 42 IRandom random = new TestRandom(new int[] { 1, 1, 0, 0, 1, 1, 0, 0, 1 }, null); … … 95 47 PWREncoding actual; 96 48 actual = PWRPPXCrossover.Apply(random, parent1, parent2); 97 Assert.IsTrue( actual.Equals(expected));49 Assert.IsTrue(TestUtils.PRWEncodingEquals(expected, actual)); 98 50 } 99 51 } -
branches/HiveStatistics/sources/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/TestUtils.cs
r11203 r11205 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 2Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System.Linq; 22 23 using HeuristicLab.Core; 23 24 using HeuristicLab.Encodings.IntegerVectorEncoding; 24 25 using HeuristicLab.Encodings.PermutationEncoding; 25 using HeuristicLab.Encodings.ScheduleEncoding;26 26 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix; 27 27 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition; 28 28 using HeuristicLab.Tests; 29 29 30 namespace HeuristicLab.Encodings.ScheduleEncoding _33.Tests {30 namespace HeuristicLab.Encodings.ScheduleEncoding.Tests { 31 31 public class TestUtils { 32 32 public static JSMEncoding CreateTestJSM1() { … … 98 98 return result; 99 99 } 100 public static bool ScheduleEquals(Schedule actual, Schedule expected) { 101 return actual.Resources.Count == expected.Resources.Count && 102 actual.Resources.Zip(expected.Resources, (a, e) => ResourceEquals(a, e)).All(_ => _); 103 } 104 105 public static bool ResourceEquals(Resource actual, Resource expected) { 106 return actual.Index == expected.Index && 107 actual.TotalDuration == expected.TotalDuration && 108 actual.Tasks.Count == expected.Tasks.Count && 109 actual.Tasks.Zip(expected.Tasks, (a, e) => TaskEquals(a, e)).All(_ => _); 110 } 111 112 public static bool TaskEquals(ScheduledTask actual, ScheduledTask expected) { 113 return 114 actual.StartTime == expected.StartTime && 115 actual.EndTime == expected.EndTime && 116 actual.Duration == expected.Duration && 117 actual.ResourceNr == expected.ResourceNr && 118 actual.JobNr == expected.JobNr && 119 actual.TaskNr == expected.TaskNr; 120 } 121 122 public static bool JSMEncodingEquals(JSMEncoding expected, JSMEncoding actual) { 123 if (expected.JobSequenceMatrix.Count != actual.JobSequenceMatrix.Count) 124 return false; 125 for (int i = 0; i < expected.JobSequenceMatrix.Count; i++) { 126 if (!PermutationEquals(expected.JobSequenceMatrix[i], actual.JobSequenceMatrix[i])) 127 return false; 128 } 129 return true; 130 } 131 private static bool PermutationEquals(Permutation p1, Permutation p2) { 132 if (p1.Length != p2.Length) 133 return false; 134 for (int i = 0; i < p1.Length; i++) { 135 if (p1[i] != p2[i]) 136 return false; 137 } 138 return true; 139 } 140 141 public static bool PRWEncodingEquals(PWREncoding expected, PWREncoding actual) { 142 if (expected.PermutationWithRepetition.Length != actual.PermutationWithRepetition.Length) 143 return false; 144 for (int i = 0; i < expected.PermutationWithRepetition.Length; i++) { 145 if (expected.PermutationWithRepetition[i] != actual.PermutationWithRepetition[i]) 146 return false; 147 } 148 return true; 149 } 100 150 } 101 151 }
Note: See TracChangeset
for help on using the changeset viewer.