Changeset 13443 for branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Decoder
- Timestamp:
- 12/08/15 14:31:05 (9 years ago)
- Location:
- branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Decoder
- Files:
-
- 1 added
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Decoder/PWRDecoder.cs
r13437 r13443 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Encodings.ScheduleEncoding;26 using HeuristicLab.Optimization;27 using HeuristicLab.Parameters;28 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 26 30 namespace HeuristicLab. Problems.Scheduling {27 namespace HeuristicLab.Encodings.ScheduleEncoding { 31 28 [Item("PWRDecoder", "An item used to convert a PWR-individual into a generalized schedule.")] 32 29 [StorableClass] 33 public class PWRDecoder : ScheduleDecoder, IStochasticOperator, IJSSPOperator { 34 35 public ILookupParameter<IRandom> RandomParameter { 36 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 37 } 38 public ILookupParameter<ItemList<Job>> JobDataParameter { 39 get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; } 40 } 41 30 public class PWRDecoder : ScheduleDecoder { 42 31 [StorableConstructor] 43 32 protected PWRDecoder(bool deserializing) : base(deserializing) { } 44 33 protected PWRDecoder(PWRDecoder original, Cloner cloner) : base(original, cloner) { } 45 public PWRDecoder() 46 : base() { 47 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 48 Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance.")); 49 ScheduleEncodingParameter.ActualName = "PermutationWithRepetition"; 50 } 34 public PWRDecoder() : base() { } 51 35 52 36 public override IDeepCloneable Clone(Cloner cloner) { … … 54 38 } 55 39 56 public override Schedule CreateScheduleFromEncoding(ISchedule encoding) { 57 var solution = encoding as PWREncoding; 58 if (solution == null) throw new InvalidOperationException("Encoding is not of type PWREncoding"); 40 public override Schedule DecodeSchedule(ISchedule solution, ItemList<Job> jobData) { 41 var pwr = solution as PWREncoding; 42 if (pwr == null) throw new InvalidOperationException("Encoding is not of type PWREncoding"); 43 return DecodeSchedule(pwr, jobData); 44 } 59 45 60 var jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone(); 46 public static Schedule DecodeSchedule(PWREncoding solution, ItemList<Job> jobData) { 47 var jobs = (ItemList<Job>)jobData.Clone(); 61 48 var resultingSchedule = new Schedule(jobs[0].Tasks.Count); 62 49 foreach (int jobNr in solution.PermutationWithRepetition) {
Note: See TracChangeset
for help on using the changeset viewer.