Changeset 11202 for branches/HiveStatistics/sources/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/TestUtils.cs
- Timestamp:
- 07/18/14 12:01:13 (10 years ago)
- Location:
- branches/HiveStatistics/sources
- Files:
-
- 3 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/TestUtils.cs
r8924 r11202 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.