Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/28/17 22:22:12 (7 years ago)
Author:
abeham
Message:

#2790:

  • Fixed small bug in JSSP where solution creator changed was not fired
  • Added IStochasticOperator to SchedulingEvaluator and added backwards compatibility code
File:
1 edited

Legend:

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

    r14185 r15083  
    2626using HeuristicLab.Encodings.ScheduleEncoding;
    2727using HeuristicLab.Operators;
     28using HeuristicLab.Optimization;
    2829using HeuristicLab.Parameters;
    2930using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3233  [Item("SchedulingEvaluator", "First applies the decoder operator to obtain a schedule from an encoding and then applies the evaluator to obtain a quality.")]
    3334  [StorableClass]
    34   public class SchedulingEvaluator : InstrumentedOperator, ISchedulingEvaluator {
     35  public class SchedulingEvaluator : InstrumentedOperator, ISchedulingEvaluator, IStochasticOperator {
    3536
    3637    public IValueLookupParameter<IScheduleDecoder> ScheduleDecoderParameter {
     
    4950      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
    5051    }
     52    // ABE: This parameter exists purely, because some IScheduleDecoders are stochastic...
     53    // ... which could be solved by letting the algorithm parameterize them ...
     54    // ... but they have to use the same RNG as the evaluator (due to parallel execution)...
     55    // ... in particular relevant for Island-GA and ALPS (Local- vs GlobalRandom).
     56    public ILookupParameter<IRandom> RandomParameter {
     57      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
     58    }
    5159
    5260    [StorableConstructor]
     
    5866      Parameters.Add(new ValueLookupParameter<IScheduleEvaluator>("ScheduleEvaluator", "The actual schedule evaluation operator."));
    5967      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
     68      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
    6069      QualityParameter.Hidden = true;
    6170    }
     
    6372    public override IDeepCloneable Clone(Cloner cloner) {
    6473      return new SchedulingEvaluator(this, cloner);
     74    }
     75   
     76    [StorableHook(HookType.AfterDeserialization)]
     77    private void AfterDeserialization() {
     78      // BackwardsCompatibility3.3
     79      #region Backwards compatible code, remove with 3.4
     80      if (!Parameters.ContainsKey("Random")) {
     81        Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
     82      }
     83      #endregion
    6584    }
    6685
Note: See TracChangeset for help on using the changeset viewer.