Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/11/12 22:57:09 (12 years ago)
Author:
abeham
Message:

#1329:

  • Moved decoders and evaluators from encoding to problem
  • Removed unnecessary state variables in operators
  • Introduced parameters in interfaces and added wiring code
  • Removed ConcreteScheduleManipulator as it does not perform any manipulation
  • Made ErrorPolicy and ForcingStrategy configurable and added views for them
  • Renamed the SchedulingEvaluationAlgorithm and also converted the AlgorithmOperator to a SingleSuccessorOperator
  • Fixed Plugin- and AssemblyFileVersion
  • Added missing license headers
Location:
trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Evaluators
Files:
1 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MakespanEvaluator.cs

    r8882 r8887  
    3030  [Item("Makespan Evaluator", "Represents an evaluator using the maximum makespan of a schedule.")]
    3131  [StorableClass]
    32   public class MakespanEvaluator : SchedulingEvaluator {
     32  public class MakespanEvaluator : ScheduleEvaluator {
     33
    3334    [StorableConstructor]
    3435    protected MakespanEvaluator(bool deserializing) : base(deserializing) { }
    35     protected MakespanEvaluator(MakespanEvaluator original, Cloner cloner)
    36       : base(original, cloner) {
     36    protected MakespanEvaluator(MakespanEvaluator original, Cloner cloner) : base(original, cloner) {}
     37    public MakespanEvaluator()
     38      : base() {
     39      QualityParameter.ActualName = "Makespan";
    3740    }
     41
    3842    public override IDeepCloneable Clone(Cloner cloner) {
    3943      return new MakespanEvaluator(this, cloner);
    4044    }
    41 
    42     public MakespanEvaluator() : base() { }
    4345
    4446    public static double GetMakespan(Schedule schedule) {
     
    4648    }
    4749
    48     protected override DoubleValue Evaluate(Schedule schedule) {
    49       return new DoubleValue(GetMakespan(schedule));
    50     }
    51 
    52     public override IOperation Apply() {
    53       return base.Apply();
     50    protected override double Evaluate(Schedule schedule) {
     51      return GetMakespan(schedule);
    5452    }
    5553  }
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MeanTardinessEvaluator.cs

    r8882 r8887  
    3232  [Item("Mean tardiness Evaluator", "Represents an evaluator using the mean tardiness of a schedule.")]
    3333  [StorableClass]
    34   public class MeanTardinessEvaluator : SchedulingEvaluator, IJSSPOperator {
     34  public class MeanTardinessEvaluator : ScheduleEvaluator, IJSSPOperator {
    3535
    3636    [StorableConstructor]
     
    5050      : base() {
    5151      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance."));
     52      QualityParameter.ActualName = "MeanTardiness";
    5253    }
    5354
     
    5859    }
    5960
    60     protected override DoubleValue Evaluate(Schedule schedule) {
    61       return new DoubleValue(GetMeanTardiness(schedule, JobDataParameter.ActualValue));
     61    protected override double Evaluate(Schedule schedule) {
     62      return GetMeanTardiness(schedule, JobDataParameter.ActualValue);
    6263    }
    6364  }
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Evaluators/SchedulingEvaluator.cs

    r8882 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2930
     31namespace HeuristicLab.Problems.Scheduling {
     32  [Item("SchedulingEvaluator", "First applies the decoder operator to obtain a schedule from an encoding and then applies the evaluator to obtain a quality.")]
     33  [StorableClass]
     34  public class SchedulingEvaluator : SingleSuccessorOperator, ISchedulingEvaluator {
    3035
    31 namespace HeuristicLab.Problems.Scheduling {
    32   [Item("Scheduling Evaluator", "Represents a evaluator class for standard scheduling problems.")]
    33   [StorableClass]
    34   public abstract class SchedulingEvaluator : SingleSuccessorOperator, IScheduleEvaluator {
     36    public IValueLookupParameter<IScheduleDecoder> ScheduleDecoderParameter {
     37      get { return (IValueLookupParameter<IScheduleDecoder>) Parameters["ScheduleDecoder"]; }
     38    }
     39    ILookupParameter<IScheduleDecoder> ISchedulingEvaluator.ScheduleDecoderParameter {
     40      get { return ScheduleDecoderParameter; }
     41    }
     42    public IValueLookupParameter<IScheduleEvaluator> ScheduleEvaluatorParameter {
     43      get { return (IValueLookupParameter<IScheduleEvaluator>) Parameters["ScheduleEvaluator"]; }
     44    }
     45    ILookupParameter<IScheduleEvaluator> ISchedulingEvaluator.ScheduleEvaluatorParameter {
     46      get { return ScheduleEvaluatorParameter; }
     47    }
     48    public ILookupParameter<DoubleValue> QualityParameter {
     49      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
     50    }
     51
    3552    [StorableConstructor]
    3653    protected SchedulingEvaluator(bool deserializing) : base(deserializing) { }
    37     protected SchedulingEvaluator(SchedulingEvaluator original, Cloner cloner)
    38       : base(original, cloner) {
     54    protected SchedulingEvaluator(SchedulingEvaluator original, Cloner cloner) : base(original, cloner) { }
     55    public SchedulingEvaluator()
     56      : base() {
     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."));
     59      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
     60      QualityParameter.Hidden = true;
    3961    }
    4062
    41     public ILookupParameter<IRandom> RandomParameter {
    42       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    43     }
    44     public ILookupParameter<DoubleValue> QualityParameter {
    45       get {
    46         if (Parameters.ContainsKey("Quality"))
    47           return (ILookupParameter<DoubleValue>)Parameters["Quality"];
    48         else
    49           return null;
    50       }
    51     }
    52     public ILookupParameter<Schedule> ScheduleParameter {
    53       get { return (ILookupParameter<Schedule>)Parameters["Schedule"]; }
     63    public override IDeepCloneable Clone(Cloner cloner) {
     64      return new SchedulingEvaluator(this, cloner);
    5465    }
    5566
    56     public SchedulingEvaluator()
    57       : base() {
    58       Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
    59       Parameters.Add(new LookupParameter<Schedule>("Schedule", "The decoded scheduling solution represented as generalized schedule."));
    60       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator."));
    61     }
     67    public override IOperation Apply() {
     68      var decoder = ScheduleDecoderParameter.ActualValue;
     69      var evaluator = ScheduleEvaluatorParameter.ActualValue;
     70      if (evaluator == null) throw new InvalidOperationException("A ScheduleEvaluator could not be found.");
    6271
    63     protected abstract DoubleValue Evaluate(Schedule schedule);
    64 
    65     public override IOperation Apply() {
    66       Schedule schedule = ScheduleParameter.ActualValue;
    67       QualityParameter.ActualValue = Evaluate(schedule);
    68       return base.Apply();
     72      var operations = new OperationCollection(base.Apply());
     73      operations.Insert(0, ExecutionContext.CreateChildOperation(evaluator));
     74      if (decoder != null) // decode before evaluating
     75        operations.Insert(0, ExecutionContext.CreateChildOperation(decoder));
     76      return operations;
    6977    }
    7078  }
Note: See TracChangeset for help on using the changeset viewer.