Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/08/15 14:31:05 (9 years ago)
Author:
mkommend
Message:

#2521: Adapted decoders for SchedulingProblem.

Location:
branches/ProblemRefactoring
Files:
5 added
1 deleted
31 edited
8 copied
1 moved

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/HeuristicLab.Encodings.ScheduleEncoding-3.3.csproj

    r13437 r13443  
    116116  </ItemGroup>
    117117  <ItemGroup>
     118    <Compile Include="JobSequenceMatrix\Decoder\JSMDecoder.cs" />
     119    <Compile Include="JobSequenceMatrix\Decoder\JSMDecodingErrorPolicy.cs" />
     120    <Compile Include="JobSequenceMatrix\Decoder\JSMDecodingErrorPolicyTypes.cs" />
     121    <Compile Include="JobSequenceMatrix\Decoder\JSMForcingStrategy.cs" />
     122    <Compile Include="JobSequenceMatrix\Decoder\JSMForcingStrategyTypes.cs" />
     123    <Compile Include="PriorityRulesVector\Decoder\PRVDecoder.cs" />
     124    <Compile Include="PermutationWithRepetition\Decoder\PWRDecoder.cs" />
     125    <Compile Include="ScheduleDecoder.cs" />
    118126    <Compile Include="Interfaces\IDirectScheduleOperator.cs" />
    119127    <Compile Include="Interfaces\IJSMOperator.cs" />
     
    123131    <Compile Include="Interfaces\IScheduleCrossover.cs" />
    124132    <Compile Include="Interfaces\ISchedule.cs" />
     133    <Compile Include="Interfaces\IScheduleDecoder.cs" />
    125134    <Compile Include="Interfaces\IScheduleEncoding.cs" />
    126135    <Compile Include="Interfaces\IScheduleManipulator.cs" />
     
    159168    <Compile Include="GTAlgorithmUtils.cs" />
    160169    <Compile Include="Job.cs" />
     170    <Compile Include="ScheduleEncoding\Decoder\DirectScheduleDecoder.cs" />
    161171    <Compile Include="ScheduleEncoding\DirectScheduleEncoding.cs" />
    162172    <Compile Include="ScheduleEncoding\Manipulators\DirectScheduleManipulator.cs" />
     
    181191      <Private>False</Private>
    182192    </ProjectReference>
     193    <ProjectReference Include="..\..\HeuristicLab.Common.Resources\3.3\HeuristicLab.Common.Resources-3.3.csproj">
     194      <Project>{0e27a536-1c4a-4624-a65e-dc4f4f23e3e1}</Project>
     195      <Name>HeuristicLab.Common.Resources-3.3</Name>
     196      <Private>False</Private>
     197    </ProjectReference>
    183198    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
    184199      <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
     
    229244      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    230245      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
     246      <Private>False</Private>
     247    </ProjectReference>
     248    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
     249      <Project>{f4539fb6-4708-40c9-be64-0a1390aea197}</Project>
     250      <Name>HeuristicLab.Random-3.3</Name>
    231251      <Private>False</Private>
    232252    </ProjectReference>
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IPRVOperator.cs

    r12012 r13443  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Data;
    2324
    2425namespace HeuristicLab.Encodings.ScheduleEncoding {
    2526  public interface IPRVOperator : IOperator {
    2627  }
     28
     29  public interface IPRVRulesOperator : IPRVOperator {
     30    ILookupParameter<IntValue> NumberOfRulesParameter { get; }
     31  }
    2732}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleDecoder.cs

    r13435 r13443  
    2323
    2424namespace HeuristicLab.Encodings.ScheduleEncoding {
    25   public interface IScheduleDecoder : IOperator {
     25  public interface IScheduleDecoder : IScheduleOperator {
    2626    ILookupParameter<ISchedule> ScheduleEncodingParameter { get; }
    2727    ILookupParameter<Schedule> ScheduleParameter { get; }
     28    ILookupParameter<ItemList<Job>> JobDataParameter { get; }
     29
     30    Schedule DecodeSchedule(ISchedule solution, ItemList<Job> jobData);
    2831  }
    2932}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleEncoding.cs

    r13437 r13443  
    3636    int Resources { get; set; }
    3737
     38
     39    Schedule Decode(ISchedule schedule, ItemList<Job> jobData);
     40  }
     41
     42  public interface IScheduleEncoding<TSchedule> : IEncoding<TSchedule>
     43    where TSchedule : class, ISchedule {
     44
    3845  }
    3946}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMJOXCrossover.cs

    r13437 r13443  
    4141
    4242    public static JSMEncoding Apply(IRandom random, JSMEncoding p1, JSMEncoding p2) {
    43       var result = new JSMEncoding();
     43      var result = new JSMEncoding(random.Next());
    4444
    4545      int nrOfResources = p1.JobSequenceMatrix.Count;
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMOXCrossover.cs

    r13437 r13443  
    3939
    4040    public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
    41       var result = new JSMEncoding();
     41      var result = new JSMEncoding(random.Next());
    4242
    4343      for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) {
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMSXXCrossover.cs

    r13437 r13443  
    4040
    4141    public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
    42       var result = new JSMEncoding();
     42      var result = new JSMEncoding(random.Next());
    4343      int subSequenceLength = random.Next(parent1.JobSequenceMatrix[0].Length);
    4444      for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) {
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Decoder/JSMDecoder.cs

    r13437 r13443  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Encodings.PermutationEncoding;
    28 using HeuristicLab.Encodings.ScheduleEncoding;
    29 using HeuristicLab.Optimization;
    3028using HeuristicLab.Parameters;
    3129using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     30using HeuristicLab.Random;
    3231
    33 namespace HeuristicLab.Problems.Scheduling {
     32namespace HeuristicLab.Encodings.ScheduleEncoding {
    3433  [Item("JobSequenceMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequence Matrix.")]
    3534  [StorableClass]
    36   public class JSMDecoder : ScheduleDecoder, IStochasticOperator, IJSSPOperator {
     35  public class JSMDecoder : ScheduleDecoder {
    3736
    38     public ILookupParameter<IRandom> RandomParameter {
    39       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    40     }
    41     public ILookupParameter<ItemList<Job>> JobDataParameter {
    42       get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
    43     }
    4437    public IValueParameter<JSMDecodingErrorPolicy> DecodingErrorPolicyParameter {
    4538      get { return (IValueParameter<JSMDecodingErrorPolicy>)Parameters["DecodingErrorPolicy"]; }
     
    6659    public JSMDecoder()
    6760      : base() {
    68       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    69       Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the Schedulingproblem - Instance."));
    7061      Parameters.Add(new ValueParameter<JSMDecodingErrorPolicy>("DecodingErrorPolicy", "Specify the policy that should be used to handle decoding errors.", new JSMDecodingErrorPolicy(JSMDecodingErrorPolicyTypes.RandomPolicy)));
    7162      Parameters.Add(new ValueParameter<JSMForcingStrategy>("ForcingStrategy", "Specifies a forcing strategy.", new JSMForcingStrategy(JSMForcingStrategyTypes.SwapForcing)));
    72 
    73       ScheduleEncodingParameter.ActualName = "JobSequenceMatrix";
    7463    }
    7564
    76     private Task SelectTaskFromConflictSet(int conflictedResourceNr, int progressOnConflictedResource, ItemList<Task> conflictSet, ItemList<Permutation> jsm) {
     65    private static Task SelectTaskFromConflictSet(JSMEncoding solution, JSMDecodingErrorPolicyTypes decodingErrorPolicy, JSMForcingStrategyTypes forcingStrategy, int conflictedResourceNr, int progressOnConflictedResource, ItemList<Task> conflictSet, IRandom random) {
    7766      if (conflictSet.Count == 1)
    7867        return conflictSet[0];
     68
     69      var jsm = solution.JobSequenceMatrix;
    7970
    8071      //get solutionCandidate from jobSequencingMatrix
     
    8879
    8980      //if solutionCandidate wasn't found in conflictSet apply DecodingErrorPolicy and ForcingPolicy
    90       Task result = ApplyDecodingErrorPolicy(conflictSet, jsm[conflictedResourceNr], progressOnConflictedResource);
     81      Task result = ApplyDecodingErrorPolicy(decodingErrorPolicy, conflictSet, jsm[conflictedResourceNr], progressOnConflictedResource, random);
    9182      int newResolutionIndex = 0;
    9283
    9384      while (newResolutionIndex < jsm[conflictedResourceNr].Length && jsm[conflictedResourceNr][newResolutionIndex] != result.JobNr)
    9485        newResolutionIndex++;
    95       ApplyForcingStrategy(jsm, conflictedResourceNr, newResolutionIndex, progressOnConflictedResource, result.JobNr);
     86      ApplyForcingStrategy(forcingStrategy, solution, conflictedResourceNr, newResolutionIndex, progressOnConflictedResource, result.JobNr);
    9687
    9788      return result;
    9889    }
    9990
    100     private Task ApplyDecodingErrorPolicy(ItemList<Task> conflictSet, Permutation resource, int progress) {
    101       if (DecodingErrorPolicy == JSMDecodingErrorPolicyTypes.RandomPolicy) {
     91    private static Task ApplyDecodingErrorPolicy(JSMDecodingErrorPolicyTypes decodingErrorPolicy, ItemList<Task> conflictSet, Permutation resource, int progress, IRandom random) {
     92      if (decodingErrorPolicy == JSMDecodingErrorPolicyTypes.RandomPolicy) {
    10293        //Random
    103         return conflictSet[RandomParameter.ActualValue.Next(conflictSet.Count - 1)];
     94        return conflictSet[random.Next(conflictSet.Count - 1)];
    10495      } else {
    10596        //Guided
     
    112103            return (conflictSet[j]);
    113104        }
    114         return conflictSet[RandomParameter.ActualValue.Next(conflictSet.Count - 1)];
     105        return conflictSet[random.Next(conflictSet.Count - 1)];
    115106      }
    116107    }
    117108
    118     private void ApplyForcingStrategy(ItemList<Permutation> jsm, int conflictedResource, int newResolutionIndex, int progressOnResource, int newResolution) {
    119       if (ForcingStrategy == JSMForcingStrategyTypes.SwapForcing) {
     109    private static void ApplyForcingStrategy(JSMForcingStrategyTypes forcingStrategy, JSMEncoding solution, int conflictedResource, int newResolutionIndex, int progressOnResource, int newResolution) {
     110      var jsm = solution.JobSequenceMatrix;
     111      if (forcingStrategy == JSMForcingStrategyTypes.SwapForcing) {
    120112        //SwapForcing
    121113        jsm[conflictedResource][newResolutionIndex] = jsm[conflictedResource][progressOnResource];
    122114        jsm[conflictedResource][progressOnResource] = newResolution;
    123       } else {
     115      } else if (forcingStrategy == JSMForcingStrategyTypes.ShiftForcing) {
    124116        //ShiftForcing
    125117        List<int> asList = jsm[conflictedResource].ToList<int>();
     
    132124        }
    133125        jsm[conflictedResource] = new Permutation(PermutationTypes.Absolute, asList.ToArray<int>());
     126      } else {
     127        throw new InvalidOperationException(string.Format("JSMDecoder encountered unknown forcing strategy {0}", forcingStrategy));
    134128      }
    135129    }
    136130
    137     public Schedule CreateScheduleFromEncoding(JSMEncoding solution, ItemList<Job> jobData) {
    138       ItemList<Permutation> jobSequenceMatrix = solution.JobSequenceMatrix;
     131    public override Schedule DecodeSchedule(ISchedule encoding, ItemList<Job> jobData) {
     132      var solution = encoding as JSMEncoding;
     133      if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
     134      return DecodeSchedule(solution, jobData, DecodingErrorPolicy, ForcingStrategy);
     135    }
    139136
     137    public static Schedule DecodeSchedule(JSMEncoding solution, ItemList<Job> jobData, JSMDecodingErrorPolicyTypes decodingErrorPolicy, JSMForcingStrategyTypes forcingStrategy) {
     138      var random = new FastRandom(solution.RandomSeed);
    140139      var jobs = (ItemList<Job>)jobData.Clone();
    141140      var resultingSchedule = new Schedule(jobs[0].Tasks.Count);
     
    162161        //STEP 3 - Select a task from the conflict set
    163162        int progressOnResource = conflictedResource.Tasks.Count;
    164         Task selectedTask = SelectTaskFromConflictSet(conflictedResourceNr, progressOnResource, conflictSet, jobSequenceMatrix);
     163        Task selectedTask = SelectTaskFromConflictSet(solution, decodingErrorPolicy, forcingStrategy, conflictedResourceNr, progressOnResource, conflictSet, random);
    165164
    166165        //STEP 4 - Add the selected task to the current schedule
     
    175174      return resultingSchedule;
    176175    }
    177 
    178     public override Schedule CreateScheduleFromEncoding(ISchedule encoding) {
    179       var solution = encoding as JSMEncoding;
    180       if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
    181       return CreateScheduleFromEncoding(solution, JobDataParameter.ActualValue);
    182     }
    183176  }
    184177}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Decoder/JSMDecodingErrorPolicy.cs

    r13434 r13443  
    2222using System.Drawing;
    2323using HeuristicLab.Common;
     24using HeuristicLab.Common.Resources;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728
    28 namespace HeuristicLab.Problems.Scheduling {
     29namespace HeuristicLab.Encodings.ScheduleEncoding {
    2930  [Item("JSMDecodingErrorPolicy", "Represents a policy for handling decoding errors.")]
    3031  [StorableClass]
     
    3233
    3334    public static new Image StaticItemImage {
    34       get { return HeuristicLab.Common.Resources.VSImageLibrary.Enum; }
     35      get { return VSImageLibrary.Enum; }
    3536    }
    3637
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Decoder/JSMDecodingErrorPolicyTypes.cs

    r13434 r13443  
    2020#endregion
    2121
    22 namespace HeuristicLab.Problems.Scheduling {
     22namespace HeuristicLab.Encodings.ScheduleEncoding {
    2323  public enum JSMDecodingErrorPolicyTypes {
    2424    RandomPolicy,
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Decoder/JSMForcingStrategy.cs

    r13434 r13443  
    2222using System.Drawing;
    2323using HeuristicLab.Common;
     24using HeuristicLab.Common.Resources;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
    2627using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2728
    28 namespace HeuristicLab.Problems.Scheduling {
     29namespace HeuristicLab.Encodings.ScheduleEncoding {
    2930  [Item("JSMForcingStrategy", "Represents a forcing strategy.")]
    3031  [StorableClass]
     
    3233
    3334    public static new Image StaticItemImage {
    34       get { return HeuristicLab.Common.Resources.VSImageLibrary.Enum; }
     35      get { return VSImageLibrary.Enum; }
    3536    }
    3637
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Decoder/JSMForcingStrategyTypes.cs

    r13434 r13443  
    2020#endregion
    2121
    22 namespace HeuristicLab.Problems.Scheduling {
     22namespace HeuristicLab.Encodings.ScheduleEncoding {
    2323  public enum JSMForcingStrategyTypes {
    2424    ShiftForcing,
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMEncoding.cs

    r13437 r13443  
    3232
    3333    [Storable]
    34     public ItemList<Permutation> JobSequenceMatrix { get; set; }
     34    public ItemList<Permutation> JobSequenceMatrix { get; private set; }
     35    [Storable]
     36    public int RandomSeed { get; private set; }
    3537
    3638    [StorableConstructor]
     
    3941      : base(original, cloner) {
    4042      this.JobSequenceMatrix = cloner.Clone(original.JobSequenceMatrix);
     43      this.RandomSeed = original.RandomSeed;
    4144    }
    4245    public override IDeepCloneable Clone(Cloner cloner) {
    4346      return new JSMEncoding(this, cloner);
    4447    }
    45     public JSMEncoding()
     48    public JSMEncoding(int randomSeed)
    4649      : base() {
     50      RandomSeed = randomSeed;
    4751      JobSequenceMatrix = new ItemList<Permutation>();
    4852    }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMRandomCreator.cs

    r13437 r13443  
    4949
    5050    public static JSMEncoding Apply(int jobs, int resources, IRandom random) {
    51       var solution = new JSMEncoding();
     51      var solution = new JSMEncoding(random.Next());
    5252      for (int i = 0; i < resources; i++) {
    5353        solution.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, jobs, random));
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JobSequenceMatrixEncoding.cs

    r13437 r13443  
    2727using HeuristicLab.Common;
    2828using HeuristicLab.Core;
    29 using HeuristicLab.Encodings.ScheduleEncoding;
    3029using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3130using HeuristicLab.PluginInfrastructure;
    3231
    33 namespace HeuristicLab.Encodings.Schedule {
     32namespace HeuristicLab.Encodings.ScheduleEncoding {
    3433  [StorableClass]
    35   public sealed class JobSequenceMatrixEncoding : ScheduleEncoding {
     34  public sealed class JobSequenceMatrixEncoding : ScheduleEncoding<JSMEncoding> {
    3635    [StorableConstructor]
    3736    private JobSequenceMatrixEncoding(bool deserializing) : base(deserializing) { }
     
    4443      : base() {
    4544      SolutionCreator = new JSMRandomCreator();
     45      Decoder = new JSMDecoder();
    4646      DiscoverOperators();
    4747    }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Decoder/PWRDecoder.cs

    r13437 r13443  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.Encodings.ScheduleEncoding;
    26 using HeuristicLab.Optimization;
    27 using HeuristicLab.Parameters;
    2825using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2926
    30 namespace HeuristicLab.Problems.Scheduling {
     27namespace HeuristicLab.Encodings.ScheduleEncoding {
    3128  [Item("PWRDecoder", "An item used to convert a PWR-individual into a generalized schedule.")]
    3229  [StorableClass]
    33   public class PWRDecoder : ScheduleDecoder, IStochasticOperator, IJSSPOperator {
    34 
    35     public ILookupParameter<IRandom> RandomParameter {
    36       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    37     }
    38     public ILookupParameter<ItemList<Job>> JobDataParameter {
    39       get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
    40     }
    41 
     30  public class PWRDecoder : ScheduleDecoder {
    4231    [StorableConstructor]
    4332    protected PWRDecoder(bool deserializing) : base(deserializing) { }
    4433    protected PWRDecoder(PWRDecoder original, Cloner cloner) : base(original, cloner) { }
    45     public PWRDecoder()
    46       : base() {
    47       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    48       Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance."));
    49       ScheduleEncodingParameter.ActualName = "PermutationWithRepetition";
    50     }
     34    public PWRDecoder() : base() { }
    5135
    5236    public override IDeepCloneable Clone(Cloner cloner) {
     
    5438    }
    5539
    56     public override Schedule CreateScheduleFromEncoding(ISchedule encoding) {
    57       var solution = encoding as PWREncoding;
    58       if (solution == null) throw new InvalidOperationException("Encoding is not of type PWREncoding");
     40    public override Schedule DecodeSchedule(ISchedule solution, ItemList<Job> jobData) {
     41      var pwr = solution as PWREncoding;
     42      if (pwr == null) throw new InvalidOperationException("Encoding is not of type PWREncoding");
     43      return DecodeSchedule(pwr, jobData);
     44    }
    5945
    60       var jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
     46    public static Schedule DecodeSchedule(PWREncoding solution, ItemList<Job> jobData) {
     47      var jobs = (ItemList<Job>)jobData.Clone();
    6148      var resultingSchedule = new Schedule(jobs[0].Tasks.Count);
    6249      foreach (int jobNr in solution.PermutationWithRepetition) {
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PermutationWithRepetitionEncoding.cs

    r13437 r13443  
    2727using HeuristicLab.Common;
    2828using HeuristicLab.Core;
    29 using HeuristicLab.Encodings.ScheduleEncoding;
    3029using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3130using HeuristicLab.PluginInfrastructure;
    3231
    33 namespace HeuristicLab.Encodings.Schedule {
     32namespace HeuristicLab.Encodings.ScheduleEncoding {
    3433  [StorableClass]
    35   public sealed class PermutationWithRepetitionEncoding : ScheduleEncoding {
     34  public sealed class PermutationWithRepetitionEncoding : ScheduleEncoding<PWREncoding> {
    3635    [StorableConstructor]
    3736    private PermutationWithRepetitionEncoding(bool deserializing) : base(deserializing) { }
     
    4443      : base() {
    4544      SolutionCreator = new PWRRandomCreator();
     45      Decoder = new PWRDecoder();
    4646      DiscoverOperators();
    4747    }
     48
    4849
    4950    #region Operator Discovery
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVDiscreteCrossover.cs

    r13437 r13443  
    4040
    4141    public static PRVEncoding Apply(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {
    42       return new PRVEncoding(DiscreteCrossover.Apply(random, new ItemArray<IntegerVector>(new IntegerVector[] { parent1.PriorityRulesVector, parent2.PriorityRulesVector })), parent1.NrOfRules);
     42      var randomSeed = random.Next();
     43      var integerVector = DiscreteCrossover.Apply(random, new ItemArray<IntegerVector>(new[] { parent1.PriorityRulesVector, parent2.PriorityRulesVector }));
     44      return new PRVEncoding(integerVector, randomSeed);
    4345    }
    4446
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVSinglePointCrossover.cs

    r13437 r13443  
    4040
    4141    public static PRVEncoding Apply(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {
    42       return new PRVEncoding(SinglePointCrossover.Apply(random, parent1.PriorityRulesVector, parent2.PriorityRulesVector), parent1.NrOfRules);
     42      var randomSeed = random.Next();
     43      var integerVector = SinglePointCrossover.Apply(random, parent1.PriorityRulesVector, parent2.PriorityRulesVector);
     44      return new PRVEncoding(integerVector, randomSeed);
    4345    }
    4446
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Decoder/PRVDecoder.cs

    r13437 r13443  
    2121
    2222using System;
     23using System.Linq;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Encodings.ScheduleEncoding;
    26 using HeuristicLab.Optimization;
    27 using HeuristicLab.Parameters;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    29 
    30 namespace HeuristicLab.Problems.Scheduling {
     28using HeuristicLab.Random;
     29
     30namespace HeuristicLab.Encodings.ScheduleEncoding {
    3131  [Item("JobSequencingMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")]
    3232  [StorableClass]
    33   public class PRVDecoder : ScheduleDecoder, IStochasticOperator, IJSSPOperator {
    34 
    35     public ILookupParameter<IRandom> RandomParameter {
    36       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    37     }
    38     public ILookupParameter<ItemList<Job>> JobDataParameter {
    39       get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
    40     }
    41 
     33  public class PRVDecoder : ScheduleDecoder {
    4234    #region Priority Rules
    4335    //smallest number of remaining tasks
    44     private Task FILORule(ItemList<Task> tasks) {
     36    private static Task FILORule(ItemList<Task> tasks) {
    4537      Task currentResult = tasks[tasks.Count - 1];
    4638      return currentResult;
     
    4840
    4941    //earliest start time
    50     private Task ESTRule(ItemList<Task> tasks, Schedule schedule) {
    51       Task currentResult = RandomRule(tasks);
     42    private static Task ESTRule(ItemList<Task> tasks, Schedule schedule) {
     43      Task currentResult = tasks.First();
    5244      double currentEST = double.MaxValue;
    5345      foreach (Task t in tasks) {
     
    6254
    6355    //shortest processingtime
    64     private Task SPTRule(ItemList<Task> tasks) {
    65       Task currentResult = RandomRule(tasks);
     56    private static Task SPTRule(ItemList<Task> tasks) {
     57      Task currentResult = tasks.First();
    6658      foreach (Task t in tasks) {
    6759        if (t.Duration < currentResult.Duration)
     
    7264
    7365    //longest processing time   
    74     private Task LPTRule(ItemList<Task> tasks) {
    75       Task currentResult = RandomRule(tasks);
     66    private static Task LPTRule(ItemList<Task> tasks) {
     67      Task currentResult = tasks.First();
    7668      foreach (Task t in tasks) {
    7769        if (t.Duration > currentResult.Duration)
     
    8274
    8375    //most work remaining
    84     private Task MWRRule(ItemList<Task> tasks, ItemList<Job> jobs) {
    85       Task currentResult = RandomRule(tasks);
     76    private static Task MWRRule(ItemList<Task> tasks, ItemList<Job> jobs) {
     77      Task currentResult = tasks.First();
    8678      double currentLargestRemainingProcessingTime = 0;
    8779      foreach (Task t in tasks) {
     
    10092
    10193    //least work remaining
    102     private Task LWRRule(ItemList<Task> tasks, ItemList<Job> jobs) {
    103       Task currentResult = RandomRule(tasks);
     94    private static Task LWRRule(ItemList<Task> tasks, ItemList<Job> jobs) {
     95      Task currentResult = tasks.First();
    10496      double currentSmallestRemainingProcessingTime = double.MaxValue;
    10597      foreach (Task t in tasks) {
     
    118110
    119111    //most operations remaining
    120     private Task MORRule(ItemList<Task> tasks, ItemList<Job> jobs) {
    121       Task currentResult = RandomRule(tasks);
     112    private static Task MORRule(ItemList<Task> tasks, ItemList<Job> jobs) {
     113      Task currentResult = tasks.First();
    122114      int currentLargestNrOfRemainingTasks = 0;
    123115      foreach (Task t in tasks) {
     
    136128
    137129    //least operationsremaining
    138     private Task LORRule(ItemList<Task> tasks, ItemList<Job> jobs) {
    139       Task currentResult = RandomRule(tasks);
     130    private static Task LORRule(ItemList<Task> tasks, ItemList<Job> jobs) {
     131      Task currentResult = tasks.First();
    140132      int currentSmallestNrOfRemainingTasks = int.MaxValue;
    141133      foreach (Task t in tasks) {
     
    154146
    155147    //first operation in Queue
    156     private Task FIFORule(ItemList<Task> tasks) {
     148    private static Task FIFORule(ItemList<Task> tasks) {
    157149      Task currentResult = tasks[0];
    158150      return currentResult;
     
    160152
    161153    //random
    162     private Task RandomRule(ItemList<Task> tasks) {
    163       Task currentResult = tasks[RandomParameter.ActualValue.Next(tasks.Count)];
     154    private static Task RandomRule(ItemList<Task> tasks, IRandom random) {
     155      Task currentResult = tasks[random.Next(tasks.Count)];
    164156      return currentResult;
    165157    }
     
    170162    protected PRVDecoder(bool deserializing) : base(deserializing) { }
    171163    protected PRVDecoder(PRVDecoder original, Cloner cloner) : base(original, cloner) { }
    172     public PRVDecoder()
    173       : base() {
    174       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    175       Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the SchedulingProblem - Instance."));
    176       ScheduleEncodingParameter.ActualName = "PriorityRulesVector";
    177     }
     164    public PRVDecoder() : base() { }
    178165
    179166    public override IDeepCloneable Clone(Cloner cloner) {
     
    181168    }
    182169
    183     private Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, int ruleIndex, int nrOfRules, Schedule schedule, ItemList<Job> jobs) {
     170    private static Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, int ruleIndex, Schedule schedule, ItemList<Job> jobs, IRandom random) {
    184171      if (conflictSet.Count == 1)
    185172        return conflictSet[0];
    186173
    187       ruleIndex = ruleIndex % nrOfRules;
     174      //TODO change to property, Encoding parameter?
     175      ruleIndex = ruleIndex % 10;
    188176      switch (ruleIndex) {
    189177        case 0: return FILORule(conflictSet);
     
    196184        case 7: return LORRule(conflictSet, jobs);
    197185        case 8: return FIFORule(conflictSet);
    198         case 9: return RandomRule(conflictSet);
    199         default: return RandomRule(conflictSet);
    200       }
    201     }
    202 
    203     public override Schedule CreateScheduleFromEncoding(ISchedule encoding) {
     186        case 9: return RandomRule(conflictSet, random);
     187        default: return RandomRule(conflictSet, random);
     188      }
     189    }
     190
     191    public override Schedule DecodeSchedule(ISchedule encoding, ItemList<Job> jobData) {
    204192      var solution = encoding as PRVEncoding;
    205193      if (solution == null) throw new InvalidOperationException("Encoding is not of type PRVEncoding");
    206 
    207       var jobs = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
     194      return DecodeSchedule(solution, jobData);
     195    }
     196
     197    public static Schedule DecodeSchedule(PRVEncoding solution, ItemList<Job> jobData) {
     198      var random = new FastRandom(solution.RandomSeed);
     199      var jobs = (ItemList<Job>)jobData.Clone();
    208200      var resultingSchedule = new Schedule(jobs[0].Tasks.Count);
    209201
     
    228220        //STEP 3 - Select an operation from the conflict set (various methods depending on how the algorithm should work..)
    229221        //Task selectedTask = SelectTaskFromConflictSet(conflictSet, solution.PriorityRulesVector [currentDecisionIndex++], solution.NrOfRules.Value);
    230         Task selectedTask = SelectTaskFromConflictSet(conflictSet, solution.PriorityRulesVector[minimal.JobNr], solution.NrOfRules, resultingSchedule, jobs);
     222        Task selectedTask = SelectTaskFromConflictSet(conflictSet, solution.PriorityRulesVector[minimal.JobNr], resultingSchedule, jobs, random);
    231223
    232224        //STEP 4 - Adding the selected operation to the current schedule
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Manipulators/PRVManipulator.cs

    r13437 r13443  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Data;
     26using HeuristicLab.Parameters;
    2527using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2628
     
    2830  [Item("PRVManipulator", "An operator which manipulates a PRV representation.")]
    2931  [StorableClass]
    30   public abstract class PRVManipulator : ScheduleManipulator, IPRVOperator {
     32  public abstract class PRVManipulator : ScheduleManipulator, IPRVRulesOperator {
     33
     34    public ILookupParameter<IntValue> NumberOfRulesParameter {
     35      get { return (ILookupParameter<IntValue>)Parameters["NumberOfRulesParameter"]; }
     36    }
     37
     38
    3139    [StorableConstructor]
    3240    protected PRVManipulator(bool deserializing) : base(deserializing) { }
    3341    protected PRVManipulator(PRVManipulator original, Cloner cloner) : base(original, cloner) { }
    34     public PRVManipulator() : base() { }
    3542
    36     protected abstract void Manipulate(IRandom random, PRVEncoding individual);
     43    public PRVManipulator()
     44      : base() {
     45      Parameters.Add(new LookupParameter<IntValue>("NumberOfRulesParameter"));
     46    }
     47
     48    protected abstract void Manipulate(IRandom random, PRVEncoding individual, int numberOfRules);
    3749
    3850    public override IOperation InstrumentedApply() {
    3951      var solution = ScheduleParameter.ActualValue as PRVEncoding;
    4052      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type PRVEncoding.");
    41       Manipulate(RandomParameter.ActualValue, solution);
     53      Manipulate(RandomParameter.ActualValue, solution, NumberOfRulesParameter.ActualValue.Value);
    4254      return base.InstrumentedApply();
    4355    }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Manipulators/PRVUniformOnePositionManipulator.cs

    r13437 r13443  
    4040    }
    4141
    42     public static void Apply(IRandom random, PRVEncoding individual) {
    43       UniformOnePositionManipulator.Apply(random, individual.PriorityRulesVector, new IntMatrix(new int[,] { { 0, individual.NrOfRules } }));
     42    public static void Apply(IRandom random, PRVEncoding individual, int numberOfRules) {
     43      UniformOnePositionManipulator.Apply(random, individual.PriorityRulesVector, new IntMatrix(new int[,] { { 0, numberOfRules } }));
    4444    }
    4545
    46     protected override void Manipulate(IRandom random, PRVEncoding individual) {
    47       Apply(random, individual);
     46    protected override void Manipulate(IRandom random, PRVEncoding individual, int numberOfRules) {
     47      Apply(random, individual, numberOfRules);
    4848    }
    4949  }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVEncoding.cs

    r13437 r13443  
    3131  public class PRVEncoding : Item, ISchedule {
    3232    [Storable]
    33     public IntegerVector PriorityRulesVector { get; set; }
    34 
     33    public IntegerVector PriorityRulesVector { get; private set; }
    3534    [Storable]
    36     public int NrOfRules { get; private set; }
     35    public int RandomSeed { get; private set; }
    3736
    3837    [StorableConstructor]
     
    4039    protected PRVEncoding(PRVEncoding original, Cloner cloner)
    4140      : base(original, cloner) {
    42       this.NrOfRules = original.NrOfRules;
    4341      this.PriorityRulesVector = cloner.Clone(original.PriorityRulesVector);
     42      this.RandomSeed = original.RandomSeed;
    4443    }
    45     public PRVEncoding(int nrOfRules)
     44
     45    public PRVEncoding(IntegerVector iv, int randomSeed)
    4646      : base() {
    47       this.NrOfRules = nrOfRules;
    48       this.PriorityRulesVector = new IntegerVector();
    49     }
    50     public PRVEncoding(IntegerVector iv, int nrOfRules)
    51       : base() {
    52       this.NrOfRules = nrOfRules;
     47      this.RandomSeed = randomSeed;
    5348      this.PriorityRulesVector = (IntegerVector)iv.Clone();
    5449    }
    55     public PRVEncoding(int length, IRandom random, int min, int max, int nrOfRules)
     50    public PRVEncoding(int length, IRandom random, int min, int max)
    5651      : base() {
    57       this.NrOfRules = nrOfRules;
     52      this.RandomSeed = random.Next();
    5853      this.PriorityRulesVector = new IntegerVector(length, random, min, max);
    5954    }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVRandomCreator.cs

    r13437 r13443  
    5555
    5656    public static PRVEncoding Apply(int jobs, int resources, IRandom random, int nrOfRules) {
    57       return new PRVEncoding(jobs * resources, random, 0, nrOfRules, nrOfRules);
     57      return new PRVEncoding(jobs * resources, random, 0, nrOfRules);
    5858    }
    5959
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PriorityRulesVectorEncoding.cs

    r13437 r13443  
    2727using HeuristicLab.Common;
    2828using HeuristicLab.Core;
    29 using HeuristicLab.Encodings.ScheduleEncoding;
     29using HeuristicLab.Data;
     30using HeuristicLab.Parameters;
    3031using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3132using HeuristicLab.PluginInfrastructure;
    3233
    33 namespace HeuristicLab.Encodings.Schedule {
     34namespace HeuristicLab.Encodings.ScheduleEncoding {
    3435  [StorableClass]
    35   public sealed class PriorityRulesVectorEncoding : ScheduleEncoding {
     36  public sealed class PriorityRulesVectorEncoding : ScheduleEncoding<PRVEncoding> {
     37
     38    private IFixedValueParameter<IntValue> numberOfRulesParameter;
     39    public IFixedValueParameter<IntValue> NumberOfRulesParameter {
     40      get { return numberOfRulesParameter; }
     41      set {
     42        if (value == null) throw new ArgumentNullException("Number of Rules parameter must not be null.");
     43        if (value.Value == null) throw new ArgumentNullException("Number of Rules parameter value must not be null.");
     44        if (numberOfRulesParameter == value) return;
     45
     46        if (numberOfRulesParameter != null) Parameters.Remove(numberOfRulesParameter);
     47        numberOfRulesParameter = value;
     48        Parameters.Add(numberOfRulesParameter);
     49        OnNumberOfRulesParameterChanged();
     50      }
     51    }
     52
     53
    3654    [StorableConstructor]
    3755    private PriorityRulesVectorEncoding(bool deserializing) : base(deserializing) { }
     
    4361    public PriorityRulesVectorEncoding()
    4462      : base() {
     63      //TODO change to meaningful value
     64      numberOfRulesParameter = new FixedValueParameter<IntValue>(Name + ".NumberOfRules", new IntValue(10));
     65      Parameters.Add(numberOfRulesParameter);
     66
    4567      SolutionCreator = new PRVRandomCreator();
     68      Decoder = new PRVDecoder();
    4669      DiscoverOperators();
     70    }
     71
     72    private void OnNumberOfRulesParameterChanged() {
     73      ConfigureOperators(Operators);
    4774    }
    4875
     
    6491        AddOperator(@operator);
    6592    }
     93
     94    public override void ConfigureOperators(IEnumerable<IItem> operators) {
     95      base.ConfigureOperators(operators);
     96      ConfigureRulesParameter(operators.OfType<IPRVRulesOperator>());
     97    }
     98
     99    private void ConfigureRulesParameter(IEnumerable<IPRVRulesOperator> rulesOperators) {
     100      foreach (var rulesOperator in rulesOperators)
     101        rulesOperator.NumberOfRulesParameter.ActualName = numberOfRulesParameter.Name;
     102    }
     103
    66104    #endregion
    67105  }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleDecoder.cs

    r13435 r13443  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Encodings.ScheduleEncoding;
    2524using HeuristicLab.Operators;
    2625using HeuristicLab.Parameters;
    2726using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827
    29 namespace HeuristicLab.Problems.Scheduling {
     28namespace HeuristicLab.Encodings.ScheduleEncoding {
    3029  [Item("ScheduleDecoder", "A schedule decoder translates a respresentation into an actual schedule.")]
    3130  [StorableClass]
     
    3332
    3433    public ILookupParameter<ISchedule> ScheduleEncodingParameter {
    35       get { return (ILookupParameter<ISchedule>)Parameters["ScheduleEncoding"]; }
     34      get { return (ILookupParameter<ISchedule>)Parameters["EncodedSchedule"]; }
    3635    }
    3736    public ILookupParameter<Schedule> ScheduleParameter {
    3837      get { return (ILookupParameter<Schedule>)Parameters["Schedule"]; }
     38    }
     39    public ILookupParameter<ItemList<Job>> JobDataParameter {
     40      get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
    3941    }
    4042
     
    4446    public ScheduleDecoder()
    4547      : base() {
    46       Parameters.Add(new LookupParameter<ISchedule>("ScheduleEncoding", "The new scheduling solution represented as encoding."));
     48      Parameters.Add(new LookupParameter<ISchedule>("EncodedSchedule", "The new scheduling solution represented as encoding."));
    4749      Parameters.Add(new LookupParameter<Schedule>("Schedule", "The decoded scheduling solution represented as generalized schedule."));
     50      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance."));
    4851    }
    4952
    50     public abstract Schedule CreateScheduleFromEncoding(ISchedule solution);
     53    public abstract Schedule DecodeSchedule(ISchedule solution, ItemList<Job> jobData);
    5154
    5255    public override IOperation Apply() {
    53       Schedule result = CreateScheduleFromEncoding(ScheduleEncodingParameter.ActualValue);
     56      Schedule result = DecodeSchedule(ScheduleEncodingParameter.ActualValue, JobDataParameter.ActualValue);
    5457      ScheduleParameter.ActualValue = result;
    5558      return base.Apply();
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding.cs

    r13437 r13443  
    2828using HeuristicLab.Core;
    2929using HeuristicLab.Data;
    30 using HeuristicLab.Encodings.ScheduleEncoding;
    3130using HeuristicLab.Optimization;
    3231using HeuristicLab.Parameters;
    3332using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3433
    35 namespace HeuristicLab.Encodings.Schedule {
     34namespace HeuristicLab.Encodings.ScheduleEncoding {
    3635  [StorableClass]
    37   public abstract class ScheduleEncoding : Encoding<ISchedule>, IScheduleEncoding {
     36  public abstract class ScheduleEncoding<TSchedule> : Encoding<ISchedule>, IScheduleEncoding
     37  where TSchedule : class, ISchedule {
    3838    #region Encoding Parameters
    3939    [Storable]
     
    8383      }
    8484    }
     85
     86    [Storable]
     87    private IValueParameter<IScheduleDecoder> decoderParameter;
     88
     89    public IValueParameter<IScheduleDecoder> DecoderParameter {
     90      get { return decoderParameter; }
     91      set {
     92        if (value == null) throw new ArgumentNullException("Decoder parameter must not be null.");
     93        if (value.Value == null) throw new ArgumentNullException("Decoder parameter value must not be null.");
     94        if (decoderParameter == value) return;
     95
     96        if (decoderParameter != null) Parameters.Remove(decoderParameter);
     97        decoderParameter = value;
     98        Parameters.Add(decoderParameter);
     99        OnDecoderParameterChanged();
     100      }
     101    }
    85102    #endregion
    86103
     
    97114    }
    98115
     116    public IScheduleDecoder Decoder {
     117      get { return DecoderParameter.Value; }
     118      set { DecoderParameter.Value = value; }
     119    }
    99120
    100121    [StorableConstructor]
    101122    protected ScheduleEncoding(bool deserializing) : base(deserializing) { }
    102     protected ScheduleEncoding(ScheduleEncoding original, Cloner cloner)
     123    protected ScheduleEncoding(ScheduleEncoding<TSchedule> original, Cloner cloner)
    103124      : base(original, cloner) {
    104125    }
     
    114135      jobsParameter = new FixedValueParameter<IntValue>(Name + ".Jobs", new IntValue(jobs));
    115136      resourcesParameter = new FixedValueParameter<IntValue>(Name + ".Resources", new IntValue(resources));
     137      decoderParameter = new ValueParameter<IScheduleDecoder>(Name + ".Decoder");
    116138
    117139      Parameters.Add(jobDataParameter);
    118140      Parameters.Add(jobsParameter);
    119141      Parameters.Add(resourcesParameter);
     142      Parameters.Add(decoderParameter);
     143    }
     144
     145    public Schedule Decode(ISchedule schedule, ItemList<Job> jobData) {
     146      return Decoder.DecodeSchedule(schedule, jobData);
    120147    }
    121148
     
    127154    }
    128155    private void OnBoundsParameterChanged() {
     156      ConfigureOperators(Operators);
     157    }
     158
     159    private void OnDecoderParameterChanged() {
    129160      ConfigureOperators(Operators);
    130161    }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers/DirectScheduleCrossover.cs

    r13437 r13443  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Encodings.ScheduleEncoding.ScheduleEncoding {
     27namespace HeuristicLab.Encodings.ScheduleEncoding {
    2828  [Item("DirectScheduleCrossover", "An operator which crosses two schedule representations.")]
    2929  [StorableClass]
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers/DirectScheduleGTCrossover.cs

    r13437 r13443  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Encodings.ScheduleEncoding.ScheduleEncoding {
     28namespace HeuristicLab.Encodings.ScheduleEncoding {
    2929  [Item("DirectScheduleGTCrossover", "Represents a crossover using the GT-Algorithm to cross two direct schedule representations.")]
    3030  [StorableClass]
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleEncoding.cs

    r13437 r13443  
    2727using HeuristicLab.Common;
    2828using HeuristicLab.Core;
    29 using HeuristicLab.Encodings.ScheduleEncoding;
    3029using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3130using HeuristicLab.PluginInfrastructure;
    3231
    33 namespace HeuristicLab.Encodings.Schedule {
     32namespace HeuristicLab.Encodings.ScheduleEncoding {
    3433  [StorableClass]
    35   public sealed class DirectScheduleEncoding : ScheduleEncoding {
     34  public sealed class DirectScheduleEncoding : ScheduleEncoding<Schedule> {
    3635    [StorableConstructor]
    3736    private DirectScheduleEncoding(bool deserializing) : base(deserializing) { }
     
    4443      : base() {
    4544      SolutionCreator = new DirectScheduleRandomCreator();
     45      Decoder = new DirectScheduleDecoder();
    4646      DiscoverOperators();
    4747    }
     48
    4849
    4950    #region Operator Discovery
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleRandomCreator.cs

    r13437 r13443  
    2020#endregion
    2121
    22 using System;
    2322using HeuristicLab.Common;
    2423using HeuristicLab.Core;
     
    5554
    5655
    57     public static Schedule Apply(int jobs, int resources, PWREncoding pwr, ItemList<Job> jobData) {
     56    public static Schedule Apply(PWREncoding pwr, ItemList<Job> jobData) {
    5857      var resultingSchedule = new Schedule(jobData[0].Tasks.Count);
    5958      foreach (int jobNr in pwr.PermutationWithRepetition) {
     
    7170
    7271    protected override ISchedule CreateSolution() {
    73       try {
    74         var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
    75         return Apply(JobsParameter.ActualValue.Value,
    76           ResourcesParameter.ActualValue.Value,
    77           new PWREncoding(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue),
    78           jobData);
    79       }
    80       catch {
    81         throw new Exception("ScheduleRandomCreator needs JobData parameter from a JSSP-Instance to create Schedule-Instances!");
    82       }
     72      var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
     73      var pwrEncoding = new PWREncoding(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value,
     74        RandomParameter.ActualValue);
     75      return Apply(pwrEncoding, jobData);
    8376    }
    8477  }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Manipulators/DirectScheduleManipulator.cs

    r13437 r13443  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Encodings.ScheduleEncoding.ScheduleEncoding {
     28namespace HeuristicLab.Encodings.ScheduleEncoding {
    2929  [Item("DirectScheduleManipulator", "An operator which manipulates a direct schedule representation.")]
    3030  [StorableClass]
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling.Views/3.3/JSMDecodingErrorPolicyView.cs

    r12012 r13443  
    2323using System.Windows.Forms;
    2424using HeuristicLab.Core.Views;
     25using HeuristicLab.Encodings.ScheduleEncoding;
    2526using HeuristicLab.MainForm;
    2627
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling.Views/3.3/JSMForcingStrategyView.cs

    r12012 r13443  
    2323using System.Windows.Forms;
    2424using HeuristicLab.Core.Views;
     25using HeuristicLab.Encodings.ScheduleEncoding;
    2526using HeuristicLab.MainForm;
    2627
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.Designer.cs

    r12012 r13443  
    1 #region License Information
    2 /* HeuristicLab
    3  * Copyright (C) 2002-2015 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
     1//#region License Information
     2///* HeuristicLab
     3// * Copyright (C) 2002-2015 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
    2121
    22 using HeuristicLab.Encodings.ScheduleEncoding.Views;
    23 namespace HeuristicLab.Problems.Scheduling.Views {
    24   partial class JobShopSchedulingProblemView {
    25     /// <summary>
    26     /// Required designer variable.
    27     /// </summary>
    28     private System.ComponentModel.IContainer components = null;
     22//using HeuristicLab.Encodings.ScheduleEncoding.Views;
     23//namespace HeuristicLab.Problems.Scheduling.Views {
     24//  partial class JobShopSchedulingProblemView {
     25//    /// <summary>
     26//    /// Required designer variable.
     27//    /// </summary>
     28//    private System.ComponentModel.IContainer components = null;
    2929
    30     /// <summary>
    31     /// Clean up any resources being used.
    32     /// </summary>
    33     /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    34     protected override void Dispose(bool disposing) {
    35       if (disposing && (components != null)) {
    36         components.Dispose();
    37       }
    38       base.Dispose(disposing);
    39     }
     30//    /// <summary>
     31//    /// Clean up any resources being used.
     32//    /// </summary>
     33//    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
     34//    protected override void Dispose(bool disposing) {
     35//      if (disposing && (components != null)) {
     36//        components.Dispose();
     37//      }
     38//      base.Dispose(disposing);
     39//    }
    4040
    41     #region Component Designer generated code
     41//    #region Component Designer generated code
    4242
    43     /// <summary>
    44     /// Required method for Designer support - do not modify
    45     /// the contents of this method with the code editor.
    46     /// </summary>
    47     private void InitializeComponent() {
    48       this.problemTabControl = new System.Windows.Forms.TabControl();
    49       this.problemTabPage = new System.Windows.Forms.TabPage();
    50       this.visualizationTabPage = new System.Windows.Forms.TabPage();
    51       this.ganttChart = new HeuristicLab.Encodings.ScheduleEncoding.Views.GanttChart();
    52       ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).BeginInit();
    53       this.problemInstanceSplitContainer.Panel1.SuspendLayout();
    54       this.problemInstanceSplitContainer.Panel2.SuspendLayout();
    55       this.problemInstanceSplitContainer.SuspendLayout();
    56       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    57       this.problemTabControl.SuspendLayout();
    58       this.problemTabPage.SuspendLayout();
    59       this.visualizationTabPage.SuspendLayout();
    60       this.SuspendLayout();
    61       //
    62       // problemInstanceSplitContainer.Panel2
    63       //
    64       this.problemInstanceSplitContainer.Panel2.Controls.Add(this.problemTabControl);
    65       //
    66       // parameterCollectionView
    67       //
    68       this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
    69       this.parameterCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;
    70       this.parameterCollectionView.Location = new System.Drawing.Point(3, 3);
    71       this.parameterCollectionView.Size = new System.Drawing.Size(491, 271);
    72       //
    73       // nameTextBox
    74       //
    75       this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    76       this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    77       this.nameTextBox.Size = new System.Drawing.Size(439, 20);
    78       //
    79       // infoLabel
    80       //
    81       this.infoLabel.Location = new System.Drawing.Point(492, 3);
    82       //
    83       // problemTabControl
    84       //
    85       this.problemTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    86             | System.Windows.Forms.AnchorStyles.Left)
    87             | System.Windows.Forms.AnchorStyles.Right)));
    88       this.problemTabControl.Controls.Add(this.problemTabPage);
    89       this.problemTabControl.Controls.Add(this.visualizationTabPage);
    90       this.problemTabControl.Location = new System.Drawing.Point(3, 27);
    91       this.problemTabControl.Name = "problemTabControl";
    92       this.problemTabControl.SelectedIndex = 0;
    93       this.problemTabControl.Size = new System.Drawing.Size(505, 303);
    94       this.problemTabControl.TabIndex = 5;
    95       //
    96       // problemTabPage
    97       //
    98       this.problemTabPage.Controls.Add(this.parameterCollectionView);
    99       this.problemTabPage.Location = new System.Drawing.Point(4, 22);
    100       this.problemTabPage.Name = "problemTabPage";
    101       this.problemTabPage.Padding = new System.Windows.Forms.Padding(3);
    102       this.problemTabPage.Size = new System.Drawing.Size(497, 277);
    103       this.problemTabPage.TabIndex = 0;
    104       this.problemTabPage.Text = "Problem";
    105       this.problemTabPage.UseVisualStyleBackColor = true;
    106       //
    107       // visualizationTabPage
    108       //
    109       this.visualizationTabPage.Controls.Add(this.ganttChart);
    110       this.visualizationTabPage.Location = new System.Drawing.Point(4, 22);
    111       this.visualizationTabPage.Name = "visualizationTabPage";
    112       this.visualizationTabPage.Padding = new System.Windows.Forms.Padding(3);
    113       this.visualizationTabPage.Size = new System.Drawing.Size(497, 277);
    114       this.visualizationTabPage.TabIndex = 1;
    115       this.visualizationTabPage.Text = "Visualization";
    116       this.visualizationTabPage.UseVisualStyleBackColor = true;
    117       //
    118       // ganttChart
    119       //
    120       this.ganttChart.Dock = System.Windows.Forms.DockStyle.Fill;
    121       this.ganttChart.Location = new System.Drawing.Point(3, 3);
    122       this.ganttChart.Name = "ganttChart";
    123       this.ganttChart.Size = new System.Drawing.Size(491, 271);
    124       this.ganttChart.TabIndex = 0;
    125       //
    126       // JobShopSchedulingProblemView
    127       //
    128       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    129       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    130       this.Name = "JobShopSchedulingProblemView";
    131       this.problemInstanceSplitContainer.Panel1.ResumeLayout(false);
    132       this.problemInstanceSplitContainer.Panel2.ResumeLayout(false);
    133       this.problemInstanceSplitContainer.Panel2.PerformLayout();
    134       ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).EndInit();
    135       this.problemInstanceSplitContainer.ResumeLayout(false);
    136       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    137       this.problemTabControl.ResumeLayout(false);
    138       this.problemTabPage.ResumeLayout(false);
    139       this.visualizationTabPage.ResumeLayout(false);
    140       this.ResumeLayout(false);
     43//    /// <summary>
     44//    /// Required method for Designer support - do not modify
     45//    /// the contents of this method with the code editor.
     46//    /// </summary>
     47//    private void InitializeComponent() {
     48//      this.problemTabControl = new System.Windows.Forms.TabControl();
     49//      this.problemTabPage = new System.Windows.Forms.TabPage();
     50//      this.visualizationTabPage = new System.Windows.Forms.TabPage();
     51//      this.ganttChart = new HeuristicLab.Encodings.ScheduleEncoding.Views.GanttChart();
     52//      ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).BeginInit();
     53//      this.problemInstanceSplitContainer.Panel1.SuspendLayout();
     54//      this.problemInstanceSplitContainer.Panel2.SuspendLayout();
     55//      this.problemInstanceSplitContainer.SuspendLayout();
     56//      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     57//      this.problemTabControl.SuspendLayout();
     58//      this.problemTabPage.SuspendLayout();
     59//      this.visualizationTabPage.SuspendLayout();
     60//      this.SuspendLayout();
     61//      //
     62//      // problemInstanceSplitContainer.Panel2
     63//      //
     64//      this.problemInstanceSplitContainer.Panel2.Controls.Add(this.problemTabControl);
     65//      //
     66//      // parameterCollectionView
     67//      //
     68//      this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
     69//      this.parameterCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;
     70//      this.parameterCollectionView.Location = new System.Drawing.Point(3, 3);
     71//      this.parameterCollectionView.Size = new System.Drawing.Size(491, 271);
     72//      //
     73//      // nameTextBox
     74//      //
     75//      this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     76//      this.errorProvider.SetIconPadding(this.nameTextBox, 2);
     77//      this.nameTextBox.Size = new System.Drawing.Size(439, 20);
     78//      //
     79//      // infoLabel
     80//      //
     81//      this.infoLabel.Location = new System.Drawing.Point(492, 3);
     82//      //
     83//      // problemTabControl
     84//      //
     85//      this.problemTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     86//            | System.Windows.Forms.AnchorStyles.Left)
     87//            | System.Windows.Forms.AnchorStyles.Right)));
     88//      this.problemTabControl.Controls.Add(this.problemTabPage);
     89//      this.problemTabControl.Controls.Add(this.visualizationTabPage);
     90//      this.problemTabControl.Location = new System.Drawing.Point(3, 27);
     91//      this.problemTabControl.Name = "problemTabControl";
     92//      this.problemTabControl.SelectedIndex = 0;
     93//      this.problemTabControl.Size = new System.Drawing.Size(505, 303);
     94//      this.problemTabControl.TabIndex = 5;
     95//      //
     96//      // problemTabPage
     97//      //
     98//      this.problemTabPage.Controls.Add(this.parameterCollectionView);
     99//      this.problemTabPage.Location = new System.Drawing.Point(4, 22);
     100//      this.problemTabPage.Name = "problemTabPage";
     101//      this.problemTabPage.Padding = new System.Windows.Forms.Padding(3);
     102//      this.problemTabPage.Size = new System.Drawing.Size(497, 277);
     103//      this.problemTabPage.TabIndex = 0;
     104//      this.problemTabPage.Text = "Problem";
     105//      this.problemTabPage.UseVisualStyleBackColor = true;
     106//      //
     107//      // visualizationTabPage
     108//      //
     109//      this.visualizationTabPage.Controls.Add(this.ganttChart);
     110//      this.visualizationTabPage.Location = new System.Drawing.Point(4, 22);
     111//      this.visualizationTabPage.Name = "visualizationTabPage";
     112//      this.visualizationTabPage.Padding = new System.Windows.Forms.Padding(3);
     113//      this.visualizationTabPage.Size = new System.Drawing.Size(497, 277);
     114//      this.visualizationTabPage.TabIndex = 1;
     115//      this.visualizationTabPage.Text = "Visualization";
     116//      this.visualizationTabPage.UseVisualStyleBackColor = true;
     117//      //
     118//      // ganttChart
     119//      //
     120//      this.ganttChart.Dock = System.Windows.Forms.DockStyle.Fill;
     121//      this.ganttChart.Location = new System.Drawing.Point(3, 3);
     122//      this.ganttChart.Name = "ganttChart";
     123//      this.ganttChart.Size = new System.Drawing.Size(491, 271);
     124//      this.ganttChart.TabIndex = 0;
     125//      //
     126//      // JobShopSchedulingProblemView
     127//      //
     128//      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     129//      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     130//      this.Name = "JobShopSchedulingProblemView";
     131//      this.problemInstanceSplitContainer.Panel1.ResumeLayout(false);
     132//      this.problemInstanceSplitContainer.Panel2.ResumeLayout(false);
     133//      this.problemInstanceSplitContainer.Panel2.PerformLayout();
     134//      ((System.ComponentModel.ISupportInitialize)(this.problemInstanceSplitContainer)).EndInit();
     135//      this.problemInstanceSplitContainer.ResumeLayout(false);
     136//      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
     137//      this.problemTabControl.ResumeLayout(false);
     138//      this.problemTabPage.ResumeLayout(false);
     139//      this.visualizationTabPage.ResumeLayout(false);
     140//      this.ResumeLayout(false);
    141141
    142     }
     142//    }
    143143
    144     #endregion
     144//    #endregion
    145145
    146     private System.Windows.Forms.TabControl problemTabControl;
    147     private System.Windows.Forms.TabPage problemTabPage;
    148     private System.Windows.Forms.TabPage visualizationTabPage;
    149     private GanttChart ganttChart;
    150   }
    151 }
     146//    private System.Windows.Forms.TabControl problemTabControl;
     147//    private System.Windows.Forms.TabPage problemTabPage;
     148//    private System.Windows.Forms.TabPage visualizationTabPage;
     149//    private GanttChart ganttChart;
     150//  }
     151//}
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs

    r12012 r13443  
    1 #region License Information
    2 /* HeuristicLab
    3  * Copyright (C) 2002-2015 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
     1//#region License Information
     2///* HeuristicLab
     3// * Copyright (C) 2002-2015 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
    2121
    22 using System;
    23 using System.Windows.Forms;
    24 using HeuristicLab.Collections;
    25 using HeuristicLab.Encodings.ScheduleEncoding;
    26 using HeuristicLab.MainForm;
    27 using HeuristicLab.Optimization.Views;
     22//using System;
     23//using System.Windows.Forms;
     24//using HeuristicLab.Collections;
     25//using HeuristicLab.Encodings.ScheduleEncoding;
     26//using HeuristicLab.MainForm;
     27//using HeuristicLab.Optimization.Views;
    2828
    29 namespace HeuristicLab.Problems.Scheduling.Views {
    30   [View("JobShop Scheduling Problem View")]
    31   [Content(typeof(JobShopSchedulingProblem), true)]
    32   public partial class JobShopSchedulingProblemView : ProblemView {
     29//namespace HeuristicLab.Problems.Scheduling.Views {
     30//  [View("JobShop Scheduling Problem View")]
     31//  [Content(typeof(JobShopSchedulingProblem), true)]
     32//  public partial class JobShopSchedulingProblemView : ProblemView {
    3333
    34     public new JobShopSchedulingProblem Content {
    35       get { return (JobShopSchedulingProblem)base.Content; }
    36       set { base.Content = value; }
    37     }
     34//    public new JobShopSchedulingProblem Content {
     35//      get { return (JobShopSchedulingProblem)base.Content; }
     36//      set { base.Content = value; }
     37//    }
    3838
    39     public JobShopSchedulingProblemView() {
    40       InitializeComponent();
    41       Controls.Remove(parameterCollectionView);
    42       parameterCollectionView.Dock = DockStyle.Fill;
    43       problemTabPage.Controls.Add(parameterCollectionView);
    44     }
     39//    public JobShopSchedulingProblemView() {
     40//      InitializeComponent();
     41//      Controls.Remove(parameterCollectionView);
     42//      parameterCollectionView.Dock = DockStyle.Fill;
     43//      problemTabPage.Controls.Add(parameterCollectionView);
     44//    }
    4545
    46     protected override void OnContentChanged() {
    47       base.OnContentChanged();
    48       FillGanttChart();
    49     }
     46//    protected override void OnContentChanged() {
     47//      base.OnContentChanged();
     48//      FillGanttChart();
     49//    }
    5050
    51     protected override void DeregisterContentEvents() {
    52       Content.JobDataParameter.ValueChanged -= JobDataParameterOnValueChanged;
    53       Content.JobData.ItemsAdded -= JobsOnChanged;
    54       Content.JobData.ItemsRemoved -= JobsOnRemoved;
    55       Content.JobData.ItemsReplaced -= JobsOnChanged;
    56       Content.JobData.CollectionReset -= JobsOnChanged;
    57       foreach (var job in Content.JobData) {
    58         job.TasksChanged -= JobOnTasksChanged;
    59       }
    60       base.DeregisterContentEvents();
    61     }
    62     protected override void RegisterContentEvents() {
    63       base.RegisterContentEvents();
    64       Content.JobDataParameter.ValueChanged += JobDataParameterOnValueChanged;
    65       Content.JobData.ItemsAdded += JobsOnChanged;
    66       Content.JobData.ItemsRemoved += JobsOnRemoved;
    67       Content.JobData.ItemsReplaced += JobsOnChanged;
    68       Content.JobData.CollectionReset += JobsOnChanged;
    69       foreach (var job in Content.JobData) {
    70         job.TasksChanged += JobOnTasksChanged;
    71       }
    72     }
     51//    protected override void DeregisterContentEvents() {
     52//      Content.JobDataParameter.ValueChanged -= JobDataParameterOnValueChanged;
     53//      Content.JobData.ItemsAdded -= JobsOnChanged;
     54//      Content.JobData.ItemsRemoved -= JobsOnRemoved;
     55//      Content.JobData.ItemsReplaced -= JobsOnChanged;
     56//      Content.JobData.CollectionReset -= JobsOnChanged;
     57//      foreach (var job in Content.JobData) {
     58//        job.TasksChanged -= JobOnTasksChanged;
     59//      }
     60//      base.DeregisterContentEvents();
     61//    }
     62//    protected override void RegisterContentEvents() {
     63//      base.RegisterContentEvents();
     64//      Content.JobDataParameter.ValueChanged += JobDataParameterOnValueChanged;
     65//      Content.JobData.ItemsAdded += JobsOnChanged;
     66//      Content.JobData.ItemsRemoved += JobsOnRemoved;
     67//      Content.JobData.ItemsReplaced += JobsOnChanged;
     68//      Content.JobData.CollectionReset += JobsOnChanged;
     69//      foreach (var job in Content.JobData) {
     70//        job.TasksChanged += JobOnTasksChanged;
     71//      }
     72//    }
    7373
    74     private void JobsOnChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) {
    75       foreach (var job in e.OldItems)
    76         job.Value.TasksChanged -= JobOnTasksChanged;
    77       foreach (var job in e.Items)
    78         job.Value.TasksChanged += JobOnTasksChanged;
    79       FillGanttChart();
    80     }
     74//    private void JobsOnChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) {
     75//      foreach (var job in e.OldItems)
     76//        job.Value.TasksChanged -= JobOnTasksChanged;
     77//      foreach (var job in e.Items)
     78//        job.Value.TasksChanged += JobOnTasksChanged;
     79//      FillGanttChart();
     80//    }
    8181
    82     private void JobsOnRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) {
    83       foreach (var job in e.Items)
    84         job.Value.TasksChanged -= JobOnTasksChanged;
    85       FillGanttChart();
    86     }
     82//    private void JobsOnRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) {
     83//      foreach (var job in e.Items)
     84//        job.Value.TasksChanged -= JobOnTasksChanged;
     85//      FillGanttChart();
     86//    }
    8787
    88     private void JobDataParameterOnValueChanged(object sender, EventArgs e) {
    89       Content.JobData.ItemsAdded += JobsOnChanged;
    90       Content.JobData.ItemsRemoved += JobsOnRemoved;
    91       Content.JobData.ItemsReplaced += JobsOnChanged;
    92       Content.JobData.CollectionReset += JobsOnChanged;
    93       foreach (var job in Content.JobData) {
    94         job.TasksChanged += JobOnTasksChanged;
    95       }
    96       FillGanttChart();
    97     }
     88//    private void JobDataParameterOnValueChanged(object sender, EventArgs e) {
     89//      Content.JobData.ItemsAdded += JobsOnChanged;
     90//      Content.JobData.ItemsRemoved += JobsOnRemoved;
     91//      Content.JobData.ItemsReplaced += JobsOnChanged;
     92//      Content.JobData.CollectionReset += JobsOnChanged;
     93//      foreach (var job in Content.JobData) {
     94//        job.TasksChanged += JobOnTasksChanged;
     95//      }
     96//      FillGanttChart();
     97//    }
    9898
    99     private void JobOnTasksChanged(object sender, EventArgs e) {
    100       FillGanttChart();
    101     }
     99//    private void JobOnTasksChanged(object sender, EventArgs e) {
     100//      FillGanttChart();
     101//    }
    102102
    103     private void FillGanttChart() {
    104       ganttChart.Reset();
    105       if (Content == null) return;
    106       int jobCount = 0;
    107       foreach (var j in Content.JobData) {
    108         double lastEndTime = 0;
    109         foreach (var t in Content.JobData[jobCount].Tasks) {
    110           int categoryNr = t.JobNr;
    111           string categoryName = "Job" + categoryNr;
    112           ganttChart.AddData(categoryName,
    113             categoryNr,
    114             t.TaskNr,
    115             lastEndTime + 1,
    116             lastEndTime + t.Duration,
    117             "Job" + t.JobNr + " - " + "Task#" + t.TaskNr);
    118           lastEndTime += t.Duration;
    119         }
    120         jobCount++;
    121       }
    122     }
    123   }
    124 }
     103//    private void FillGanttChart() {
     104//      ganttChart.Reset();
     105//      if (Content == null) return;
     106//      int jobCount = 0;
     107//      foreach (var j in Content.JobData) {
     108//        double lastEndTime = 0;
     109//        foreach (var t in Content.JobData[jobCount].Tasks) {
     110//          int categoryNr = t.JobNr;
     111//          string categoryName = "Job" + categoryNr;
     112//          ganttChart.AddData(categoryName,
     113//            categoryNr,
     114//            t.TaskNr,
     115//            lastEndTime + 1,
     116//            lastEndTime + t.Duration,
     117//            "Job" + t.JobNr + " - " + "Task#" + t.TaskNr);
     118//          lastEndTime += t.Duration;
     119//        }
     120//        jobCount++;
     121//      }
     122//    }
     123//  }
     124//}
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/HeuristicLab.Problems.Scheduling-3.3.csproj

    r13437 r13443  
    114114    <Compile Include="Analyzers\BestSchedulingSolutionAnalyzer.cs" />
    115115    <Compile Include="Analyzers\SchedulingAnalyzer.cs" />
    116     <Compile Include="Decoders\JSMForcingStrategy.cs" />
    117     <Compile Include="Decoders\JSMDecoder.cs" />
    118     <Compile Include="Decoders\JSMDecodingErrorPolicy.cs" />
    119     <Compile Include="Decoders\JSMDecodingErrorPolicyTypes.cs" />
    120     <Compile Include="Decoders\JSMForcingStrategyTypes.cs" />
    121     <Compile Include="Decoders\PRVDecoder.cs" />
    122     <Compile Include="Decoders\PWRDecoder.cs" />
    123     <Compile Include="Decoders\ScheduleDecoder.cs" />
    124116    <Compile Include="Evaluators\MeanTardinessEvaluator.cs" />
    125117    <Compile Include="Evaluators\MakespanEvaluator.cs" />
    126118    <Compile Include="Evaluators\ScheduleEvaluator.cs" />
    127119    <Compile Include="Interfaces\IJSSPOperator.cs" />
    128     <Compile Include="Interfaces\IScheduleDecoder.cs" />
    129120    <Compile Include="Interfaces\IScheduleEvaluator.cs" />
    130121    <Compile Include="Interfaces\ISchedulingEvaluator.cs" />
     
    210201      <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project>
    211202      <Name>HeuristicLab.Problems.Instances-3.3</Name>
     203      <Private>False</Private>
     204    </ProjectReference>
     205    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
     206      <Project>{f4539fb6-4708-40c9-be64-0a1390aea197}</Project>
     207      <Name>HeuristicLab.Random-3.3</Name>
    212208      <Private>False</Private>
    213209    </ProjectReference>
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem new.cs

    r13437 r13443  
    2626using HeuristicLab.Data;
    2727using HeuristicLab.Encodings.PermutationEncoding;
    28 using HeuristicLab.Encodings.Schedule;
    2928using HeuristicLab.Encodings.ScheduleEncoding;
    3029using HeuristicLab.Optimization;
    3130using HeuristicLab.Parameters;
    3231using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    33 using HeuristicLab.PluginInfrastructure;
    3432using HeuristicLab.Problems.Instances;
    3533
     
    9593      get { return (IFixedValueParameter<IntValue>)Parameters["Resources"]; }
    9694    }
    97     public IValueParameter<IScheduleEvaluator> ScheduleEvaluatorParameter {
    98       get { return (IValueParameter<IScheduleEvaluator>)Parameters["ScheduleEvaluator"]; }
    99     }
    100     public OptionalValueParameter<IScheduleDecoder> ScheduleDecoderParameter {
    101       get { return (OptionalValueParameter<IScheduleDecoder>)Parameters["ScheduleDecoder"]; }
    102     }
    10395    #endregion
    10496
     
    118110      get { return ResourcesParameter.Value.Value; }
    119111      set { ResourcesParameter.Value.Value = value; }
    120     }
    121     public IScheduleEvaluator ScheduleEvaluator {
    122       get { return ScheduleEvaluatorParameter.Value; }
    123       set { ScheduleEvaluatorParameter.Value = value; }
    124     }
    125     public IScheduleDecoder ScheduleDecoder {
    126       get { return ScheduleDecoderParameter.Value; }
    127       set { ScheduleDecoderParameter.Value = value; }
    128112    }
    129113    #endregion
     
    151135      Parameters.Add(new FixedValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue()));
    152136      Parameters.Add(new FixedValueParameter<IntValue>("Resources", "The number of resources used in this JSSP instance.", new IntValue()));
    153       Parameters.Add(new ValueParameter<IScheduleEvaluator>("ScheduleEvaluator", "The evaluator used to determine the quality of a solution.", new MakespanEvaluator()));
    154       Parameters.Add(new OptionalValueParameter<IScheduleDecoder>("ScheduleDecoder", "The operator that decodes the representation and creates a schedule.", new JSMDecoder()));
    155137
    156138      Encoding = new DirectScheduleEncoding();
     
    162144
    163145    public override double Evaluate(ISchedule solution, IRandom random) {
    164       //TODO change to decoder
    165       var schedule = (Schedule)solution;
     146      var schedule = Encoding.Decode(solution, JobData);
    166147      return MakespanEvaluator.GetMakespan(schedule);
    167148    }
     
    194175    }
    195176    private void ScheduleEvaluatorParameter_ValueChanged(object sender, EventArgs eventArgs) {
    196       ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged;
     177      //ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged;
    197178      ParameterizeOperators();
    198179    }
     
    205186    }
    206187    private void ScheduleDecoderParameter_ValueChanged(object sender, EventArgs eventArgs) {
    207       if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged;
     188      //if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged;
    208189      ParameterizeOperators();
    209190    }
     
    222203
    223204    private void ApplyEncoding() {
    224       if (SolutionCreator.GetType() == typeof(JSMRandomCreator)) {
    225         Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>());
    226         ScheduleDecoder = new JSMDecoder();
    227       } else if (SolutionCreator.GetType() == typeof(PRVRandomCreator)) {
    228         Operators.AddRange(ApplicationManager.Manager.GetInstances<IPRVOperator>());
    229         ScheduleDecoder = new PRVDecoder();
    230       } else if (SolutionCreator.GetType() == typeof(PWRRandomCreator)) {
    231         Operators.AddRange(ApplicationManager.Manager.GetInstances<IPWROperator>());
    232         ScheduleDecoder = new PWRDecoder();
    233       } else if (SolutionCreator.GetType() == typeof(DirectScheduleRandomCreator)) {
    234         Operators.AddRange(ApplicationManager.Manager.GetInstances<IDirectScheduleOperator>());
    235         ScheduleDecoder = null;
    236       }
     205      //if (SolutionCreator.GetType() == typeof(JSMRandomCreator)) {
     206      //  Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>());
     207      //  ScheduleDecoder = new JSMDecoder();
     208      //} else if (SolutionCreator.GetType() == typeof(PRVRandomCreator)) {
     209      //  Operators.AddRange(ApplicationManager.Manager.GetInstances<IPRVOperator>());
     210      //  ScheduleDecoder = new PRVDecoder();
     211      //} else if (SolutionCreator.GetType() == typeof(PWRRandomCreator)) {
     212      //  Operators.AddRange(ApplicationManager.Manager.GetInstances<IPWROperator>());
     213      //  ScheduleDecoder = new PWRDecoder();
     214      //} else if (SolutionCreator.GetType() == typeof(DirectScheduleRandomCreator)) {
     215      //  Operators.AddRange(ApplicationManager.Manager.GetInstances<IDirectScheduleOperator>());
     216      //  ScheduleDecoder = null;
     217      //}
    237218    }
    238219
     
    301282      BestKnownQuality = data.BestKnownQuality ?? double.NaN;
    302283      if (data.BestKnownSchedule != null) {
    303         var enc = new JSMEncoding();
    304         enc.JobSequenceMatrix = new ItemList<Permutation>(data.Resources);
     284        var enc = new JSMEncoding(0);
    305285        for (int i = 0; i < data.Resources; i++) {
    306           enc.JobSequenceMatrix[i] = new Permutation(PermutationTypes.Absolute, new int[data.Jobs]);
     286          enc.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, new int[data.Jobs]));
    307287          for (int j = 0; j < data.Jobs; j++) {
    308288            enc.JobSequenceMatrix[i][j] = data.BestKnownSchedule[i, j];
    309289          }
    310290        }
    311         BestKnownSolution = new JSMDecoder().CreateScheduleFromEncoding(enc, jobData);
    312         if (ScheduleEvaluator is MeanTardinessEvaluator)
    313           BestKnownQuality = MeanTardinessEvaluator.GetMeanTardiness(BestKnownSolution, jobData);
    314         else if (ScheduleEvaluator is MakespanEvaluator)
    315           BestKnownQuality = MakespanEvaluator.GetMakespan(BestKnownSolution);
     291        BestKnownSolution = JSMDecoder.DecodeSchedule(enc, jobData, JSMDecodingErrorPolicyTypes.RandomPolicy, JSMForcingStrategyTypes.SwapForcing);
     292        //if (ScheduleEvaluator is MeanTardinessEvaluator)
     293        //  BestKnownQuality = MeanTardinessEvaluator.GetMeanTardiness(BestKnownSolution, jobData);
     294        //else if (ScheduleEvaluator is MakespanEvaluator)
     295        //  BestKnownQuality = MakespanEvaluator.GetMakespan(BestKnownSolution);
    316296      }
    317297
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs

    r13437 r13443  
    1 #region License Information
    2 /* HeuristicLab
    3  * Copyright (C) 2002-2015 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 
    22 using System;
    23 using System.Drawing;
    24 using System.Linq;
    25 using HeuristicLab.Common;
    26 using HeuristicLab.Core;
    27 using HeuristicLab.Data;
    28 using HeuristicLab.Encodings.PermutationEncoding;
    29 using HeuristicLab.Encodings.ScheduleEncoding;
    30 using HeuristicLab.Parameters;
    31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    32 using HeuristicLab.PluginInfrastructure;
    33 using HeuristicLab.Problems.Instances;
    34 
    35 namespace HeuristicLab.Problems.Scheduling {
    36   [Item("Job Shop Scheduling Problem (JSSP)", "Represents a standard Job Shop Scheduling Problem")]
    37   [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 120)]
    38   [StorableClass]
    39   public sealed class JobShopSchedulingProblem : SchedulingProblem, IProblemInstanceConsumer<JSSPData>, IProblemInstanceExporter<JSSPData>, IStorableContent {
    40     #region Default Instance
    41     private static readonly JSSPData DefaultInstance = new JSSPData() {
    42       Jobs = 10,
    43       Resources = 10,
    44       BestKnownQuality = 930,
    45       ProcessingTimes = new double[,] {
    46           { 29, 78,  9, 36, 49, 11, 62, 56, 44, 21 },
    47           { 43, 90, 75, 11, 69, 28, 46, 46, 72, 30 },
    48           { 91, 85, 39, 74, 90, 10, 12, 89, 45, 33 },
    49           { 81, 95, 71, 99,  9, 52, 85, 98, 22, 43 },
    50           { 14,  6, 22, 61, 26, 69, 21, 49, 72, 53 },
    51           { 84,  2, 52, 95, 48, 72, 47, 65,  6, 25 },
    52           { 46, 37, 61, 13, 32, 21, 32, 89, 30, 55 },
    53           { 31, 86, 46, 74, 32, 88, 19, 48, 36, 79 },
    54           { 76, 69, 76, 51, 85, 11, 40, 89, 26, 74 },
    55           { 85, 13, 61,  7, 64, 76, 47, 52, 90, 45 }
    56         },
    57       Demands = new int[,] {
    58           { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
    59           { 0, 2, 4, 9, 3, 1, 6, 5, 7, 8 },
    60           { 1, 0, 3, 2, 8, 5, 7, 6, 9, 4 },
    61           { 1, 2, 0, 4, 6, 8, 7, 3, 9, 5 },
    62           { 2, 0, 1, 5, 3, 4, 8, 7, 9, 6 },
    63           { 2, 1, 5, 3, 8, 9, 0, 6, 4, 7 },
    64           { 1, 0, 3, 2, 6, 5, 9, 8, 7, 4 },
    65           { 2, 0, 1, 5, 4, 6, 8, 9, 7, 3 },
    66           { 0, 1, 3, 5, 2, 9, 6, 7, 4, 8 },
    67           { 1, 0, 2, 6, 8, 9, 5, 3, 4, 7 }
    68         }
    69     };
    70     #endregion
    71 
    72     public string Filename { get; set; }
    73     public override Image ItemImage {
    74       get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    75     }
    76 
    77     #region Parameter Properties
    78     public IValueParameter<ItemList<Job>> JobDataParameter {
    79       get { return (IValueParameter<ItemList<Job>>)Parameters["JobData"]; }
    80     }
    81     public OptionalValueParameter<Schedule> BestKnownSolutionParameter {
    82       get { return (OptionalValueParameter<Schedule>)Parameters["BestKnownSolution"]; }
    83     }
    84 
    85     public IFixedValueParameter<IntValue> JobsParameter {
    86       get { return (IFixedValueParameter<IntValue>)Parameters["Jobs"]; }
    87     }
    88     public IFixedValueParameter<IntValue> ResourcesParameter {
    89       get { return (IFixedValueParameter<IntValue>)Parameters["Resources"]; }
    90     }
    91     public IValueParameter<IScheduleEvaluator> ScheduleEvaluatorParameter {
    92       get { return (IValueParameter<IScheduleEvaluator>)Parameters["ScheduleEvaluator"]; }
    93     }
    94     public OptionalValueParameter<IScheduleDecoder> ScheduleDecoderParameter {
    95       get { return (OptionalValueParameter<IScheduleDecoder>)Parameters["ScheduleDecoder"]; }
    96     }
    97     #endregion
    98 
    99     #region Properties
    100     public ItemList<Job> JobData {
    101       get { return JobDataParameter.Value; }
    102       set { JobDataParameter.Value = value; }
    103     }
    104     public Schedule BestKnownSolution {
    105       get { return BestKnownSolutionParameter.Value; }
    106       set { BestKnownSolutionParameter.Value = value; }
    107     }
    108     public int Jobs {
    109       get { return JobsParameter.Value.Value; }
    110       set { JobsParameter.Value.Value = value; }
    111     }
    112     public int Resources {
    113       get { return ResourcesParameter.Value.Value; }
    114       set { ResourcesParameter.Value.Value = value; }
    115     }
    116     public IScheduleEvaluator ScheduleEvaluator {
    117       get { return ScheduleEvaluatorParameter.Value; }
    118       set { ScheduleEvaluatorParameter.Value = value; }
    119     }
    120     public IScheduleDecoder ScheduleDecoder {
    121       get { return ScheduleDecoderParameter.Value; }
    122       set { ScheduleDecoderParameter.Value = value; }
    123     }
    124     #endregion
    125 
    126     [StorableConstructor]
    127     private JobShopSchedulingProblem(bool deserializing) : base(deserializing) { }
    128     private JobShopSchedulingProblem(JobShopSchedulingProblem original, Cloner cloner)
    129       : base(original, cloner) {
    130       RegisterEventHandlers();
    131     }
    132     public JobShopSchedulingProblem()
    133       : base(new SchedulingEvaluator(), new JSMRandomCreator()) {
    134       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>()));
    135       Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));
    136 
    137       Parameters.Add(new FixedValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue()));
    138       Parameters.Add(new FixedValueParameter<IntValue>("Resources", "The number of resources used in this JSSP instance.", new IntValue()));
    139       Parameters.Add(new ValueParameter<IScheduleEvaluator>("ScheduleEvaluator", "The evaluator used to determine the quality of a solution.", new MakespanEvaluator()));
    140       Parameters.Add(new OptionalValueParameter<IScheduleDecoder>("ScheduleDecoder", "The operator that decodes the representation and creates a schedule.", new JSMDecoder()));
    141 
    142       EvaluatorParameter.GetsCollected = false;
    143       EvaluatorParameter.Hidden = true;
    144       ScheduleDecoderParameter.Hidden = true;
    145 
    146       InitializeOperators();
    147       Load(DefaultInstance);
    148       RegisterEventHandlers();
    149     }
    150 
    151     public override IDeepCloneable Clone(Cloner cloner) {
    152       return new JobShopSchedulingProblem(this, cloner);
    153     }
    154 
    155     [StorableHook(HookType.AfterDeserialization)]
    156     private void AfterDeserialization() {
    157       RegisterEventHandlers();
    158     }
    159 
    160     private void RegisterEventHandlers() {
    161       ScheduleEvaluatorParameter.ValueChanged += ScheduleEvaluatorParameter_ValueChanged;
    162       ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged;
    163       SolutionCreator.ScheduleParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
    164       ScheduleDecoderParameter.ValueChanged += ScheduleDecoderParameter_ValueChanged;
    165       if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged;
    166     }
    167 
    168     #region Events
    169     protected override void OnSolutionCreatorChanged() {
    170       SolutionCreator.ScheduleParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
    171       InitializeOperators();
    172     }
    173     protected override void OnEvaluatorChanged() {
    174       base.OnEvaluatorChanged();
    175       ParameterizeOperators();
    176     }
    177     private void ScheduleEvaluatorParameter_ValueChanged(object sender, EventArgs eventArgs) {
    178       ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged;
    179       ParameterizeOperators();
    180     }
    181     private void ScheduleEvaluator_QualityParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
    182       ParameterizeOperators();
    183     }
    184 
    185     private void SolutionCreator_SchedulingEncodingParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
    186       ParameterizeOperators();
    187     }
    188     private void ScheduleDecoderParameter_ValueChanged(object sender, EventArgs eventArgs) {
    189       if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged;
    190       ParameterizeOperators();
    191     }
    192     private void ScheduleDecoder_ScheduleParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
    193       ParameterizeOperators();
    194     }
    195     #endregion
    196 
    197     #region Problem Instance Handling
    198     public void Load(JSSPData data) {
    199       var jobData = new ItemList<Job>(data.Jobs);
    200       for (int j = 0; j < data.Jobs; j++) {
    201         var job = new Job(j, data.DueDates != null ? data.DueDates[j] : double.MaxValue);
    202         for (int t = 0; t < data.Resources; t++) {
    203           job.Tasks.Add(new Task(t, data.Demands[j, t], j, data.ProcessingTimes[j, t]));
    204         }
    205         jobData.Add(job);
    206       }
    207 
    208       BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null;
    209       if (data.BestKnownSchedule != null) {
    210         var enc = new JSMEncoding();
    211         enc.JobSequenceMatrix = new ItemList<Permutation>(data.Resources);
    212         for (int i = 0; i < data.Resources; i++) {
    213           enc.JobSequenceMatrix[i] = new Permutation(PermutationTypes.Absolute, new int[data.Jobs]);
    214           for (int j = 0; j < data.Jobs; j++) {
    215             enc.JobSequenceMatrix[i][j] = data.BestKnownSchedule[i, j];
    216           }
    217         }
    218         BestKnownSolution = new JSMDecoder().CreateScheduleFromEncoding(enc, jobData);
    219         if (ScheduleEvaluator is MeanTardinessEvaluator)
    220           BestKnownQuality = new DoubleValue(MeanTardinessEvaluator.GetMeanTardiness(BestKnownSolution, jobData));
    221         else if (ScheduleEvaluator is MakespanEvaluator)
    222           BestKnownQuality = new DoubleValue(MakespanEvaluator.GetMakespan(BestKnownSolution));
    223       }
    224 
    225       JobData = jobData;
    226       Jobs = data.Jobs;
    227       Resources = data.Resources;
    228     }
    229 
    230     public JSSPData Export() {
    231       var result = new JSSPData {
    232         Name = Name,
    233         Description = Description,
    234         Jobs = Jobs,
    235         Resources = Resources,
    236         ProcessingTimes = new double[Jobs, Resources],
    237         Demands = new int[Jobs, Resources],
    238         DueDates = new double[Jobs]
    239       };
    240 
    241       foreach (var job in JobData) {
    242         var counter = 0;
    243         result.DueDates[job.Index] = job.DueDate;
    244         foreach (var task in job.Tasks) {
    245           result.ProcessingTimes[task.JobNr, counter] = task.Duration;
    246           result.Demands[task.JobNr, counter] = task.ResourceNr;
    247           counter++;
    248         }
    249       }
    250       return result;
    251     }
    252     #endregion
    253 
    254     #region Helpers
    255     private void InitializeOperators() {
    256       Operators.Clear();
    257       ApplyEncoding();
    258       Operators.Add(new BestSchedulingSolutionAnalyzer());
    259       ParameterizeOperators();
    260     }
    261 
    262     private void ApplyEncoding() {
    263       if (SolutionCreator.GetType() == typeof(JSMRandomCreator)) {
    264         Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>());
    265         ScheduleDecoder = new JSMDecoder();
    266       } else if (SolutionCreator.GetType() == typeof(PRVRandomCreator)) {
    267         Operators.AddRange(ApplicationManager.Manager.GetInstances<IPRVOperator>());
    268         ScheduleDecoder = new PRVDecoder();
    269       } else if (SolutionCreator.GetType() == typeof(PWRRandomCreator)) {
    270         Operators.AddRange(ApplicationManager.Manager.GetInstances<IPWROperator>());
    271         ScheduleDecoder = new PWRDecoder();
    272       } else if (SolutionCreator.GetType() == typeof(DirectScheduleRandomCreator)) {
    273         Operators.AddRange(ApplicationManager.Manager.GetInstances<IDirectScheduleOperator>());
    274         ScheduleDecoder = null;
    275       }
    276     }
    277 
    278     private void ParameterizeOperators() {
    279       Evaluator.ScheduleDecoderParameter.ActualName = ScheduleDecoderParameter.Name;
    280       Evaluator.ScheduleDecoderParameter.Hidden = true;
    281       Evaluator.ScheduleEvaluatorParameter.ActualName = ScheduleEvaluatorParameter.Name;
    282       Evaluator.ScheduleEvaluatorParameter.Hidden = true;
    283       Evaluator.QualityParameter.ActualName = ScheduleEvaluator.QualityParameter.ActualName;
    284       Evaluator.QualityParameter.Hidden = true;
    285 
    286       if (ScheduleDecoder != null)
    287         ScheduleDecoder.ScheduleEncodingParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
    288 
    289       if (ScheduleDecoder != null) {
    290         ScheduleEvaluator.ScheduleParameter.ActualName = ScheduleDecoder.ScheduleParameter.ActualName;
    291         ScheduleEvaluator.ScheduleParameter.Hidden = true;
    292       } else if (SolutionCreator is DirectScheduleRandomCreator) {
    293         var directEvaluator = (DirectScheduleRandomCreator)SolutionCreator;
    294         ScheduleEvaluator.ScheduleParameter.ActualName = directEvaluator.ScheduleParameter.ActualName;
    295         ScheduleEvaluator.ScheduleParameter.Hidden = true;
    296       } else {
    297         ScheduleEvaluator.ScheduleParameter.ActualName = ScheduleEvaluator.ScheduleParameter.Name;
    298         ScheduleEvaluator.ScheduleParameter.Hidden = false;
    299       }
    300 
    301       foreach (var op in Operators.OfType<IScheduleManipulator>()) {
    302         op.ScheduleParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
    303         op.ScheduleParameter.Hidden = true;
    304       }
    305 
    306       foreach (var op in Operators.OfType<IScheduleCrossover>()) {
    307         op.ChildParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
    308         op.ChildParameter.Hidden = true;
    309         op.ParentsParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
    310         op.ParentsParameter.Hidden = true;
    311       }
    312 
    313       foreach (var op in Operators.OfType<BestSchedulingSolutionAnalyzer>()) {
    314         op.QualityParameter.ActualName = ScheduleEvaluator.QualityParameter.ActualName;
    315         if (ScheduleDecoder != null) {
    316           op.ScheduleParameter.ActualName = ScheduleDecoder.ScheduleParameter.ActualName;
    317           op.ScheduleParameter.Hidden = true;
    318         } else if (SolutionCreator is DirectScheduleRandomCreator) {
    319           op.ScheduleParameter.ActualName = ((DirectScheduleRandomCreator)SolutionCreator).ScheduleParameter.ActualName;
    320           op.ScheduleParameter.Hidden = true;
    321         } else {
    322           op.ScheduleParameter.ActualName = op.ScheduleParameter.Name;
    323           op.ScheduleParameter.Hidden = false;
    324         }
    325       }
    326     }
    327     #endregion
    328 
    329   }
    330 }
     1//#region License Information
     2///* HeuristicLab
     3// * Copyright (C) 2002-2015 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
     22//using System;
     23//using System.Drawing;
     24//using System.Linq;
     25//using HeuristicLab.Common;
     26//using HeuristicLab.Core;
     27//using HeuristicLab.Data;
     28//using HeuristicLab.Encodings.PermutationEncoding;
     29//using HeuristicLab.Encodings.ScheduleEncoding;
     30//using HeuristicLab.Parameters;
     31//using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     32//using HeuristicLab.PluginInfrastructure;
     33//using HeuristicLab.Problems.Instances;
     34
     35//namespace HeuristicLab.Problems.Scheduling {
     36//  [Item("Job Shop Scheduling Problem (JSSP)", "Represents a standard Job Shop Scheduling Problem")]
     37//  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 120)]
     38//  [StorableClass]
     39//  public sealed class JobShopSchedulingProblem : SchedulingProblem, IProblemInstanceConsumer<JSSPData>, IProblemInstanceExporter<JSSPData>, IStorableContent {
     40//    #region Default Instance
     41//    private static readonly JSSPData DefaultInstance = new JSSPData() {
     42//      Jobs = 10,
     43//      Resources = 10,
     44//      BestKnownQuality = 930,
     45//      ProcessingTimes = new double[,] {
     46//          { 29, 78,  9, 36, 49, 11, 62, 56, 44, 21 },
     47//          { 43, 90, 75, 11, 69, 28, 46, 46, 72, 30 },
     48//          { 91, 85, 39, 74, 90, 10, 12, 89, 45, 33 },
     49//          { 81, 95, 71, 99,  9, 52, 85, 98, 22, 43 },
     50//          { 14,  6, 22, 61, 26, 69, 21, 49, 72, 53 },
     51//          { 84,  2, 52, 95, 48, 72, 47, 65,  6, 25 },
     52//          { 46, 37, 61, 13, 32, 21, 32, 89, 30, 55 },
     53//          { 31, 86, 46, 74, 32, 88, 19, 48, 36, 79 },
     54//          { 76, 69, 76, 51, 85, 11, 40, 89, 26, 74 },
     55//          { 85, 13, 61,  7, 64, 76, 47, 52, 90, 45 }
     56//        },
     57//      Demands = new int[,] {
     58//          { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
     59//          { 0, 2, 4, 9, 3, 1, 6, 5, 7, 8 },
     60//          { 1, 0, 3, 2, 8, 5, 7, 6, 9, 4 },
     61//          { 1, 2, 0, 4, 6, 8, 7, 3, 9, 5 },
     62//          { 2, 0, 1, 5, 3, 4, 8, 7, 9, 6 },
     63//          { 2, 1, 5, 3, 8, 9, 0, 6, 4, 7 },
     64//          { 1, 0, 3, 2, 6, 5, 9, 8, 7, 4 },
     65//          { 2, 0, 1, 5, 4, 6, 8, 9, 7, 3 },
     66//          { 0, 1, 3, 5, 2, 9, 6, 7, 4, 8 },
     67//          { 1, 0, 2, 6, 8, 9, 5, 3, 4, 7 }
     68//        }
     69//    };
     70//    #endregion
     71
     72//    public string Filename { get; set; }
     73//    public override Image ItemImage {
     74//      get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
     75//    }
     76
     77//    #region Parameter Properties
     78//    public IValueParameter<ItemList<Job>> JobDataParameter {
     79//      get { return (IValueParameter<ItemList<Job>>)Parameters["JobData"]; }
     80//    }
     81//    public OptionalValueParameter<Schedule> BestKnownSolutionParameter {
     82//      get { return (OptionalValueParameter<Schedule>)Parameters["BestKnownSolution"]; }
     83//    }
     84
     85//    public IFixedValueParameter<IntValue> JobsParameter {
     86//      get { return (IFixedValueParameter<IntValue>)Parameters["Jobs"]; }
     87//    }
     88//    public IFixedValueParameter<IntValue> ResourcesParameter {
     89//      get { return (IFixedValueParameter<IntValue>)Parameters["Resources"]; }
     90//    }
     91//    public IValueParameter<IScheduleEvaluator> ScheduleEvaluatorParameter {
     92//      get { return (IValueParameter<IScheduleEvaluator>)Parameters["ScheduleEvaluator"]; }
     93//    }
     94//    public OptionalValueParameter<IScheduleDecoder> ScheduleDecoderParameter {
     95//      get { return (OptionalValueParameter<IScheduleDecoder>)Parameters["ScheduleDecoder"]; }
     96//    }
     97//    #endregion
     98
     99//    #region Properties
     100//    public ItemList<Job> JobData {
     101//      get { return JobDataParameter.Value; }
     102//      set { JobDataParameter.Value = value; }
     103//    }
     104//    public Schedule BestKnownSolution {
     105//      get { return BestKnownSolutionParameter.Value; }
     106//      set { BestKnownSolutionParameter.Value = value; }
     107//    }
     108//    public int Jobs {
     109//      get { return JobsParameter.Value.Value; }
     110//      set { JobsParameter.Value.Value = value; }
     111//    }
     112//    public int Resources {
     113//      get { return ResourcesParameter.Value.Value; }
     114//      set { ResourcesParameter.Value.Value = value; }
     115//    }
     116//    public IScheduleEvaluator ScheduleEvaluator {
     117//      get { return ScheduleEvaluatorParameter.Value; }
     118//      set { ScheduleEvaluatorParameter.Value = value; }
     119//    }
     120//    public IScheduleDecoder ScheduleDecoder {
     121//      get { return ScheduleDecoderParameter.Value; }
     122//      set { ScheduleDecoderParameter.Value = value; }
     123//    }
     124//    #endregion
     125
     126//    [StorableConstructor]
     127//    private JobShopSchedulingProblem(bool deserializing) : base(deserializing) { }
     128//    private JobShopSchedulingProblem(JobShopSchedulingProblem original, Cloner cloner)
     129//      : base(original, cloner) {
     130//      RegisterEventHandlers();
     131//    }
     132//    public JobShopSchedulingProblem()
     133//      : base(new SchedulingEvaluator(), new JSMRandomCreator()) {
     134//      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>()));
     135//      Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));
     136
     137//      Parameters.Add(new FixedValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue()));
     138//      Parameters.Add(new FixedValueParameter<IntValue>("Resources", "The number of resources used in this JSSP instance.", new IntValue()));
     139//      Parameters.Add(new ValueParameter<IScheduleEvaluator>("ScheduleEvaluator", "The evaluator used to determine the quality of a solution.", new MakespanEvaluator()));
     140//      Parameters.Add(new OptionalValueParameter<IScheduleDecoder>("ScheduleDecoder", "The operator that decodes the representation and creates a schedule.", new JSMDecoder()));
     141
     142//      EvaluatorParameter.GetsCollected = false;
     143//      EvaluatorParameter.Hidden = true;
     144//      ScheduleDecoderParameter.Hidden = true;
     145
     146//      InitializeOperators();
     147//      Load(DefaultInstance);
     148//      RegisterEventHandlers();
     149//    }
     150
     151//    public override IDeepCloneable Clone(Cloner cloner) {
     152//      return new JobShopSchedulingProblem(this, cloner);
     153//    }
     154
     155//    [StorableHook(HookType.AfterDeserialization)]
     156//    private void AfterDeserialization() {
     157//      RegisterEventHandlers();
     158//    }
     159
     160//    private void RegisterEventHandlers() {
     161//      ScheduleEvaluatorParameter.ValueChanged += ScheduleEvaluatorParameter_ValueChanged;
     162//      ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged;
     163//      SolutionCreator.ScheduleParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
     164//      ScheduleDecoderParameter.ValueChanged += ScheduleDecoderParameter_ValueChanged;
     165//      if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged;
     166//    }
     167
     168//    #region Events
     169//    protected override void OnSolutionCreatorChanged() {
     170//      SolutionCreator.ScheduleParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
     171//      InitializeOperators();
     172//    }
     173//    protected override void OnEvaluatorChanged() {
     174//      base.OnEvaluatorChanged();
     175//      ParameterizeOperators();
     176//    }
     177//    private void ScheduleEvaluatorParameter_ValueChanged(object sender, EventArgs eventArgs) {
     178//      ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged;
     179//      ParameterizeOperators();
     180//    }
     181//    private void ScheduleEvaluator_QualityParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
     182//      ParameterizeOperators();
     183//    }
     184
     185//    private void SolutionCreator_SchedulingEncodingParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
     186//      ParameterizeOperators();
     187//    }
     188//    private void ScheduleDecoderParameter_ValueChanged(object sender, EventArgs eventArgs) {
     189//      if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged;
     190//      ParameterizeOperators();
     191//    }
     192//    private void ScheduleDecoder_ScheduleParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
     193//      ParameterizeOperators();
     194//    }
     195//    #endregion
     196
     197//    #region Problem Instance Handling
     198//    public void Load(JSSPData data) {
     199//      var jobData = new ItemList<Job>(data.Jobs);
     200//      for (int j = 0; j < data.Jobs; j++) {
     201//        var job = new Job(j, data.DueDates != null ? data.DueDates[j] : double.MaxValue);
     202//        for (int t = 0; t < data.Resources; t++) {
     203//          job.Tasks.Add(new Task(t, data.Demands[j, t], j, data.ProcessingTimes[j, t]));
     204//        }
     205//        jobData.Add(job);
     206//      }
     207
     208//      BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null;
     209//      if (data.BestKnownSchedule != null) {
     210//        var enc = new JSMEncoding(0);
     211//        for (int i = 0; i < data.Resources; i++) {
     212//          enc.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, new int[data.Jobs]));
     213//          for (int j = 0; j < data.Jobs; j++) {
     214//            enc.JobSequenceMatrix[i][j] = data.BestKnownSchedule[i, j];
     215//          }
     216//        }
     217//        BestKnownSolution = JSMDecoder.DecodeSchedule(enc, jobData, JSMDecodingErrorPolicyTypes.RandomPolicy, JSMForcingStrategyTypes.SwapForcing);
     218//        if (ScheduleEvaluator is MeanTardinessEvaluator)
     219//          BestKnownQuality = new DoubleValue(MeanTardinessEvaluator.GetMeanTardiness(BestKnownSolution, jobData));
     220//        else if (ScheduleEvaluator is MakespanEvaluator)
     221//          BestKnownQuality = new DoubleValue(MakespanEvaluator.GetMakespan(BestKnownSolution));
     222//      }
     223
     224//      JobData = jobData;
     225//      Jobs = data.Jobs;
     226//      Resources = data.Resources;
     227//    }
     228
     229//    public JSSPData Export() {
     230//      var result = new JSSPData {
     231//        Name = Name,
     232//        Description = Description,
     233//        Jobs = Jobs,
     234//        Resources = Resources,
     235//        ProcessingTimes = new double[Jobs, Resources],
     236//        Demands = new int[Jobs, Resources],
     237//        DueDates = new double[Jobs]
     238//      };
     239
     240//      foreach (var job in JobData) {
     241//        var counter = 0;
     242//        result.DueDates[job.Index] = job.DueDate;
     243//        foreach (var task in job.Tasks) {
     244//          result.ProcessingTimes[task.JobNr, counter] = task.Duration;
     245//          result.Demands[task.JobNr, counter] = task.ResourceNr;
     246//          counter++;
     247//        }
     248//      }
     249//      return result;
     250//    }
     251//    #endregion
     252
     253//    #region Helpers
     254//    private void InitializeOperators() {
     255//      Operators.Clear();
     256//      ApplyEncoding();
     257//      Operators.Add(new BestSchedulingSolutionAnalyzer());
     258//      ParameterizeOperators();
     259//    }
     260
     261//    private void ApplyEncoding() {
     262//      if (SolutionCreator.GetType() == typeof(JSMRandomCreator)) {
     263//        Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>());
     264//        ScheduleDecoder = new JSMDecoder();
     265//      } else if (SolutionCreator.GetType() == typeof(PRVRandomCreator)) {
     266//        Operators.AddRange(ApplicationManager.Manager.GetInstances<IPRVOperator>());
     267//        ScheduleDecoder = new PRVDecoder();
     268//      } else if (SolutionCreator.GetType() == typeof(PWRRandomCreator)) {
     269//        Operators.AddRange(ApplicationManager.Manager.GetInstances<IPWROperator>());
     270//        ScheduleDecoder = new PWRDecoder();
     271//      } else if (SolutionCreator.GetType() == typeof(DirectScheduleRandomCreator)) {
     272//        Operators.AddRange(ApplicationManager.Manager.GetInstances<IDirectScheduleOperator>());
     273//        ScheduleDecoder = null;
     274//      }
     275//    }
     276
     277//    private void ParameterizeOperators() {
     278//      Evaluator.ScheduleDecoderParameter.ActualName = ScheduleDecoderParameter.Name;
     279//      Evaluator.ScheduleDecoderParameter.Hidden = true;
     280//      Evaluator.ScheduleEvaluatorParameter.ActualName = ScheduleEvaluatorParameter.Name;
     281//      Evaluator.ScheduleEvaluatorParameter.Hidden = true;
     282//      Evaluator.QualityParameter.ActualName = ScheduleEvaluator.QualityParameter.ActualName;
     283//      Evaluator.QualityParameter.Hidden = true;
     284
     285//      if (ScheduleDecoder != null)
     286//        ScheduleDecoder.ScheduleEncodingParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
     287
     288//      if (ScheduleDecoder != null) {
     289//        ScheduleEvaluator.ScheduleParameter.ActualName = ScheduleDecoder.ScheduleParameter.ActualName;
     290//        ScheduleEvaluator.ScheduleParameter.Hidden = true;
     291//      } else if (SolutionCreator is DirectScheduleRandomCreator) {
     292//        var directEvaluator = (DirectScheduleRandomCreator)SolutionCreator;
     293//        ScheduleEvaluator.ScheduleParameter.ActualName = directEvaluator.ScheduleParameter.ActualName;
     294//        ScheduleEvaluator.ScheduleParameter.Hidden = true;
     295//      } else {
     296//        ScheduleEvaluator.ScheduleParameter.ActualName = ScheduleEvaluator.ScheduleParameter.Name;
     297//        ScheduleEvaluator.ScheduleParameter.Hidden = false;
     298//      }
     299
     300//      foreach (var op in Operators.OfType<IScheduleManipulator>()) {
     301//        op.ScheduleParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
     302//        op.ScheduleParameter.Hidden = true;
     303//      }
     304
     305//      foreach (var op in Operators.OfType<IScheduleCrossover>()) {
     306//        op.ChildParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
     307//        op.ChildParameter.Hidden = true;
     308//        op.ParentsParameter.ActualName = SolutionCreator.ScheduleParameter.ActualName;
     309//        op.ParentsParameter.Hidden = true;
     310//      }
     311
     312//      foreach (var op in Operators.OfType<BestSchedulingSolutionAnalyzer>()) {
     313//        op.QualityParameter.ActualName = ScheduleEvaluator.QualityParameter.ActualName;
     314//        if (ScheduleDecoder != null) {
     315//          op.ScheduleParameter.ActualName = ScheduleDecoder.ScheduleParameter.ActualName;
     316//          op.ScheduleParameter.Hidden = true;
     317//        } else if (SolutionCreator is DirectScheduleRandomCreator) {
     318//          op.ScheduleParameter.ActualName = ((DirectScheduleRandomCreator)SolutionCreator).ScheduleParameter.ActualName;
     319//          op.ScheduleParameter.Hidden = true;
     320//        } else {
     321//          op.ScheduleParameter.ActualName = op.ScheduleParameter.Name;
     322//          op.ScheduleParameter.Hidden = false;
     323//        }
     324//      }
     325//    }
     326//    #endregion
     327
     328//  }
     329//}
  • branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/SchedulingProblem.cs

    r12012 r13443  
    1 #region License Information
    2 /* HeuristicLab
    3  * Copyright (C) 2002-2015 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
     1//#region License Information
     2///* HeuristicLab
     3// * Copyright (C) 2002-2015 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
    2121
    22 using HeuristicLab.Common;
    23 using HeuristicLab.Core;
    24 using HeuristicLab.Encodings.ScheduleEncoding;
    25 using HeuristicLab.Optimization;
    26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     22//using HeuristicLab.Common;
     23//using HeuristicLab.Core;
     24//using HeuristicLab.Encodings.ScheduleEncoding;
     25//using HeuristicLab.Optimization;
     26//using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Problems.Scheduling {
    29   [Item("SchedulingProblem", "Abstract class that represents a Scheduling Problem")]
    30   [StorableClass]
    31   public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem<ISchedulingEvaluator, IScheduleCreator> {
    32     [StorableConstructor]
    33     protected SchedulingProblem(bool deserializing) : base(deserializing) { }
    34     protected SchedulingProblem(SchedulingProblem original, Cloner cloner) : base(original, cloner) { }
    35     protected SchedulingProblem(ISchedulingEvaluator evaluator, IScheduleCreator creator) : base(evaluator, creator) { }
    36   }
    37 }
     28//namespace HeuristicLab.Problems.Scheduling {
     29//  [Item("SchedulingProblem", "Abstract class that represents a Scheduling Problem")]
     30//  [StorableClass]
     31//  public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem<ISchedulingEvaluator, IScheduleCreator> {
     32//    [StorableConstructor]
     33//    protected SchedulingProblem(bool deserializing) : base(deserializing) { }
     34//    protected SchedulingProblem(SchedulingProblem original, Cloner cloner) : base(original, cloner) { }
     35//    protected SchedulingProblem(ISchedulingEvaluator evaluator, IScheduleCreator creator) : base(evaluator, creator) { }
     36//  }
     37//}
Note: See TracChangeset for help on using the changeset viewer.