Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleDecoder.cs

Last change on this file was 17461, checked in by abeham, 5 years ago

#2521: worked on scheduling problem

File size: 3.1 KB
RevLine 
[8887]1#region License Information
2/* HeuristicLab
[17226]3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[8887]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
[13469]22using System;
[16725]23using HEAL.Attic;
[8887]24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Operators;
27using HeuristicLab.Parameters;
28
[13443]29namespace HeuristicLab.Encodings.ScheduleEncoding {
[8887]30  [Item("ScheduleDecoder", "A schedule decoder translates a respresentation into an actual schedule.")]
[16725]31  [StorableType("57A68F4B-4B35-4DB4-9B5E-D5154DD46E45")]
[13469]32  public abstract class ScheduleDecoder<TSchedule> : SingleSuccessorOperator, IScheduleDecoder<TSchedule>
[17461]33  where TSchedule : class, IScheduleSolution {
[8887]34
[17461]35    public ILookupParameter<IScheduleSolution> ScheduleEncodingParameter {
36      get { return (ILookupParameter<IScheduleSolution>)Parameters["EncodedSchedule"]; }
[8887]37    }
38    public ILookupParameter<Schedule> ScheduleParameter {
39      get { return (ILookupParameter<Schedule>)Parameters["Schedule"]; }
40    }
[13443]41    public ILookupParameter<ItemList<Job>> JobDataParameter {
42      get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
43    }
[8887]44
45    [StorableConstructor]
[16725]46    protected ScheduleDecoder(StorableConstructorFlag _) : base(_) { }
[13469]47    protected ScheduleDecoder(ScheduleDecoder<TSchedule> original, Cloner cloner) : base(original, cloner) { }
[8887]48    public ScheduleDecoder()
49      : base() {
[17461]50      Parameters.Add(new LookupParameter<IScheduleSolution>("EncodedSchedule", "The new scheduling solution represented as encoding."));
[8887]51      Parameters.Add(new LookupParameter<Schedule>("Schedule", "The decoded scheduling solution represented as generalized schedule."));
[13443]52      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance."));
[8887]53    }
54
[17461]55    public Schedule DecodeSchedule(IScheduleSolution schedule, ItemList<Job> jobData) {
[13469]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);
[8887]61
62    public override IOperation Apply() {
[13443]63      Schedule result = DecodeSchedule(ScheduleEncodingParameter.ActualValue, JobDataParameter.ActualValue);
[8887]64      ScheduleParameter.ActualValue = result;
65      return base.Apply();
66    }
67  }
68}
Note: See TracBrowser for help on using the repository browser.