- Timestamp:
- 06/10/11 16:18:44 (14 years ago)
- Location:
- branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3
- Property svn:ignore
-
old new 2 2 bin 3 3 obj 4 HeuristicLab.Problems.Scheduling-3.3.csproj.user
-
- Property svn:ignore
-
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/GTAlgorithmUtils.cs
r6293 r6406 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using HeuristicLab.Encodings.SchedulingEncoding; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 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 21 22 using System; 6 23 using HeuristicLab.Core; 24 using HeuristicLab.Encodings.ScheduleEncoding; 7 25 8 namespace HeuristicLab.Problems.Scheduling .Decoders{26 namespace HeuristicLab.Problems.Scheduling { 9 27 public static class GTAlgorithmUtils { 10 28 … … 45 63 return result; 46 64 } 47 65 48 66 public static double ComputeEarliestStartTime(Task t, Schedule schedule) { 49 ScheduledTask previousTask = schedule.GetLastScheduledTaskForJobNr 67 ScheduledTask previousTask = schedule.GetLastScheduledTaskForJobNr(t.JobNr.Value); 50 68 Resource affectedResource = schedule.Resources[t.ResourceNr.Value]; 51 69 double lastMachineEndTime = affectedResource.TotalDuration.Value; -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/JSMDecoder.cs
r6364 r6406 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 23 using System.Linq; 25 using System.Text;24 using HeuristicLab.Common; 26 25 using HeuristicLab.Core; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;28 using HeuristicLab.Common;29 using HeuristicLab.Data;30 26 using HeuristicLab.Encodings.PermutationEncoding; 27 using HeuristicLab.Encodings.ScheduleEncoding; 28 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix; 31 29 using HeuristicLab.Optimization; 32 30 using HeuristicLab.Parameters; 33 using HeuristicLab.Encodings.SchedulingEncoding.JobSequenceMatrix; 34 using HeuristicLab.Encodings.SchedulingEncoding; 35 using HeuristicLab.Problems.Scheduling.Interfaces; 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 36 32 37 namespace HeuristicLab.Problems.Scheduling .Decoders{38 [Item("Job Sequence MatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequence Matrix.")]33 namespace HeuristicLab.Problems.Scheduling { 34 [Item("JobSequenceMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequence Matrix.")] 39 35 [StorableClass] 40 public class JSMDecoder : SchedulingDecoder<JSMEncoding>, IStochasticOperator, IJSSPOperator { 41 [StorableConstructor] 42 protected JSMDecoder(bool deserializing) : base(deserializing) { } 43 protected JSMDecoder(JSMDecoder original, Cloner cloner) 44 : base(original, cloner) { 45 this.resultingSchedule = cloner.Clone(original.resultingSchedule); 46 this.jobs = cloner.Clone(original.jobs); 47 this.decodingErrorPolicy = original.decodingErrorPolicy; 48 this.forcingStrategy = original.forcingStrategy; 49 } 50 public override IDeepCloneable Clone(Cloner cloner) { 51 return new JSMDecoder(this, cloner); 52 } 53 36 public class JSMDecoder : ScheduleDecoder<JSMEncoding>, IStochasticOperator, IJSSPOperator { 54 37 public ILookupParameter<IRandom> RandomParameter { 55 38 get { return (LookupParameter<IRandom>)Parameters["Random"]; } … … 70 53 71 54 [Storable] 72 private JSMForcingStrategyTypes forcingStrategy = JSMForcingStrategyTypes.ShiftForcing; 55 private JSMForcingStrategyTypes forcingStrategy = JSMForcingStrategyTypes.ShiftForcing; 73 56 #endregion 57 58 [StorableConstructor] 59 protected JSMDecoder(bool deserializing) : base(deserializing) { } 60 protected JSMDecoder(JSMDecoder original, Cloner cloner) 61 : base(original, cloner) { 62 this.resultingSchedule = cloner.Clone(original.resultingSchedule); 63 this.jobs = cloner.Clone(original.jobs); 64 this.decodingErrorPolicy = original.decodingErrorPolicy; 65 this.forcingStrategy = original.forcingStrategy; 66 } 67 public override IDeepCloneable Clone(Cloner cloner) { 68 return new JSMDecoder(this, cloner); 69 } 74 70 75 71 public JSMDecoder() … … 77 73 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 78 74 Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the Schedulingproblem - Instance.")); 75 ScheduleEncodingParameter.ActualName = "JobSequenceMatrix"; 79 76 } 80 77 81 78 82 79 private Task SelectTaskFromConflictSet(int conflictedResourceNr, int progressOnConflictedResource, ItemList<Task> conflictSet, ItemList<Permutation> jsm) { 83 80 if (conflictSet.Count == 1) 84 81 return conflictSet[0]; 85 82 86 83 //get solutionCandidate from jobSequencingMatrix 87 84 int solutionCandidateJobNr = jsm[conflictedResourceNr][progressOnConflictedResource]; … … 104 101 } 105 102 private Task ApplyDecodingErrorPolicy(ItemList<Task> conflictSet, Permutation resource, int progress) { 106 if (decodingErrorPolicy == JSMDecodingErrorPolicyTypes.RandomPolicy) { 103 if (decodingErrorPolicy == JSMDecodingErrorPolicyTypes.RandomPolicy) { 107 104 //Random 108 105 return conflictSet[RandomParameter.ActualValue.Next(conflictSet.Count - 1)]; … … 118 115 } 119 116 return conflictSet[RandomParameter.ActualValue.Next(conflictSet.Count - 1)]; 120 } 117 } 121 118 } 122 119 private void ApplyForcingStrategy(ItemList<Permutation> jsm, int conflictedResource, int newResolutionIndex, int progressOnResource, int newResolution) { … … 132 129 asList.Insert(progressOnResource, newResolution); 133 130 } else { 134 asList.Insert(progressOnResource, newResolution); 131 asList.Insert(progressOnResource, newResolution); 135 132 asList.RemoveAt(newResolutionIndex); 136 133 } 137 jsm[conflictedResource] = new Permutation 138 } 134 jsm[conflictedResource] = new Permutation(PermutationTypes.Absolute, asList.ToArray<int>()); 135 } 139 136 } 140 137 … … 143 140 144 141 jobs = (ItemList<Job>)jobData.Clone(); 145 resultingSchedule = new Schedule( new IntValue(jobs[0].Tasks.Count));142 resultingSchedule = new Schedule(jobs[0].Tasks.Count); 146 143 147 144 //Reset scheduled tasks in result … … 186 183 public override IOperation Apply() { 187 184 return base.Apply(); 188 } 185 } 189 186 } 190 187 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/JSMDecodingErrorPolicyTypes.cs
r6293 r6406 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 6 namespace HeuristicLab.Problems.Scheduling.Decoders { 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 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 21 namespace HeuristicLab.Problems.Scheduling { 7 22 public enum JSMDecodingErrorPolicyTypes { 8 23 RandomPolicy, -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/JSMForcingStrategyTypes.cs
r6293 r6406 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 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 5 21 6 namespace HeuristicLab.Problems.Scheduling .Decoders{22 namespace HeuristicLab.Problems.Scheduling { 7 23 public enum JSMForcingStrategyTypes { 8 24 ShiftForcing, -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/PRVDecoder.cs
r6364 r6406 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 22 using HeuristicLab.Common; 26 23 using HeuristicLab.Core; 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Common; 29 using HeuristicLab.Data; 30 using HeuristicLab.Encodings.PermutationEncoding; 24 using HeuristicLab.Encodings.ScheduleEncoding; 25 using HeuristicLab.Encodings.ScheduleEncoding.PriorityRulesVector; 31 26 using HeuristicLab.Optimization; 32 27 using HeuristicLab.Parameters; 33 using HeuristicLab.Problems.Scheduling.Interfaces; 34 using HeuristicLab.Encodings.SchedulingEncoding.PriorityRulesVector; 35 using HeuristicLab.Encodings.SchedulingEncoding; 36 37 namespace HeuristicLab.Problems.Scheduling.Decoders { 38 [Item("Job Sequencing Matrix Decoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")] 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 30 namespace HeuristicLab.Problems.Scheduling { 31 [Item("JobSequencingMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")] 39 32 [StorableClass] 40 public class PRVDecoder : SchedulingDecoder<PRVEncoding>, IStochasticOperator, IJSSPOperator { 33 public class PRVDecoder : ScheduleDecoder<PRVEncoding>, IStochasticOperator, IJSSPOperator { 34 public ILookupParameter<IRandom> RandomParameter { 35 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 36 } 37 public ILookupParameter<ItemList<Job>> JobDataParameter { 38 get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; } 39 } 40 41 #region Private Members 42 [Storable] 43 private Schedule resultingSchedule; 44 45 [Storable] 46 private ItemList<Job> jobs; 47 #endregion 48 49 #region Priority Rules 50 //smallest number of remaining tasks 51 private Task FILORule(ItemList<Task> tasks) { 52 Task currentResult = tasks[tasks.Count - 1]; 53 return currentResult; 54 } 55 56 //earliest start time 57 private Task ESTRule(ItemList<Task> tasks) { 58 Task currentResult = RandomRule(tasks); 59 double currentEST = double.MaxValue; 60 foreach (Task t in tasks) { 61 double est = GTAlgorithmUtils.ComputeEarliestStartTime(t, resultingSchedule); 62 if (est < currentEST) { 63 currentEST = est; 64 currentResult = t; 65 } 66 } 67 return currentResult; 68 } 69 70 //shortest processingtime 71 private Task SPTRule(ItemList<Task> tasks) { 72 Task currentResult = RandomRule(tasks); 73 foreach (Task t in tasks) { 74 if (t.Duration.Value < currentResult.Duration.Value) 75 currentResult = t; 76 } 77 return currentResult; 78 } 79 80 //longest processing time 81 private Task LPTRule(ItemList<Task> tasks) { 82 Task currentResult = RandomRule(tasks); 83 foreach (Task t in tasks) { 84 if (t.Duration.Value > currentResult.Duration.Value) 85 currentResult = t; 86 } 87 return currentResult; 88 } 89 90 //most work remaining 91 private Task MWRRule(ItemList<Task> tasks) { 92 Task currentResult = RandomRule(tasks); 93 double currentLargestRemainingProcessingTime = 0; 94 foreach (Task t in tasks) { 95 double remainingProcessingTime = 0; 96 foreach (Task jt in jobs[t.JobNr.Value].Tasks) { 97 if (!jt.IsScheduled.Value) 98 remainingProcessingTime += jt.Duration.Value; 99 } 100 if (remainingProcessingTime > currentLargestRemainingProcessingTime) { 101 currentLargestRemainingProcessingTime = remainingProcessingTime; 102 currentResult = t; 103 } 104 } 105 return currentResult; 106 } 107 108 //least work remaining 109 private Task LWRRule(ItemList<Task> tasks) { 110 Task currentResult = RandomRule(tasks); 111 double currentSmallestRemainingProcessingTime = double.MaxValue; 112 foreach (Task t in tasks) { 113 double remainingProcessingTime = 0; 114 foreach (Task jt in jobs[t.JobNr.Value].Tasks) { 115 if (!jt.IsScheduled.Value) 116 remainingProcessingTime += jt.Duration.Value; 117 } 118 if (remainingProcessingTime < currentSmallestRemainingProcessingTime) { 119 currentSmallestRemainingProcessingTime = remainingProcessingTime; 120 currentResult = t; 121 } 122 } 123 return currentResult; 124 } 125 126 //most operations remaining 127 private Task MORRule(ItemList<Task> tasks) { 128 Task currentResult = RandomRule(tasks); 129 int currentLargestNrOfRemainingTasks = 0; 130 foreach (Task t in tasks) { 131 int nrOfRemainingTasks = 0; 132 foreach (Task jt in jobs[t.JobNr.Value].Tasks) { 133 if (!jt.IsScheduled.Value) 134 nrOfRemainingTasks++; 135 } 136 if (currentLargestNrOfRemainingTasks < nrOfRemainingTasks) { 137 currentLargestNrOfRemainingTasks = nrOfRemainingTasks; 138 currentResult = t; 139 } 140 } 141 return currentResult; 142 } 143 144 //least operationsremaining 145 private Task LORRule(ItemList<Task> tasks) { 146 Task currentResult = RandomRule(tasks); 147 int currentSmallestNrOfRemainingTasks = int.MaxValue; 148 foreach (Task t in tasks) { 149 int nrOfRemainingTasks = 0; 150 foreach (Task jt in jobs[t.JobNr.Value].Tasks) { 151 if (!jt.IsScheduled.Value) 152 nrOfRemainingTasks++; 153 } 154 if (currentSmallestNrOfRemainingTasks > nrOfRemainingTasks) { 155 currentSmallestNrOfRemainingTasks = nrOfRemainingTasks; 156 currentResult = t; 157 } 158 } 159 return currentResult; 160 } 161 162 //first operation in Queue 163 private Task FIFORule(ItemList<Task> tasks) { 164 Task currentResult = tasks[0]; 165 return currentResult; 166 } 167 168 //random 169 private Task RandomRule(ItemList<Task> tasks) { 170 Task currentResult = tasks[RandomParameter.ActualValue.Next(tasks.Count)]; 171 return currentResult; 172 } 173 174 #endregion 175 41 176 [StorableConstructor] 42 177 protected PRVDecoder(bool deserializing) : base(deserializing) { } 43 178 protected PRVDecoder(PRVDecoder original, Cloner cloner) 44 179 : base(original, cloner) { 45 180 this.resultingSchedule = cloner.Clone(original.resultingSchedule); 46 181 } 47 182 public override IDeepCloneable Clone(Cloner cloner) { 48 183 return new PRVDecoder(this, cloner); 49 184 } 50 51 public ILookupParameter<IRandom> RandomParameter {52 get { return (LookupParameter<IRandom>)Parameters["Random"]; }53 }54 public ILookupParameter<ItemList<Job>> JobDataParameter {55 get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }56 }57 58 #region Private Members59 [Storable]60 private Schedule resultingSchedule;61 62 [Storable]63 private ItemList<Job> jobs;64 #endregion65 66 #region Priority Rules67 //smallest number of remaining tasks68 private Task FILORule(ItemList<Task> tasks) {69 Task currentResult = tasks[tasks.Count-1];70 return currentResult;71 }72 73 //earliest start time74 private Task ESTRule(ItemList<Task> tasks) {75 Task currentResult = RandomRule(tasks);76 double currentEST = double.MaxValue;77 foreach (Task t in tasks) {78 double est = GTAlgorithmUtils.ComputeEarliestStartTime(t, resultingSchedule);79 if (est < currentEST) {80 currentEST = est;81 currentResult = t;82 }83 }84 return currentResult;85 }86 87 //shortest processingtime88 private Task SPTRule(ItemList<Task> tasks) {89 Task currentResult = RandomRule(tasks);90 foreach (Task t in tasks) {91 if (t.Duration.Value < currentResult.Duration.Value)92 currentResult = t;93 }94 return currentResult;95 }96 97 //longest processing time98 private Task LPTRule(ItemList<Task> tasks) {99 Task currentResult = RandomRule(tasks);100 foreach (Task t in tasks) {101 if (t.Duration.Value > currentResult.Duration.Value)102 currentResult = t;103 }104 return currentResult;105 }106 107 //most work remaining108 private Task MWRRule(ItemList<Task> tasks) {109 Task currentResult = RandomRule(tasks);110 double currentLargestRemainingProcessingTime = 0;111 foreach (Task t in tasks) {112 double remainingProcessingTime = 0;113 foreach (Task jt in jobs[t.JobNr.Value].Tasks) {114 if (!jt.IsScheduled.Value)115 remainingProcessingTime += jt.Duration.Value;116 }117 if (remainingProcessingTime > currentLargestRemainingProcessingTime) {118 currentLargestRemainingProcessingTime = remainingProcessingTime;119 currentResult = t;120 }121 }122 return currentResult;123 }124 125 //least work remaining126 private Task LWRRule(ItemList<Task> tasks) {127 Task currentResult = RandomRule(tasks);128 double currentSmallestRemainingProcessingTime = double.MaxValue;129 foreach (Task t in tasks) {130 double remainingProcessingTime = 0;131 foreach (Task jt in jobs[t.JobNr.Value].Tasks) {132 if (!jt.IsScheduled.Value)133 remainingProcessingTime += jt.Duration.Value;134 }135 if (remainingProcessingTime < currentSmallestRemainingProcessingTime) {136 currentSmallestRemainingProcessingTime = remainingProcessingTime;137 currentResult = t;138 }139 }140 return currentResult;141 }142 143 //most operations remaining144 private Task MORRule(ItemList<Task> tasks) {145 Task currentResult = RandomRule(tasks);146 int currentLargestNrOfRemainingTasks = 0;147 foreach (Task t in tasks) {148 int nrOfRemainingTasks = 0;149 foreach (Task jt in jobs[t.JobNr.Value].Tasks) {150 if (!jt.IsScheduled.Value)151 nrOfRemainingTasks++;152 }153 if (currentLargestNrOfRemainingTasks < nrOfRemainingTasks) {154 currentLargestNrOfRemainingTasks = nrOfRemainingTasks;155 currentResult = t;156 }157 }158 return currentResult;159 }160 161 //least operationsremaining162 private Task LORRule(ItemList<Task> tasks) {163 Task currentResult = RandomRule(tasks);164 int currentSmallestNrOfRemainingTasks = int.MaxValue;165 foreach (Task t in tasks) {166 int nrOfRemainingTasks = 0;167 foreach (Task jt in jobs[t.JobNr.Value].Tasks) {168 if (!jt.IsScheduled.Value)169 nrOfRemainingTasks++;170 }171 if (currentSmallestNrOfRemainingTasks > nrOfRemainingTasks) {172 currentSmallestNrOfRemainingTasks = nrOfRemainingTasks;173 currentResult = t;174 }175 }176 return currentResult;177 }178 179 //first operation in Queue180 private Task FIFORule(ItemList<Task> tasks) {181 Task currentResult = tasks[0];182 return currentResult;183 }184 185 //random186 private Task RandomRule(ItemList<Task> tasks) {187 Task currentResult = tasks[RandomParameter.ActualValue.Next(tasks.Count)];188 return currentResult;189 }190 191 #endregion192 185 193 186 public PRVDecoder() 194 187 : base() { 195 188 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 196 Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance.")); 197 } 198 199 189 Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the SchedulingProblem - Instance.")); 190 ScheduleEncodingParameter.ActualName = "PriorityRulesVector"; 191 } 200 192 201 193 private Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, int ruleIndex, int nrOfRules) { … … 221 213 public override Schedule CreateScheduleFromEncoding(PRVEncoding solution) { 222 214 jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone(); 223 resultingSchedule = new Schedule( new IntValue(jobs[0].Tasks.Count));215 resultingSchedule = new Schedule(jobs[0].Tasks.Count); 224 216 225 217 //Reset scheduled tasks in result … … 247 239 //STEP 4 - Adding the selected operation to the current schedule 248 240 selectedTask.IsScheduled.Value = true; 249 double startTime = GTAlgorithmUtils.ComputeEarliestStartTime 241 double startTime = GTAlgorithmUtils.ComputeEarliestStartTime(selectedTask, resultingSchedule); 250 242 resultingSchedule.ScheduleTask(selectedTask.ResourceNr.Value, startTime, selectedTask.Duration.Value, selectedTask.JobNr.Value); 251 243 … … 259 251 public override IOperation Apply() { 260 252 return base.Apply(); 261 } 253 } 262 254 } 263 255 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/PWRDecoder.cs
r6293 r6406 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 22 using HeuristicLab.Common; 26 23 using HeuristicLab.Core; 27 using HeuristicLab. Persistence.Default.CompositeSerializers.Storable;28 using HeuristicLab. Common;24 using HeuristicLab.Encodings.ScheduleEncoding; 25 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition; 29 26 using HeuristicLab.Optimization; 30 27 using HeuristicLab.Parameters; 31 using HeuristicLab.Data; 32 using HeuristicLab.Encodings.SchedulingEncoding; 33 using HeuristicLab.Encodings.SchedulingEncoding.PermutationWithRepetition; 34 using HeuristicLab.Problems.Scheduling.Interfaces; 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 35 29 36 namespace HeuristicLab.Problems.Scheduling .Decoders{30 namespace HeuristicLab.Problems.Scheduling { 37 31 [Item("PWRDecoder", "An item used to convert a PWR-individual into a generalized schedule.")] 38 32 [StorableClass] 39 public class PWRDecoder : SchedulingDecoder<PWREncoding>, IStochasticOperator, IJSSPOperator { 33 public class PWRDecoder : ScheduleDecoder<PWREncoding>, IStochasticOperator, IJSSPOperator { 34 public ILookupParameter<IRandom> RandomParameter { 35 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 36 } 37 public ILookupParameter<ItemList<Job>> JobDataParameter { 38 get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; } 39 } 40 40 41 [StorableConstructor] 41 42 protected PWRDecoder(bool deserializing) : base(deserializing) { } … … 47 48 } 48 49 49 public ILookupParameter<IRandom> RandomParameter {50 get { return (LookupParameter<IRandom>)Parameters["Random"]; }51 }52 public ILookupParameter<ItemList<Job>> JobDataParameter {53 get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }54 }55 56 50 public PWRDecoder() 57 51 : base() { 58 52 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 59 53 Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance.")); 54 ScheduleEncodingParameter.ActualName = "PermutationWithRepetition"; 60 55 } 61 56 62 57 public override Schedule CreateScheduleFromEncoding(PWREncoding solution) { 63 58 ItemList<Job> jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone(); 64 Schedule resultingSchedule = new Schedule( new IntValue(jobs[0].Tasks.Count));59 Schedule resultingSchedule = new Schedule(jobs[0].Tasks.Count); 65 60 foreach (int jobNr in solution.PermutationWithRepetition) { 66 61 int i = 0; 67 62 while (jobs[jobNr].Tasks[i].IsScheduled.Value) i++; 68 63 Task currentTask = jobs[jobNr].Tasks[i]; 69 double startTime = GTAlgorithmUtils.ComputeEarliestStartTime 64 double startTime = GTAlgorithmUtils.ComputeEarliestStartTime(currentTask, resultingSchedule); 70 65 currentTask.IsScheduled.Value = true; 71 resultingSchedule.ScheduleTask(currentTask.ResourceNr.Value, startTime, currentTask.Duration.Value, currentTask.JobNr.Value);66 resultingSchedule.ScheduleTask(currentTask.ResourceNr.Value, startTime, currentTask.Duration.Value, currentTask.JobNr.Value); 72 67 } 73 68 return resultingSchedule; … … 76 71 public override IOperation Apply() { 77 72 return base.Apply(); 78 } 73 } 79 74 } 80 75 }
Note: See TracChangeset
for help on using the changeset viewer.