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
File:
1 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  }
Note: See TracChangeset for help on using the changeset viewer.