Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MeanTardinessEvaluator.cs @ 6406

Last change on this file since 6406 was 6406, checked in by jhelm, 13 years ago

#1329: Applied suggestions from codereview. Added unit-tests. Renamed encoding-project.

File size: 2.7 KB
RevLine 
[6266]1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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
[6406]22using HeuristicLab.Common;
[6266]23using HeuristicLab.Core;
24using HeuristicLab.Data;
[6406]25using HeuristicLab.Encodings.ScheduleEncoding;
[6266]26using HeuristicLab.Parameters;
[6406]27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[6266]28
[6406]29namespace HeuristicLab.Problems.Scheduling {
[6364]30  [Item("Mean tardiness Evaluator", "Represents an evaluator using the mean tardiness of a schedule.")]
[6266]31  [StorableClass]
[6364]32  public class MeanTardinessEvaluator : SchedulingEvaluator, IJSSPOperator {
[6266]33    [StorableConstructor]
34    protected MeanTardinessEvaluator(bool deserializing) : base(deserializing) { }
35    protected MeanTardinessEvaluator(MeanTardinessEvaluator original, Cloner cloner)
36      : base(original, cloner) {
37    }
38    public override IDeepCloneable Clone(Cloner cloner) {
39      return new MeanTardinessEvaluator(this, cloner);
40    }
41
42    #region Parameter Properties
[6364]43    public ILookupParameter<ItemList<Job>> JobDataParameter {
44      get { return (ILookupParameter<ItemList<Job>>)Parameters["JobData"]; }
[6266]45    }
46    #endregion
47    #region Properties
[6364]48    public ItemList<Job> JobData {
49      get { return JobDataParameter.ActualValue; }
[6266]50    }
51    #endregion
52
[6406]53    public MeanTardinessEvaluator()
54      : base() {
[6364]55      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance."));
[6266]56    }
57
58    protected override DoubleValue evaluate(Schedule schedule) {
59      double totalTardiness = 0;
60      foreach (Resource r in schedule.Resources) {
[6364]61        double tardiness = r.Tasks[r.Tasks.Count - 1].EndTime.Value - JobData[r.Tasks[r.Tasks.Count - 1].JobNr.Value].DueDate.Value;
[6266]62        if (tardiness > 0)
63          totalTardiness += tardiness;
64      }
65      return new DoubleValue(totalTardiness / schedule.Resources.Count);
66    }
67
68    public override IOperation Apply() {
69      return base.Apply();
70    }
71  }
72}
Note: See TracBrowser for help on using the repository browser.