- Timestamp:
- 06/10/11 16:18:44 (13 years ago)
- Location:
- branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3
- Files:
-
- 2 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/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 }
Note: See TracChangeset
for help on using the changeset viewer.