Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/11/12 22:57:09 (11 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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Decoders/PRVDecoder.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    3132  [Item("JobSequencingMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")]
    3233  [StorableClass]
    33   public class PRVDecoder : ScheduleDecoder<PRVEncoding>, IStochasticOperator, IJSSPOperator {
     34  public class PRVDecoder : ScheduleDecoder, IStochasticOperator, IJSSPOperator {
     35
    3436    public ILookupParameter<IRandom> RandomParameter {
    3537      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     
    3840      get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
    3941    }
    40 
    41     #region Private Members
    42     [Storable]
    43     private Schedule resultingSchedule;
    44 
    45     [Storable]
    46     private ItemList<Job> jobs;
    47     #endregion
    4842
    4943    #region Priority Rules
     
    5549
    5650    //earliest start time
    57     private Task ESTRule(ItemList<Task> tasks) {
     51    private Task ESTRule(ItemList<Task> tasks, Schedule schedule) {
    5852      Task currentResult = RandomRule(tasks);
    5953      double currentEST = double.MaxValue;
    6054      foreach (Task t in tasks) {
    61         double est = GTAlgorithmUtils.ComputeEarliestStartTime(t, resultingSchedule);
     55        double est = GTAlgorithmUtils.ComputeEarliestStartTime(t, schedule);
    6256        if (est < currentEST) {
    6357          currentEST = est;
     
    8983
    9084    //most work remaining
    91     private Task MWRRule(ItemList<Task> tasks) {
     85    private Task MWRRule(ItemList<Task> tasks, ItemList<Job> jobs) {
    9286      Task currentResult = RandomRule(tasks);
    9387      double currentLargestRemainingProcessingTime = 0;
     
    107101
    108102    //least work remaining
    109     private Task LWRRule(ItemList<Task> tasks) {
     103    private Task LWRRule(ItemList<Task> tasks, ItemList<Job> jobs) {
    110104      Task currentResult = RandomRule(tasks);
    111105      double currentSmallestRemainingProcessingTime = double.MaxValue;
     
    125119
    126120    //most operations remaining
    127     private Task MORRule(ItemList<Task> tasks) {
     121    private Task MORRule(ItemList<Task> tasks, ItemList<Job> jobs) {
    128122      Task currentResult = RandomRule(tasks);
    129123      int currentLargestNrOfRemainingTasks = 0;
     
    143137
    144138    //least operationsremaining
    145     private Task LORRule(ItemList<Task> tasks) {
     139    private Task LORRule(ItemList<Task> tasks, ItemList<Job> jobs) {
    146140      Task currentResult = RandomRule(tasks);
    147141      int currentSmallestNrOfRemainingTasks = int.MaxValue;
     
    176170    [StorableConstructor]
    177171    protected PRVDecoder(bool deserializing) : base(deserializing) { }
    178     protected PRVDecoder(PRVDecoder original, Cloner cloner)
    179       : base(original, cloner) {
    180       this.resultingSchedule = cloner.Clone(original.resultingSchedule);
    181     }
    182     public override IDeepCloneable Clone(Cloner cloner) {
    183       return new PRVDecoder(this, cloner);
    184     }
    185 
     172    protected PRVDecoder(PRVDecoder original, Cloner cloner) : base(original, cloner) { }
    186173    public PRVDecoder()
    187174      : base() {
     
    191178    }
    192179
    193     private Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, int ruleIndex, int nrOfRules) {
     180    public override IDeepCloneable Clone(Cloner cloner) {
     181      return new PRVDecoder(this, cloner);
     182    }
     183
     184    private Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, int ruleIndex, int nrOfRules, Schedule schedule, ItemList<Job> jobs) {
    194185      if (conflictSet.Count == 1)
    195186        return conflictSet[0];
     
    198189      switch (ruleIndex) {
    199190        case 0: return FILORule(conflictSet);
    200         case 1: return ESTRule(conflictSet);
     191        case 1: return ESTRule(conflictSet, schedule);
    201192        case 2: return SPTRule(conflictSet);
    202193        case 3: return LPTRule(conflictSet);
    203         case 4: return MWRRule(conflictSet);
    204         case 5: return LWRRule(conflictSet);
    205         case 6: return MORRule(conflictSet);
    206         case 7: return LORRule(conflictSet);
     194        case 4: return MWRRule(conflictSet, jobs);
     195        case 5: return LWRRule(conflictSet, jobs);
     196        case 6: return MORRule(conflictSet, jobs);
     197        case 7: return LORRule(conflictSet, jobs);
    207198        case 8: return FIFORule(conflictSet);
    208199        case 9: return RandomRule(conflictSet);
     
    211202    }
    212203
    213     public override Schedule CreateScheduleFromEncoding(PRVEncoding solution) {
    214       jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
    215       resultingSchedule = new Schedule(jobs[0].Tasks.Count);
     204    public override Schedule CreateScheduleFromEncoding(IScheduleEncoding encoding) {
     205      var solution = encoding as PRVEncoding;
     206      if (solution == null) throw new InvalidOperationException("Encoding is not of type PWREncoding");
     207
     208      var jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
     209      var resultingSchedule = new Schedule(jobs[0].Tasks.Count);
    216210
    217211      //Reset scheduled tasks in result
     
    235229        //STEP 3 - Select an operation from the conflict set (various methods depending on how the algorithm should work..)
    236230        //Task selectedTask = SelectTaskFromConflictSet(conflictSet, solution.PriorityRulesVector [currentDecisionIndex++], solution.NrOfRules.Value);
    237         Task selectedTask = SelectTaskFromConflictSet(conflictSet, solution.PriorityRulesVector[minimal.JobNr], solution.NrOfRules.Value);
     231        Task selectedTask = SelectTaskFromConflictSet(conflictSet, solution.PriorityRulesVector[minimal.JobNr], solution.NrOfRules.Value, resultingSchedule, jobs);
    238232
    239233        //STEP 4 - Adding the selected operation to the current schedule
     
    248242      return resultingSchedule;
    249243    }
    250 
    251     public override IOperation Apply() {
    252       return base.Apply();
    253     }
    254244  }
    255245}
Note: See TracChangeset for help on using the changeset viewer.