Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/08/15 14:31:05 (8 years ago)
Author:
mkommend
Message:

#2521: Adapted decoders for SchedulingProblem.

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  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.Encodings.ScheduleEncoding;
    26 using HeuristicLab.Optimization;
    27 using HeuristicLab.Parameters;
    2825using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2926
    30 namespace HeuristicLab.Problems.Scheduling {
     27namespace HeuristicLab.Encodings.ScheduleEncoding {
    3128  [Item("PWRDecoder", "An item used to convert a PWR-individual into a generalized schedule.")]
    3229  [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 {
    4231    [StorableConstructor]
    4332    protected PWRDecoder(bool deserializing) : base(deserializing) { }
    4433    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() { }
    5135
    5236    public override IDeepCloneable Clone(Cloner cloner) {
     
    5438    }
    5539
    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    }
    5945
    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();
    6148      var resultingSchedule = new Schedule(jobs[0].Tasks.Count);
    6249      foreach (int jobNr in solution.PermutationWithRepetition) {
Note: See TracChangeset for help on using the changeset viewer.