Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1329: Did some minor refactoring.

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