Changeset 6406 for branches/Scheduling/HeuristicLab.Problems.Scheduling
- Timestamp:
- 06/10/11 16:18:44 (14 years ago)
- Location:
- branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3
- Files:
-
- 20 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/Analyzers/BestSchedulingSolutionAnalyzer.cs
r6293 r6406 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 22 using System.Linq; 25 using System.Text; 23 using HeuristicLab.Common; 24 using HeuristicLab.Core; 25 using HeuristicLab.Data; 26 using HeuristicLab.Encodings.ScheduleEncoding; 26 27 using HeuristicLab.Optimization; 27 using HeuristicLab. Core;28 using HeuristicLab.Parameters; 28 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Common;30 using HeuristicLab.Parameters;31 using HeuristicLab.Data;32 using HeuristicLab.Encodings.SchedulingEncoding;33 30 34 namespace HeuristicLab.Problems.Scheduling .Analyzers{31 namespace HeuristicLab.Problems.Scheduling { 35 32 36 33 [Item("BestSchedulingSolutionAnalyzer", "An operator for analyzing the best solution of Scheduling Problems given in schedule-representation.")] … … 53 50 } 54 51 55 public BestSchedulingSolutionAnalyzer () : base () { 52 public BestSchedulingSolutionAnalyzer() 53 : base() { 56 54 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator.")); 57 55 } … … 59 57 public override IOperation Apply() { 60 58 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 61 ItemArray<Schedule> solutions = Schedul ingSolutionParameter.ActualValue;59 ItemArray<Schedule> solutions = ScheduleParameter.ActualValue; 62 60 ResultCollection results = ResultsParameter.ActualValue; 63 61 bool max = MaximizationParameter.ActualValue.Value; … … 79 77 if (bestSolution == null) { 80 78 bestSolution = (Schedule)solutions[i].Clone(); 81 bestSolution.Quality .Value = qualities [i].Value;79 bestSolution.Quality = (DoubleValue)qualities[i].Clone(); 82 80 BestSolutionParameter.ActualValue = bestSolution; 83 81 results.Add(new Result("Best Scheduling Solution", bestSolution)); -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Analyzers/SchedulingAnalyzer.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; 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.ScheduleEncoding; 26 26 using HeuristicLab.Operators; 27 27 using HeuristicLab.Optimization; 28 28 using HeuristicLab.Parameters; 29 using HeuristicLab.Data;30 using HeuristicLab.Core;31 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 32 using HeuristicLab.Common;33 using HeuristicLab.Encodings.SchedulingEncoding;34 30 35 namespace HeuristicLab.Problems.Scheduling .Analyzers{36 [Item("Scheduling 31 namespace HeuristicLab.Problems.Scheduling { 32 [Item("SchedulingAnalyzer", "Represents the generalized form of Analyzers for Scheduling Problems.")] 37 33 [StorableClass] 38 34 public abstract class SchedulingAnalyzer : SingleSuccessorOperator, IAnalyzer { … … 62 58 get { return (LookupParameter<Schedule>)Parameters["BestKnownSolution"]; } 63 59 } 64 public ScopeTreeLookupParameter<Schedule> Schedul ingSolutionParameter {65 get { return (ScopeTreeLookupParameter<Schedule>)Parameters[" DecodedSchedulingSolution"]; }60 public ScopeTreeLookupParameter<Schedule> ScheduleParameter { 61 get { return (ScopeTreeLookupParameter<Schedule>)Parameters["Schedule"]; } 66 62 } 67 63 #endregion 68 64 69 public SchedulingAnalyzer () : base() { 65 public SchedulingAnalyzer() 66 : base() { 70 67 Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem.")); 71 68 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the JSSP solutions which should be analyzed.")); 72 Parameters.Add(new ScopeTreeLookupParameter<Schedule>(" DecodedSchedulingSolution", "The solutions from which the best solution has to be chosen from."));69 Parameters.Add(new ScopeTreeLookupParameter<Schedule>("Schedule", "The solutions from which the best solution has to be chosen from.")); 73 70 Parameters.Add(new LookupParameter<Schedule>("BestSolution", "The best JSSP solution.")); 74 71 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best JSSP solution should be stored.")); -
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 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MakespanEvaluator.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; 24 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.ScheduleEncoding; 27 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Common;29 using HeuristicLab.Data;30 using HeuristicLab.Optimization;31 using HeuristicLab.Parameters;32 using HeuristicLab.Encodings.SchedulingEncoding;33 27 34 namespace HeuristicLab.Problems.Scheduling .Evaluators{28 namespace HeuristicLab.Problems.Scheduling { 35 29 [Item("Makespan Evaluator", "Represents an evaluator using the maximum makespan of a schedule.")] 36 30 [StorableClass] … … 45 39 } 46 40 47 public MakespanEvaluator () : base() { }41 public MakespanEvaluator() : base() { } 48 42 49 43 protected override DoubleValue evaluate(Schedule schedule) { 50 DoubleValue quality = new DoubleValue 44 DoubleValue quality = new DoubleValue(0); 51 45 foreach (Resource r in schedule.Resources) { 52 46 if (r.TotalDuration.Value > quality.Value) { -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MeanTardinessEvaluator.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; 24 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.ScheduleEncoding; 26 using HeuristicLab.Parameters; 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Common;29 using HeuristicLab.Data;30 using HeuristicLab.Optimization;31 using HeuristicLab.Parameters;32 using HeuristicLab.Encodings.SchedulingEncoding;33 using HeuristicLab.Problems.Scheduling.Interfaces;34 28 35 namespace HeuristicLab.Problems.Scheduling .Evaluators{29 namespace HeuristicLab.Problems.Scheduling { 36 30 [Item("Mean tardiness Evaluator", "Represents an evaluator using the mean tardiness of a schedule.")] 37 31 [StorableClass] … … 57 51 #endregion 58 52 59 public MeanTardinessEvaluator() : base() { 53 public MeanTardinessEvaluator() 54 : base() { 60 55 Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance.")); 61 56 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/SchedulingEvaluationAlgorithm.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; 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.ScheduleEncoding; 26 26 using HeuristicLab.Operators; 27 using HeuristicLab.Parameters; 27 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Core;29 using HeuristicLab.Common;30 using HeuristicLab.Optimization;31 using HeuristicLab.Data;32 using HeuristicLab.Parameters;33 using HeuristicLab.Encodings.SchedulingEncoding.Interfaces;34 using HeuristicLab.Encodings.SchedulingEncoding;35 29 36 namespace HeuristicLab.Problems.Scheduling .Evaluators{30 namespace HeuristicLab.Problems.Scheduling { 37 31 [Item("Scheduling Evaluation Algorithm", "Represents a composition of a decoder and an evaluator for scheduling problems.")] 38 32 [StorableClass] 39 public class SchedulingEvaluationAlgorithm : AlgorithmOperator, ISchedul ingEvaluationAlgorithm {33 public class SchedulingEvaluationAlgorithm : AlgorithmOperator, IScheduleEvaluationAlgorithm { 40 34 [StorableConstructor] 41 35 protected SchedulingEvaluationAlgorithm(bool deserializing) : base(deserializing) { } 42 36 protected SchedulingEvaluationAlgorithm(SchedulingEvaluationAlgorithm original, Cloner cloner) 43 37 : base(original, cloner) { 44 38 this.evaluator = cloner.Clone(original.evaluator); 45 39 } 46 40 public override IDeepCloneable Clone(Cloner cloner) { … … 60 54 } 61 55 62 public void InitializeOperatorGraph<T>(Schedul ingDecoder<T> decoder) where T: Item, ISchedulingEncoding{56 public void InitializeOperatorGraph<T>(ScheduleDecoder<T> decoder) where T : Item, IScheduleEncoding { 63 57 OperatorGraph.Operators.Clear(); 64 58 OperatorGraph.InitialOperator = decoder; … … 68 62 public SchedulingEvaluationAlgorithm() 69 63 : base() { 70 71 72 64 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution.")); 65 evaluator = new Placeholder(); 66 evaluator.OperatorParameter.ActualName = "SolutionEvaluator"; 73 67 } 74 68 -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/SchedulingEvaluator.cs
r6364 r6406 20 20 #endregion 21 21 22 using HeuristicLab.Common; 23 using HeuristicLab.Core; 24 using HeuristicLab.Data; 25 using HeuristicLab.Encodings.ScheduleEncoding; 26 using HeuristicLab.Operators; 27 using HeuristicLab.Parameters; 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 22 29 23 30 24 using HeuristicLab.Core; 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Optimization; 27 using HeuristicLab.Data; 28 using HeuristicLab.Common; 29 using HeuristicLab.Parameters; 30 using System; 31 using HeuristicLab.Operators; 32 using HeuristicLab.Encodings.SchedulingEncoding.Interfaces; 33 using HeuristicLab.Encodings.SchedulingEncoding; 34 35 36 namespace HeuristicLab.Problems.Scheduling.Evaluators { 31 namespace HeuristicLab.Problems.Scheduling { 37 32 [Item("Scheduling Evaluator", "Represents a evaluator class for standard scheduling problems.")] 38 33 [StorableClass] 39 public abstract class SchedulingEvaluator : SingleSuccessorOperator, ISchedul ingEvaluator {34 public abstract class SchedulingEvaluator : SingleSuccessorOperator, IScheduleEvaluator { 40 35 [StorableConstructor] 41 36 protected SchedulingEvaluator(bool deserializing) : base(deserializing) { } … … 48 43 } 49 44 public ILookupParameter<DoubleValue> QualityParameter { 50 get { 45 get { 51 46 if (Parameters.ContainsKey("Quality")) 52 47 return (ILookupParameter<DoubleValue>)Parameters["Quality"]; … … 55 50 } 56 51 } 57 public ILookupParameter<Schedule> DecodedSchedulingSolutionParameter {58 get { return (ILookupParameter<Schedule>)Parameters[" DecodedSchedulingSolution"]; }52 public ILookupParameter<Schedule> ScheduleParameter { 53 get { return (ILookupParameter<Schedule>)Parameters["Schedule"]; } 59 54 } 60 55 61 public SchedulingEvaluator () : base () { 56 public SchedulingEvaluator() 57 : base() { 62 58 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution.")); 63 Parameters.Add(new LookupParameter<Schedule>(" DecodedSchedulingSolution", "The decoded scheduling solution represented as generalized schedule."));59 Parameters.Add(new LookupParameter<Schedule>("Schedule", "The decoded scheduling solution represented as generalized schedule.")); 64 60 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator.")); 65 61 } 66 62 67 63 protected abstract DoubleValue evaluate(Schedule schedule); 68 64 69 65 public override IOperation Apply() { 70 Schedule decodedSchedulingSolution = DecodedSchedulingSolutionParameter.ActualValue;71 QualityParameter.ActualValue = evaluate( decodedSchedulingSolution);66 Schedule schedule = ScheduleParameter.ActualValue; 67 QualityParameter.ActualValue = evaluate(schedule); 72 68 return base.Apply(); 73 69 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/HeuristicLab.Problems.Scheduling-3.3.csproj
r6364 r6406 59 59 <Compile Include="Evaluators\MakespanEvaluator.cs" /> 60 60 <Compile Include="Evaluators\SchedulingEvaluator.cs" /> 61 <Compile Include="IndexedTaskList.cs" />62 61 <Compile Include="Interfaces\IJSSPOperator.cs" /> 63 62 <Compile Include="Job.cs" /> … … 103 102 <Name>HeuristicLab.Encodings.PermutationEncoding-3.3</Name> 104 103 </ProjectReference> 105 <ProjectReference Include="..\..\HeuristicLab.Encodings.Schedul ingEncoding\3.3\HeuristicLab.Encodings.SchedulingEncoding-3.3.csproj">104 <ProjectReference Include="..\..\HeuristicLab.Encodings.ScheduleEncoding\3.3\HeuristicLab.Encodings.ScheduleEncoding-3.3.csproj"> 106 105 <Project>{17F3EF80-B2C3-4B8D-A4D5-BE9CE3BA2606}</Project> 107 <Name>HeuristicLab.Encodings.Schedul ingEncoding-3.3</Name>106 <Name>HeuristicLab.Encodings.ScheduleEncoding-3.3</Name> 108 107 </ProjectReference> 109 108 <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj"> -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Interfaces/IJSSPOperator.cs
r6364 r6406 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using HeuristicLab.Core; 6 using HeuristicLab.Parameters; 1 using HeuristicLab.Core; 7 2 8 namespace HeuristicLab.Problems.Scheduling .Interfaces{3 namespace HeuristicLab.Problems.Scheduling { 9 4 public interface IJSSPOperator : IOperator { 10 ILookupParameter<ItemList<Job>> JobDataParameter {get;}5 ILookupParameter<ItemList<Job>> JobDataParameter { get; } 11 6 } 12 7 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Job.cs
r6364 r6406 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 22 using System.Text; 23 using HeuristicLab.Common; 26 24 using HeuristicLab.Core; 27 using HeuristicLab. Common;25 using HeuristicLab.Data; 28 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Data;30 using HeuristicLab.Parameters;31 27 32 28 namespace HeuristicLab.Problems.Scheduling { … … 34 30 [StorableClass] 35 31 public class Job : Item { 32 [Storable] 33 public DoubleValue DueDate { get; set; } 34 [Storable] 35 public IntValue Index { get; set; } 36 [Storable] 37 public ItemList<Task> Tasks { get; set; } 38 36 39 [StorableConstructor] 37 40 protected Job(bool deserializing) : base(deserializing) { } 38 41 protected Job(Job original, Cloner cloner) 39 42 : base(original, cloner) { 40 41 42 43 this.DueDate = cloner.Clone(original.DueDate); 44 this.Index = cloner.Clone(original.Index); 45 this.Tasks = cloner.Clone(original.Tasks); 43 46 } 44 47 public override IDeepCloneable Clone(Cloner cloner) { 45 48 return new Job(this, cloner); 46 49 } 47 48 public DoubleValue DueDate { get; set; } 49 50 public IntValue Index { 51 get; 52 set; 53 } 54 public ItemList<Task> Tasks { 55 get; 56 set; 57 } 58 59 60 public Job(IntValue index, DoubleValue dueDate) : base () { 50 public Job(IntValue index, DoubleValue dueDate) 51 : base() { 61 52 Index = index; 62 53 Tasks = new ItemList<Task>(); … … 72 63 sb.Append("Job#" + Index + " [ "); 73 64 foreach (Task t in Tasks) { 74 sb.Append(t.ToString 65 sb.Append(t.ToString() + " "); 75 66 } 76 67 if (DueDate != null) -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs
r6364 r6406 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 25 using System.Text; 24 using System.IO; 25 using HeuristicLab.Common; 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 28 using HeuristicLab.Encodings.PermutationEncoding; 29 using HeuristicLab.Encodings.ScheduleEncoding; 30 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix; 31 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition; 32 using HeuristicLab.Encodings.ScheduleEncoding.PriorityRulesVector; 33 using HeuristicLab.Parameters; 26 34 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Core;28 using HeuristicLab.Optimization;29 using HeuristicLab.Common;30 using System.Drawing;31 using HeuristicLab.Data;32 using System.IO;33 using HeuristicLab.Problems.Scheduling.Evaluators;34 using HeuristicLab.Parameters;35 using HeuristicLab.Problems.Scheduling.Analyzers;36 35 using HeuristicLab.PluginInfrastructure; 37 using HeuristicLab.Encodings.SchedulingEncoding;38 using HeuristicLab.Encodings.SchedulingEncoding.Interfaces;39 using HeuristicLab.Encodings.SchedulingEncoding.JobSequenceMatrix;40 using HeuristicLab.Encodings.PermutationEncoding;41 using HeuristicLab.Encodings.SchedulingEncoding.PriorityRulesVector;42 using HeuristicLab.Encodings.SchedulingEncoding.PermutationWithRepetition;43 using HeuristicLab.Problems.Scheduling.Decoders;44 36 45 37 namespace HeuristicLab.Problems.Scheduling { … … 48 40 [StorableClass] 49 41 public sealed class JobShopSchedulingProblem : SchedulingProblem { 42 #region Parameter Properties 43 public ValueParameter<ItemList<Job>> JobDataParameter { 44 get { return (ValueParameter<ItemList<Job>>)Parameters["JobData"]; } 45 } 46 public OptionalValueParameter<Schedule> BestKnownSolutionParameter { 47 get { return (OptionalValueParameter<Schedule>)Parameters["BestKnownSolution"]; } 48 } 49 50 public ValueParameter<IntValue> JobsParameter { 51 get { return (ValueParameter<IntValue>)Parameters["Jobs"]; } 52 } 53 public ValueParameter<IntValue> ResourcesParameter { 54 get { return (ValueParameter<IntValue>)Parameters["Resources"]; } 55 } 56 public ValueParameter<SchedulingEvaluator> SolutionEvaluatorParameter { 57 get { return (ValueParameter<SchedulingEvaluator>)Parameters["SolutionEvaluator"]; } 58 } 59 public ValueParameter<BoolValue> DueDatesParameter { 60 get { return (ValueParameter<BoolValue>)Parameters["DueDates"]; } 61 } 62 #endregion 63 64 #region Properties 65 public ItemList<Job> JobData { 66 get { return JobDataParameter.Value; } 67 set { JobDataParameter.Value = value; } 68 } 69 public Schedule BestKnownSolution { 70 get { return BestKnownSolutionParameter.Value; } 71 set { BestKnownSolutionParameter.Value = value; } 72 } 73 public IntValue Jobs { 74 get { return JobsParameter.Value; } 75 set { JobsParameter.Value = value; } 76 } 77 public IntValue Resources { 78 get { return ResourcesParameter.Value; } 79 set { ResourcesParameter.Value = value; } 80 } 81 public SchedulingEvaluator SolutionEvaluator { 82 get { return SolutionEvaluatorParameter.Value; } 83 set { SolutionEvaluatorParameter.Value = value; } 84 } 85 public BoolValue DueDates { 86 get { return DueDatesParameter.Value; } 87 set { DueDatesParameter.Value = value; } 88 } 89 #endregion 90 91 public JobShopSchedulingProblem() 92 : base(new SchedulingEvaluationAlgorithm(), new JSMRandomCreator()) { 93 Parameters.Add(new ValueParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance.", new ItemList<Job>())); 94 Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance.")); 95 96 Parameters.Add(new ValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue())); 97 Parameters.Add(new ValueParameter<IntValue>("Resources", "The number of resources used this JSSP instance.", new IntValue())); 98 Parameters.Add(new ValueParameter<BoolValue>("DueDates", "Determines whether the problem instance uses due dates or not.", new BoolValue())); 99 Parameters.Add(new ValueParameter<SchedulingEvaluator>("SolutionEvaluator", "The evaluator used to determine the quality of a solution.", new MakespanEvaluator())); 100 101 InitializeOperators(); 102 InitializeProblemInstance(); 103 } 104 50 105 [StorableConstructor] 51 106 private JobShopSchedulingProblem(bool deserializing) : base(deserializing) { } 52 107 private JobShopSchedulingProblem(JobShopSchedulingProblem original, Cloner cloner) 53 108 : base(original, cloner) { 54 this.Jobs = cloner.Clone(original.Jobs);55 this.Resources = cloner.Clone(original.Resources);56 this.JobData = cloner.Clone(original.JobData);57 this.SolutionEvaluator = cloner.Clone(original.SolutionEvaluator);58 this.DueDates = cloner.Clone(original.DueDates);59 109 } 60 110 public override IDeepCloneable Clone(Cloner cloner) { 61 111 return new JobShopSchedulingProblem(this, cloner); 62 }63 64 65 #region Parameter Properties66 public ValueParameter<ItemList<Job>> JobDataParameter {67 get { return (ValueParameter<ItemList<Job>>)Parameters["JobData"]; }68 }69 public OptionalValueParameter<Schedule> BestKnownSolutionParameter {70 get { return (OptionalValueParameter<Schedule>)Parameters["BestKnownSolution"]; }71 }72 73 public ValueParameter<IntValue> JobsParameter {74 get { return (ValueParameter<IntValue>)Parameters["Jobs"]; }75 }76 public ValueParameter<IntValue> ResourcesParameter {77 get { return (ValueParameter<IntValue>)Parameters["Resources"]; }78 }79 public ValueParameter<SchedulingEvaluator> SolutionEvaluatorParameter {80 get { return (ValueParameter<SchedulingEvaluator>)Parameters["SolutionEvaluator"]; }81 }82 public ValueParameter<BoolValue> DueDatesParameter {83 get { return (ValueParameter<BoolValue>)Parameters["DueDates"]; }84 }85 #endregion86 87 #region Properties88 public ItemList<Job> JobData {89 get { return JobDataParameter.Value; }90 set { JobDataParameter.Value = value; }91 }92 public Schedule BestKnownSolution {93 get { return BestKnownSolutionParameter.Value; }94 set { BestKnownSolutionParameter.Value = value; }95 }96 public IntValue Jobs {97 get { return JobsParameter.Value; }98 set { JobsParameter.Value = value; }99 }100 public IntValue Resources {101 get { return ResourcesParameter.Value; }102 set { ResourcesParameter.Value = value; }103 }104 public SchedulingEvaluator SolutionEvaluator {105 get { return SolutionEvaluatorParameter.Value; }106 set { SolutionEvaluatorParameter.Value = value; }107 }108 public BoolValue DueDates {109 get { return DueDatesParameter.Value; }110 set { DueDatesParameter.Value = value; }111 }112 #endregion113 114 115 public JobShopSchedulingProblem()116 : base(new SchedulingEvaluationAlgorithm (), new JSMRandomCreator ()) {117 Parameters.Add(new ValueParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance.", new ItemList<Job>()));118 Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));119 120 Parameters.Add(new ValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue()));121 Parameters.Add(new ValueParameter<IntValue>("Resources", "The number of resources used this JSSP instance.", new IntValue()));122 Parameters.Add(new ValueParameter<BoolValue>("DueDates", "Determines whether the problem instance uses due dates or not.", new BoolValue()));123 Parameters.Add(new ValueParameter<SchedulingEvaluator>("SolutionEvaluator", "The evaluator used to determine the quality of a solution.", new MakespanEvaluator()));124 125 InitializeOperators();126 InitializeProblemInstance();127 112 } 128 113 … … 131 116 InitializeOperators(); 132 117 } 118 119 protected override void OnEvaluatorChanged() { 120 base.OnEvaluatorChanged(); 121 } 133 122 #endregion 134 123 135 124 #region Helpers 136 private void InitializeProblemInstance 137 Jobs = new IntValue (10);138 Resources = new IntValue (10);139 BestKnownQuality = new DoubleValue 125 private void InitializeProblemInstance() { 126 Jobs = new IntValue(10); 127 Resources = new IntValue(10); 128 BestKnownQuality = new DoubleValue(930); 140 129 JobData = new ItemList<Job>(); 141 130 List<string> data = new List<string> … … 167 156 if (SolutionCreator.GetType().Equals(typeof(JSMRandomCreator))) { 168 157 Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>()); 169 ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<JSMEncoding>(new JSMDecoder()); 158 JSMDecoder decoder = new JSMDecoder(); 159 ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<JSMEncoding>(decoder); 170 160 } else { 171 161 if (SolutionCreator.GetType().Equals(typeof(PRVRandomCreator))) { 172 162 Operators.AddRange(ApplicationManager.Manager.GetInstances<IPRVOperator>()); 173 ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PRVEncoding>(new PRVDecoder()); 163 PRVDecoder decoder = new PRVDecoder(); 164 ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PRVEncoding>(decoder); 174 165 } else { 175 166 if (SolutionCreator.GetType().Equals(typeof(PWRRandomCreator))) { 176 167 Operators.AddRange(ApplicationManager.Manager.GetInstances<IPWROperator>()); 177 ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PWREncoding>(new PWRDecoder()); 168 PWRDecoder decoder = new PWRDecoder(); 169 ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PWREncoding>(decoder); 178 170 } 179 171 } … … 197 189 } 198 190 private int[] GetIntArray(List<string> data) { 199 int[] arr = new int 200 for (int i = 0; i < data.Count; i++ 191 int[] arr = new int[data.Count]; 192 for (int i = 0; i < data.Count; i++) { 201 193 arr[i] = Int32.Parse(data[i]); 202 194 } 203 195 return arr; 204 196 } 205 private Job CreateJobFromData (List<string> data, int jobCount){197 private Job CreateJobFromData(List<string> data, int jobCount) { 206 198 DoubleValue dueDate = null; 207 199 int dataCount = data.Count; … … 233 225 if (data.Count > 0 && ((int)data[0][0] >= 48 && (int)data[0][0] <= 57)) { 234 226 int jobCount = 0; 235 Jobs = new IntValue 236 Resources = new IntValue 227 Jobs = new IntValue(Int32.Parse(data[0])); 228 Resources = new IntValue(Int32.Parse(data[1])); 237 229 //data[2] = bestKnownQuality (double) 238 230 //data[3] = dueDates (0|1) 239 231 DueDates.Value = false; 240 232 if (data.Count > 2) 241 BestKnownQualityParameter.ActualValue = new DoubleValue(Double.Parse 233 BestKnownQualityParameter.ActualValue = new DoubleValue(Double.Parse(data[2])); 242 234 if (data.Count > 3 && data[3] == "1") 243 235 DueDates.Value = true; … … 265 257 JSMEncoding solution = new JSMEncoding(); 266 258 while (!solutionFile.EndOfStream && !solutionFound) { 267 259 268 260 string line = solutionFile.ReadLine(); 269 261 List<string> data = SplitString(line); … … 274 266 data = SplitString(line); 275 267 while (data != null && data.Count > 0 && ((int)data[0][0] >= 48 && (int)data[0][0] <= 57)) { 276 Permutation p = new Permutation(PermutationTypes.Absolute, GetIntArray 268 Permutation p = new Permutation(PermutationTypes.Absolute, GetIntArray(data)); 277 269 solution.JobSequenceMatrix.Add(p); 278 270 -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Plugin.cs
r6364 r6406 23 23 24 24 namespace HeuristicLab.Problems.Scheduling { 25 [Plugin("HeuristicLab.Problems.Scheduling", "3.3.3.6 293")]25 [Plugin("HeuristicLab.Problems.Scheduling", "3.3.3.6364")] 26 26 [PluginFile("HeuristicLab.Problems.Scheduling-3.3.dll", PluginFileType.Assembly)] 27 27 public class HeuristicLabProblemsSchedulingPlugin : PluginBase { -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/SchedulingProblem.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; 23 using HeuristicLab.Core; 24 using HeuristicLab.Encodings.ScheduleEncoding; 26 25 using HeuristicLab.Optimization; 27 using HeuristicLab.Core;28 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Common;30 using HeuristicLab.Encodings.SchedulingEncoding.Interfaces;31 27 32 28 namespace HeuristicLab.Problems.Scheduling { 33 [Item("Scheduling 29 [Item("SchedulingProblem", "Abstract class that represents a Scheduling Problem")] 34 30 [StorableClass] 35 public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem<ISchedul ingEvaluationAlgorithm, ISchedulingCreator> {31 public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem<IScheduleEvaluationAlgorithm, IScheduleCreator> { 36 32 [StorableConstructor] 37 33 protected SchedulingProblem(bool deserializing) : base(deserializing) { } … … 40 36 } 41 37 42 protected SchedulingProblem (ISchedulingEvaluationAlgorithm se, ISchedulingCreator sc) : base (se, sc) {}38 protected SchedulingProblem(IScheduleEvaluationAlgorithm se, IScheduleCreator sc) : base(se, sc) { } 43 39 44 40 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Task.cs
r6293 r6406 20 20 #endregion 21 21 22 using System;23 using System.Collections.Generic;24 using System.Linq;25 22 using System.Text; 23 using HeuristicLab.Common; 24 using HeuristicLab.Core; 26 25 using HeuristicLab.Data; 27 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Core;29 using HeuristicLab.Common;30 27 31 28 namespace HeuristicLab.Problems.Scheduling { … … 33 30 [StorableClass] 34 31 public class Task : Item { 32 [Storable] 33 public IntValue TaskNr { get; set; } 34 [Storable] 35 public IntValue ResourceNr { get; set; } 36 [Storable] 37 public IntValue JobNr { get; set; } 38 [Storable] 39 public DoubleValue Duration { get; set; } 40 [Storable] 41 public BoolValue IsScheduled { get; set; } 42 35 43 [StorableConstructor] 36 44 protected Task(bool deserializing) : base(deserializing) { } … … 48 56 49 57 50 public IntValue TaskNr { get; set; } 51 public IntValue ResourceNr { get; set; } 52 public IntValue JobNr { get; set; } 53 public DoubleValue Duration { get; set; } 54 public BoolValue IsScheduled { get; set; } 55 56 57 public Task (int taskNr, int resNr, int jobNr, double duration) : base () { 58 Duration = new DoubleValue (duration); 59 ResourceNr = new IntValue (resNr); 60 JobNr = new IntValue (jobNr); 61 TaskNr = new IntValue (taskNr); 58 public Task(int taskNr, int resNr, int jobNr, double duration) 59 : base() { 60 Duration = new DoubleValue(duration); 61 ResourceNr = new IntValue(resNr); 62 JobNr = new IntValue(jobNr); 63 TaskNr = new IntValue(taskNr); 62 64 IsScheduled = new BoolValue(false); 63 65 }
Note: See TracChangeset
for help on using the changeset viewer.