Changeset 11594 for branches/Breadcrumbs/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding
- Timestamp:
- 11/27/14 11:23:37 (10 years ago)
- Location:
- branches/Breadcrumbs
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Breadcrumbs
- 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/Breadcrumbs/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers/DirectScheduleCrossover.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic 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. … … 45 45 public abstract Schedule Cross(IRandom random, Schedule parent1, Schedule parent2); 46 46 47 public override IOperation Apply() {47 public override IOperation InstrumentedApply() { 48 48 var parents = ParentsParameter.ActualValue; 49 49 ChildParameter.ActualValue = 50 50 Cross(RandomParameter.ActualValue, parents[0] as Schedule, parents[1] as Schedule); 51 return base. Apply();51 return base.InstrumentedApply(); 52 52 } 53 53 } -
branches/Breadcrumbs/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers/DirectScheduleGTCrossover.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic 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. -
branches/Breadcrumbs/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleRandomCreator.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic 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. -
branches/Breadcrumbs/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/GTAlgorithmUtils.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic 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. -
branches/Breadcrumbs/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Job.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic 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; 22 23 using System.ComponentModel; 23 24 using System.Text; 25 using HeuristicLab.Collections; 24 26 using HeuristicLab.Common; 25 27 using HeuristicLab.Core; … … 38 40 bool changed = dueDate != value; 39 41 dueDate = value; 40 if (changed) OnPropertyChanged("DueDate"); 42 if (changed) { 43 OnPropertyChanged("DueDate"); 44 OnToStringChanged(); 45 } 41 46 } 42 47 } … … 49 54 bool changed = index != value; 50 55 index = value; 51 if (changed) OnPropertyChanged("Index"); 56 if (changed) { 57 OnPropertyChanged("Index"); 58 OnToStringChanged(); 59 } 52 60 } 53 61 } … … 68 76 protected Job(Job original, Cloner cloner) 69 77 : base(original, cloner) { 70 this.DueDate = original.DueDate; 71 this.Index = original.Index; 72 this.Tasks = cloner.Clone(original.Tasks); 78 this.dueDate = original.DueDate; 79 this.index = original.Index; 80 this.tasks = cloner.Clone(original.Tasks); 81 RegisterEventHandlers(); 73 82 } 74 83 public Job() : this(-1, double.MaxValue) { } 75 84 public Job(int index, double dueDate) 76 85 : base() { 77 DueDate = dueDate; 78 Index = index; 79 Tasks = new ItemList<Task>(); 86 this.dueDate = dueDate; 87 this.index = index; 88 this.tasks = new ItemList<Task>(); 89 RegisterEventHandlers(); 80 90 } 81 91 … … 84 94 } 85 95 96 [StorableHook(HookType.AfterDeserialization)] 97 private void AfterDeserialization() { 98 RegisterEventHandlers(); 99 } 100 101 private void RegisterEventHandlers() { 102 Tasks.ItemsAdded += TasksOnItemsChanged; 103 Tasks.ItemsRemoved += TasksOnItemsRemoved; 104 Tasks.ItemsReplaced += TasksOnItemsChanged; 105 Tasks.CollectionReset += TasksOnItemsChanged; 106 foreach (var task in Tasks) { 107 task.PropertyChanged += TaskOnPropertyChanged; 108 task.ToStringChanged += TaskOnToStringChanged; 109 } 110 } 111 112 private void TasksOnItemsChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<Task>> e) { 113 foreach (var task in e.OldItems) { 114 task.Value.PropertyChanged -= TaskOnPropertyChanged; 115 task.Value.ToStringChanged -= TaskOnToStringChanged; 116 } 117 foreach (var task in e.Items) { 118 task.Value.PropertyChanged += TaskOnPropertyChanged; 119 task.Value.ToStringChanged += TaskOnToStringChanged; 120 } 121 OnTasksChanged(); 122 OnToStringChanged(); 123 } 124 125 private void TasksOnItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Task>> e) { 126 foreach (var task in e.Items) { 127 task.Value.PropertyChanged -= TaskOnPropertyChanged; 128 task.Value.ToStringChanged -= TaskOnToStringChanged; 129 } 130 OnTasksChanged(); 131 OnToStringChanged(); 132 } 133 134 private void TaskOnPropertyChanged(object sender, EventArgs e) { 135 OnTasksChanged(); 136 } 137 138 private void TaskOnToStringChanged(object sender, EventArgs e) { 139 OnToStringChanged(); 140 } 141 86 142 public override string ToString() { 87 143 var sb = new StringBuilder(); 88 144 sb.Append("Job#" + Index + " [ "); 89 145 foreach (Task t in Tasks) { 90 sb.Append(t .ToString()+ " ");146 sb.Append(t + " "); 91 147 } 92 148 sb.Append("{" + DueDate + "} "); … … 100 156 } 101 157 158 public event EventHandler TasksChanged; 159 protected virtual void OnTasksChanged() { 160 var handler = TasksChanged; 161 if (handler != null) handler(this, EventArgs.Empty); 162 } 163 102 164 public event PropertyChangedEventHandler PropertyChanged; 103 165 protected virtual void OnPropertyChanged(string propertyName) { -
branches/Breadcrumbs/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Manipulators/DirectScheduleManipulator.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic 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. … … 40 40 protected abstract void Manipulate(IRandom random, Schedule individual); 41 41 42 public override IOperation Apply() {42 public override IOperation InstrumentedApply() { 43 43 var schedule = ScheduleEncodingParameter.ActualValue as Schedule; 44 44 if (schedule == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type Schedule."); 45 45 Manipulate(RandomParameter.ActualValue, schedule); 46 return base. Apply();46 return base.InstrumentedApply(); 47 47 } 48 48 -
branches/Breadcrumbs/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Resource.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic 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. … … 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 } -
branches/Breadcrumbs/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Schedule.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic 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. … … 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 } -
branches/Breadcrumbs/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/ScheduledTask.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic 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. … … 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 } -
branches/Breadcrumbs/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Task.cs
r9456 r11594 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 3Heuristic 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. … … 38 38 bool changed = taskNr != value; 39 39 taskNr = value; 40 if (changed) OnPropertyChanged("TaskNr"); 40 if (changed) { 41 OnPropertyChanged("TaskNr"); 42 OnToStringChanged(); 43 } 41 44 } 42 45 } … … 48 51 bool changed = resourceNr != value; 49 52 resourceNr = value; 50 if (changed) OnPropertyChanged("ResourceNr"); 53 if (changed) { 54 OnPropertyChanged("ResourceNr"); 55 OnToStringChanged(); 56 } 51 57 } 52 58 } … … 89 95 protected Task(Task original, Cloner cloner) 90 96 : base(original, cloner) { 91 this. ResourceNr = original.ResourceNr;92 this. JobNr = original.JobNr;93 this. Duration = original.Duration;94 this. TaskNr = original.TaskNr;95 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; 96 102 } 97 103 public Task() : this(-1, -1, -1, 0) { } 98 104 public Task(int taskNr, int resNr, int jobNr, double duration) 99 105 : base() { 100 Duration = duration;101 ResourceNr = resNr;102 JobNr = jobNr;103 TaskNr = taskNr;104 IsScheduled = false;106 this.duration = duration; 107 this.resourceNr = resNr; 108 this.jobNr = jobNr; 109 this.taskNr = taskNr; 110 this.isScheduled = false; 105 111 } 106 112 … … 115 121 } 116 122 117 public override bool Equals(object obj) {118 if (obj.GetType() == typeof(Task))119 return AreEqual(this, obj as Task);120 else121 return false;122 }123 124 public override int GetHashCode() {125 return TaskNr ^ JobNr;126 }127 128 public static bool AreEqual(Task task1, Task task2) {129 return (task1.Duration == task2.Duration &&130 task1.IsScheduled == task2.IsScheduled &&131 task1.JobNr == task2.JobNr &&132 task1.ResourceNr == task2.ResourceNr &&133 task1.TaskNr == task2.TaskNr);134 }135 136 123 public event PropertyChangedEventHandler PropertyChanged; 137 124 protected virtual void OnPropertyChanged(string propertyName) {
Note: See TracChangeset
for help on using the changeset viewer.