- Timestamp:
- 02/20/14 13:46:04 (11 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMEncoding.cs
r9456 r10476 20 20 #endregion 21 21 22 using System; 22 23 using System.Text; 23 24 using HeuristicLab.Common; … … 53 54 54 55 foreach (Permutation p in JobSequenceMatrix) { 55 sb.Append (p.ToString() + " \n");56 sb.AppendLine(p.ToString()); 56 57 } 57 58 … … 59 60 return sb.ToString(); 60 61 } 61 62 63 public override bool Equals(object obj) {64 if (obj.GetType() == typeof(JSMEncoding))65 return AreEqual(this, obj as JSMEncoding);66 67 return false;68 }69 public override int GetHashCode() {70 if (JobSequenceMatrix.Count == 1)71 return JobSequenceMatrix[0].GetHashCode();72 if (JobSequenceMatrix.Count == 2)73 return JobSequenceMatrix[0].GetHashCode() ^ JobSequenceMatrix[1].GetHashCode();74 return 0;75 }76 private static bool AreEqual(JSMEncoding jSMEncoding1, JSMEncoding jSMEncoding2) {77 if (jSMEncoding1.JobSequenceMatrix.Count != jSMEncoding2.JobSequenceMatrix.Count)78 return false;79 for (int i = 0; i < jSMEncoding1.JobSequenceMatrix.Count; i++) {80 if (!AreEqual(jSMEncoding1.JobSequenceMatrix[i], jSMEncoding2.JobSequenceMatrix[i]))81 return false;82 }83 return true;84 }85 86 private static bool AreEqual(Permutation p1, Permutation p2) {87 if (p1.Length != p2.Length)88 return false;89 for (int i = 0; i < p1.Length; i++) {90 if (p1[i] != p2[i])91 return false;92 }93 return true;94 }95 62 } 96 63 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWREncoding.cs
r9456 r10476 75 75 return sb.ToString(); 76 76 } 77 78 public override bool Equals(object obj) {79 if (obj.GetType() == typeof(PWREncoding))80 return AreEqual(this, obj as PWREncoding);81 else82 return base.Equals(obj);83 }84 85 public override int GetHashCode() {86 if (PermutationWithRepetition.Length == 1)87 return PermutationWithRepetition[0].GetHashCode();88 if (PermutationWithRepetition.Length == 2)89 return PermutationWithRepetition[0].GetHashCode() ^ PermutationWithRepetition[1].GetHashCode();90 return 0;91 }92 93 private bool AreEqual(PWREncoding pWREncoding1, PWREncoding pWREncoding2) {94 if (pWREncoding1.PermutationWithRepetition.Length != pWREncoding2.PermutationWithRepetition.Length)95 return false;96 for (int i = 0; i < pWREncoding1.PermutationWithRepetition.Length; i++) {97 if (pWREncoding1.PermutationWithRepetition[i] != pWREncoding2.PermutationWithRepetition[i])98 return false;99 }100 return true;101 }102 77 } 103 78 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVEncoding.cs
r9456 r10476 74 74 75 75 foreach (int i in PriorityRulesVector) { 76 sb.Append(i .ToString()+ " ");76 sb.Append(i + " "); 77 77 } 78 78 -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Job.cs
r10433 r10476 76 76 protected Job(Job original, Cloner cloner) 77 77 : base(original, cloner) { 78 this. DueDate = original.DueDate;79 this. Index = original.Index;80 this. Tasks = cloner.Clone(original.Tasks);78 this.dueDate = original.DueDate; 79 this.index = original.Index; 80 this.tasks = cloner.Clone(original.Tasks); 81 81 RegisterEventHandlers(); 82 82 } … … 84 84 public Job(int index, double dueDate) 85 85 : base() { 86 DueDate = dueDate;87 Index = index;88 Tasks = new ItemList<Task>();86 this.dueDate = dueDate; 87 this.index = index; 88 this.tasks = new ItemList<Task>(); 89 89 RegisterEventHandlers(); 90 90 } … … 135 135 sb.Append("Job#" + Index + " [ "); 136 136 foreach (Task t in Tasks) { 137 sb.Append(t .ToString()+ " ");137 sb.Append(t + " "); 138 138 } 139 139 sb.Append("{" + DueDate + "} "); -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Resource.cs
r9456 r10476 73 73 sb.Append("Resource#" + Index + " [ "); 74 74 foreach (ScheduledTask t in Tasks) { 75 sb.Append(t .ToString()+ " ");75 sb.Append(t+ " "); 76 76 } 77 77 sb.Append("]"); 78 78 return sb.ToString(); 79 79 } 80 81 82 public override bool Equals(object obj) {83 if (obj.GetType() == typeof(Resource))84 return AreEqual(this, obj as Resource);85 else86 return false;87 }88 89 public override int GetHashCode() {90 if (Tasks.Count == 1)91 return Tasks[0].GetHashCode();92 if (Tasks.Count == 2)93 return Tasks[0].GetHashCode() ^ Tasks[1].GetHashCode();94 return 0;95 }96 97 private static bool AreEqual(Resource res1, Resource res2) {98 if (res1.Tasks.Count != res2.Tasks.Count)99 return false;100 for (int i = 0; i < res1.Tasks.Count; i++) {101 if (!res1.Tasks[i].Equals(res2.Tasks[i]))102 return false;103 }104 105 return true;106 }107 80 } 108 81 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Schedule.cs
r9456 r10476 149 149 sb.Append("[ "); 150 150 foreach (Resource r in Resources) { 151 sb.Append (r.ToString() + " \n");151 sb.AppendLine(r.ToString()); 152 152 } 153 153 sb.Append("]"); … … 164 164 return quality; 165 165 } 166 167 public override bool Equals(object obj) {168 if (obj.GetType() == typeof(Schedule))169 return AreEqual(this, obj as Schedule);170 else171 return false;172 }173 public override int GetHashCode() {174 if (Resources.Count == 1)175 return Resources[0].GetHashCode();176 if (Resources.Count == 2)177 return Resources[0].GetHashCode() ^ Resources[1].GetHashCode();178 return 0;179 }180 181 private static bool AreEqual(Schedule schedule1, Schedule schedule2) {182 if (schedule1.Resources.Count != schedule2.Resources.Count)183 return false;184 for (int i = 0; i < schedule1.Resources.Count; i++) {185 if (!schedule1.Resources[i].Equals(schedule2.Resources[i]))186 return false;187 }188 189 return true;190 }191 192 166 } 193 167 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/ScheduledTask.cs
r9456 r10476 75 75 return sb.ToString(); 76 76 } 77 78 public override bool Equals(object obj) {79 if (obj.GetType() == typeof(ScheduledTask))80 return AreEqual(this, obj as ScheduledTask);81 else82 return false;83 }84 85 public override int GetHashCode() {86 return TaskNr ^ JobNr;87 }88 89 public static bool AreEqual(ScheduledTask task1, ScheduledTask task2) {90 return (91 task1.TaskNr == task2.TaskNr &&92 task1.Duration == task2.Duration &&93 task1.JobNr == task2.JobNr &&94 task1.ResourceNr == task2.ResourceNr &&95 task1.StartTime == task2.StartTime &&96 task1.EndTime == task2.EndTime);97 }98 77 } 99 78 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Task.cs
r10433 r10476 95 95 protected Task(Task original, Cloner cloner) 96 96 : base(original, cloner) { 97 this. ResourceNr = original.ResourceNr;98 this. JobNr = original.JobNr;99 this. Duration = original.Duration;100 this. TaskNr = original.TaskNr;101 this. IsScheduled = original.IsScheduled;97 this.resourceNr = original.ResourceNr; 98 this.jobNr = original.JobNr; 99 this.duration = original.Duration; 100 this.taskNr = original.TaskNr; 101 this.isScheduled = original.IsScheduled; 102 102 } 103 103 public Task() : this(-1, -1, -1, 0) { } 104 104 public Task(int taskNr, int resNr, int jobNr, double duration) 105 105 : base() { 106 Duration = duration;107 ResourceNr = resNr;108 JobNr = jobNr;109 TaskNr = taskNr;110 IsScheduled = false;106 this.duration = duration; 107 this.resourceNr = resNr; 108 this.jobNr = jobNr; 109 this.taskNr = taskNr; 110 this.isScheduled = false; 111 111 } 112 112
Note: See TracChangeset
for help on using the changeset viewer.