Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/11/12 22:57:09 (12 years ago)
Author:
abeham
Message:

#1329:

  • Moved decoders and evaluators from encoding to problem
  • Removed unnecessary state variables in operators
  • Introduced parameters in interfaces and added wiring code
  • Removed ConcreteScheduleManipulator as it does not perform any manipulation
  • Made ErrorPolicy and ForcingStrategy configurable and added views for them
  • Renamed the SchedulingEvaluationAlgorithm and also converted the AlgorithmOperator to a SingleSuccessorOperator
  • Fixed Plugin- and AssemblyFileVersion
  • Added missing license headers
Location:
trunk/sources/HeuristicLab.Problems.Scheduling/3.3
Files:
7 added
1 deleted
13 edited

Legend:

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

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    3435  [Item("JobSequenceMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequence Matrix.")]
    3536  [StorableClass]
    36   public class JSMDecoder : ScheduleDecoder<JSMEncoding>, IStochasticOperator, IJSSPOperator {
     37  public class JSMDecoder : ScheduleDecoder, IStochasticOperator, IJSSPOperator {
     38
    3739    public ILookupParameter<IRandom> RandomParameter {
    3840      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     
    4143      get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
    4244    }
     45    public IValueParameter<JSMDecodingErrorPolicy> DecodingErrorPolicyParameter {
     46      get { return (IValueParameter<JSMDecodingErrorPolicy>)Parameters["DecodingErrorPolicy"]; }
     47    }
     48    public IValueParameter<JSMForcingStrategy> ForcingStrategyParameter {
     49      get { return (IValueParameter<JSMForcingStrategy>)Parameters["ForcingStrategy"]; }
     50    }
    4351
    44     #region Private Members
    45     [Storable]
    46     private Schedule resultingSchedule;
     52    private JSMDecodingErrorPolicyTypes DecodingErrorPolicy {
     53      get { return DecodingErrorPolicyParameter.Value.Value; }
     54    }
    4755
    48     [Storable]
    49     private ItemList<Job> jobs;
    50 
    51     [Storable]
    52     private JSMDecodingErrorPolicyTypes decodingErrorPolicy = JSMDecodingErrorPolicyTypes.GuidedPolicy;
    53 
    54     [Storable]
    55     private JSMForcingStrategyTypes forcingStrategy = JSMForcingStrategyTypes.ShiftForcing;
    56     #endregion
     56    private JSMForcingStrategyTypes ForcingStrategy {
     57      get { return ForcingStrategyParameter.Value.Value; }
     58    }
    5759
    5860    [StorableConstructor]
    5961    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     }
     62    protected JSMDecoder(JSMDecoder original, Cloner cloner) : base(original, cloner) { }
    6763    public override IDeepCloneable Clone(Cloner cloner) {
    6864      return new JSMDecoder(this, cloner);
     
    7369      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    7470      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the Schedulingproblem - Instance."));
     71      Parameters.Add(new ValueParameter<JSMDecodingErrorPolicy>("DecodingErrorPolicy", "Specify the policy that should be used to handle decoding errors.", new JSMDecodingErrorPolicy(JSMDecodingErrorPolicyTypes.RandomPolicy)));
     72      Parameters.Add(new ValueParameter<JSMForcingStrategy>("ForcingStrategy", "Specifies a forcing strategy.", new JSMForcingStrategy(JSMForcingStrategyTypes.SwapForcing)));
     73
    7574      ScheduleEncodingParameter.ActualName = "JobSequenceMatrix";
    7675    }
    77 
    7876
    7977    private Task SelectTaskFromConflictSet(int conflictedResourceNr, int progressOnConflictedResource, ItemList<Task> conflictSet, ItemList<Permutation> jsm) {
     
    10098      return result;
    10199    }
     100
    102101    private Task ApplyDecodingErrorPolicy(ItemList<Task> conflictSet, Permutation resource, int progress) {
    103       if (decodingErrorPolicy == JSMDecodingErrorPolicyTypes.RandomPolicy) {
     102      if (DecodingErrorPolicy == JSMDecodingErrorPolicyTypes.RandomPolicy) {
    104103        //Random
    105104        return conflictSet[RandomParameter.ActualValue.Next(conflictSet.Count - 1)];
     
    117116      }
    118117    }
     118
    119119    private void ApplyForcingStrategy(ItemList<Permutation> jsm, int conflictedResource, int newResolutionIndex, int progressOnResource, int newResolution) {
    120       if (forcingStrategy == JSMForcingStrategyTypes.SwapForcing) {
     120      if (ForcingStrategy == JSMForcingStrategyTypes.SwapForcing) {
    121121        //SwapForcing
    122122        jsm[conflictedResource][newResolutionIndex] = jsm[conflictedResource][progressOnResource];
     
    139139      ItemList<Permutation> jobSequenceMatrix = solution.JobSequenceMatrix;
    140140
    141       jobs = (ItemList<Job>)jobData.Clone();
    142       resultingSchedule = new Schedule(jobs[0].Tasks.Count);
     141      var jobs = (ItemList<Job>)jobData.Clone();
     142      var resultingSchedule = new Schedule(jobs[0].Tasks.Count);
    143143
    144144      //Reset scheduled tasks in result
     
    177177    }
    178178
    179     public override Schedule CreateScheduleFromEncoding(JSMEncoding solution) {
     179    public override Schedule CreateScheduleFromEncoding(IScheduleEncoding encoding) {
     180      var solution = encoding as JSMEncoding;
     181      if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
    180182      return CreateScheduleFromEncoding(solution, JobDataParameter.ActualValue);
    181     }
    182 
    183     public override IOperation Apply() {
    184       return base.Apply();
    185183    }
    186184  }
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Decoders/JSMDecodingErrorPolicyTypes.cs

    r8603 r8887  
    1919 */
    2020#endregion
     21
    2122namespace HeuristicLab.Problems.Scheduling {
    2223  public enum JSMDecodingErrorPolicyTypes {
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Decoders/PRVDecoder.cs

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

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    3132  [Item("PWRDecoder", "An item used to convert a PWR-individual into a generalized schedule.")]
    3233  [StorableClass]
    33   public class PWRDecoder : ScheduleDecoder<PWREncoding>, IStochasticOperator, IJSSPOperator {
     34  public class PWRDecoder : ScheduleDecoder, IStochasticOperator, IJSSPOperator {
     35
    3436    public ILookupParameter<IRandom> RandomParameter {
    3537      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     
    4143    [StorableConstructor]
    4244    protected PWRDecoder(bool deserializing) : base(deserializing) { }
    43     protected PWRDecoder(PWRDecoder original, Cloner cloner)
    44       : base(original, cloner) {
    45     }
    46     public override IDeepCloneable Clone(Cloner cloner) {
    47       return new PWRDecoder(this, cloner);
    48     }
    49 
     45    protected PWRDecoder(PWRDecoder original, Cloner cloner) : base(original, cloner) { }
    5046    public PWRDecoder()
    5147      : base() {
     
    5551    }
    5652
    57     public override Schedule CreateScheduleFromEncoding(PWREncoding solution) {
    58       ItemList<Job> jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
    59       Schedule resultingSchedule = new Schedule(jobs[0].Tasks.Count);
     53    public override IDeepCloneable Clone(Cloner cloner) {
     54      return new PWRDecoder(this, cloner);
     55    }
     56
     57    public override Schedule CreateScheduleFromEncoding(IScheduleEncoding encoding) {
     58      var solution = encoding as PWREncoding;
     59      if (solution == null) throw new InvalidOperationException("Encoding is not of type PWREncoding");
     60
     61      var jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
     62      var resultingSchedule = new Schedule(jobs[0].Tasks.Count);
    6063      foreach (int jobNr in solution.PermutationWithRepetition) {
    6164        int i = 0;
     
    6871      return resultingSchedule;
    6972    }
    70 
    71     public override IOperation Apply() {
    72       return base.Apply();
    73     }
    7473  }
    7574}
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MakespanEvaluator.cs

    r8882 r8887  
    3030  [Item("Makespan Evaluator", "Represents an evaluator using the maximum makespan of a schedule.")]
    3131  [StorableClass]
    32   public class MakespanEvaluator : SchedulingEvaluator {
     32  public class MakespanEvaluator : ScheduleEvaluator {
     33
    3334    [StorableConstructor]
    3435    protected MakespanEvaluator(bool deserializing) : base(deserializing) { }
    35     protected MakespanEvaluator(MakespanEvaluator original, Cloner cloner)
    36       : base(original, cloner) {
     36    protected MakespanEvaluator(MakespanEvaluator original, Cloner cloner) : base(original, cloner) {}
     37    public MakespanEvaluator()
     38      : base() {
     39      QualityParameter.ActualName = "Makespan";
    3740    }
     41
    3842    public override IDeepCloneable Clone(Cloner cloner) {
    3943      return new MakespanEvaluator(this, cloner);
    4044    }
    41 
    42     public MakespanEvaluator() : base() { }
    4345
    4446    public static double GetMakespan(Schedule schedule) {
     
    4648    }
    4749
    48     protected override DoubleValue Evaluate(Schedule schedule) {
    49       return new DoubleValue(GetMakespan(schedule));
    50     }
    51 
    52     public override IOperation Apply() {
    53       return base.Apply();
     50    protected override double Evaluate(Schedule schedule) {
     51      return GetMakespan(schedule);
    5452    }
    5553  }
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MeanTardinessEvaluator.cs

    r8882 r8887  
    3232  [Item("Mean tardiness Evaluator", "Represents an evaluator using the mean tardiness of a schedule.")]
    3333  [StorableClass]
    34   public class MeanTardinessEvaluator : SchedulingEvaluator, IJSSPOperator {
     34  public class MeanTardinessEvaluator : ScheduleEvaluator, IJSSPOperator {
    3535
    3636    [StorableConstructor]
     
    5050      : base() {
    5151      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance."));
     52      QualityParameter.ActualName = "MeanTardiness";
    5253    }
    5354
     
    5859    }
    5960
    60     protected override DoubleValue Evaluate(Schedule schedule) {
    61       return new DoubleValue(GetMeanTardiness(schedule, JobDataParameter.ActualValue));
     61    protected override double Evaluate(Schedule schedule) {
     62      return GetMeanTardiness(schedule, JobDataParameter.ActualValue);
    6263    }
    6364  }
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Evaluators/SchedulingEvaluator.cs

    r8882 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2930
     31namespace HeuristicLab.Problems.Scheduling {
     32  [Item("SchedulingEvaluator", "First applies the decoder operator to obtain a schedule from an encoding and then applies the evaluator to obtain a quality.")]
     33  [StorableClass]
     34  public class SchedulingEvaluator : SingleSuccessorOperator, ISchedulingEvaluator {
    3035
    31 namespace HeuristicLab.Problems.Scheduling {
    32   [Item("Scheduling Evaluator", "Represents a evaluator class for standard scheduling problems.")]
    33   [StorableClass]
    34   public abstract class SchedulingEvaluator : SingleSuccessorOperator, IScheduleEvaluator {
     36    public IValueLookupParameter<IScheduleDecoder> ScheduleDecoderParameter {
     37      get { return (IValueLookupParameter<IScheduleDecoder>) Parameters["ScheduleDecoder"]; }
     38    }
     39    ILookupParameter<IScheduleDecoder> ISchedulingEvaluator.ScheduleDecoderParameter {
     40      get { return ScheduleDecoderParameter; }
     41    }
     42    public IValueLookupParameter<IScheduleEvaluator> ScheduleEvaluatorParameter {
     43      get { return (IValueLookupParameter<IScheduleEvaluator>) Parameters["ScheduleEvaluator"]; }
     44    }
     45    ILookupParameter<IScheduleEvaluator> ISchedulingEvaluator.ScheduleEvaluatorParameter {
     46      get { return ScheduleEvaluatorParameter; }
     47    }
     48    public ILookupParameter<DoubleValue> QualityParameter {
     49      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
     50    }
     51
    3552    [StorableConstructor]
    3653    protected SchedulingEvaluator(bool deserializing) : base(deserializing) { }
    37     protected SchedulingEvaluator(SchedulingEvaluator original, Cloner cloner)
    38       : base(original, cloner) {
     54    protected SchedulingEvaluator(SchedulingEvaluator original, Cloner cloner) : base(original, cloner) { }
     55    public SchedulingEvaluator()
     56      : base() {
     57      Parameters.Add(new ValueLookupParameter<IScheduleDecoder>("ScheduleDecoder", "The decoding operator that is used to calculate a schedule from the used representation."));
     58      Parameters.Add(new ValueLookupParameter<IScheduleEvaluator>("ScheduleEvaluator", "The actual schedule evaluation operator."));
     59      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
     60      QualityParameter.Hidden = true;
    3961    }
    4062
    41     public ILookupParameter<IRandom> RandomParameter {
    42       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    43     }
    44     public ILookupParameter<DoubleValue> QualityParameter {
    45       get {
    46         if (Parameters.ContainsKey("Quality"))
    47           return (ILookupParameter<DoubleValue>)Parameters["Quality"];
    48         else
    49           return null;
    50       }
    51     }
    52     public ILookupParameter<Schedule> ScheduleParameter {
    53       get { return (ILookupParameter<Schedule>)Parameters["Schedule"]; }
     63    public override IDeepCloneable Clone(Cloner cloner) {
     64      return new SchedulingEvaluator(this, cloner);
    5465    }
    5566
    56     public SchedulingEvaluator()
    57       : base() {
    58       Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality value aka fitness value of the solution."));
    59       Parameters.Add(new LookupParameter<Schedule>("Schedule", "The decoded scheduling solution represented as generalized schedule."));
    60       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator."));
    61     }
     67    public override IOperation Apply() {
     68      var decoder = ScheduleDecoderParameter.ActualValue;
     69      var evaluator = ScheduleEvaluatorParameter.ActualValue;
     70      if (evaluator == null) throw new InvalidOperationException("A ScheduleEvaluator could not be found.");
    6271
    63     protected abstract DoubleValue Evaluate(Schedule schedule);
    64 
    65     public override IOperation Apply() {
    66       Schedule schedule = ScheduleParameter.ActualValue;
    67       QualityParameter.ActualValue = Evaluate(schedule);
    68       return base.Apply();
     72      var operations = new OperationCollection(base.Apply());
     73      operations.Insert(0, ExecutionContext.CreateChildOperation(evaluator));
     74      if (decoder != null) // decode before evaluating
     75        operations.Insert(0, ExecutionContext.CreateChildOperation(decoder));
     76      return operations;
    6977    }
    7078  }
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/HeuristicLab.Problems.Scheduling-3.3.csproj

    r8882 r8887  
    107107    <Compile Include="Analyzers\BestSchedulingSolutionAnalyzer.cs" />
    108108    <Compile Include="Analyzers\SchedulingAnalyzer.cs" />
     109    <Compile Include="Decoders\JSMForcingStrategy.cs" />
    109110    <Compile Include="Decoders\JSMDecoder.cs" />
     111    <Compile Include="Decoders\JSMDecodingErrorPolicy.cs" />
    110112    <Compile Include="Decoders\JSMDecodingErrorPolicyTypes.cs" />
    111113    <Compile Include="Decoders\JSMForcingStrategyTypes.cs" />
    112114    <Compile Include="Decoders\PRVDecoder.cs" />
    113115    <Compile Include="Decoders\PWRDecoder.cs" />
     116    <Compile Include="Decoders\ScheduleDecoder.cs" />
    114117    <Compile Include="Evaluators\MeanTardinessEvaluator.cs" />
    115118    <Compile Include="Evaluators\MakespanEvaluator.cs" />
     119    <Compile Include="Evaluators\ScheduleEvaluator.cs" />
     120    <Compile Include="Interfaces\IJSSPOperator.cs" />
     121    <Compile Include="Interfaces\IScheduleDecoder.cs" />
     122    <Compile Include="Interfaces\ISchedulingEvaluator.cs" />
     123    <Compile Include="Interfaces\IScheduleEvaluator.cs" />
     124    <Compile Include="JobShopSchedulingProblem.cs" />
    116125    <Compile Include="Evaluators\SchedulingEvaluator.cs" />
    117     <Compile Include="Interfaces\IJSSPOperator.cs" />
    118     <Compile Include="JobShopSchedulingProblem.cs" />
    119     <Compile Include="Evaluators\SchedulingEvaluationAlgorithm.cs" />
    120126    <Compile Include="SchedulingProblem.cs" />
    121127    <Compile Include="Plugin.cs" />
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Interfaces/IJSSPOperator.cs

    r6475 r8887  
    1 using HeuristicLab.Core;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 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 HeuristicLab.Core;
    223using HeuristicLab.Encodings.ScheduleEncoding;
    324
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs

    r8886 r8887  
    2020#endregion
    2121
     22using System;
    2223using System.Drawing;
     24using System.Linq;
    2325using HeuristicLab.Common;
    2426using HeuristicLab.Core;
     
    7173    #endregion
    7274
     75    public string Filename { get; set; }
     76    public override Image ItemImage {
     77      get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
     78    }
     79
    7380    #region Parameter Properties
    74     public ValueParameter<ItemList<Job>> JobDataParameter {
    75       get { return (ValueParameter<ItemList<Job>>)Parameters["JobData"]; }
     81    public IValueParameter<ItemList<Job>> JobDataParameter {
     82      get { return (IValueParameter<ItemList<Job>>)Parameters["JobData"]; }
    7683    }
    7784    public OptionalValueParameter<Schedule> BestKnownSolutionParameter {
     
    8592      get { return (IFixedValueParameter<IntValue>)Parameters["Resources"]; }
    8693    }
    87     public ValueParameter<SchedulingEvaluator> SolutionEvaluatorParameter {
    88       get { return (ValueParameter<SchedulingEvaluator>)Parameters["SolutionEvaluator"]; }
     94    public IValueParameter<IScheduleEvaluator> ScheduleEvaluatorParameter {
     95      get { return (IValueParameter<IScheduleEvaluator>)Parameters["ScheduleEvaluator"]; }
     96    }
     97    public OptionalValueParameter<IScheduleDecoder> ScheduleDecoderParameter {
     98      get { return (OptionalValueParameter<IScheduleDecoder>)Parameters["ScheduleDecoder"]; }
    8999    }
    90100    #endregion
     
    107117      set { ResourcesParameter.Value.Value = value; }
    108118    }
    109     public SchedulingEvaluator SolutionEvaluator {
    110       get { return SolutionEvaluatorParameter.Value; }
    111       set { SolutionEvaluatorParameter.Value = value; }
    112     }
    113     public override Image ItemImage {
    114       get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    115     }
    116     public string Filename { get; set; }
    117     #endregion
    118 
    119     public JobShopSchedulingProblem()
    120       : base(new SchedulingEvaluationAlgorithm(), new JSMRandomCreator()) {
    121       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>()));
    122       Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));
    123 
    124       Parameters.Add(new FixedValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue()));
    125       Parameters.Add(new FixedValueParameter<IntValue>("Resources", "The number of resources used in this JSSP instance.", new IntValue()));
    126       Parameters.Add(new ValueParameter<SchedulingEvaluator>("SolutionEvaluator", "The evaluator used to determine the quality of a solution.", new MakespanEvaluator()));
    127 
    128       InitializeOperators();
    129       Load(DefaultInstance);
    130     }
     119    public IScheduleEvaluator ScheduleEvaluator {
     120      get { return ScheduleEvaluatorParameter.Value; }
     121      set { ScheduleEvaluatorParameter.Value = value; }
     122    }
     123    public IScheduleDecoder ScheduleDecoder {
     124      get { return ScheduleDecoderParameter.Value; }
     125      set { ScheduleDecoderParameter.Value = value; }
     126    }
     127    #endregion
    131128
    132129    [StorableConstructor]
     
    134131    private JobShopSchedulingProblem(JobShopSchedulingProblem original, Cloner cloner)
    135132      : base(original, cloner) {
    136     }
     133      RegisterEventHandlers();
     134    }
     135    public JobShopSchedulingProblem()
     136      : base(new SchedulingEvaluator(), new JSMRandomCreator()) {
     137      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>()));
     138      Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));
     139
     140      Parameters.Add(new FixedValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue()));
     141      Parameters.Add(new FixedValueParameter<IntValue>("Resources", "The number of resources used in this JSSP instance.", new IntValue()));
     142      Parameters.Add(new ValueParameter<IScheduleEvaluator>("ScheduleEvaluator", "The evaluator used to determine the quality of a solution.", new MakespanEvaluator()));
     143      Parameters.Add(new OptionalValueParameter<IScheduleDecoder>("ScheduleDecoder", "The operator that decodes the representation and creates a schedule.", new JSMDecoder()));
     144
     145      EvaluatorParameter.GetsCollected = false;
     146      EvaluatorParameter.Hidden = true;
     147      ScheduleDecoderParameter.Hidden = true;
     148
     149      InitializeOperators();
     150      Load(DefaultInstance);
     151      RegisterEventHandlers();
     152    }
     153
    137154    public override IDeepCloneable Clone(Cloner cloner) {
    138155      return new JobShopSchedulingProblem(this, cloner);
     156    }
     157
     158    [StorableHook(HookType.AfterDeserialization)]
     159    private void AfterDeserialization() {
     160      RegisterEventHandlers();
     161    }
     162
     163    private void RegisterEventHandlers() {
     164      ScheduleEvaluatorParameter.ValueChanged += ScheduleEvaluatorParameter_ValueChanged;
     165      ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged;
     166      SolutionCreatorParameter.ValueChanged += SolutionCreatorParameter_ValueChanged;
     167      SolutionCreator.ScheduleEncodingParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
     168      ScheduleDecoderParameter.ValueChanged += ScheduleDecoderParameter_ValueChanged;
     169      if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged;
    139170    }
    140171
     
    142173    protected override void OnSolutionCreatorChanged() {
    143174      InitializeOperators();
     175    }
     176    protected override void OnEvaluatorChanged() {
     177      base.OnEvaluatorChanged();
     178      ParameterizeOperators();
     179    }
     180    private void ScheduleEvaluatorParameter_ValueChanged(object sender, EventArgs eventArgs) {
     181      ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged;
     182      ParameterizeOperators();
     183    }
     184    private void ScheduleEvaluator_QualityParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
     185      ParameterizeOperators();
     186    }
     187    private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs eventArgs) {
     188      SolutionCreator.ScheduleEncodingParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
     189      ParameterizeOperators();
     190    }
     191    private void SolutionCreator_SchedulingEncodingParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
     192      ParameterizeOperators();
     193    }
     194    private void ScheduleDecoderParameter_ValueChanged(object sender, EventArgs eventArgs) {
     195      if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged;
     196      ParameterizeOperators();
     197    }
     198    private void ScheduleDecoder_ScheduleParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
     199      ParameterizeOperators();
    144200    }
    145201    #endregion
     
    156212      }
    157213
    158       if (data.BestKnownQuality.HasValue) BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value);
    159       else BestKnownQuality = null;
     214      BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null;
    160215      if (data.BestKnownSchedule != null) {
    161216        var enc = new JSMEncoding();
     
    168223        }
    169224        BestKnownSolution = new JSMDecoder().CreateScheduleFromEncoding(enc, jobData);
    170         if (SolutionEvaluator is MeanTardinessEvaluator)
     225        if (ScheduleEvaluator is MeanTardinessEvaluator)
    171226          BestKnownQuality = new DoubleValue(MeanTardinessEvaluator.GetMeanTardiness(BestKnownSolution, jobData));
    172         else if (SolutionEvaluator is MakespanEvaluator)
     227        else if (ScheduleEvaluator is MakespanEvaluator)
    173228          BestKnownQuality = new DoubleValue(MakespanEvaluator.GetMakespan(BestKnownSolution));
    174229      }
     
    208263      ApplyEncoding();
    209264      Operators.Add(new BestSchedulingSolutionAnalyzer());
     265      ParameterizeOperators();
    210266    }
    211267
     
    213269      if (SolutionCreator.GetType() == typeof(JSMRandomCreator)) {
    214270        Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>());
    215         var decoder = new JSMDecoder();
    216         ((SchedulingEvaluationAlgorithm)EvaluatorParameter.ActualValue).InitializeOperatorGraph(decoder);
     271        ScheduleDecoder = new JSMDecoder();
    217272      } else if (SolutionCreator.GetType() == typeof(PRVRandomCreator)) {
    218273        Operators.AddRange(ApplicationManager.Manager.GetInstances<IPRVOperator>());
    219         var decoder = new PRVDecoder();
    220         ((SchedulingEvaluationAlgorithm)EvaluatorParameter.ActualValue).InitializeOperatorGraph(decoder);
     274        ScheduleDecoder = new PRVDecoder();
    221275      } else if (SolutionCreator.GetType() == typeof(PWRRandomCreator)) {
    222276        Operators.AddRange(ApplicationManager.Manager.GetInstances<IPWROperator>());
    223         var decoder = new PWRDecoder();
    224         ((SchedulingEvaluationAlgorithm)EvaluatorParameter.ActualValue).InitializeOperatorGraph(decoder);
     277        ScheduleDecoder = new PWRDecoder();
    225278      } else if (SolutionCreator.GetType() == typeof(DirectScheduleRandomCreator)) {
    226279        Operators.AddRange(ApplicationManager.Manager.GetInstances<IDirectScheduleOperator>());
    227         ((SchedulingEvaluationAlgorithm)EvaluatorParameter.ActualValue).InitializeOperatorGraph<Schedule>();
     280        ScheduleDecoder = null;
     281      }
     282    }
     283
     284    private void ParameterizeOperators() {
     285      Evaluator.ScheduleDecoderParameter.ActualName = ScheduleDecoderParameter.Name;
     286      Evaluator.ScheduleDecoderParameter.Hidden = true;
     287      Evaluator.ScheduleEvaluatorParameter.ActualName = ScheduleEvaluatorParameter.Name;
     288      Evaluator.ScheduleEvaluatorParameter.Hidden = true;
     289      Evaluator.QualityParameter.ActualName = ScheduleEvaluator.QualityParameter.ActualName;
     290      Evaluator.QualityParameter.Hidden = true;
     291
     292      if (ScheduleDecoder != null)
     293        ScheduleDecoder.ScheduleEncodingParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
     294
     295      if (ScheduleDecoder != null) {
     296        ScheduleEvaluator.ScheduleParameter.ActualName = ScheduleDecoder.ScheduleParameter.ActualName;
     297        ScheduleEvaluator.ScheduleParameter.Hidden = true;
     298      } else if (SolutionCreator is DirectScheduleRandomCreator) {
     299        var directEvaluator = (DirectScheduleRandomCreator)SolutionCreator;
     300        ScheduleEvaluator.ScheduleParameter.ActualName = directEvaluator.ScheduleEncodingParameter.ActualName;
     301        ScheduleEvaluator.ScheduleParameter.Hidden = true;
     302      } else {
     303        ScheduleEvaluator.ScheduleParameter.ActualName = ScheduleEvaluator.ScheduleParameter.Name;
     304        ScheduleEvaluator.ScheduleParameter.Hidden = false;
     305      }
     306
     307      foreach (var op in Operators.OfType<IScheduleManipulator>()) {
     308        op.ScheduleEncodingParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
     309        op.ScheduleEncodingParameter.Hidden = true;
     310      }
     311
     312      foreach (var op in Operators.OfType<IScheduleCrossover>()) {
     313        op.ChildParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
     314        op.ChildParameter.Hidden = true;
     315        op.ParentsParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
     316        op.ParentsParameter.Hidden = true;
     317      }
     318
     319      foreach (var op in Operators.OfType<BestSchedulingSolutionAnalyzer>()) {
     320        op.QualityParameter.ActualName = ScheduleEvaluator.QualityParameter.ActualName;
     321        if (ScheduleDecoder != null) {
     322          op.ScheduleParameter.ActualName = ScheduleDecoder.ScheduleParameter.ActualName;
     323          op.ScheduleParameter.Hidden = true;
     324        } else if (SolutionCreator is DirectScheduleRandomCreator) {
     325          op.ScheduleParameter.ActualName = ((DirectScheduleRandomCreator)SolutionCreator).ScheduleEncodingParameter.ActualName;
     326          op.ScheduleParameter.Hidden = true;
     327        } else {
     328          op.ScheduleParameter.ActualName = op.ScheduleParameter.Name;
     329          op.ScheduleParameter.Hidden = false;
     330        }
    228331      }
    229332    }
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Plugin.cs.frame

    r8882 r8887  
    2323
    2424namespace HeuristicLab.Problems.Scheduling {
    25   [Plugin("HeuristicLab.Problems.Scheduling", "3.3.3.$WCREV$")]
     25  [Plugin("HeuristicLab.Problems.Scheduling", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Problems.Scheduling-3.3.dll", PluginFileType.Assembly)]
    2727  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Properties/AssemblyInfo.cs.frame

    r8759 r8887  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.3.0.0")]
    55 [assembly: AssemblyFileVersion("3.3.0.$WCREV$")]
     55[assembly: AssemblyFileVersion("3.3.7.$WCREV$")]
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/SchedulingProblem.cs

    r8603 r8887  
    2929  [Item("SchedulingProblem", "Abstract class that represents a Scheduling Problem")]
    3030  [StorableClass]
    31   public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem<IScheduleEvaluationAlgorithm, IScheduleCreator> {
     31  public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem<ISchedulingEvaluator, IScheduleCreator> {
    3232    [StorableConstructor]
    3333    protected SchedulingProblem(bool deserializing) : base(deserializing) { }
    34     protected SchedulingProblem(SchedulingProblem original, Cloner cloner)
    35       : base(original, cloner) {
    36     }
    37 
    38     protected SchedulingProblem(IScheduleEvaluationAlgorithm se, IScheduleCreator sc) : base(se, sc) { }
    39 
     34    protected SchedulingProblem(SchedulingProblem original, Cloner cloner) : base(original, cloner) { }
     35    protected SchedulingProblem(ISchedulingEvaluator evaluator, IScheduleCreator creator) : base(evaluator, creator) { }
    4036  }
    4137}
Note: See TracChangeset for help on using the changeset viewer.