Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/10/11 16:18:44 (14 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:
20 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/Analyzers/BestSchedulingSolutionAnalyzer.cs

    r6293 r6406  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    2422using System.Linq;
    25 using System.Text;
     23using HeuristicLab.Common;
     24using HeuristicLab.Core;
     25using HeuristicLab.Data;
     26using HeuristicLab.Encodings.ScheduleEncoding;
    2627using HeuristicLab.Optimization;
    27 using HeuristicLab.Core;
     28using HeuristicLab.Parameters;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    29 using HeuristicLab.Common;
    30 using HeuristicLab.Parameters;
    31 using HeuristicLab.Data;
    32 using HeuristicLab.Encodings.SchedulingEncoding;
    3330
    34 namespace HeuristicLab.Problems.Scheduling.Analyzers {
     31namespace HeuristicLab.Problems.Scheduling {
    3532
    3633  [Item("BestSchedulingSolutionAnalyzer", "An operator for analyzing the best solution of Scheduling Problems given in schedule-representation.")]
     
    5350    }
    5451
    55     public BestSchedulingSolutionAnalyzer () : base () {
     52    public BestSchedulingSolutionAnalyzer()
     53      : base() {
    5654      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator."));
    5755    }
     
    5957    public override IOperation Apply() {
    6058      ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    61       ItemArray<Schedule> solutions = SchedulingSolutionParameter.ActualValue;
     59      ItemArray<Schedule> solutions = ScheduleParameter.ActualValue;
    6260      ResultCollection results = ResultsParameter.ActualValue;
    6361      bool max = MaximizationParameter.ActualValue.Value;
     
    7977      if (bestSolution == null) {
    8078        bestSolution = (Schedule)solutions[i].Clone();
    81         bestSolution.Quality.Value = qualities [i].Value;
     79        bestSolution.Quality = (DoubleValue)qualities[i].Clone();
    8280        BestSolutionParameter.ActualValue = bestSolution;
    8381        results.Add(new Result("Best Scheduling Solution", bestSolution));
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Analyzers/SchedulingAnalyzer.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;
     23using HeuristicLab.Core;
     24using HeuristicLab.Data;
     25using HeuristicLab.Encodings.ScheduleEncoding;
    2626using HeuristicLab.Operators;
    2727using HeuristicLab.Optimization;
    2828using HeuristicLab.Parameters;
    29 using HeuristicLab.Data;
    30 using HeuristicLab.Core;
    3129using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    32 using HeuristicLab.Common;
    33 using HeuristicLab.Encodings.SchedulingEncoding;
    3430
    35 namespace HeuristicLab.Problems.Scheduling.Analyzers {
    36   [Item("Scheduling Analyzer", "Represents the generalized form of Analyzers for Scheduling Problems.")]
     31namespace HeuristicLab.Problems.Scheduling {
     32  [Item("SchedulingAnalyzer", "Represents the generalized form of Analyzers for Scheduling Problems.")]
    3733  [StorableClass]
    3834  public abstract class SchedulingAnalyzer : SingleSuccessorOperator, IAnalyzer {
     
    6258      get { return (LookupParameter<Schedule>)Parameters["BestKnownSolution"]; }
    6359    }
    64     public ScopeTreeLookupParameter<Schedule> SchedulingSolutionParameter {
    65       get { return (ScopeTreeLookupParameter<Schedule>)Parameters["DecodedSchedulingSolution"]; }
     60    public ScopeTreeLookupParameter<Schedule> ScheduleParameter {
     61      get { return (ScopeTreeLookupParameter<Schedule>)Parameters["Schedule"]; }
    6662    }
    6763    #endregion
    6864
    69     public SchedulingAnalyzer () : base() {
     65    public SchedulingAnalyzer()
     66      : base() {
    7067      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem."));
    7168      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the JSSP solutions which should be analyzed."));
    72       Parameters.Add(new ScopeTreeLookupParameter<Schedule>("DecodedSchedulingSolution", "The solutions from which the best solution has to be chosen from."));
     69      Parameters.Add(new ScopeTreeLookupParameter<Schedule>("Schedule", "The solutions from which the best solution has to be chosen from."));
    7370      Parameters.Add(new LookupParameter<Schedule>("BestSolution", "The best JSSP solution."));
    7471      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best JSSP solution should be stored."));
  • 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}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MakespanEvaluator.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;
     24using HeuristicLab.Data;
     25using HeuristicLab.Encodings.ScheduleEncoding;
    2726using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Common;
    29 using HeuristicLab.Data;
    30 using HeuristicLab.Optimization;
    31 using HeuristicLab.Parameters;
    32 using HeuristicLab.Encodings.SchedulingEncoding;
    3327
    34 namespace HeuristicLab.Problems.Scheduling.Evaluators {
     28namespace HeuristicLab.Problems.Scheduling {
    3529  [Item("Makespan Evaluator", "Represents an evaluator using the maximum makespan of a schedule.")]
    3630  [StorableClass]
     
    4539    }
    4640
    47     public MakespanEvaluator () : base () { }
     41    public MakespanEvaluator() : base() { }
    4842
    4943    protected override DoubleValue evaluate(Schedule schedule) {
    50       DoubleValue quality = new DoubleValue (0);
     44      DoubleValue quality = new DoubleValue(0);
    5145      foreach (Resource r in schedule.Resources) {
    5246        if (r.TotalDuration.Value > quality.Value) {
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MeanTardinessEvaluator.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;
     24using HeuristicLab.Data;
     25using HeuristicLab.Encodings.ScheduleEncoding;
     26using HeuristicLab.Parameters;
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Common;
    29 using HeuristicLab.Data;
    30 using HeuristicLab.Optimization;
    31 using HeuristicLab.Parameters;
    32 using HeuristicLab.Encodings.SchedulingEncoding;
    33 using HeuristicLab.Problems.Scheduling.Interfaces;
    3428
    35 namespace HeuristicLab.Problems.Scheduling.Evaluators {
     29namespace HeuristicLab.Problems.Scheduling {
    3630  [Item("Mean tardiness Evaluator", "Represents an evaluator using the mean tardiness of a schedule.")]
    3731  [StorableClass]
     
    5751    #endregion
    5852
    59     public MeanTardinessEvaluator() : base() {
     53    public MeanTardinessEvaluator()
     54      : base() {
    6055      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance."));
    6156    }
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/SchedulingEvaluationAlgorithm.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;
     23using HeuristicLab.Core;
     24using HeuristicLab.Data;
     25using HeuristicLab.Encodings.ScheduleEncoding;
    2626using HeuristicLab.Operators;
     27using HeuristicLab.Parameters;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Core;
    29 using HeuristicLab.Common;
    30 using HeuristicLab.Optimization;
    31 using HeuristicLab.Data;
    32 using HeuristicLab.Parameters;
    33 using HeuristicLab.Encodings.SchedulingEncoding.Interfaces;
    34 using HeuristicLab.Encodings.SchedulingEncoding;
    3529
    36 namespace HeuristicLab.Problems.Scheduling.Evaluators {
     30namespace HeuristicLab.Problems.Scheduling {
    3731  [Item("Scheduling Evaluation Algorithm", "Represents a composition of a decoder and an evaluator for scheduling problems.")]
    3832  [StorableClass]
    39   public class SchedulingEvaluationAlgorithm : AlgorithmOperator, ISchedulingEvaluationAlgorithm {
     33  public class SchedulingEvaluationAlgorithm : AlgorithmOperator, IScheduleEvaluationAlgorithm {
    4034    [StorableConstructor]
    4135    protected SchedulingEvaluationAlgorithm(bool deserializing) : base(deserializing) { }
    4236    protected SchedulingEvaluationAlgorithm(SchedulingEvaluationAlgorithm original, Cloner cloner)
    4337      : base(original, cloner) {
    44         this.evaluator = cloner.Clone(original.evaluator);
     38      this.evaluator = cloner.Clone(original.evaluator);
    4539    }
    4640    public override IDeepCloneable Clone(Cloner cloner) {
     
    6054    }
    6155
    62     public void InitializeOperatorGraph<T>(SchedulingDecoder<T> decoder) where T: Item, ISchedulingEncoding{
     56    public void InitializeOperatorGraph<T>(ScheduleDecoder<T> decoder) where T : Item, IScheduleEncoding {
    6357      OperatorGraph.Operators.Clear();
    6458      OperatorGraph.InitialOperator = decoder;
     
    6862    public SchedulingEvaluationAlgorithm()
    6963      : base() {
    70         Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
    71         evaluator = new Placeholder();
    72         evaluator.OperatorParameter.ActualName = "SolutionEvaluator";
     64      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
     65      evaluator = new Placeholder();
     66      evaluator.OperatorParameter.ActualName = "SolutionEvaluator";
    7367    }
    7468
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/SchedulingEvaluator.cs

    r6364 r6406  
    2020#endregion
    2121
     22using HeuristicLab.Common;
     23using HeuristicLab.Core;
     24using HeuristicLab.Data;
     25using HeuristicLab.Encodings.ScheduleEncoding;
     26using HeuristicLab.Operators;
     27using HeuristicLab.Parameters;
     28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2229
    2330
    24 using HeuristicLab.Core;
    25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    26 using HeuristicLab.Optimization;
    27 using HeuristicLab.Data;
    28 using HeuristicLab.Common;
    29 using HeuristicLab.Parameters;
    30 using System;
    31 using HeuristicLab.Operators;
    32 using HeuristicLab.Encodings.SchedulingEncoding.Interfaces;
    33 using HeuristicLab.Encodings.SchedulingEncoding;
    34 
    35 
    36 namespace HeuristicLab.Problems.Scheduling.Evaluators {
     31namespace HeuristicLab.Problems.Scheduling {
    3732  [Item("Scheduling Evaluator", "Represents a evaluator class for standard scheduling problems.")]
    3833  [StorableClass]
    39   public abstract class SchedulingEvaluator : SingleSuccessorOperator, ISchedulingEvaluator {
     34  public abstract class SchedulingEvaluator : SingleSuccessorOperator, IScheduleEvaluator {
    4035    [StorableConstructor]
    4136    protected SchedulingEvaluator(bool deserializing) : base(deserializing) { }
     
    4843    }
    4944    public ILookupParameter<DoubleValue> QualityParameter {
    50       get { 
     45      get {
    5146        if (Parameters.ContainsKey("Quality"))
    5247          return (ILookupParameter<DoubleValue>)Parameters["Quality"];
     
    5550      }
    5651    }
    57     public ILookupParameter<Schedule> DecodedSchedulingSolutionParameter {
    58       get { return (ILookupParameter<Schedule>)Parameters["DecodedSchedulingSolution"]; }
     52    public ILookupParameter<Schedule> ScheduleParameter {
     53      get { return (ILookupParameter<Schedule>)Parameters["Schedule"]; }
    5954    }
    6055
    61     public SchedulingEvaluator () : base () {
     56    public SchedulingEvaluator()
     57      : base() {
    6258      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
    63       Parameters.Add(new LookupParameter<Schedule>("DecodedSchedulingSolution", "The decoded scheduling solution represented as generalized schedule."));
     59      Parameters.Add(new LookupParameter<Schedule>("Schedule", "The decoded scheduling solution represented as generalized schedule."));
    6460      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator."));
    6561    }
    6662
    6763    protected abstract DoubleValue evaluate(Schedule schedule);
    68    
     64
    6965    public override IOperation Apply() {
    70       Schedule decodedSchedulingSolution = DecodedSchedulingSolutionParameter.ActualValue;
    71       QualityParameter.ActualValue = evaluate(decodedSchedulingSolution);
     66      Schedule schedule = ScheduleParameter.ActualValue;
     67      QualityParameter.ActualValue = evaluate(schedule);
    7268      return base.Apply();
    7369    }
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/HeuristicLab.Problems.Scheduling-3.3.csproj

    r6364 r6406  
    5959    <Compile Include="Evaluators\MakespanEvaluator.cs" />
    6060    <Compile Include="Evaluators\SchedulingEvaluator.cs" />
    61     <Compile Include="IndexedTaskList.cs" />
    6261    <Compile Include="Interfaces\IJSSPOperator.cs" />
    6362    <Compile Include="Job.cs" />
     
    103102      <Name>HeuristicLab.Encodings.PermutationEncoding-3.3</Name>
    104103    </ProjectReference>
    105     <ProjectReference Include="..\..\HeuristicLab.Encodings.SchedulingEncoding\3.3\HeuristicLab.Encodings.SchedulingEncoding-3.3.csproj">
     104    <ProjectReference Include="..\..\HeuristicLab.Encodings.ScheduleEncoding\3.3\HeuristicLab.Encodings.ScheduleEncoding-3.3.csproj">
    106105      <Project>{17F3EF80-B2C3-4B8D-A4D5-BE9CE3BA2606}</Project>
    107       <Name>HeuristicLab.Encodings.SchedulingEncoding-3.3</Name>
     106      <Name>HeuristicLab.Encodings.ScheduleEncoding-3.3</Name>
    108107    </ProjectReference>
    109108    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Interfaces/IJSSPOperator.cs

    r6364 r6406  
    1 using System;
    2 using System.Collections.Generic;
    3 using System.Linq;
    4 using System.Text;
    5 using HeuristicLab.Core;
    6 using HeuristicLab.Parameters;
     1using HeuristicLab.Core;
    72
    8 namespace HeuristicLab.Problems.Scheduling.Interfaces {
     3namespace HeuristicLab.Problems.Scheduling {
    94  public interface IJSSPOperator : IOperator {
    10      ILookupParameter<ItemList<Job>> JobDataParameter {get;}
     5    ILookupParameter<ItemList<Job>> JobDataParameter { get; }
    116  }
    127}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Job.cs

    r6364 r6406  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    2522using System.Text;
     23using HeuristicLab.Common;
    2624using HeuristicLab.Core;
    27 using HeuristicLab.Common;
     25using HeuristicLab.Data;
    2826using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    29 using HeuristicLab.Data;
    30 using HeuristicLab.Parameters;
    3127
    3228namespace HeuristicLab.Problems.Scheduling {
     
    3430  [StorableClass]
    3531  public class Job : Item {
     32    [Storable]
     33    public DoubleValue DueDate { get; set; }
     34    [Storable]
     35    public IntValue Index { get; set; }
     36    [Storable]
     37    public ItemList<Task> Tasks { get; set; }
     38
    3639    [StorableConstructor]
    3740    protected Job(bool deserializing) : base(deserializing) { }
    3841    protected Job(Job original, Cloner cloner)
    3942      : base(original, cloner) {
    40         this.DueDate = cloner.Clone(original.DueDate);
    41         this.Index = cloner.Clone(original.Index);
    42         this.Tasks = cloner.Clone(original.Tasks);
     43      this.DueDate = cloner.Clone(original.DueDate);
     44      this.Index = cloner.Clone(original.Index);
     45      this.Tasks = cloner.Clone(original.Tasks);
    4346    }
    4447    public override IDeepCloneable Clone(Cloner cloner) {
    4548      return new Job(this, cloner);
    4649    }
    47 
    48     public DoubleValue DueDate { get; set; }
    49 
    50     public IntValue Index {
    51       get;
    52       set;
    53     }
    54     public ItemList<Task> Tasks {
    55       get;
    56       set;
    57     }
    58 
    59 
    60     public Job(IntValue index, DoubleValue dueDate) : base () {
     50    public Job(IntValue index, DoubleValue dueDate)
     51      : base() {
    6152      Index = index;
    6253      Tasks = new ItemList<Task>();
     
    7263      sb.Append("Job#" + Index + " [ ");
    7364      foreach (Task t in Tasks) {
    74         sb.Append(t.ToString () + " ");
     65        sb.Append(t.ToString() + " ");
    7566      }
    7667      if (DueDate != null)
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs

    r6364 r6406  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
     24using System.IO;
     25using HeuristicLab.Common;
     26using HeuristicLab.Core;
     27using HeuristicLab.Data;
     28using HeuristicLab.Encodings.PermutationEncoding;
     29using HeuristicLab.Encodings.ScheduleEncoding;
     30using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;
     31using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;
     32using HeuristicLab.Encodings.ScheduleEncoding.PriorityRulesVector;
     33using HeuristicLab.Parameters;
    2634using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    27 using HeuristicLab.Core;
    28 using HeuristicLab.Optimization;
    29 using HeuristicLab.Common;
    30 using System.Drawing;
    31 using HeuristicLab.Data;
    32 using System.IO;
    33 using HeuristicLab.Problems.Scheduling.Evaluators;
    34 using HeuristicLab.Parameters;
    35 using HeuristicLab.Problems.Scheduling.Analyzers;
    3635using HeuristicLab.PluginInfrastructure;
    37 using HeuristicLab.Encodings.SchedulingEncoding;
    38 using HeuristicLab.Encodings.SchedulingEncoding.Interfaces;
    39 using HeuristicLab.Encodings.SchedulingEncoding.JobSequenceMatrix;
    40 using HeuristicLab.Encodings.PermutationEncoding;
    41 using HeuristicLab.Encodings.SchedulingEncoding.PriorityRulesVector;
    42 using HeuristicLab.Encodings.SchedulingEncoding.PermutationWithRepetition;
    43 using HeuristicLab.Problems.Scheduling.Decoders;
    4436
    4537namespace HeuristicLab.Problems.Scheduling {
     
    4840  [StorableClass]
    4941  public sealed class JobShopSchedulingProblem : SchedulingProblem {
     42    #region Parameter Properties
     43    public ValueParameter<ItemList<Job>> JobDataParameter {
     44      get { return (ValueParameter<ItemList<Job>>)Parameters["JobData"]; }
     45    }
     46    public OptionalValueParameter<Schedule> BestKnownSolutionParameter {
     47      get { return (OptionalValueParameter<Schedule>)Parameters["BestKnownSolution"]; }
     48    }
     49
     50    public ValueParameter<IntValue> JobsParameter {
     51      get { return (ValueParameter<IntValue>)Parameters["Jobs"]; }
     52    }
     53    public ValueParameter<IntValue> ResourcesParameter {
     54      get { return (ValueParameter<IntValue>)Parameters["Resources"]; }
     55    }
     56    public ValueParameter<SchedulingEvaluator> SolutionEvaluatorParameter {
     57      get { return (ValueParameter<SchedulingEvaluator>)Parameters["SolutionEvaluator"]; }
     58    }
     59    public ValueParameter<BoolValue> DueDatesParameter {
     60      get { return (ValueParameter<BoolValue>)Parameters["DueDates"]; }
     61    }
     62    #endregion
     63
     64    #region Properties
     65    public ItemList<Job> JobData {
     66      get { return JobDataParameter.Value; }
     67      set { JobDataParameter.Value = value; }
     68    }
     69    public Schedule BestKnownSolution {
     70      get { return BestKnownSolutionParameter.Value; }
     71      set { BestKnownSolutionParameter.Value = value; }
     72    }
     73    public IntValue Jobs {
     74      get { return JobsParameter.Value; }
     75      set { JobsParameter.Value = value; }
     76    }
     77    public IntValue Resources {
     78      get { return ResourcesParameter.Value; }
     79      set { ResourcesParameter.Value = value; }
     80    }
     81    public SchedulingEvaluator SolutionEvaluator {
     82      get { return SolutionEvaluatorParameter.Value; }
     83      set { SolutionEvaluatorParameter.Value = value; }
     84    }
     85    public BoolValue DueDates {
     86      get { return DueDatesParameter.Value; }
     87      set { DueDatesParameter.Value = value; }
     88    }
     89    #endregion
     90
     91    public JobShopSchedulingProblem()
     92      : base(new SchedulingEvaluationAlgorithm(), new JSMRandomCreator()) {
     93      Parameters.Add(new ValueParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance.", new ItemList<Job>()));
     94      Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));
     95
     96      Parameters.Add(new ValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue()));
     97      Parameters.Add(new ValueParameter<IntValue>("Resources", "The number of resources used this JSSP instance.", new IntValue()));
     98      Parameters.Add(new ValueParameter<BoolValue>("DueDates", "Determines whether the problem instance uses due dates or not.", new BoolValue()));
     99      Parameters.Add(new ValueParameter<SchedulingEvaluator>("SolutionEvaluator", "The evaluator used to determine the quality of a solution.", new MakespanEvaluator()));
     100
     101      InitializeOperators();
     102      InitializeProblemInstance();
     103    }
     104
    50105    [StorableConstructor]
    51106    private JobShopSchedulingProblem(bool deserializing) : base(deserializing) { }
    52107    private JobShopSchedulingProblem(JobShopSchedulingProblem original, Cloner cloner)
    53108      : base(original, cloner) {
    54       this.Jobs = cloner.Clone(original.Jobs);
    55       this.Resources = cloner.Clone(original.Resources);
    56       this.JobData = cloner.Clone(original.JobData);
    57       this.SolutionEvaluator = cloner.Clone(original.SolutionEvaluator);
    58       this.DueDates = cloner.Clone(original.DueDates);
    59109    }
    60110    public override IDeepCloneable Clone(Cloner cloner) {
    61111      return new JobShopSchedulingProblem(this, cloner);
    62     }
    63 
    64 
    65     #region Parameter Properties
    66     public ValueParameter<ItemList<Job>> JobDataParameter {
    67       get { return (ValueParameter<ItemList<Job>>)Parameters["JobData"]; }
    68     }
    69     public OptionalValueParameter<Schedule> BestKnownSolutionParameter {
    70       get { return (OptionalValueParameter<Schedule>)Parameters["BestKnownSolution"]; }
    71     }
    72 
    73     public ValueParameter<IntValue> JobsParameter {
    74       get { return (ValueParameter<IntValue>)Parameters["Jobs"]; }
    75     }
    76     public ValueParameter<IntValue> ResourcesParameter {
    77       get { return (ValueParameter<IntValue>)Parameters["Resources"]; }
    78     }
    79     public ValueParameter<SchedulingEvaluator> SolutionEvaluatorParameter {
    80       get { return (ValueParameter<SchedulingEvaluator>)Parameters["SolutionEvaluator"]; }
    81     }
    82     public ValueParameter<BoolValue> DueDatesParameter {
    83       get { return (ValueParameter<BoolValue>)Parameters["DueDates"]; }
    84     }
    85     #endregion
    86 
    87     #region Properties
    88     public ItemList<Job> JobData {
    89       get { return JobDataParameter.Value; }
    90       set { JobDataParameter.Value = value; }
    91     }
    92     public Schedule BestKnownSolution {
    93       get { return BestKnownSolutionParameter.Value; }
    94       set { BestKnownSolutionParameter.Value = value; }
    95     }
    96     public IntValue Jobs {
    97       get { return JobsParameter.Value; }
    98       set { JobsParameter.Value = value; }
    99     }
    100     public IntValue Resources {
    101       get { return ResourcesParameter.Value; }
    102       set { ResourcesParameter.Value = value; }
    103     }
    104     public SchedulingEvaluator SolutionEvaluator {
    105       get { return SolutionEvaluatorParameter.Value; }
    106       set { SolutionEvaluatorParameter.Value = value; }
    107     }
    108     public BoolValue DueDates {
    109       get { return DueDatesParameter.Value; }
    110       set { DueDatesParameter.Value = value; }
    111     }
    112     #endregion
    113 
    114 
    115     public JobShopSchedulingProblem()
    116       : base(new SchedulingEvaluationAlgorithm (), new JSMRandomCreator ()) {
    117       Parameters.Add(new ValueParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance.", new ItemList<Job>()));
    118       Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));
    119 
    120       Parameters.Add(new ValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue()));
    121       Parameters.Add(new ValueParameter<IntValue>("Resources", "The number of resources used this JSSP instance.", new IntValue()));
    122       Parameters.Add(new ValueParameter<BoolValue>("DueDates", "Determines whether the problem instance uses due dates or not.", new BoolValue()));
    123       Parameters.Add(new ValueParameter<SchedulingEvaluator>("SolutionEvaluator", "The evaluator used to determine the quality of a solution.", new MakespanEvaluator()));
    124 
    125       InitializeOperators();
    126       InitializeProblemInstance();
    127112    }
    128113
     
    131116      InitializeOperators();
    132117    }
     118
     119    protected override void OnEvaluatorChanged() {
     120      base.OnEvaluatorChanged();
     121    }
    133122    #endregion
    134123
    135124    #region Helpers
    136     private void InitializeProblemInstance () {
    137       Jobs = new IntValue (10);
    138       Resources = new IntValue (10);
    139       BestKnownQuality = new DoubleValue (930);
     125    private void InitializeProblemInstance() {
     126      Jobs = new IntValue(10);
     127      Resources = new IntValue(10);
     128      BestKnownQuality = new DoubleValue(930);
    140129      JobData = new ItemList<Job>();
    141130      List<string> data = new List<string>
     
    167156      if (SolutionCreator.GetType().Equals(typeof(JSMRandomCreator))) {
    168157        Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>());
    169         ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<JSMEncoding>(new JSMDecoder());
     158        JSMDecoder decoder = new JSMDecoder();
     159        ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<JSMEncoding>(decoder);
    170160      } else {
    171161        if (SolutionCreator.GetType().Equals(typeof(PRVRandomCreator))) {
    172162          Operators.AddRange(ApplicationManager.Manager.GetInstances<IPRVOperator>());
    173           ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PRVEncoding>(new PRVDecoder());
     163          PRVDecoder decoder = new PRVDecoder();
     164          ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PRVEncoding>(decoder);
    174165        } else {
    175166          if (SolutionCreator.GetType().Equals(typeof(PWRRandomCreator))) {
    176167            Operators.AddRange(ApplicationManager.Manager.GetInstances<IPWROperator>());
    177             ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PWREncoding>(new PWRDecoder());
     168            PWRDecoder decoder = new PWRDecoder();
     169            ((SchedulingEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PWREncoding>(decoder);
    178170          }
    179171        }
     
    197189    }
    198190    private int[] GetIntArray(List<string> data) {
    199       int[] arr = new int [data.Count];
    200       for (int i = 0; i < data.Count; i++ ) {
     191      int[] arr = new int[data.Count];
     192      for (int i = 0; i < data.Count; i++) {
    201193        arr[i] = Int32.Parse(data[i]);
    202194      }
    203195      return arr;
    204196    }
    205     private Job CreateJobFromData (List<string> data, int jobCount)  {
     197    private Job CreateJobFromData(List<string> data, int jobCount) {
    206198      DoubleValue dueDate = null;
    207199      int dataCount = data.Count;
     
    233225        if (data.Count > 0 && ((int)data[0][0] >= 48 && (int)data[0][0] <= 57)) {
    234226          int jobCount = 0;
    235           Jobs = new IntValue (Int32.Parse(data[0]));
    236           Resources = new IntValue (Int32.Parse(data[1]));
     227          Jobs = new IntValue(Int32.Parse(data[0]));
     228          Resources = new IntValue(Int32.Parse(data[1]));
    237229          //data[2] = bestKnownQuality (double)
    238230          //data[3] = dueDates (0|1)
    239231          DueDates.Value = false;
    240232          if (data.Count > 2)
    241             BestKnownQualityParameter.ActualValue = new DoubleValue(Double.Parse (data[2]));
     233            BestKnownQualityParameter.ActualValue = new DoubleValue(Double.Parse(data[2]));
    242234          if (data.Count > 3 && data[3] == "1")
    243235            DueDates.Value = true;
     
    265257      JSMEncoding solution = new JSMEncoding();
    266258      while (!solutionFile.EndOfStream && !solutionFound) {
    267        
     259
    268260        string line = solutionFile.ReadLine();
    269261        List<string> data = SplitString(line);
     
    274266          data = SplitString(line);
    275267          while (data != null && data.Count > 0 && ((int)data[0][0] >= 48 && (int)data[0][0] <= 57)) {
    276             Permutation p = new Permutation(PermutationTypes.Absolute, GetIntArray (data));
     268            Permutation p = new Permutation(PermutationTypes.Absolute, GetIntArray(data));
    277269            solution.JobSequenceMatrix.Add(p);
    278270
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Plugin.cs

    r6364 r6406  
    2323
    2424namespace HeuristicLab.Problems.Scheduling {
    25   [Plugin("HeuristicLab.Problems.Scheduling", "3.3.3.6293")]
     25  [Plugin("HeuristicLab.Problems.Scheduling", "3.3.3.6364")]
    2626  [PluginFile("HeuristicLab.Problems.Scheduling-3.3.dll", PluginFileType.Assembly)]
    2727  public class HeuristicLabProblemsSchedulingPlugin : PluginBase {
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/SchedulingProblem.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;
     23using HeuristicLab.Core;
     24using HeuristicLab.Encodings.ScheduleEncoding;
    2625using HeuristicLab.Optimization;
    27 using HeuristicLab.Core;
    2826using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    29 using HeuristicLab.Common;
    30 using HeuristicLab.Encodings.SchedulingEncoding.Interfaces;
    3127
    3228namespace HeuristicLab.Problems.Scheduling {
    33   [Item("Scheduling Problem", "Abstract class that represents a Scheduling Problem")]
     29  [Item("SchedulingProblem", "Abstract class that represents a Scheduling Problem")]
    3430  [StorableClass]
    35   public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem<ISchedulingEvaluationAlgorithm, ISchedulingCreator> {
     31  public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem<IScheduleEvaluationAlgorithm, IScheduleCreator> {
    3632    [StorableConstructor]
    3733    protected SchedulingProblem(bool deserializing) : base(deserializing) { }
     
    4036    }
    4137
    42     protected SchedulingProblem (ISchedulingEvaluationAlgorithm se, ISchedulingCreator sc) : base (se, sc) {}
     38    protected SchedulingProblem(IScheduleEvaluationAlgorithm se, IScheduleCreator sc) : base(se, sc) { }
    4339
    4440  }
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Task.cs

    r6293 r6406  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    2522using System.Text;
     23using HeuristicLab.Common;
     24using HeuristicLab.Core;
    2625using HeuristicLab.Data;
    2726using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    28 using HeuristicLab.Core;
    29 using HeuristicLab.Common;
    3027
    3128namespace HeuristicLab.Problems.Scheduling {
     
    3330  [StorableClass]
    3431  public class Task : Item {
     32    [Storable]
     33    public IntValue TaskNr { get; set; }
     34    [Storable]
     35    public IntValue ResourceNr { get; set; }
     36    [Storable]
     37    public IntValue JobNr { get; set; }
     38    [Storable]
     39    public DoubleValue Duration { get; set; }
     40    [Storable]
     41    public BoolValue IsScheduled { get; set; }
     42
    3543    [StorableConstructor]
    3644    protected Task(bool deserializing) : base(deserializing) { }
     
    4856
    4957
    50     public IntValue TaskNr { get; set; }
    51     public IntValue ResourceNr { get; set; }
    52     public IntValue JobNr { get; set; }
    53     public DoubleValue Duration { get; set; }
    54     public BoolValue IsScheduled { get; set; }
    55 
    56 
    57     public Task (int taskNr, int resNr, int jobNr, double duration) : base () {
    58       Duration = new DoubleValue (duration);
    59       ResourceNr = new IntValue (resNr);
    60       JobNr = new IntValue (jobNr);
    61       TaskNr = new IntValue (taskNr);
     58    public Task(int taskNr, int resNr, int jobNr, double duration)
     59      : base() {
     60      Duration = new DoubleValue(duration);
     61      ResourceNr = new IntValue(resNr);
     62      JobNr = new IntValue(jobNr);
     63      TaskNr = new IntValue(taskNr);
    6264      IsScheduled = new BoolValue(false);
    6365    }
Note: See TracChangeset for help on using the changeset viewer.