1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2012 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 |
|
---|
22 | using HeuristicLab.Common;
|
---|
23 | using HeuristicLab.Core;
|
---|
24 | using HeuristicLab.Data;
|
---|
25 | using HeuristicLab.Encodings.ScheduleEncoding;
|
---|
26 | using HeuristicLab.Parameters;
|
---|
27 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Problems.Scheduling {
|
---|
30 | [Item("Mean tardiness Evaluator", "Represents an evaluator using the mean tardiness of a schedule.")]
|
---|
31 | [StorableClass]
|
---|
32 | public class MeanTardinessEvaluator : SchedulingEvaluator, IJSSPOperator {
|
---|
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
|
---|
43 | public ILookupParameter<ItemList<Job>> JobDataParameter {
|
---|
44 | get { return (ILookupParameter<ItemList<Job>>)Parameters["JobData"]; }
|
---|
45 | }
|
---|
46 | #endregion
|
---|
47 | #region Properties
|
---|
48 | public ItemList<Job> JobData {
|
---|
49 | get { return JobDataParameter.ActualValue; }
|
---|
50 | }
|
---|
51 | #endregion
|
---|
52 |
|
---|
53 | public MeanTardinessEvaluator()
|
---|
54 | : base() {
|
---|
55 | Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance."));
|
---|
56 | }
|
---|
57 |
|
---|
58 | protected override DoubleValue evaluate(Schedule schedule) {
|
---|
59 | double totalTardiness = 0;
|
---|
60 | foreach (Resource r in schedule.Resources) {
|
---|
61 | double tardiness = r.Tasks[r.Tasks.Count - 1].EndTime - JobData[r.Tasks[r.Tasks.Count - 1].JobNr].DueDate;
|
---|
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 | }
|
---|