- Timestamp:
- 11/11/12 22:57:09 (12 years ago)
- 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 30 30 [Item("Makespan Evaluator", "Represents an evaluator using the maximum makespan of a schedule.")] 31 31 [StorableClass] 32 public class MakespanEvaluator : SchedulingEvaluator { 32 public class MakespanEvaluator : ScheduleEvaluator { 33 33 34 [StorableConstructor] 34 35 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"; 37 40 } 41 38 42 public override IDeepCloneable Clone(Cloner cloner) { 39 43 return new MakespanEvaluator(this, cloner); 40 44 } 41 42 public MakespanEvaluator() : base() { }43 45 44 46 public static double GetMakespan(Schedule schedule) { … … 46 48 } 47 49 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); 54 52 } 55 53 } -
trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MeanTardinessEvaluator.cs
r8882 r8887 32 32 [Item("Mean tardiness Evaluator", "Represents an evaluator using the mean tardiness of a schedule.")] 33 33 [StorableClass] 34 public class MeanTardinessEvaluator : Schedul ingEvaluator, IJSSPOperator {34 public class MeanTardinessEvaluator : ScheduleEvaluator, IJSSPOperator { 35 35 36 36 [StorableConstructor] … … 50 50 : base() { 51 51 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"; 52 53 } 53 54 … … 58 59 } 59 60 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); 62 63 } 63 64 } -
trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Evaluators/SchedulingEvaluator.cs
r8882 r8887 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 30 31 namespace 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 { 30 35 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 35 52 [StorableConstructor] 36 53 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; 39 61 } 40 62 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); 54 65 } 55 66 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."); 62 71 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; 69 77 } 70 78 }
Note: See TracChangeset
for help on using the changeset viewer.