Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/10/11 16:18:44 (13 years ago)
Author:
jhelm
Message:

#1329: Applied suggestions from codereview. Added unit-tests. Renamed encoding-project.

Location:
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3

    • Property svn:ignore
      •  

        old new  
        22bin
        33obj
         4HeuristicLab.Problems.Scheduling-3.3.csproj.user
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/GTAlgorithmUtils.cs

    r6293 r6406  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using HeuristicLab.Encodings.SchedulingEncoding;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     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
     22using System;
    623using HeuristicLab.Core;
     24using HeuristicLab.Encodings.ScheduleEncoding;
    725
    8 namespace HeuristicLab.Problems.Scheduling.Decoders {
     26namespace HeuristicLab.Problems.Scheduling {
    927  public static class GTAlgorithmUtils {
    1028
     
    4563      return result;
    4664    }
    47    
     65
    4866    public static double ComputeEarliestStartTime(Task t, Schedule schedule) {
    49       ScheduledTask previousTask = schedule.GetLastScheduledTaskForJobNr (t.JobNr.Value);
     67      ScheduledTask previousTask = schedule.GetLastScheduledTaskForJobNr(t.JobNr.Value);
    5068      Resource affectedResource = schedule.Resources[t.ResourceNr.Value];
    5169      double lastMachineEndTime = affectedResource.TotalDuration.Value;
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/JSMDecoder.cs

    r6364 r6406  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Linq;
    25 using System.Text;
     24using HeuristicLab.Common;
    2625using HeuristicLab.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Common;
    29 using HeuristicLab.Data;
    3026using HeuristicLab.Encodings.PermutationEncoding;
     27using HeuristicLab.Encodings.ScheduleEncoding;
     28using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;
    3129using HeuristicLab.Optimization;
    3230using HeuristicLab.Parameters;
    33 using HeuristicLab.Encodings.SchedulingEncoding.JobSequenceMatrix;
    34 using HeuristicLab.Encodings.SchedulingEncoding;
    35 using HeuristicLab.Problems.Scheduling.Interfaces;
     31using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3632
    37 namespace HeuristicLab.Problems.Scheduling.Decoders {
    38   [Item("Job Sequence Matrix Decoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequence Matrix.")]
     33namespace HeuristicLab.Problems.Scheduling {
     34  [Item("JobSequenceMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequence Matrix.")]
    3935  [StorableClass]
    40   public class JSMDecoder : SchedulingDecoder<JSMEncoding>, IStochasticOperator, IJSSPOperator {
    41     [StorableConstructor]
    42     protected JSMDecoder(bool deserializing) : base(deserializing) { }
    43     protected JSMDecoder(JSMDecoder original, Cloner cloner)
    44       : base(original, cloner) {
    45         this.resultingSchedule = cloner.Clone(original.resultingSchedule);
    46         this.jobs = cloner.Clone(original.jobs);
    47         this.decodingErrorPolicy = original.decodingErrorPolicy;
    48         this.forcingStrategy = original.forcingStrategy;
    49     }
    50     public override IDeepCloneable Clone(Cloner cloner) {
    51       return new JSMDecoder(this, cloner);
    52     }
    53 
     36  public class JSMDecoder : ScheduleDecoder<JSMEncoding>, IStochasticOperator, IJSSPOperator {
    5437    public ILookupParameter<IRandom> RandomParameter {
    5538      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     
    7053
    7154    [Storable]
    72     private JSMForcingStrategyTypes forcingStrategy = JSMForcingStrategyTypes.ShiftForcing; 
     55    private JSMForcingStrategyTypes forcingStrategy = JSMForcingStrategyTypes.ShiftForcing;
    7356    #endregion
     57
     58    [StorableConstructor]
     59    protected JSMDecoder(bool deserializing) : base(deserializing) { }
     60    protected JSMDecoder(JSMDecoder original, Cloner cloner)
     61      : base(original, cloner) {
     62      this.resultingSchedule = cloner.Clone(original.resultingSchedule);
     63      this.jobs = cloner.Clone(original.jobs);
     64      this.decodingErrorPolicy = original.decodingErrorPolicy;
     65      this.forcingStrategy = original.forcingStrategy;
     66    }
     67    public override IDeepCloneable Clone(Cloner cloner) {
     68      return new JSMDecoder(this, cloner);
     69    }
    7470
    7571    public JSMDecoder()
     
    7773      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    7874      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the Schedulingproblem - Instance."));
     75      ScheduleEncodingParameter.ActualName = "JobSequenceMatrix";
    7976    }
    8077
    81    
     78
    8279    private Task SelectTaskFromConflictSet(int conflictedResourceNr, int progressOnConflictedResource, ItemList<Task> conflictSet, ItemList<Permutation> jsm) {
    8380      if (conflictSet.Count == 1)
    8481        return conflictSet[0];
    85      
     82
    8683      //get solutionCandidate from jobSequencingMatrix
    8784      int solutionCandidateJobNr = jsm[conflictedResourceNr][progressOnConflictedResource];
     
    104101    }
    105102    private Task ApplyDecodingErrorPolicy(ItemList<Task> conflictSet, Permutation resource, int progress) {
    106       if (decodingErrorPolicy == JSMDecodingErrorPolicyTypes.RandomPolicy) { 
     103      if (decodingErrorPolicy == JSMDecodingErrorPolicyTypes.RandomPolicy) {
    107104        //Random
    108105        return conflictSet[RandomParameter.ActualValue.Next(conflictSet.Count - 1)];
     
    118115        }
    119116        return conflictSet[RandomParameter.ActualValue.Next(conflictSet.Count - 1)];
    120       }   
     117      }
    121118    }
    122119    private void ApplyForcingStrategy(ItemList<Permutation> jsm, int conflictedResource, int newResolutionIndex, int progressOnResource, int newResolution) {
     
    132129          asList.Insert(progressOnResource, newResolution);
    133130        } else {
    134           asList.Insert(progressOnResource, newResolution); 
     131          asList.Insert(progressOnResource, newResolution);
    135132          asList.RemoveAt(newResolutionIndex);
    136133        }
    137         jsm[conflictedResource] = new Permutation (PermutationTypes.Absolute, asList.ToArray<int>());
    138       } 
     134        jsm[conflictedResource] = new Permutation(PermutationTypes.Absolute, asList.ToArray<int>());
     135      }
    139136    }
    140137
     
    143140
    144141      jobs = (ItemList<Job>)jobData.Clone();
    145       resultingSchedule = new Schedule(new IntValue(jobs[0].Tasks.Count));
     142      resultingSchedule = new Schedule(jobs[0].Tasks.Count);
    146143
    147144      //Reset scheduled tasks in result
     
    186183    public override IOperation Apply() {
    187184      return base.Apply();
    188     }   
     185    }
    189186  }
    190187}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/JSMDecodingErrorPolicyTypes.cs

    r6293 r6406  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 
    6 namespace HeuristicLab.Problems.Scheduling.Decoders {
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     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
     21namespace HeuristicLab.Problems.Scheduling {
    722  public enum JSMDecodingErrorPolicyTypes {
    823    RandomPolicy,
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/JSMForcingStrategyTypes.cs

    r6293 r6406  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     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
    521
    6 namespace HeuristicLab.Problems.Scheduling.Decoders {
     22namespace HeuristicLab.Problems.Scheduling {
    723  public enum JSMForcingStrategyTypes {
    824    ShiftForcing,
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/PRVDecoder.cs

    r6364 r6406  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
     22using HeuristicLab.Common;
    2623using HeuristicLab.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Common;
    29 using HeuristicLab.Data;
    30 using HeuristicLab.Encodings.PermutationEncoding;
     24using HeuristicLab.Encodings.ScheduleEncoding;
     25using HeuristicLab.Encodings.ScheduleEncoding.PriorityRulesVector;
    3126using HeuristicLab.Optimization;
    3227using HeuristicLab.Parameters;
    33 using HeuristicLab.Problems.Scheduling.Interfaces;
    34 using HeuristicLab.Encodings.SchedulingEncoding.PriorityRulesVector;
    35 using HeuristicLab.Encodings.SchedulingEncoding;
    36 
    37 namespace HeuristicLab.Problems.Scheduling.Decoders {
    38   [Item("Job Sequencing Matrix Decoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")]
     28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29
     30namespace HeuristicLab.Problems.Scheduling {
     31  [Item("JobSequencingMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")]
    3932  [StorableClass]
    40   public class PRVDecoder : SchedulingDecoder<PRVEncoding>, IStochasticOperator, IJSSPOperator {
     33  public class PRVDecoder : ScheduleDecoder<PRVEncoding>, IStochasticOperator, IJSSPOperator {
     34    public ILookupParameter<IRandom> RandomParameter {
     35      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     36    }
     37    public ILookupParameter<ItemList<Job>> JobDataParameter {
     38      get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
     39    }
     40
     41    #region Private Members
     42    [Storable]
     43    private Schedule resultingSchedule;
     44
     45    [Storable]
     46    private ItemList<Job> jobs;
     47    #endregion
     48
     49    #region Priority Rules
     50    //smallest number of remaining tasks
     51    private Task FILORule(ItemList<Task> tasks) {
     52      Task currentResult = tasks[tasks.Count - 1];
     53      return currentResult;
     54    }
     55
     56    //earliest start time
     57    private Task ESTRule(ItemList<Task> tasks) {
     58      Task currentResult = RandomRule(tasks);
     59      double currentEST = double.MaxValue;
     60      foreach (Task t in tasks) {
     61        double est = GTAlgorithmUtils.ComputeEarliestStartTime(t, resultingSchedule);
     62        if (est < currentEST) {
     63          currentEST = est;
     64          currentResult = t;
     65        }
     66      }
     67      return currentResult;
     68    }
     69
     70    //shortest processingtime
     71    private Task SPTRule(ItemList<Task> tasks) {
     72      Task currentResult = RandomRule(tasks);
     73      foreach (Task t in tasks) {
     74        if (t.Duration.Value < currentResult.Duration.Value)
     75          currentResult = t;
     76      }
     77      return currentResult;
     78    }
     79
     80    //longest processing time   
     81    private Task LPTRule(ItemList<Task> tasks) {
     82      Task currentResult = RandomRule(tasks);
     83      foreach (Task t in tasks) {
     84        if (t.Duration.Value > currentResult.Duration.Value)
     85          currentResult = t;
     86      }
     87      return currentResult;
     88    }
     89
     90    //most work remaining
     91    private Task MWRRule(ItemList<Task> tasks) {
     92      Task currentResult = RandomRule(tasks);
     93      double currentLargestRemainingProcessingTime = 0;
     94      foreach (Task t in tasks) {
     95        double remainingProcessingTime = 0;
     96        foreach (Task jt in jobs[t.JobNr.Value].Tasks) {
     97          if (!jt.IsScheduled.Value)
     98            remainingProcessingTime += jt.Duration.Value;
     99        }
     100        if (remainingProcessingTime > currentLargestRemainingProcessingTime) {
     101          currentLargestRemainingProcessingTime = remainingProcessingTime;
     102          currentResult = t;
     103        }
     104      }
     105      return currentResult;
     106    }
     107
     108    //least work remaining
     109    private Task LWRRule(ItemList<Task> tasks) {
     110      Task currentResult = RandomRule(tasks);
     111      double currentSmallestRemainingProcessingTime = double.MaxValue;
     112      foreach (Task t in tasks) {
     113        double remainingProcessingTime = 0;
     114        foreach (Task jt in jobs[t.JobNr.Value].Tasks) {
     115          if (!jt.IsScheduled.Value)
     116            remainingProcessingTime += jt.Duration.Value;
     117        }
     118        if (remainingProcessingTime < currentSmallestRemainingProcessingTime) {
     119          currentSmallestRemainingProcessingTime = remainingProcessingTime;
     120          currentResult = t;
     121        }
     122      }
     123      return currentResult;
     124    }
     125
     126    //most operations remaining
     127    private Task MORRule(ItemList<Task> tasks) {
     128      Task currentResult = RandomRule(tasks);
     129      int currentLargestNrOfRemainingTasks = 0;
     130      foreach (Task t in tasks) {
     131        int nrOfRemainingTasks = 0;
     132        foreach (Task jt in jobs[t.JobNr.Value].Tasks) {
     133          if (!jt.IsScheduled.Value)
     134            nrOfRemainingTasks++;
     135        }
     136        if (currentLargestNrOfRemainingTasks < nrOfRemainingTasks) {
     137          currentLargestNrOfRemainingTasks = nrOfRemainingTasks;
     138          currentResult = t;
     139        }
     140      }
     141      return currentResult;
     142    }
     143
     144    //least operationsremaining
     145    private Task LORRule(ItemList<Task> tasks) {
     146      Task currentResult = RandomRule(tasks);
     147      int currentSmallestNrOfRemainingTasks = int.MaxValue;
     148      foreach (Task t in tasks) {
     149        int nrOfRemainingTasks = 0;
     150        foreach (Task jt in jobs[t.JobNr.Value].Tasks) {
     151          if (!jt.IsScheduled.Value)
     152            nrOfRemainingTasks++;
     153        }
     154        if (currentSmallestNrOfRemainingTasks > nrOfRemainingTasks) {
     155          currentSmallestNrOfRemainingTasks = nrOfRemainingTasks;
     156          currentResult = t;
     157        }
     158      }
     159      return currentResult;
     160    }
     161
     162    //first operation in Queue
     163    private Task FIFORule(ItemList<Task> tasks) {
     164      Task currentResult = tasks[0];
     165      return currentResult;
     166    }
     167
     168    //random
     169    private Task RandomRule(ItemList<Task> tasks) {
     170      Task currentResult = tasks[RandomParameter.ActualValue.Next(tasks.Count)];
     171      return currentResult;
     172    }
     173
     174    #endregion
     175
    41176    [StorableConstructor]
    42177    protected PRVDecoder(bool deserializing) : base(deserializing) { }
    43178    protected PRVDecoder(PRVDecoder original, Cloner cloner)
    44179      : base(original, cloner) {
    45         this.resultingSchedule = cloner.Clone(original.resultingSchedule);
     180      this.resultingSchedule = cloner.Clone(original.resultingSchedule);
    46181    }
    47182    public override IDeepCloneable Clone(Cloner cloner) {
    48183      return new PRVDecoder(this, cloner);
    49184    }
    50 
    51     public ILookupParameter<IRandom> RandomParameter {
    52       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    53     }
    54     public ILookupParameter<ItemList<Job>> JobDataParameter {
    55       get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
    56     }
    57 
    58     #region Private Members
    59     [Storable]
    60     private Schedule resultingSchedule;
    61 
    62     [Storable]
    63     private ItemList<Job> jobs;
    64     #endregion
    65 
    66     #region Priority Rules
    67     //smallest number of remaining tasks
    68     private Task FILORule(ItemList<Task> tasks) {
    69       Task currentResult = tasks[tasks.Count-1];
    70       return currentResult;
    71     }
    72 
    73     //earliest start time
    74     private Task ESTRule(ItemList<Task> tasks) {
    75       Task currentResult = RandomRule(tasks);
    76       double currentEST = double.MaxValue;
    77       foreach (Task t in tasks) {
    78         double est = GTAlgorithmUtils.ComputeEarliestStartTime(t, resultingSchedule);
    79         if (est < currentEST) {
    80           currentEST = est;
    81           currentResult = t;
    82         }
    83       }
    84       return currentResult;
    85     }
    86    
    87     //shortest processingtime
    88     private Task SPTRule(ItemList<Task> tasks) {
    89       Task currentResult = RandomRule(tasks);
    90       foreach (Task t in tasks) {
    91         if (t.Duration.Value < currentResult.Duration.Value)
    92           currentResult = t;
    93       }
    94       return currentResult;
    95     }
    96 
    97     //longest processing time   
    98     private Task LPTRule(ItemList<Task> tasks) {
    99       Task currentResult = RandomRule(tasks);
    100       foreach (Task t in tasks) {
    101         if (t.Duration.Value > currentResult.Duration.Value)
    102           currentResult = t;
    103       }
    104       return currentResult;
    105     }
    106 
    107     //most work remaining
    108     private Task MWRRule(ItemList<Task> tasks) {
    109       Task currentResult = RandomRule(tasks);
    110       double currentLargestRemainingProcessingTime = 0;
    111       foreach (Task t in tasks) {
    112         double remainingProcessingTime = 0;
    113         foreach (Task jt in jobs[t.JobNr.Value].Tasks) {
    114           if (!jt.IsScheduled.Value)
    115             remainingProcessingTime += jt.Duration.Value;
    116         }
    117         if (remainingProcessingTime > currentLargestRemainingProcessingTime) {
    118           currentLargestRemainingProcessingTime = remainingProcessingTime;
    119           currentResult = t;
    120         }
    121       }
    122       return currentResult;
    123     }
    124    
    125     //least work remaining
    126     private Task LWRRule(ItemList<Task> tasks) {
    127       Task currentResult = RandomRule(tasks);
    128       double currentSmallestRemainingProcessingTime = double.MaxValue;
    129       foreach (Task t in tasks) {
    130         double remainingProcessingTime = 0;
    131         foreach (Task jt in jobs[t.JobNr.Value].Tasks) {
    132           if (!jt.IsScheduled.Value)
    133             remainingProcessingTime += jt.Duration.Value;
    134         }
    135         if (remainingProcessingTime < currentSmallestRemainingProcessingTime) {
    136           currentSmallestRemainingProcessingTime = remainingProcessingTime;
    137           currentResult = t;
    138         }
    139       }
    140       return currentResult;
    141     }
    142 
    143     //most operations remaining
    144     private Task MORRule(ItemList<Task> tasks) {
    145       Task currentResult = RandomRule(tasks);
    146       int currentLargestNrOfRemainingTasks = 0;
    147       foreach (Task t in tasks) {
    148         int nrOfRemainingTasks = 0;
    149         foreach (Task jt in jobs[t.JobNr.Value].Tasks) {
    150           if (!jt.IsScheduled.Value)
    151             nrOfRemainingTasks++;
    152         }
    153         if (currentLargestNrOfRemainingTasks < nrOfRemainingTasks) {
    154           currentLargestNrOfRemainingTasks = nrOfRemainingTasks;
    155           currentResult = t;
    156         }
    157       }
    158       return currentResult;
    159     }
    160    
    161     //least operationsremaining
    162     private Task LORRule(ItemList<Task> tasks) {
    163       Task currentResult = RandomRule(tasks);
    164       int currentSmallestNrOfRemainingTasks = int.MaxValue;
    165       foreach (Task t in tasks) {
    166         int nrOfRemainingTasks = 0;
    167         foreach (Task jt in jobs[t.JobNr.Value].Tasks) {
    168           if (!jt.IsScheduled.Value)
    169             nrOfRemainingTasks++;
    170         }
    171         if (currentSmallestNrOfRemainingTasks > nrOfRemainingTasks) {
    172           currentSmallestNrOfRemainingTasks = nrOfRemainingTasks;
    173           currentResult = t;
    174         }
    175       }
    176       return currentResult;
    177     }
    178                
    179     //first operation in Queue
    180     private Task FIFORule(ItemList<Task> tasks) {
    181       Task currentResult = tasks[0];
    182       return currentResult;
    183     }
    184                  
    185     //random
    186     private Task RandomRule(ItemList<Task> tasks) {
    187       Task currentResult = tasks[RandomParameter.ActualValue.Next(tasks.Count)];
    188       return currentResult;
    189     }
    190 
    191     #endregion
    192185
    193186    public PRVDecoder()
    194187      : base() {
    195188      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    196       Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance."));
    197     }
    198 
    199 
     189      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the SchedulingProblem - Instance."));
     190      ScheduleEncodingParameter.ActualName = "PriorityRulesVector";
     191    }
    200192
    201193    private Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, int ruleIndex, int nrOfRules) {
     
    221213    public override Schedule CreateScheduleFromEncoding(PRVEncoding solution) {
    222214      jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
    223       resultingSchedule = new Schedule(new IntValue(jobs[0].Tasks.Count));
     215      resultingSchedule = new Schedule(jobs[0].Tasks.Count);
    224216
    225217      //Reset scheduled tasks in result
     
    247239        //STEP 4 - Adding the selected operation to the current schedule
    248240        selectedTask.IsScheduled.Value = true;
    249         double startTime = GTAlgorithmUtils.ComputeEarliestStartTime (selectedTask, resultingSchedule);
     241        double startTime = GTAlgorithmUtils.ComputeEarliestStartTime(selectedTask, resultingSchedule);
    250242        resultingSchedule.ScheduleTask(selectedTask.ResourceNr.Value, startTime, selectedTask.Duration.Value, selectedTask.JobNr.Value);
    251243
     
    259251    public override IOperation Apply() {
    260252      return base.Apply();
    261     } 
     253    }
    262254  }
    263255}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/PWRDecoder.cs

    r6293 r6406  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
     22using HeuristicLab.Common;
    2623using HeuristicLab.Core;
    27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Common;
     24using HeuristicLab.Encodings.ScheduleEncoding;
     25using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;
    2926using HeuristicLab.Optimization;
    3027using HeuristicLab.Parameters;
    31 using HeuristicLab.Data;
    32 using HeuristicLab.Encodings.SchedulingEncoding;
    33 using HeuristicLab.Encodings.SchedulingEncoding.PermutationWithRepetition;
    34 using HeuristicLab.Problems.Scheduling.Interfaces;
     28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3529
    36 namespace HeuristicLab.Problems.Scheduling.Decoders {
     30namespace HeuristicLab.Problems.Scheduling {
    3731  [Item("PWRDecoder", "An item used to convert a PWR-individual into a generalized schedule.")]
    3832  [StorableClass]
    39   public class PWRDecoder : SchedulingDecoder<PWREncoding>, IStochasticOperator, IJSSPOperator {
     33  public class PWRDecoder : ScheduleDecoder<PWREncoding>, IStochasticOperator, IJSSPOperator {
     34    public ILookupParameter<IRandom> RandomParameter {
     35      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     36    }
     37    public ILookupParameter<ItemList<Job>> JobDataParameter {
     38      get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
     39    }
     40
    4041    [StorableConstructor]
    4142    protected PWRDecoder(bool deserializing) : base(deserializing) { }
     
    4748    }
    4849
    49     public ILookupParameter<IRandom> RandomParameter {
    50       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    51     }
    52     public ILookupParameter<ItemList<Job>> JobDataParameter {
    53       get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
    54     }
    55 
    5650    public PWRDecoder()
    5751      : base() {
    5852      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    5953      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance."));
     54      ScheduleEncodingParameter.ActualName = "PermutationWithRepetition";
    6055    }
    6156
    6257    public override Schedule CreateScheduleFromEncoding(PWREncoding solution) {
    6358      ItemList<Job> jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
    64       Schedule resultingSchedule = new Schedule(new IntValue(jobs[0].Tasks.Count));
     59      Schedule resultingSchedule = new Schedule(jobs[0].Tasks.Count);
    6560      foreach (int jobNr in solution.PermutationWithRepetition) {
    6661        int i = 0;
    6762        while (jobs[jobNr].Tasks[i].IsScheduled.Value) i++;
    6863        Task currentTask = jobs[jobNr].Tasks[i];
    69         double startTime = GTAlgorithmUtils.ComputeEarliestStartTime (currentTask, resultingSchedule);
     64        double startTime = GTAlgorithmUtils.ComputeEarliestStartTime(currentTask, resultingSchedule);
    7065        currentTask.IsScheduled.Value = true;
    71         resultingSchedule.ScheduleTask(currentTask.ResourceNr.Value,startTime, currentTask.Duration.Value, currentTask.JobNr.Value);
     66        resultingSchedule.ScheduleTask(currentTask.ResourceNr.Value, startTime, currentTask.Duration.Value, currentTask.JobNr.Value);
    7267      }
    7368      return resultingSchedule;
     
    7671    public override IOperation Apply() {
    7772      return base.Apply();
    78     } 
     73    }
    7974  }
    8075}
Note: See TracChangeset for help on using the changeset viewer.