Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Evaluators/SchedulingEvaluator.cs @ 14469

Last change on this file since 14469 was 14185, checked in by swagner, 8 years ago

#2526: Updated year of copyrights in license headers

File size: 3.7 KB
RevLine 
[6266]1#region License Information
2/* HeuristicLab
[14185]3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[6266]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
[8887]22using System;
[6406]23using HeuristicLab.Common;
[6266]24using HeuristicLab.Core;
25using HeuristicLab.Data;
[6406]26using HeuristicLab.Encodings.ScheduleEncoding;
27using HeuristicLab.Operators;
[6266]28using HeuristicLab.Parameters;
[6406]29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
[6266]30
[6406]31namespace HeuristicLab.Problems.Scheduling {
[8887]32  [Item("SchedulingEvaluator", "First applies the decoder operator to obtain a schedule from an encoding and then applies the evaluator to obtain a quality.")]
[6266]33  [StorableClass]
[10291]34  public class SchedulingEvaluator : InstrumentedOperator, ISchedulingEvaluator {
[6266]35
[8887]36    public IValueLookupParameter<IScheduleDecoder> ScheduleDecoderParameter {
[10291]37      get { return (IValueLookupParameter<IScheduleDecoder>)Parameters["ScheduleDecoder"]; }
[6266]38    }
[8887]39    ILookupParameter<IScheduleDecoder> ISchedulingEvaluator.ScheduleDecoderParameter {
40      get { return ScheduleDecoderParameter; }
41    }
42    public IValueLookupParameter<IScheduleEvaluator> ScheduleEvaluatorParameter {
[10291]43      get { return (IValueLookupParameter<IScheduleEvaluator>)Parameters["ScheduleEvaluator"]; }
[8887]44    }
45    ILookupParameter<IScheduleEvaluator> ISchedulingEvaluator.ScheduleEvaluatorParameter {
46      get { return ScheduleEvaluatorParameter; }
47    }
[6266]48    public ILookupParameter<DoubleValue> QualityParameter {
[8887]49      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
[6266]50    }
51
[8887]52    [StorableConstructor]
53    protected SchedulingEvaluator(bool deserializing) : base(deserializing) { }
54    protected SchedulingEvaluator(SchedulingEvaluator original, Cloner cloner) : base(original, cloner) { }
[6406]55    public SchedulingEvaluator()
56      : base() {
[8887]57      Parameters.Add(new ValueLookupParameter<IScheduleDecoder>("ScheduleDecoder", "The decoding operator that is used to calculate a schedule from the used representation."));
58      Parameters.Add(new ValueLookupParameter<IScheduleEvaluator>("ScheduleEvaluator", "The actual schedule evaluation operator."));
[6266]59      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
[8887]60      QualityParameter.Hidden = true;
[6266]61    }
62
[8887]63    public override IDeepCloneable Clone(Cloner cloner) {
64      return new SchedulingEvaluator(this, cloner);
65    }
[6406]66
[10291]67    public override IOperation InstrumentedApply() {
[8887]68      var decoder = ScheduleDecoderParameter.ActualValue;
69      var evaluator = ScheduleEvaluatorParameter.ActualValue;
70      if (evaluator == null) throw new InvalidOperationException("A ScheduleEvaluator could not be found.");
71
[10291]72      var operations = new OperationCollection(base.InstrumentedApply());
[8887]73      operations.Insert(0, ExecutionContext.CreateChildOperation(evaluator));
74      if (decoder != null) // decode before evaluating
75        operations.Insert(0, ExecutionContext.CreateChildOperation(decoder));
76      return operations;
[6266]77    }
78  }
79}
Note: See TracBrowser for help on using the repository browser.