Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17461


Ignore:
Timestamp:
02/28/20 16:23:01 (4 years ago)
Author:
abeham
Message:

#2521: worked on scheduling problem

Location:
branches/2521_ProblemRefactoring
Files:
7 added
9 deleted
50 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab 3.3.sln

    r17260 r17461  
    458458EndProject
    459459Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.PTSP.Views-3.3", "HeuristicLab.Problems.PTSP.Views\3.3\HeuristicLab.Problems.PTSP.Views-3.3.csproj", "{90B6CA12-9791-4430-B2D7-CD3ED7F75E2B}"
     460EndProject
     461Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.Scheduling-3.3", "HeuristicLab.Problems.Scheduling\3.3\HeuristicLab.Problems.Scheduling-3.3.csproj", "{2BF1D639-1A74-44ED-AAAD-41ECD395AD93}"
     462EndProject
     463Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.Scheduling.Views-3.3", "HeuristicLab.Problems.Scheduling.Views\3.3\HeuristicLab.Problems.Scheduling.Views-3.3.csproj", "{78763A4E-E163-48C2-98EB-709760D06F25}"
    460464EndProject
    461465Global
     
    22292233    {90B6CA12-9791-4430-B2D7-CD3ED7F75E2B}.Release|x86.ActiveCfg = Release|x86
    22302234    {90B6CA12-9791-4430-B2D7-CD3ED7F75E2B}.Release|x86.Build.0 = Release|x86
     2235    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     2236    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|Any CPU.Build.0 = Debug|Any CPU
     2237    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|x64.ActiveCfg = Debug|x64
     2238    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|x64.Build.0 = Debug|x64
     2239    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|x86.ActiveCfg = Debug|x86
     2240    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|x86.Build.0 = Debug|x86
     2241    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|Any CPU.ActiveCfg = Release|Any CPU
     2242    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|Any CPU.Build.0 = Release|Any CPU
     2243    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|x64.ActiveCfg = Release|x64
     2244    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|x64.Build.0 = Release|x64
     2245    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|x86.ActiveCfg = Release|x86
     2246    {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|x86.Build.0 = Release|x86
     2247    {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
     2248    {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|Any CPU.Build.0 = Debug|Any CPU
     2249    {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|x64.ActiveCfg = Debug|x64
     2250    {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|x64.Build.0 = Debug|x64
     2251    {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|x86.ActiveCfg = Debug|x86
     2252    {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|x86.Build.0 = Debug|x86
     2253    {78763A4E-E163-48C2-98EB-709760D06F25}.Release|Any CPU.ActiveCfg = Release|Any CPU
     2254    {78763A4E-E163-48C2-98EB-709760D06F25}.Release|Any CPU.Build.0 = Release|Any CPU
     2255    {78763A4E-E163-48C2-98EB-709760D06F25}.Release|x64.ActiveCfg = Release|x64
     2256    {78763A4E-E163-48C2-98EB-709760D06F25}.Release|x64.Build.0 = Release|x64
     2257    {78763A4E-E163-48C2-98EB-709760D06F25}.Release|x86.ActiveCfg = Release|x86
     2258    {78763A4E-E163-48C2-98EB-709760D06F25}.Release|x86.Build.0 = Release|x86
    22312259  EndGlobalSection
    22322260  GlobalSection(SolutionProperties) = preSolution
  • branches/2521_ProblemRefactoring/HeuristicLab.Collections/3.3/IObservableCollection.cs

    r17226 r17461  
    2626namespace HeuristicLab.Collections {
    2727  [StorableType("289d81e9-a167-416c-aaa8-c40aa1ea96f9")]
    28   public interface IObservableCollection<T> : ICollection<T>, INotifyObservableCollectionItemsChanged<T>, INotifyPropertyChanged { }
     28  public interface IObservableCollection<T> : ICollection<T>, INotifyObservableCollectionItemsChanged<T>, INotifyPropertyChanged {
     29  }
    2930}
  • branches/2521_ProblemRefactoring/HeuristicLab.Collections/3.3/ObservableCollection.cs

    r17226 r17461  
    2020#endregion
    2121
    22 using HEAL.Attic;
    2322using System;
    2423using System.Collections;
     
    2625using System.ComponentModel;
    2726using System.Linq;
     27using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Collections {
     
    9797    public void AddRange(IEnumerable<T> collection) {
    9898      int capacity = list.Capacity;
    99       ICollection<T> items = collection as ICollection<T> ?? collection.ToList();
     99      var items = collection as ICollection<T> ?? collection.ToList();
    100100      list.AddRange(items);
    101101      if (items.Count > 0) {
     102        OnItemsAdded(items);
    102103        if (list.Capacity != capacity)
    103104          OnPropertyChanged("Capacity");
    104         OnPropertyChanged("Count");
    105         OnItemsAdded(items);
     105        OnPropertyChanged("Item[]");
     106        OnPropertyChanged("Count");
    106107      }
    107108    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Core/3.3/Interfaces/IConstrainedValueParameter.cs

    r17226 r17461  
     1using System.Collections.Generic;
    12using HEAL.Attic;
    23#region License Information
     
    2627  public interface IConstrainedValueParameter<T> : IValueParameter<T> where T : class, IItem {
    2728    IItemSet<T> ValidValues { get; }
     29
     30    void Populate(IEnumerable<IItem> items);
    2831  }
    2932}
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/HeuristicLab.Encodings.ScheduleEncoding-3.3.csproj

    r16723 r17461  
    128128    <Compile Include="Interfaces\IScheduleCreator.cs" />
    129129    <Compile Include="Interfaces\IScheduleCrossover.cs" />
    130     <Compile Include="Interfaces\ISchedule.cs" />
     130    <Compile Include="Interfaces\IScheduleSolution.cs" />
    131131    <Compile Include="Interfaces\IScheduleDecoder.cs" />
    132132    <Compile Include="Interfaces\IScheduleEncoding.cs" />
     
    138138    <Compile Include="JobSequenceMatrix\Crossovers\JSMSXXCrossover.cs" />
    139139    <Compile Include="JobSequenceMatrix\JobSequenceMatrixEncoding.cs" />
    140     <Compile Include="JobSequenceMatrix\JSMEncoding.cs" />
     140    <Compile Include="JobSequenceMatrix\JSM.cs" />
    141141    <Compile Include="JobSequenceMatrix\JSMRandomCreator.cs" />
    142142    <Compile Include="JobSequenceMatrix\Manipulators\JSMManipulator.cs" />
     
    149149    <Compile Include="PermutationWithRepetition\Manipulators\PWRInsertionManipulator.cs" />
    150150    <Compile Include="PermutationWithRepetition\PermutationWithRepetitionEncoding.cs" />
    151     <Compile Include="PermutationWithRepetition\PWREncoding.cs" />
     151    <Compile Include="PermutationWithRepetition\PWR.cs" />
    152152    <Compile Include="PermutationWithRepetition\PWRRandomCreator.cs" />
    153153    <Compile Include="Plugin.cs" />
     
    158158    <Compile Include="PriorityRulesVector\Manipulators\PRVUniformOnePositionManipulator.cs" />
    159159    <Compile Include="PriorityRulesVector\PriorityRulesVectorEncoding.cs" />
    160     <Compile Include="PriorityRulesVector\PRVEncoding.cs" />
     160    <Compile Include="PriorityRulesVector\PRV.cs" />
    161161    <Compile Include="PriorityRulesVector\PRVRandomCreator.cs" />
    162162    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleCreator.cs

    r17226 r17461  
    2828  [StorableType("d6738639-c5fc-46af-8997-7527ea718759")]
    2929  public interface IScheduleCreator<TSchedule> : ISolutionCreator<TSchedule>, IScheduleOperator
    30   where TSchedule : class,ISchedule {
     30  where TSchedule : class, IScheduleSolution {
    3131    ILookupParameter<TSchedule> ScheduleParameter { get; }
    3232    IValueLookupParameter<IntValue> JobsParameter { get; }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleCrossover.cs

    r17226 r17461  
    2727  [StorableType("809a6136-3a7a-4389-9119-2bb48f6d650a")]
    2828  public interface IScheduleCrossover : ICrossover, IScheduleOperator {
    29     ILookupParameter<ISchedule> ChildParameter { get; }
    30     IScopeTreeLookupParameter<ISchedule> ParentsParameter { get; }
     29    ILookupParameter<IScheduleSolution> ChildParameter { get; }
     30    IScopeTreeLookupParameter<IScheduleSolution> ParentsParameter { get; }
    3131  }
    3232}
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleDecoder.cs

    r16723 r17461  
    2626  [StorableType("010C752F-0F5E-4B93-8695-8DD74903DBE7")]
    2727  public interface IScheduleDecoder : IScheduleOperator {
    28     ILookupParameter<ISchedule> ScheduleEncodingParameter { get; }
     28    ILookupParameter<IScheduleSolution> ScheduleEncodingParameter { get; }
    2929    ILookupParameter<Schedule> ScheduleParameter { get; }
    3030    ILookupParameter<ItemList<Job>> JobDataParameter { get; }
    3131
    32     Schedule DecodeSchedule(ISchedule solution, ItemList<Job> jobData);
     32    Schedule DecodeSchedule(IScheduleSolution solution, ItemList<Job> jobData);
    3333  }
    3434
    3535  public interface IScheduleDecoder<TSchedule> : IScheduleDecoder
    36     where TSchedule : class, ISchedule {
     36    where TSchedule : class, IScheduleSolution {
    3737    Schedule DecodeSchedule(TSchedule solution, ItemList<Job> jobData);
    3838  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleEncoding.cs

    r17226 r17461  
    2222#endregion
    2323
     24using HEAL.Attic;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
    2627using HeuristicLab.Optimization;
    27 using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Encodings.ScheduleEncoding {
    3030  [StorableType("09b9d24c-2576-495a-b06c-338d095cba0d")]
    31   public interface IScheduleEncoding : IEncoding<ISchedule> {
    32     IFixedValueParameter<ItemList<Job>> JobDataParameter { get; set; }
     31  public interface IScheduleEncoding : IEncoding<IScheduleSolution> {
     32    IValueParameter<ItemList<Job>> JobDataParameter { get; set; }
    3333    IFixedValueParameter<IntValue> JobsParameter { get; set; }
    3434    IFixedValueParameter<IntValue> ResourcesParameter { get; set; }
     
    3939
    4040
    41     Schedule Decode(ISchedule schedule, ItemList<Job> jobData);
     41    Schedule Decode(IScheduleSolution schedule, ItemList<Job> jobData);
    4242  }
    4343
    4444  public interface IScheduleEncoding<TSchedule> : IEncoding<TSchedule>
    45     where TSchedule : class, ISchedule {
     45    where TSchedule : class, IScheduleSolution {
    4646
    4747  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleManipulator.cs

    r17226 r17461  
    2727  [StorableType("aa89fd6f-db49-457d-abc9-5600aa8f24e5")]
    2828  public interface IScheduleManipulator : IManipulator, IScheduleOperator {
    29     ILookupParameter<ISchedule> ScheduleParameter { get; }
     29    ILookupParameter<IScheduleSolution> ScheduleParameter { get; }
    3030  }
    3131}
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMCrossover.cs

    r17226 r17461  
    3535    public JSMCrossover() : base() { }
    3636
    37     public abstract JSMEncoding Cross(IRandom random, JSMEncoding parent1, JSMEncoding parent2);
     37    public abstract JSM Cross(IRandom random, JSM parent1, JSM parent2);
    3838
    3939    public override IOperation InstrumentedApply() {
     
    4141
    4242      ChildParameter.ActualValue =
    43         Cross(RandomParameter.ActualValue, parents[0] as JSMEncoding, parents[1] as JSMEncoding);
     43        Cross(RandomParameter.ActualValue, parents[0] as JSM, parents[1] as JSM);
    4444
    4545      return base.InstrumentedApply();
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMJOXCrossover.cs

    r17226 r17461  
    4040    }
    4141
    42     public static JSMEncoding Apply(IRandom random, JSMEncoding p1, JSMEncoding p2) {
    43       var result = new JSMEncoding(random.Next());
     42    public static JSM Apply(IRandom random, JSM p1, JSM p2) {
     43      var result = new JSM(random.Next());
    4444
    4545      int nrOfResources = p1.JobSequenceMatrix.Count;
     
    5353
    5454      bool dominantParent = random.Next(2) == 1;
    55       JSMEncoding parent1 = dominantParent ? p1 : p2;
    56       JSMEncoding parent2 = dominantParent ? p2 : p1;
     55      JSM parent1 = dominantParent ? p1 : p2;
     56      JSM parent2 = dominantParent ? p2 : p1;
    5757
    5858      //Fill childmatrix with values
     
    7575    }
    7676
    77     public override JSMEncoding Cross(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
     77    public override JSM Cross(IRandom random, JSM parent1, JSM parent2) {
    7878      return Apply(random, parent1, parent2);
    7979    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMOXCrossover.cs

    r17226 r17461  
    3838    }
    3939
    40     public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
    41       var result = new JSMEncoding(random.Next());
     40    public static JSM Apply(IRandom random, JSM parent1, JSM parent2) {
     41      var result = new JSM(random.Next());
    4242
    4343      for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) {
     
    5050    }
    5151
    52     public override JSMEncoding Cross(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
     52    public override JSM Cross(IRandom random, JSM parent1, JSM parent2) {
    5353      return Apply(random, parent1, parent2);
    5454    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMSXXCrossover.cs

    r17226 r17461  
    3939    }
    4040
    41     public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
    42       var result = new JSMEncoding(random.Next());
     41    public static JSM Apply(IRandom random, JSM parent1, JSM parent2) {
     42      var result = new JSM(random.Next());
    4343      int subSequenceLength = random.Next(parent1.JobSequenceMatrix[0].Length);
    4444      for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) {
     
    9191    }
    9292
    93     public override JSMEncoding Cross(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
     93    public override JSM Cross(IRandom random, JSM parent1, JSM parent2) {
    9494      return Apply(random, parent1, parent2);
    9595    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Decoder/JSMDecoder.cs

    r16725 r17461  
    3434  [Item("JobSequenceMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequence Matrix.")]
    3535  [StorableType("BBE354C2-7599-43CC-ACDC-F8F0F65BE3F5")]
    36   public class JSMDecoder : ScheduleDecoder<JSMEncoding> {
     36  public class JSMDecoder : ScheduleDecoder<JSM>, IJSMOperator {
    3737
    3838    public IFixedValueParameter<EnumValue<JSMDecodingErrorPolicy>> DecodingErrorPolicyParameter {
     
    6464    }
    6565
    66     private static Task SelectTaskFromConflictSet(JSMEncoding solution, JSMDecodingErrorPolicy decodingErrorPolicy, JSMForcingStrategy forcingStrategy, int conflictedResourceNr, int progressOnConflictedResource, ItemList<Task> conflictSet, IRandom random) {
     66    private static Task SelectTaskFromConflictSet(JSM solution, JSMDecodingErrorPolicy decodingErrorPolicy, JSMForcingStrategy forcingStrategy, int conflictedResourceNr, int progressOnConflictedResource, ItemList<Task> conflictSet, IRandom random) {
    6767      if (conflictSet.Count == 1)
    6868        return conflictSet[0];
     
    108108    }
    109109
    110     private static void ApplyForcingStrategy(JSMForcingStrategy forcingStrategy, JSMEncoding solution, int conflictedResource, int newResolutionIndex, int progressOnResource, int newResolution) {
     110    private static void ApplyForcingStrategy(JSMForcingStrategy forcingStrategy, JSM solution, int conflictedResource, int newResolutionIndex, int progressOnResource, int newResolution) {
    111111      var jsm = solution.JobSequenceMatrix;
    112112      if (forcingStrategy == JSMForcingStrategy.SwapForcing) {
     
    130130    }
    131131
    132     public override Schedule DecodeSchedule(JSMEncoding encoding, ItemList<Job> jobData) {
     132    public override Schedule DecodeSchedule(JSM encoding, ItemList<Job> jobData) {
    133133      return Decode(encoding, jobData, DecodingErrorPolicy, ForcingStrategy);
    134134    }
    135135
    136     public static Schedule Decode(JSMEncoding solution, ItemList<Job> jobData, JSMDecodingErrorPolicy decodingErrorPolicy, JSMForcingStrategy forcingStrategy) {
     136    public static Schedule Decode(JSM solution, ItemList<Job> jobData, JSMDecodingErrorPolicy decodingErrorPolicy, JSMForcingStrategy forcingStrategy) {
    137137      var random = new FastRandom(solution.RandomSeed);
    138138      var jobs = (ItemList<Job>)jobData.Clone();
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMRandomCreator.cs

    r17226 r17461  
    3030  [Item("JobSequenceMatrixCreator", "Creator class used to create Job Sequence Matrix solutions for standard JobShop scheduling problems.")]
    3131  [StorableType("F8053C69-31C2-4E05-8FA0-5AED15FAF804")]
    32   public class JSMRandomCreator : ScheduleCreator<JSMEncoding>, IStochasticOperator {
     32  public class JSMRandomCreator : ScheduleCreator<JSM>, IStochasticOperator {
    3333
    3434    public ILookupParameter<IRandom> RandomParameter {
     
    4848    }
    4949
    50     public static JSMEncoding Apply(int jobs, int resources, IRandom random) {
    51       var solution = new JSMEncoding(random.Next());
     50    public static JSM Apply(int jobs, int resources, IRandom random) {
     51      var solution = new JSM(random.Next());
    5252      for (int i = 0; i < resources; i++) {
    5353        solution.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, jobs, random));
     
    5656    }
    5757
    58     protected override JSMEncoding CreateSolution() {
     58    protected override JSM CreateSolution() {
    5959      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue);
    6060    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JobSequenceMatrixEncoding.cs

    r16725 r17461  
    3131
    3232namespace HeuristicLab.Encodings.ScheduleEncoding {
     33  [Item("Job Sequence Matrix Encoding", "Represents an encoding of schedules in form of a job sequence per resource.")]
    3334  [StorableType("9C090369-0214-42E6-8C3E-369751F5A9E1")]
    34   public sealed class JobSequenceMatrixEncoding : ScheduleEncoding<JSMEncoding> {
     35  public sealed class JobSequenceMatrixEncoding : ScheduleEncoding<JSM> {
    3536    [StorableConstructor]
    3637    private JobSequenceMatrixEncoding(StorableConstructorFlag _) : base(_) { }
     
    4142
    4243    public JobSequenceMatrixEncoding()
    43       : base() {
     44      : base("JSM") {
    4445      SolutionCreator = new JSMRandomCreator();
    4546      Decoder = new JSMDecoder();
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMManipulator.cs

    r17226 r17461  
    3434    public JSMManipulator() : base() { }
    3535
    36     protected abstract void Manipulate(IRandom random, ISchedule individual);
     36    protected abstract void Manipulate(IRandom random, IScheduleSolution individual);
    3737
    3838    public override IOperation InstrumentedApply() {
    39       var solution = ScheduleParameter.ActualValue as JSMEncoding;
     39      var solution = ScheduleParameter.ActualValue as JSM;
    4040      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type JSMEncoding.");
    4141      Manipulate(RandomParameter.ActualValue, solution);
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMShiftChangeManipulator.cs

    r17226 r17461  
    4242    }
    4343
    44     public static void Apply(IRandom random, JSMEncoding individual) {
     44    public static void Apply(IRandom random, JSM individual) {
    4545      int nrOfJobs = individual.JobSequenceMatrix[0].Length;
    4646      int jobIndex = random.Next(nrOfJobs);
     
    6363    }
    6464
    65     protected override void Manipulate(IRandom random, ISchedule encoding) {
    66       var solution = encoding as JSMEncoding;
     65    protected override void Manipulate(IRandom random, IScheduleSolution encoding) {
     66      var solution = encoding as JSM;
    6767      if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
    6868      Apply(random, solution);
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMSwapManipulator.cs

    r17226 r17461  
    4040    }
    4141
    42     public static void Apply(IRandom random, JSMEncoding individual) {
     42    public static void Apply(IRandom random, JSM individual) {
    4343      int resourceIndex = random.Next(individual.JobSequenceMatrix.Count);
    4444      Permutation p = individual.JobSequenceMatrix[resourceIndex];
     
    5050    }
    5151
    52     protected override void Manipulate(IRandom random, ISchedule individual) {
    53       var solution = individual as JSMEncoding;
     52    protected override void Manipulate(IRandom random, IScheduleSolution individual) {
     53      var solution = individual as JSM;
    5454      if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
    5555      Apply(random, solution);
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRCrossover.cs

    r17226 r17461  
    3838    }
    3939
    40     public abstract PWREncoding Cross(IRandom random, PWREncoding parent1, PWREncoding parent2);
     40    public abstract PWR Cross(IRandom random, PWR parent1, PWR parent2);
    4141
    4242    public override IOperation InstrumentedApply() {
     
    4444
    4545      ChildParameter.ActualValue =
    46         Cross(RandomParameter.ActualValue, parents[0] as PWREncoding, parents[1] as PWREncoding);
     46        Cross(RandomParameter.ActualValue, parents[0] as PWR, parents[1] as PWR);
    4747
    4848      return base.InstrumentedApply();
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRGOXCrossover.cs

    r17226 r17461  
    5555    }
    5656
    57     public static PWREncoding Apply(IRandom random, PWREncoding parent1, PWREncoding parent2) {
    58       var result = new PWREncoding();
     57    public static PWR Apply(IRandom random, PWR parent1, PWR parent2) {
     58      var result = new PWR();
    5959
    6060      var p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList();
     
    8787    }
    8888
    89     public override PWREncoding Cross(IRandom random, PWREncoding parent1, PWREncoding parent2) {
     89    public override PWR Cross(IRandom random, PWR parent1, PWR parent2) {
    9090      return Apply(random, parent1, parent2);
    9191    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRPPXCrossover.cs

    r17226 r17461  
    4141    }
    4242
    43     public static PWREncoding Apply(IRandom random, PWREncoding parent1, PWREncoding parent2) {
    44       var result = new PWREncoding();
     43    public static PWR Apply(IRandom random, PWR parent1, PWR parent2) {
     44      var result = new PWR();
    4545      var p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList();
    4646      var p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList();
     
    6969    }
    7070
    71     public override PWREncoding Cross(IRandom random, PWREncoding parent1, PWREncoding parent2) {
     71    public override PWR Cross(IRandom random, PWR parent1, PWR parent2) {
    7272      return Apply(random, parent1, parent2);
    7373    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Decoder/PWRDecoder.cs

    r16725 r17461  
    2727  [Item("PWRDecoder", "An item used to convert a PWR-individual into a generalized schedule.")]
    2828  [StorableType("60D171BE-9704-40E1-9C63-0E56D95403CD")]
    29   public class PWRDecoder : ScheduleDecoder<PWREncoding> {
     29  public class PWRDecoder : ScheduleDecoder<PWR>, IPWROperator {
    3030    [StorableConstructor]
    3131    protected PWRDecoder(StorableConstructorFlag _) : base(_) { }
     
    3737    }
    3838
    39     public override Schedule DecodeSchedule(PWREncoding solution, ItemList<Job> jobData) {
     39    public override Schedule DecodeSchedule(PWR solution, ItemList<Job> jobData) {
    4040      return Decode(solution, jobData);
    4141    }
    4242
    43     public static Schedule Decode(PWREncoding solution, ItemList<Job> jobData) {
     43    public static Schedule Decode(PWR solution, ItemList<Job> jobData) {
    4444      var jobs = (ItemList<Job>)jobData.Clone();
    4545      var resultingSchedule = new Schedule(jobs[0].Tasks.Count);
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Manipulators/PWRInsertionManipulator.cs

    r17226 r17461  
    4040    }
    4141
    42     public static void Apply(IRandom random, PWREncoding individual) {
     42    public static void Apply(IRandom random, PWR individual) {
    4343      int cutIndex = random.Next(individual.PermutationWithRepetition.Length);
    4444      int insertIndex = random.Next(individual.PermutationWithRepetition.Length);
     
    5555    }
    5656
    57     protected override void Manipulate(IRandom random, PWREncoding individual) {
     57    protected override void Manipulate(IRandom random, PWR individual) {
    5858      Apply(random, individual);
    5959    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Manipulators/PWRManipulator.cs

    r17226 r17461  
    3535    public PWRManipulator() : base() { }
    3636
    37     protected abstract void Manipulate(IRandom random, PWREncoding individual);
     37    protected abstract void Manipulate(IRandom random, PWR individual);
    3838
    3939    public override IOperation InstrumentedApply() {
    40       var solution = ScheduleParameter.ActualValue as PWREncoding;
     40      var solution = ScheduleParameter.ActualValue as PWR;
    4141      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type PWREncoding.");
    4242      Manipulate(RandomParameter.ActualValue, solution);
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWRRandomCreator.cs

    r17226 r17461  
    2929  [Item("PermutationWithRepetitionRandomCreator", "Creates PWR-individuals at random.")]
    3030  [StorableType("6E753916-C0FD-4585-B6A6-47FD66ED098F")]
    31   public class PWRRandomCreator : ScheduleCreator<PWREncoding>, IStochasticOperator {
     31  public class PWRRandomCreator : ScheduleCreator<PWR>, IStochasticOperator {
    3232
    3333    public ILookupParameter<IRandom> RandomParameter {
     
    4747    }
    4848
    49     public static PWREncoding Apply(int jobs, int resources, IRandom random) {
    50       return new PWREncoding(jobs, resources, random);
     49    public static PWR Apply(int jobs, int resources, IRandom random) {
     50      return new PWR(jobs, resources, random);
    5151    }
    5252
    53     protected override PWREncoding CreateSolution() {
     53    protected override PWR CreateSolution() {
    5454      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue);
    5555    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PermutationWithRepetitionEncoding.cs

    r16725 r17461  
    3232namespace HeuristicLab.Encodings.ScheduleEncoding {
    3333  [StorableType("468EF506-0749-469B-B9B9-36655AA0178D")]
    34   public sealed class PermutationWithRepetitionEncoding : ScheduleEncoding<PWREncoding> {
     34  public sealed class PermutationWithRepetitionEncoding : ScheduleEncoding<PWR> {
    3535    [StorableConstructor]
    3636    private PermutationWithRepetitionEncoding(StorableConstructorFlag _) : base(_) { }
     
    4141
    4242    public PermutationWithRepetitionEncoding()
    43       : base() {
     43      : base("PWR") {
    4444      SolutionCreator = new PWRRandomCreator();
    4545      Decoder = new PWRDecoder();
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVCrossover.cs

    r17226 r17461  
    3434    public PRVCrossover() : base() { }
    3535
    36     public abstract PRVEncoding Cross(IRandom random, PRVEncoding parent1, PRVEncoding parent2);
     36    public abstract PRV Cross(IRandom random, PRV parent1, PRV parent2);
    3737
    3838    public override IOperation InstrumentedApply() {
    3939      var parents = ParentsParameter.ActualValue;
    4040      ChildParameter.ActualValue =
    41         Cross(RandomParameter.ActualValue, parents[0] as PRVEncoding, parents[1] as PRVEncoding);
     41        Cross(RandomParameter.ActualValue, parents[0] as PRV, parents[1] as PRV);
    4242      return base.InstrumentedApply();
    4343    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVDiscreteCrossover.cs

    r17226 r17461  
    3939    }
    4040
    41     public static PRVEncoding Apply(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {
     41    public static PRV Apply(IRandom random, PRV parent1, PRV parent2) {
    4242      var randomSeed = random.Next();
    4343      var integerVector = DiscreteCrossover.Apply(random, new ItemArray<IntegerVector>(new[] { parent1.PriorityRulesVector, parent2.PriorityRulesVector }));
    44       return new PRVEncoding(integerVector, randomSeed);
     44      return new PRV(integerVector, randomSeed);
    4545    }
    4646
    47     public override PRVEncoding Cross(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {
     47    public override PRV Cross(IRandom random, PRV parent1, PRV parent2) {
    4848      return Apply(random, parent1, parent2);
    4949    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVSinglePointCrossover.cs

    r17226 r17461  
    3939    }
    4040
    41     public static PRVEncoding Apply(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {
     41    public static PRV Apply(IRandom random, PRV parent1, PRV parent2) {
    4242      var randomSeed = random.Next();
    4343      var integerVector = SinglePointCrossover.Apply(random, parent1.PriorityRulesVector, parent2.PriorityRulesVector);
    44       return new PRVEncoding(integerVector, randomSeed);
     44      return new PRV(integerVector, randomSeed);
    4545    }
    4646
    47     public override PRVEncoding Cross(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {
     47    public override PRV Cross(IRandom random, PRV parent1, PRV parent2) {
    4848      return Apply(random, parent1, parent2);
    4949    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Decoder/PRVDecoder.cs

    r16725 r17461  
    2929  [Item("JobSequencingMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")]
    3030  [StorableType("2D059957-AC7C-4B33-BADE-96706AEBAF29")]
    31   public class PRVDecoder : ScheduleDecoder<PRVEncoding> {
     31  public class PRVDecoder : ScheduleDecoder<PRV>, IPRVOperator {
    3232    #region Priority Rules
    3333    //smallest number of remaining tasks
     
    187187    }
    188188
    189     public override Schedule DecodeSchedule(PRVEncoding encoding, ItemList<Job> jobData) {
     189    public override Schedule DecodeSchedule(PRV encoding, ItemList<Job> jobData) {
    190190      return Decode(encoding, jobData);
    191191    }
    192192
    193     public static Schedule Decode(PRVEncoding solution, ItemList<Job> jobData) {
     193    public static Schedule Decode(PRV solution, ItemList<Job> jobData) {
    194194      var random = new FastRandom(solution.RandomSeed);
    195195      var jobs = (ItemList<Job>)jobData.Clone();
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Manipulators/PRVManipulator.cs

    r17226 r17461  
    4646    }
    4747
    48     protected abstract void Manipulate(IRandom random, PRVEncoding individual, int numberOfRules);
     48    protected abstract void Manipulate(IRandom random, PRV individual, int numberOfRules);
    4949
    5050    public override IOperation InstrumentedApply() {
    51       var solution = ScheduleParameter.ActualValue as PRVEncoding;
     51      var solution = ScheduleParameter.ActualValue as PRV;
    5252      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type PRVEncoding.");
    5353      Manipulate(RandomParameter.ActualValue, solution, NumberOfRulesParameter.ActualValue.Value);
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Manipulators/PRVUniformOnePositionManipulator.cs

    r17226 r17461  
    4040    }
    4141
    42     public static void Apply(IRandom random, PRVEncoding individual, int numberOfRules) {
     42    public static void Apply(IRandom random, PRV individual, int numberOfRules) {
    4343      UniformOnePositionManipulator.Apply(random, individual.PriorityRulesVector, new IntMatrix(new int[,] { { 0, numberOfRules } }));
    4444    }
    4545
    46     protected override void Manipulate(IRandom random, PRVEncoding individual, int numberOfRules) {
     46    protected override void Manipulate(IRandom random, PRV individual, int numberOfRules) {
    4747      Apply(random, individual, numberOfRules);
    4848    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVRandomCreator.cs

    r17226 r17461  
    2929  [Item("PriorityRulesRandomCreator", "Creator class used to create PRV encoding objects for scheduling problems.")]
    3030  [StorableType("5FF2A11E-86F9-4A8B-8E1C-713D6801506C")]
    31   public class PRVRandomCreator : ScheduleCreator<PRVEncoding>, IStochasticOperator {
     31  public class PRVRandomCreator : ScheduleCreator<PRV>, IStochasticOperator {
    3232
    3333    [Storable]
     
    5454    }
    5555
    56     public static PRVEncoding Apply(int jobs, int resources, IRandom random, int nrOfRules) {
    57       return new PRVEncoding(jobs * resources, random, 0, nrOfRules);
     56    public static PRV Apply(int jobs, int resources, IRandom random, int nrOfRules) {
     57      return new PRV(jobs * resources, random, 0, nrOfRules);
    5858    }
    5959
    60     protected override PRVEncoding CreateSolution() {
     60    protected override PRV CreateSolution() {
    6161      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue, NrOfRules);
    6262    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PriorityRulesVectorEncoding.cs

    r16725 r17461  
    3434namespace HeuristicLab.Encodings.ScheduleEncoding {
    3535  [StorableType("9C419EE5-F3A8-4F06-8263-7D37D3AE1C72")]
    36   public sealed class PriorityRulesVectorEncoding : ScheduleEncoding<PRVEncoding> {
     36  public sealed class PriorityRulesVectorEncoding : ScheduleEncoding<PRV> {
    3737
    3838    private IFixedValueParameter<IntValue> numberOfRulesParameter;
     
    6060
    6161    public PriorityRulesVectorEncoding()
    62       : base() {
     62      : base("PRV") {
    6363      //TODO change to meaningful value
    6464      numberOfRulesParameter = new FixedValueParameter<IntValue>(Name + ".NumberOfRules", new IntValue(10));
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleCreator.cs

    r17226 r17461  
    3131  [StorableType("3DDA1485-4518-4F1D-A475-795FFE63C98E")]
    3232  public abstract class ScheduleCreator<TSchedule> : InstrumentedOperator, IScheduleCreator<TSchedule>
    33   where TSchedule : class,ISchedule {
     33  where TSchedule : class,IScheduleSolution {
    3434
    3535    public ILookupParameter<TSchedule> ScheduleParameter {
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleCrossover.cs

    r17226 r17461  
    3232  public abstract class ScheduleCrossover : InstrumentedOperator, IScheduleCrossover, IStochasticOperator {
    3333
    34     public ILookupParameter<ISchedule> ChildParameter {
    35       get { return (ILookupParameter<ISchedule>)Parameters["Child"]; }
     34    public ILookupParameter<IScheduleSolution> ChildParameter {
     35      get { return (ILookupParameter<IScheduleSolution>)Parameters["Child"]; }
    3636    }
    37     public IScopeTreeLookupParameter<ISchedule> ParentsParameter {
    38       get { return (IScopeTreeLookupParameter<ISchedule>)Parameters["Parents"]; }
     37    public IScopeTreeLookupParameter<IScheduleSolution> ParentsParameter {
     38      get { return (IScopeTreeLookupParameter<IScheduleSolution>)Parameters["Parents"]; }
    3939    }
    4040    public ILookupParameter<IRandom> RandomParameter {
     
    4848      : base() {
    4949      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    50       Parameters.Add(new LookupParameter<ISchedule>("Child", "The child solution resulting from the crossover."));
     50      Parameters.Add(new LookupParameter<IScheduleSolution>("Child", "The child solution resulting from the crossover."));
    5151      ChildParameter.ActualName = "Schedule";
    52       Parameters.Add(new ScopeTreeLookupParameter<ISchedule>("Parents", "The parent solution which should be crossed."));
     52      Parameters.Add(new ScopeTreeLookupParameter<IScheduleSolution>("Parents", "The parent solution which should be crossed."));
    5353      ParentsParameter.ActualName = "Schedule";
    5454    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleDecoder.cs

    r17226 r17461  
    3131  [StorableType("57A68F4B-4B35-4DB4-9B5E-D5154DD46E45")]
    3232  public abstract class ScheduleDecoder<TSchedule> : SingleSuccessorOperator, IScheduleDecoder<TSchedule>
    33   where TSchedule : class, ISchedule {
     33  where TSchedule : class, IScheduleSolution {
    3434
    35     public ILookupParameter<ISchedule> ScheduleEncodingParameter {
    36       get { return (ILookupParameter<ISchedule>)Parameters["EncodedSchedule"]; }
     35    public ILookupParameter<IScheduleSolution> ScheduleEncodingParameter {
     36      get { return (ILookupParameter<IScheduleSolution>)Parameters["EncodedSchedule"]; }
    3737    }
    3838    public ILookupParameter<Schedule> ScheduleParameter {
     
    4848    public ScheduleDecoder()
    4949      : base() {
    50       Parameters.Add(new LookupParameter<ISchedule>("EncodedSchedule", "The new scheduling solution represented as encoding."));
     50      Parameters.Add(new LookupParameter<IScheduleSolution>("EncodedSchedule", "The new scheduling solution represented as encoding."));
    5151      Parameters.Add(new LookupParameter<Schedule>("Schedule", "The decoded scheduling solution represented as generalized schedule."));
    5252      Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance."));
    5353    }
    5454
    55     public Schedule DecodeSchedule(ISchedule schedule, ItemList<Job> jobData) {
     55    public Schedule DecodeSchedule(IScheduleSolution schedule, ItemList<Job> jobData) {
    5656      TSchedule solution = schedule as TSchedule;
    5757      if (solution == null) throw new InvalidOperationException("Encoding is not of type " + typeof(TSchedule).GetPrettyName());
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding.cs

    r17226 r17461  
    3333  [StorableType("D2FB1AF9-EF13-4ED2-B3E9-D5BE4E5772EA")]
    3434  public abstract class ScheduleEncoding<TSchedule> : Encoding<TSchedule>, IScheduleEncoding
    35   where TSchedule : class, ISchedule {
     35  where TSchedule : class, IScheduleSolution {
    3636    #region Encoding Parameters
    3737    [Storable]
    38     private IFixedValueParameter<ItemList<Job>> jobDataParameter;
    39     public IFixedValueParameter<ItemList<Job>> JobDataParameter {
     38    private IValueParameter<ItemList<Job>> jobDataParameter;
     39    public IValueParameter<ItemList<Job>> JobDataParameter {
    4040      get { return jobDataParameter; }
    4141      set {
     
    126126    }
    127127
    128     protected ScheduleEncoding() : this("Schedule") { }
    129128    protected ScheduleEncoding(string name) : this(name, Enumerable.Empty<Job>()) { }
    130129    protected ScheduleEncoding(string name, IEnumerable<Job> jobData)
     
    133132      int resources = jobData.SelectMany(j => j.Tasks).Select(t => t.ResourceNr).Distinct().Count();
    134133
    135       jobDataParameter = new FixedValueParameter<ItemList<Job>>(Name + ".JobData", new ItemList<Job>(jobData));
     134      jobDataParameter = new ValueParameter<ItemList<Job>>(Name + ".JobData", new ItemList<Job>(jobData));
    136135      jobsParameter = new FixedValueParameter<IntValue>(Name + ".Jobs", new IntValue(jobs));
    137136      resourcesParameter = new FixedValueParameter<IntValue>(Name + ".Resources", new IntValue(resources));
     
    144143    }
    145144
    146     public Schedule Decode(ISchedule schedule, ItemList<Job> jobData) {
     145    public Schedule Decode(IScheduleSolution schedule, ItemList<Job> jobData) {
    147146      return Decoder.DecodeSchedule(schedule, jobData);
    148147    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Decoder/DirectScheduleDecoder.cs

    r16725 r17461  
    2727  [Item("DirectScheduleDecoder", "An item used to convert a direct schedule into a generalized schedule.")]
    2828  [StorableType("151C772B-6E6C-40D9-B171-F5626C676A5F")]
    29   public class DirectScheduleDecoder : ScheduleDecoder<Schedule> {
     29  public class DirectScheduleDecoder : ScheduleDecoder<Schedule>, IDirectScheduleOperator {
    3030    [StorableConstructor]
    3131    protected DirectScheduleDecoder(StorableConstructorFlag _) : base(_) { }
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleEncoding.cs

    r16725 r17461  
    3131
    3232namespace HeuristicLab.Encodings.ScheduleEncoding {
     33  [Item("Direct Schedule Encoding", "Encodes a solution by directly assigning start and end types to the tasks.")]
    3334  [StorableType("BB1BD851-3E77-4357-942C-EAF5BE6760B4")]
    3435  public sealed class DirectScheduleEncoding : ScheduleEncoding<Schedule> {
     
    4142
    4243    public DirectScheduleEncoding()
    43       : base() {
     44      : base("Schedule") {
    4445      SolutionCreator = new DirectScheduleRandomCreator();
    4546      Decoder = new DirectScheduleDecoder();
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleRandomCreator.cs

    r17226 r17461  
    5454
    5555
    56     public static Schedule Apply(PWREncoding pwr, ItemList<Job> jobData) {
     56    public static Schedule Apply(PWR pwr, ItemList<Job> jobData) {
    5757      var resultingSchedule = new Schedule(jobData[0].Tasks.Count);
    5858      foreach (int jobNr in pwr.PermutationWithRepetition) {
     
    7070    protected override Schedule CreateSolution() {
    7171      var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
    72       var pwrEncoding = new PWREncoding(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value,
     72      var pwrEncoding = new PWR(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value,
    7373        RandomParameter.ActualValue);
    7474      return Apply(pwrEncoding, jobData);
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Schedule.cs

    r17360 r17461  
    3131  [Item("Schedule", "Represents the general solution for scheduling problems.")]
    3232  [StorableType("EA6D14A3-7FA6-4B4B-B7F6-40B42657D398")]
    33   public class Schedule : NamedItem, ISchedule {
     33  public class Schedule : NamedItem, IScheduleSolution {
    3434
    3535    #region Properties
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleManipulator.cs

    r17226 r17461  
    3232  public abstract class ScheduleManipulator : InstrumentedOperator, IScheduleManipulator, IStochasticOperator {
    3333
    34     public ILookupParameter<ISchedule> ScheduleParameter {
    35       get { return (ILookupParameter<ISchedule>)Parameters["Schedule"]; }
     34    public ILookupParameter<IScheduleSolution> ScheduleParameter {
     35      get { return (ILookupParameter<IScheduleSolution>)Parameters["Schedule"]; }
    3636    }
    3737
     
    4545    public ScheduleManipulator()
    4646      : base() {
    47       Parameters.Add(new LookupParameter<ISchedule>("Schedule", "The scheduling solution to be manipulated."));
     47      Parameters.Add(new LookupParameter<IScheduleSolution>("Schedule", "The scheduling solution to be manipulated."));
    4848      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    4949    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs

    r17317 r17461  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Drawing;
     25using System.Linq;
    2426using HEAL.Attic;
    2527using HeuristicLab.Collections;
     
    168170    #endregion
    169171
     172    public void Populate(IEnumerable<IItem> items) {
     173      ValidValues.Clear();
     174      ValidValues.UnionWith(items.OfType<T>());
     175    }
     176
    170177    [StorableHook(HookType.AfterDeserialization)]
    171178    private void AfterDeserialization() {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling.Views/3.3/HeuristicLab.Problems.Scheduling.Views-3.3.csproj

    r16723 r17461  
    116116  </ItemGroup>
    117117  <ItemGroup>
    118     <Compile Include="JobShopSchedulingProblemView.cs" />
     118    <Compile Include="JobShopSchedulingProblemView.cs">
     119      <SubType>UserControl</SubType>
     120    </Compile>
    119121    <Compile Include="JobShopSchedulingProblemView.Designer.cs">
    120122      <DependentUpon>JobShopSchedulingProblemView.cs</DependentUpon>
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs

    r17226 r17461  
    2020#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;
     22using System;
     23using System.Windows.Forms;
     24using HeuristicLab.Collections;
     25using HeuristicLab.Encodings.ScheduleEncoding;
     26using HeuristicLab.MainForm;
     27using 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 {
     29namespace 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/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/HeuristicLab.Problems.Scheduling-3.3.csproj

    r16723 r17461  
    112112  </ItemGroup>
    113113  <ItemGroup>
    114     <Compile Include="Analyzers\BestSchedulingSolutionAnalyzer.cs" />
    115     <Compile Include="Analyzers\SchedulingAnalyzer.cs" />
    116     <Compile Include="Evaluators\MeanTardinessEvaluator.cs" />
    117     <Compile Include="Evaluators\MakespanEvaluator.cs" />
    118     <Compile Include="Evaluators\ScheduleEvaluator.cs" />
    119     <Compile Include="Interfaces\IJSSPOperator.cs" />
    120     <Compile Include="Interfaces\IScheduleEvaluator.cs" />
    121     <Compile Include="Interfaces\ISchedulingEvaluator.cs" />
    122     <Compile Include="JobShopSchedulingProblem new.cs" />
     114    <Compile Include="Objectives\MeanTardiness.cs" />
     115    <Compile Include="Objectives\Makespan.cs" />
    123116    <Compile Include="JobShopSchedulingProblem.cs" />
    124     <Compile Include="Evaluators\SchedulingEvaluator.cs" />
    125117    <Compile Include="Plugin.cs" />
    126118    <Compile Include="Properties\AssemblyInfo.cs" />
    127     <Compile Include="SchedulingProblem.cs" />
    128119  </ItemGroup>
    129120  <ItemGroup>
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs

    r17226 r17461  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
     23using System.ComponentModel;
    2324using System.Drawing;
    2425using System.Linq;
     26using System.Threading;
     27using HEAL.Attic;
    2528using HeuristicLab.Common;
    2629using HeuristicLab.Core;
     
    2831using HeuristicLab.Encodings.PermutationEncoding;
    2932using HeuristicLab.Encodings.ScheduleEncoding;
    30 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;
    31 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;
    32 using HeuristicLab.Encodings.ScheduleEncoding.PriorityRulesVector;
     33using HeuristicLab.Optimization;
    3334using HeuristicLab.Parameters;
    34 using HEAL.Attic;
    35 using HeuristicLab.PluginInfrastructure;
    3635using HeuristicLab.Problems.Instances;
    3736
    3837namespace HeuristicLab.Problems.Scheduling {
     38  public enum JSSPObjective { Makespan, Tardiness }
     39
    3940  [Item("Job Shop Scheduling Problem (JSSP)", "Represents a standard Job Shop Scheduling Problem")]
    4041  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 120)]
    41   [StorableType("BB12CCEC-A109-4A26-A1C7-5A0703AB7687")]
    42   public sealed class JobShopSchedulingProblem : SchedulingProblem, IProblemInstanceConsumer<JSSPData>, IProblemInstanceExporter<JSSPData>, IStorableContent {
     42  [StorableType("d6c72bd1-c6cc-4efb-9cc5-b73bb3845799")]
     43  public sealed class JobShopSchedulingProblem : SingleObjectiveProblem<IScheduleEncoding, IScheduleSolution>, IProblemInstanceConsumer<JSSPData>, IProblemInstanceExporter<JSSPData>, IStorableContent {
    4344    #region Default Instance
    4445    private static readonly JSSPData DefaultInstance = new JSSPData() {
    45       Name = "Job Shop Scheduling Problem (JSSP)",
    46       Description = "The default instance of the JSSP problem in HeuristicLab",
    4746      Jobs = 10,
    4847      Resources = 10,
     
    7574    #endregion
    7675
    77     public string Filename { get; set; }
    7876    public override Image ItemImage {
    7977      get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
    8078    }
    81 
     79   
    8280    #region Parameter Properties
    83     public IValueParameter<ItemList<Job>> JobDataParameter {
    84       get { return (IValueParameter<ItemList<Job>>)Parameters["JobData"]; }
    85     }
    86     public OptionalValueParameter<Schedule> BestKnownSolutionParameter {
    87       get { return (OptionalValueParameter<Schedule>)Parameters["BestKnownSolution"]; }
    88     }
    89 
    90     public IFixedValueParameter<IntValue> JobsParameter {
    91       get { return (IFixedValueParameter<IntValue>)Parameters["Jobs"]; }
    92     }
    93     public IFixedValueParameter<IntValue> ResourcesParameter {
    94       get { return (IFixedValueParameter<IntValue>)Parameters["Resources"]; }
    95     }
    96     public IValueParameter<IScheduleEvaluator> ScheduleEvaluatorParameter {
    97       get { return (IValueParameter<IScheduleEvaluator>)Parameters["ScheduleEvaluator"]; }
    98     }
    99     public OptionalValueParameter<IScheduleDecoder> ScheduleDecoderParameter {
    100       get { return (OptionalValueParameter<IScheduleDecoder>)Parameters["ScheduleDecoder"]; }
    101     }
     81    [Storable] public IValueParameter<ItemList<Job>> JobDataParameter { get; private set; }
     82    [Storable] public OptionalValueParameter<Schedule> BestKnownSolutionParameter { get; private set; }
     83    [Storable] public IFixedValueParameter<IntValue> JobsParameter { get; private set; }
     84    [Storable] public IFixedValueParameter<IntValue> ResourcesParameter { get; private set; }
     85    [Storable] public IFixedValueParameter<EnumValue<JSSPObjective>> ObjectiveParameter { get; private set; }
    10286    #endregion
    10387
     
    119103      set { ResourcesParameter.Value.Value = value; }
    120104    }
    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; }
     105    public JSSPObjective Objective {
     106      get { return ObjectiveParameter.Value.Value; }
     107      set { ObjectiveParameter.Value.Value = value; }
    128108    }
    129109    #endregion
     
    131111    [StorableConstructor]
    132112    private JobShopSchedulingProblem(StorableConstructorFlag _) : base(_) { }
    133     private JobShopSchedulingProblem(JobShopSchedulingProblem original, Cloner cloner)
    134       : base(original, cloner) {
    135       RegisterEventHandlers();
    136     }
    137     public JobShopSchedulingProblem()
    138       : base(new SchedulingEvaluator(), new JSMRandomCreator()) {
    139       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>()));
    140       Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));
    141 
    142       Parameters.Add(new FixedValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue()));
    143       Parameters.Add(new FixedValueParameter<IntValue>("Resources", "The number of resources used in this JSSP instance.", new IntValue()));
    144       Parameters.Add(new ValueParameter<IScheduleEvaluator>("ScheduleEvaluator", "The evaluator used to determine the quality of a solution.", new MakespanEvaluator()));
    145       Parameters.Add(new OptionalValueParameter<IScheduleDecoder>("ScheduleDecoder", "The operator that decodes the representation and creates a schedule.", new JSMDecoder()));
    146 
    147       EvaluatorParameter.GetsCollected = false;
    148       EvaluatorParameter.Hidden = true;
    149       ScheduleDecoderParameter.Hidden = true;
    150 
    151       InitializeOperators();
    152       Load(DefaultInstance);
    153       RegisterEventHandlers();
    154     }
    155 
    156     public override IDeepCloneable Clone(Cloner cloner) {
    157       return new JobShopSchedulingProblem(this, cloner);
    158     }
    159 
    160113    [StorableHook(HookType.AfterDeserialization)]
    161114    private void AfterDeserialization() {
     
    163116    }
    164117
     118    private JobShopSchedulingProblem(JobShopSchedulingProblem original, Cloner cloner)
     119      : base(original, cloner) {
     120      JobDataParameter = cloner.Clone(original.JobDataParameter);
     121      BestKnownSolutionParameter = cloner.Clone(original.BestKnownSolutionParameter);
     122      JobsParameter = cloner.Clone(original.JobsParameter);
     123      ResourcesParameter = cloner.Clone(original.ResourcesParameter);
     124      ObjectiveParameter = cloner.Clone(original.ObjectiveParameter);
     125
     126      RegisterEventHandlers();
     127    }
     128    public override IDeepCloneable Clone(Cloner cloner) {
     129      return new JobShopSchedulingProblem(this, cloner);
     130    }
     131
     132    public JobShopSchedulingProblem()
     133      : base(new JobSequenceMatrixEncoding()) {
     134      Parameters.Add(JobDataParameter = 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(BestKnownSolutionParameter = new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));
     136      Parameters.Add(JobsParameter = new FixedValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue()));
     137      Parameters.Add(ResourcesParameter = new FixedValueParameter<IntValue>("Resources", "The number of resources used in this JSSP instance.", new IntValue()));
     138      Parameters.Add(ObjectiveParameter = new FixedValueParameter<EnumValue<JSSPObjective>>("Objective", "The objective to use in the evaluation of a schedule.", new EnumValue<JSSPObjective>(JSSPObjective.Makespan)));
     139      EncodingParameter.Hidden = false;
     140
     141      Encoding.ResourcesParameter = ResourcesParameter;
     142      Encoding.JobsParameter = JobsParameter;
     143      Encoding.JobDataParameter = JobDataParameter;
     144
     145      Load(DefaultInstance);
     146      RegisterEventHandlers();
     147    }
     148
     149    public override ISingleObjectiveEvaluationResult Evaluate(IScheduleSolution solution, IRandom random, CancellationToken cancellationToken) {
     150      var schedule = Encoding.Decode(solution, JobData);
     151      switch (Objective) {
     152        case JSSPObjective.Makespan:
     153          return new SingleObjectiveEvaluationResult(Makespan.Calculate(schedule));
     154        case JSSPObjective.Tardiness:
     155          return new SingleObjectiveEvaluationResult(MeanTardiness.Calculate(schedule, JobData));
     156        default:
     157          throw new InvalidOperationException("Objective " + Objective + " unknown");
     158      }
     159    }
     160
     161    public override void Analyze(IScheduleSolution[] solutions, double[] qualities, ResultCollection results, IRandom random) {
     162      base.Analyze(solutions, qualities, results, random);
     163
     164      bool max = Maximization;
     165
     166      int i = -1;
     167      if (!max)
     168        i = qualities.Select((x, index) => new { index, x }).OrderBy(x => x.x).First().index;
     169      else i = qualities.Select((x, index) => new { index, x }).OrderByDescending(x => x.x).First().index;
     170
     171      if (double.IsNaN(BestKnownQuality) ||
     172          max && qualities[i] > BestKnownQuality ||
     173          !max && qualities[i] < BestKnownQuality) {
     174        BestKnownQuality = qualities[i];
     175        BestKnownSolution = Encoding.Decode(solutions[i], JobData);
     176      }
     177      Schedule bestSolution;
     178      if (results.TryGetValue("Best Scheduling Solution", out var result)) {
     179        bestSolution = result.Value as Schedule;
     180      } else bestSolution = null;
     181
     182      if (bestSolution == null || IsBetter(bestSolution.Quality, qualities[i]))
     183        results.AddOrUpdateResult("Best Scheduling Solution", Encoding.Decode(solutions[i], JobData));
     184    }
     185
     186    protected override void OnEncodingChanged() {
     187      base.OnEncodingChanged();
     188      Encoding.ResourcesParameter = ResourcesParameter;
     189      Encoding.JobsParameter = JobsParameter;
     190      Encoding.JobDataParameter = JobDataParameter;
     191    }
     192
     193
    165194    private void RegisterEventHandlers() {
    166       ScheduleEvaluatorParameter.ValueChanged += ScheduleEvaluatorParameter_ValueChanged;
    167       ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged;
    168       SolutionCreator.ScheduleEncodingParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
    169       ScheduleDecoderParameter.ValueChanged += ScheduleDecoderParameter_ValueChanged;
    170       if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged;
    171     }
    172 
    173     #region Events
    174     protected override void OnSolutionCreatorChanged() {
    175       base.OnSolutionCreatorChanged();
    176       SolutionCreator.ScheduleEncodingParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged;
    177       InitializeOperators();
    178     }
    179     protected override void OnEvaluatorChanged() {
    180       base.OnEvaluatorChanged();
    181       ParameterizeOperators();
    182     }
    183     private void ScheduleEvaluatorParameter_ValueChanged(object sender, EventArgs eventArgs) {
    184       ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged;
    185       ParameterizeOperators();
    186     }
    187     private void ScheduleEvaluator_QualityParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
    188       ParameterizeOperators();
    189     }
    190 
    191     private void SolutionCreator_SchedulingEncodingParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
    192       ParameterizeOperators();
    193     }
    194     private void ScheduleDecoderParameter_ValueChanged(object sender, EventArgs eventArgs) {
    195       if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged;
    196       ParameterizeOperators();
    197     }
    198     private void ScheduleDecoder_ScheduleParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
    199       ParameterizeOperators();
    200     }
    201     #endregion
     195      JobDataParameter.ValueChanged += JobDataParameterOnValueChanged;
     196      JobData.PropertyChanged += JobDataOnPropertyChanged;
     197    }
     198
     199    private void JobDataParameterOnValueChanged(object sender, EventArgs e) {
     200      JobData.PropertyChanged += JobDataOnPropertyChanged;
     201      Jobs = JobData.Count;
     202    }
     203
     204    private void JobDataOnPropertyChanged(object sender, PropertyChangedEventArgs e) {
     205      if (e.PropertyName == nameof(JobData.Count)) {
     206        Jobs = JobData.Count;
     207      }
     208    }
    202209
    203210    #region Problem Instance Handling
     
    212219      }
    213220
    214       BestKnownQuality = data.BestKnownQuality.HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null;
     221      BestKnownQuality = data.BestKnownQuality ?? double.NaN;
    215222      if (data.BestKnownSchedule != null) {
    216         var enc = new JSMEncoding();
    217         enc.JobSequenceMatrix = new ItemList<Permutation>(data.Resources);
     223        var enc = new JSM(0);
    218224        for (int i = 0; i < data.Resources; i++) {
    219           enc.JobSequenceMatrix[i] = new Permutation(PermutationTypes.Absolute, new int[data.Jobs]);
     225          enc.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, new int[data.Jobs]));
    220226          for (int j = 0; j < data.Jobs; j++) {
    221227            enc.JobSequenceMatrix[i][j] = data.BestKnownSchedule[i, j];
    222228          }
    223229        }
    224         BestKnownSolution = new JSMDecoder().CreateScheduleFromEncoding(enc, jobData);
    225         if (ScheduleEvaluator is MeanTardinessEvaluator)
    226           BestKnownQuality = new DoubleValue(MeanTardinessEvaluator.GetMeanTardiness(BestKnownSolution, jobData));
    227         else if (ScheduleEvaluator is MakespanEvaluator)
    228           BestKnownQuality = new DoubleValue(MakespanEvaluator.GetMakespan(BestKnownSolution));
    229       }
    230       Name = data.Name;
    231       Description = data.Description;
     230        BestKnownSolution = JSMDecoder.Decode(enc, jobData, JSMDecodingErrorPolicy.RandomPolicy, JSMForcingStrategy.SwapForcing);
     231        switch (Objective) {
     232          case JSSPObjective.Makespan:
     233            BestKnownQuality = Makespan.Calculate(BestKnownSolution);
     234            break;
     235          case JSSPObjective.Tardiness:
     236            BestKnownQuality = MeanTardiness.Calculate(BestKnownSolution, jobData);
     237            break;
     238        }
     239      }
     240
    232241      JobData = jobData;
    233       Jobs = data.Jobs;
    234242      Resources = data.Resources;
    235243    }
     
    259267    #endregion
    260268
    261     #region Helpers
    262     private void InitializeOperators() {
    263       Operators.Clear();
    264       ApplyEncoding();
    265       Operators.Add(new BestSchedulingSolutionAnalyzer());
    266       ParameterizeOperators();
    267     }
    268 
    269     private void ApplyEncoding() {
    270       if (SolutionCreator.GetType() == typeof(JSMRandomCreator)) {
    271         Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>());
    272         ScheduleDecoder = new JSMDecoder();
    273       } else if (SolutionCreator.GetType() == typeof(PRVRandomCreator)) {
    274         Operators.AddRange(ApplicationManager.Manager.GetInstances<IPRVOperator>());
    275         ScheduleDecoder = new PRVDecoder();
    276       } else if (SolutionCreator.GetType() == typeof(PWRRandomCreator)) {
    277         Operators.AddRange(ApplicationManager.Manager.GetInstances<IPWROperator>());
    278         ScheduleDecoder = new PWRDecoder();
    279       } else if (SolutionCreator.GetType() == typeof(DirectScheduleRandomCreator)) {
    280         Operators.AddRange(ApplicationManager.Manager.GetInstances<IDirectScheduleOperator>());
    281         ScheduleDecoder = null;
    282       }
    283     }
    284 
    285     private void ParameterizeOperators() {
    286       Evaluator.ScheduleDecoderParameter.ActualName = ScheduleDecoderParameter.Name;
    287       Evaluator.ScheduleDecoderParameter.Hidden = true;
    288       Evaluator.ScheduleEvaluatorParameter.ActualName = ScheduleEvaluatorParameter.Name;
    289       Evaluator.ScheduleEvaluatorParameter.Hidden = true;
    290       Evaluator.QualityParameter.ActualName = ScheduleEvaluator.QualityParameter.ActualName;
    291       Evaluator.QualityParameter.Hidden = true;
    292 
    293       if (ScheduleDecoder != null)
    294         ScheduleDecoder.ScheduleEncodingParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
    295 
    296       if (ScheduleDecoder != null) {
    297         ScheduleEvaluator.ScheduleParameter.ActualName = ScheduleDecoder.ScheduleParameter.ActualName;
    298         ScheduleEvaluator.ScheduleParameter.Hidden = true;
    299       } else if (SolutionCreator is DirectScheduleRandomCreator) {
    300         var directEvaluator = (DirectScheduleRandomCreator)SolutionCreator;
    301         ScheduleEvaluator.ScheduleParameter.ActualName = directEvaluator.ScheduleEncodingParameter.ActualName;
    302         ScheduleEvaluator.ScheduleParameter.Hidden = true;
    303       } else {
    304         ScheduleEvaluator.ScheduleParameter.ActualName = ScheduleEvaluator.ScheduleParameter.Name;
    305         ScheduleEvaluator.ScheduleParameter.Hidden = false;
    306       }
    307 
    308       foreach (var op in Operators.OfType<IScheduleManipulator>()) {
    309         op.ScheduleEncodingParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
    310         op.ScheduleEncodingParameter.Hidden = true;
    311       }
    312 
    313       foreach (var op in Operators.OfType<IScheduleCrossover>()) {
    314         op.ChildParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
    315         op.ChildParameter.Hidden = true;
    316         op.ParentsParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;
    317         op.ParentsParameter.Hidden = true;
    318       }
    319 
    320       foreach (var op in Operators.OfType<BestSchedulingSolutionAnalyzer>()) {
    321         op.QualityParameter.ActualName = ScheduleEvaluator.QualityParameter.ActualName;
    322         if (ScheduleDecoder != null) {
    323           op.ScheduleParameter.ActualName = ScheduleDecoder.ScheduleParameter.ActualName;
    324           op.ScheduleParameter.Hidden = true;
    325         } else if (SolutionCreator is DirectScheduleRandomCreator) {
    326           op.ScheduleParameter.ActualName = ((DirectScheduleRandomCreator)SolutionCreator).ScheduleEncodingParameter.ActualName;
    327           op.ScheduleParameter.Hidden = true;
    328         } else {
    329           op.ScheduleParameter.ActualName = op.ScheduleParameter.Name;
    330           op.ScheduleParameter.Hidden = false;
    331         }
    332       }
    333     }
    334     #endregion
    335 
    336269  }
    337270}
Note: See TracChangeset for help on using the changeset viewer.