Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/15/15 15:16:24 (8 years ago)
Author:
mkommend
Message:

#2521: Refactored problem base classes and adapted scheduling encoding, scheduling problem and unit tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleDecoder.cs

    r13443 r13469  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2930  [Item("ScheduleDecoder", "A schedule decoder translates a respresentation into an actual schedule.")]
    3031  [StorableClass]
    31   public abstract class ScheduleDecoder : SingleSuccessorOperator, IScheduleDecoder {
     32  public abstract class ScheduleDecoder<TSchedule> : SingleSuccessorOperator, IScheduleDecoder<TSchedule>
     33  where TSchedule : class, ISchedule {
    3234
    3335    public ILookupParameter<ISchedule> ScheduleEncodingParameter {
     
    4345    [StorableConstructor]
    4446    protected ScheduleDecoder(bool deserializing) : base(deserializing) { }
    45     protected ScheduleDecoder(ScheduleDecoder original, Cloner cloner) : base(original, cloner) { }
     47    protected ScheduleDecoder(ScheduleDecoder<TSchedule> original, Cloner cloner) : base(original, cloner) { }
    4648    public ScheduleDecoder()
    4749      : base() {
     
    5153    }
    5254
    53     public abstract Schedule DecodeSchedule(ISchedule solution, ItemList<Job> jobData);
     55    public Schedule DecodeSchedule(ISchedule schedule, ItemList<Job> jobData) {
     56      TSchedule solution = schedule as TSchedule;
     57      if (solution == null) throw new InvalidOperationException("Encoding is not of type " + typeof(TSchedule).GetPrettyName());
     58      return DecodeSchedule(solution, jobData);
     59    }
     60    public abstract Schedule DecodeSchedule(TSchedule schedule, ItemList<Job> jobData);
    5461
    5562    public override IOperation Apply() {
Note: See TracChangeset for help on using the changeset viewer.