Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/06/11 11:23:43 (13 years ago)
Author:
jhelm
Message:

#1329: Did some minor refactoring.

Location:
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/JSMDecoder.cs

    r6293 r6364  
    3636
    3737namespace HeuristicLab.Problems.Scheduling.Decoders {
    38   [Item("Job Sequencing Matrix Decoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")]
     38  [Item("Job Sequence Matrix Decoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequence Matrix.")]
    3939  [StorableClass]
    4040  public class JSMDecoder : SchedulingDecoder<JSMEncoding>, IStochasticOperator, IJSSPOperator {
     
    7676      : base() {
    7777      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    78       Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance."));
     78      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the Schedulingproblem - Instance."));
    7979    }
    8080
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Decoders/PRVDecoder.cs

    r6293 r6364  
    197197    }
    198198
    199     private ItemList<Task> GetEarliestNotScheduledTasks() {
    200       ItemList<Task> result = new ItemList<Task>();
    201       foreach (Job j in jobs) {
    202         foreach (Task t in j.Tasks) {
    203           if (!t.IsScheduled.Value) {
    204             result.Add(t);
    205             break;
    206           }
    207         }
    208       }
    209       return result;
    210     }
    211     private Task GetTaskWithMinimalEC(ItemList<Task> earliestTasksList) {
    212       double minEct = double.MaxValue;
    213       Task result = null;
    214       foreach (Task t in earliestTasksList) {
    215         double ect = GTAlgorithmUtils.ComputeEarliestCompletionTime(t, resultingSchedule);
    216         if (ect < minEct) {
    217           result = t;
    218           minEct = ect;
    219         }
    220       }
    221       return result;
    222     }
    223     private ItemList<Task> GetConflictSetForTask(Task conflictedTask, ItemList<Task> earliestTasksList) {
    224       ItemList<Task> result = new ItemList<Task>();
    225       double conflictedCompletionTime = GTAlgorithmUtils.ComputeEarliestCompletionTime(conflictedTask, resultingSchedule);
    226       foreach (Task t in earliestTasksList) {
    227         if (t.ResourceNr.Value == conflictedTask.ResourceNr.Value) {
    228           if (GTAlgorithmUtils.ComputeEarliestStartTime(t, resultingSchedule) < conflictedCompletionTime)
    229             result.Add(t);
    230         }
    231       }
    232       return result;
    233     }
     199
     200
    234201    private Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, int ruleIndex, int nrOfRules) {
    235202      if (conflictSet.Count == 1)
    236203        return conflictSet[0];
    237      
     204
    238205      ruleIndex = ruleIndex % nrOfRules;
    239206      switch (ruleIndex) {
     
    249216        case 9: return RandomRule(conflictSet);
    250217        default: return RandomRule(conflictSet);
    251       } 
     218      }
    252219    }
    253220
     
    265232      //GT-Algorithm
    266233      //STEP 0 - Compute a list of "earliest operations"
    267       ItemList<Task> earliestTasksList = GetEarliestNotScheduledTasks();
    268       int currentDecisionIndex = 0;
     234      ItemList<Task> earliestTasksList = GTAlgorithmUtils.GetEarliestNotScheduledTasks(jobs);
     235      //int currentDecisionIndex = 0;
    269236      while (earliestTasksList.Count > 0) {
    270237        //STEP 1 - Get earliest not scheduled operation with minimal earliest completing time
    271         Task minimal = GetTaskWithMinimalEC(earliestTasksList);
     238        Task minimal = GTAlgorithmUtils.GetTaskWithMinimalEC(earliestTasksList, resultingSchedule);
    272239
    273240        //STEP 2 - Compute a conflict set of all operations that can be scheduled on the machine the previously selected operation runs on
    274         ItemList<Task> conflictSet = GetConflictSetForTask(minimal, earliestTasksList);
     241        ItemList<Task> conflictSet = GTAlgorithmUtils.GetConflictSetForTask(minimal, earliestTasksList, jobs, resultingSchedule);
    275242
    276243        //STEP 3 - Select an operation from the conflict set (various methods depending on how the algorithm should work..)
    277         Task selectedTask = SelectTaskFromConflictSet(conflictSet, solution.PriorityRulesVector [currentDecisionIndex++], solution.NrOfRules.Value);
     244        //Task selectedTask = SelectTaskFromConflictSet(conflictSet, solution.PriorityRulesVector [currentDecisionIndex++], solution.NrOfRules.Value);
     245        Task selectedTask = SelectTaskFromConflictSet(conflictSet, solution.PriorityRulesVector[minimal.JobNr.Value], solution.NrOfRules.Value);
    278246
    279247        //STEP 4 - Adding the selected operation to the current schedule
     
    283251
    284252        //STEP 5 - Back to STEP 1
    285         earliestTasksList = GetEarliestNotScheduledTasks();
     253        earliestTasksList = GTAlgorithmUtils.GetEarliestNotScheduledTasks(jobs);
    286254      }
    287255
Note: See TracChangeset for help on using the changeset viewer.