Changeset 8887


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

#1329:

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

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/JobView.cs

    r8886 r8887  
    3131  public partial class JobView : ItemView {
    3232    private ItemListView<Task> tasksView;
    33     private bool SuppressEvents = false;
     33    protected bool SuppressEvents = false;
    3434
    3535    public new Job Content {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/TaskView.cs

    r8886 r8887  
    3030  [Content(typeof(Task))]
    3131  public partial class TaskView : ItemView {
    32     private bool SuppressEvents = false;
     32    protected bool SuppressEvents = false;
    3333
    3434    public new Task Content {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/HeuristicLab.Encodings.ScheduleEncoding-3.3.csproj

    r8806 r8887  
    110110  <ItemGroup>
    111111    <Compile Include="Interfaces\IDirectScheduleOperator.cs" />
    112     <Compile Include="Interfaces\IScheduleEvaluationAlgorithm.cs" />
    113112    <Compile Include="Interfaces\IJSMOperator.cs" />
    114113    <Compile Include="Interfaces\IPRVOperator.cs" />
     
    116115    <Compile Include="Interfaces\IScheduleCreator.cs" />
    117116    <Compile Include="Interfaces\IScheduleCrossover.cs" />
    118     <Compile Include="Interfaces\IScheduleDecoder.cs" />
    119117    <Compile Include="Interfaces\IScheduleEncoding.cs" />
    120     <Compile Include="Interfaces\IScheduleEvaluator.cs" />
    121118    <Compile Include="Interfaces\IScheduleManipulator.cs" />
    122119    <Compile Include="Interfaces\IScheduleOperator.cs" />
     
    151148    <Compile Include="ScheduleEncoding\Job.cs" />
    152149    <Compile Include="ScheduleEncoding\Manipulators\DirectScheduleManipulator.cs" />
    153     <Compile Include="ScheduleEncoding\Manipulators\ConcreteScheduleManipulator.cs" />
    154150    <Compile Include="ScheduleEncoding\DirectScheduleRandomCreator.cs" />
    155151    <Compile Include="ScheduleEncoding\Resource.cs" />
     
    158154    <Compile Include="ScheduleCreator.cs" />
    159155    <Compile Include="ScheduleCrossover.cs" />
    160     <Compile Include="ScheduleDecoder.cs" />
    161156    <Compile Include="ScheduleEncoding\Task.cs" />
    162157    <Compile Include="ScheduleManipulator.cs" />
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IDirectScheduleOperator.cs

    r8603 r8887  
    2121
    2222using HeuristicLab.Core;
     23
    2324namespace HeuristicLab.Encodings.ScheduleEncoding {
    2425  public interface IDirectScheduleOperator : IOperator {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IJSMOperator.cs

    r6406 r8887  
    1 using HeuristicLab.Core;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using HeuristicLab.Core;
    223
    324namespace HeuristicLab.Encodings.ScheduleEncoding {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IPRVOperator.cs

    r6406 r8887  
    1 using HeuristicLab.Core;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using HeuristicLab.Core;
    223
    324namespace HeuristicLab.Encodings.ScheduleEncoding {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IPWROperator.cs

    r6406 r8887  
    1 using HeuristicLab.Core;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using HeuristicLab.Core;
    223
    324namespace HeuristicLab.Encodings.ScheduleEncoding {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleCreator.cs

    r6406 r8887  
    1 using HeuristicLab.Optimization;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using HeuristicLab.Core;
     23using HeuristicLab.Optimization;
    224
    325namespace HeuristicLab.Encodings.ScheduleEncoding {
    426  public interface IScheduleCreator : ISolutionCreator, IScheduleOperator {
     27    ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter { get; }
    528  }
    629}
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleCrossover.cs

    r6406 r8887  
    1 using HeuristicLab.Optimization;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using HeuristicLab.Core;
     23using HeuristicLab.Optimization;
    224
    325namespace HeuristicLab.Encodings.ScheduleEncoding {
    426  public interface IScheduleCrossover : ICrossover, IScheduleOperator {
     27    ILookupParameter<IScheduleEncoding> ChildParameter { get; }
     28    IScopeTreeLookupParameter<IScheduleEncoding> ParentsParameter { get; }
    529  }
    630}
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Optimization;
    2324
    2425namespace HeuristicLab.Encodings.ScheduleEncoding {
    2526  public interface IScheduleManipulator : IManipulator, IScheduleOperator {
     27    ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter { get; }
    2628  }
    2729}
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleOperator.cs

    r6406 r8887  
    1 using HeuristicLab.Core;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using HeuristicLab.Core;
    223
    324namespace HeuristicLab.Encodings.ScheduleEncoding {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMCrossover.cs

    r8603 r8887  
    2727  [Item("JSMCrossover", "An operator which crosses two JSM representations.")]
    2828  [StorableClass]
    29   public abstract class JSMCrossover : ScheduleCrossover<JSMEncoding>, IJSMOperator {
     29  public abstract class JSMCrossover : ScheduleCrossover, IJSMOperator {
    3030
    3131    [StorableConstructor]
     
    4141
    4242    public override IOperation Apply() {
    43       ItemArray<JSMEncoding> parents = ParentsParameter.ActualValue;
     43      var parents = ParentsParameter.ActualValue;
    4444
    4545      ChildParameter.ActualValue =
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMJOXCrossover.cs

    r8603 r8887  
    3030  [StorableClass]
    3131  public class JSMJOXCrossover : JSMCrossover {
     32
    3233    [StorableConstructor]
    3334    protected JSMJOXCrossover(bool deserializing) : base(deserializing) { }
    34     protected JSMJOXCrossover(JSMJOXCrossover original, Cloner cloner)
    35       : base(original, cloner) {
    36     }
     35    protected JSMJOXCrossover(JSMJOXCrossover original, Cloner cloner) : base(original, cloner) { }
     36    public JSMJOXCrossover() : base() { }
     37
    3738    public override IDeepCloneable Clone(Cloner cloner) {
    3839      return new JSMJOXCrossover(this, cloner);
    3940    }
    40     public JSMJOXCrossover() : base() { }
    41 
    4241
    4342    public static JSMEncoding Apply(IRandom random, JSMEncoding p1, JSMEncoding p2) {
    44       JSMEncoding result = new JSMEncoding();
     43      var result = new JSMEncoding();
    4544
    4645      int nrOfResources = p1.JobSequenceMatrix.Count;
     
    4847
    4948      //Determine randomly which jobindexes persist
    50       BoolArray persist = new BoolArray(nrOfJobs);
     49      var persist = new BoolArray(nrOfJobs);
    5150      for (int i = 0; i < persist.Length; i++) {
    5251        persist[i] = random.Next(2) == 1;
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMOXCrossover.cs

    r8603 r8887  
    2828  [StorableClass]
    2929  public class JSMOXCrossover : JSMCrossover {
     30
    3031    [StorableConstructor]
    3132    protected JSMOXCrossover(bool deserializing) : base(deserializing) { }
    32     protected JSMOXCrossover(JSMOXCrossover original, Cloner cloner)
    33       : base(original, cloner) {
    34     }
     33    protected JSMOXCrossover(JSMOXCrossover original, Cloner cloner) : base(original, cloner) { }
     34    public JSMOXCrossover() : base() { }
     35
    3536    public override IDeepCloneable Clone(Cloner cloner) {
    3637      return new JSMOXCrossover(this, cloner);
    3738    }
    38     public JSMOXCrossover() : base() { }
    39 
    4039
    4140    public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
    42       JSMEncoding result = new JSMEncoding();
     41      var result = new JSMEncoding();
    4342
    4443      for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMSXXCrossover.cs

    r8603 r8887  
    2929  [StorableClass]
    3030  public class JSMSXXCrossover : JSMCrossover {
     31
    3132    [StorableConstructor]
    3233    protected JSMSXXCrossover(bool deserializing) : base(deserializing) { }
    33     protected JSMSXXCrossover(JSMSXXCrossover original, Cloner cloner)
    34       : base(original, cloner) {
    35     }
     34    protected JSMSXXCrossover(JSMSXXCrossover original, Cloner cloner) : base(original, cloner) { }
     35    public JSMSXXCrossover() : base() { }
     36
    3637    public override IDeepCloneable Clone(Cloner cloner) {
    3738      return new JSMSXXCrossover(this, cloner);
    3839    }
    39     public JSMSXXCrossover() : base() { }
    40 
    4140
    4241    public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
    43       JSMEncoding result = new JSMEncoding();
     42      var result = new JSMEncoding();
    4443      int subSequenceLength = random.Next(parent1.JobSequenceMatrix[0].Length);
    4544      for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) {
    46         Permutation p1 = (Permutation)parent1.JobSequenceMatrix[i].Clone();
    47         Permutation p2 = (Permutation)parent2.JobSequenceMatrix[i].Clone();
     45        var p1 = (Permutation)parent1.JobSequenceMatrix[i].Clone();
     46        var p2 = (Permutation)parent2.JobSequenceMatrix[i].Clone();
    4847        FindAndExchangeSubsequences(p1, p2, subSequenceLength);
    4948        result.JobSequenceMatrix.Add(p1);
     
    5150      return result;
    5251    }
     52
    5353    private static void FindAndExchangeSubsequences(Permutation p1, Permutation p2, int subSequenceLength) {
    5454      for (int i = 0; i <= p1.Length - subSequenceLength; i++) {
     
    6363      }
    6464    }
     65
    6566    private static void ExchangeSubsequences(Permutation p1, int index1, Permutation p2, int index2, int subSequenceLength) {
    66       Permutation aux = (Permutation)p1.Clone();
     67      var aux = (Permutation)p1.Clone();
    6768      for (int i = 0; i < subSequenceLength; i++) {
    6869        p1[i + index1] = p2[i + index2];
     
    7071      }
    7172    }
     73
    7274    private static bool AreEqualSubsequences(int[] ss1, int[] ss2) {
    7375      int counter = 0;
     
    8082      return counter == ss1.Length;
    8183    }
     84
    8285    private static int[] GetSubSequenceAtPosition(Permutation p1, int index, int subSequenceLength) {
    83       int[] result = new int[subSequenceLength];
     86      var result = new int[subSequenceLength];
    8487      for (int i = 0; i < subSequenceLength; i++)
    8588        result[i] = p1[i + index];
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMEncoding.cs

    r8603 r8887  
    3030  [StorableClass]
    3131  public class JSMEncoding : Item, IScheduleEncoding {
     32
    3233    [Storable]
    3334    public ItemList<Permutation> JobSequenceMatrix { get; set; }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMRandomCreator.cs

    r8603 r8887  
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2929
    30 
    3130namespace HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix {
    3231  [Item("JobSequenceMatrixCreator", "Creator class used to create Job Sequence Matrix solutions for standard JobShop scheduling problems.")]
    3332  [StorableClass]
    34   public class JSMRandomCreator : ScheduleCreator<JSMEncoding>, IStochasticOperator {
    35     #region Parameter Properties
     33  public class JSMRandomCreator : ScheduleCreator, IStochasticOperator {
     34
    3635    public ILookupParameter<IRandom> RandomParameter {
    3736      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     
    4342      get { return (IValueLookupParameter<IntValue>)Parameters["Resources"]; }
    4443    }
    45     #endregion
    46 
    4744
    4845    [StorableConstructor]
    4946    protected JSMRandomCreator(bool deserializing) : base(deserializing) { }
    50     protected JSMRandomCreator(JSMRandomCreator original, Cloner cloner)
    51       : base(original, cloner) {
    52     }
    53     public override IDeepCloneable Clone(Cloner cloner) {
    54       return new JSMRandomCreator(this, cloner);
    55     }
     47    protected JSMRandomCreator(JSMRandomCreator original, Cloner cloner) : base(original, cloner) { }
    5648    public JSMRandomCreator()
    5749      : base() {
     
    6355    }
    6456
     57    public override IDeepCloneable Clone(Cloner cloner) {
     58      return new JSMRandomCreator(this, cloner);
     59    }
    6560
    6661    public static JSMEncoding Apply(int jobs, int resources, IRandom random) {
    67       JSMEncoding solution = new JSMEncoding();
    68 
     62      var solution = new JSMEncoding();
    6963      for (int i = 0; i < resources; i++) {
    7064        solution.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, jobs, random));
    7165      }
    72 
    7366      return solution;
    7467    }
    7568
    76 
    77     protected override JSMEncoding CreateSolution() {
     69    protected override IScheduleEncoding CreateSolution() {
    7870      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue);
    7971    }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2728  [Item("JSMManipulator", "An operator which manipulates a JSM representation.")]
    2829  [StorableClass]
    29   public abstract class JSMManipulator : ScheduleManipulator<JSMEncoding>, IJSMOperator {
     30  public abstract class JSMManipulator : ScheduleManipulator, IJSMOperator {
    3031    [StorableConstructor]
    3132    protected JSMManipulator(bool deserializing) : base(deserializing) { }
     
    3637    }
    3738
    38     protected abstract void Manipulate(IRandom random, JSMEncoding individual);
    39 
     39    protected abstract void Manipulate(IRandom random, IScheduleEncoding individual);
    4040
    4141    public override IOperation Apply() {
    42       JSMEncoding solution = ScheduleEncodingParameter.ActualValue;
     42      var solution = ScheduleEncodingParameter.ActualValue as JSMEncoding;
     43      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type JSMEncoding.");
    4344      Manipulate(RandomParameter.ActualValue, solution);
    4445      return base.Apply();
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMShiftChangeManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    2829
    2930namespace HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix {
    30 
    3131  [Item("JSMShiftChangeManipulator", "Represents a manipulation operation where the operations of a randomly determined job are shifted in one direction for all resources.")]
    3232  [StorableClass]
    3333  public class JSMShiftChangeManipulator : JSMManipulator {
     34
    3435    [StorableConstructor]
    3536    protected JSMShiftChangeManipulator(bool deserializing) : base(deserializing) { }
    36     protected JSMShiftChangeManipulator(JSMShiftChangeManipulator original, Cloner cloner)
    37       : base(original, cloner) {
    38     }
     37    protected JSMShiftChangeManipulator(JSMShiftChangeManipulator original, Cloner cloner) : base(original, cloner) { }
     38    public JSMShiftChangeManipulator() : base() { }
     39
    3940    public override IDeepCloneable Clone(Cloner cloner) {
    4041      return new JSMShiftChangeManipulator(this, cloner);
    4142    }
    42 
    43     public JSMShiftChangeManipulator() : base() { }
    44 
    4543
    4644    public static void Apply(IRandom random, JSMEncoding individual) {
     
    6563    }
    6664
    67     protected override void Manipulate(IRandom random, JSMEncoding individual) {
    68       Apply(random, individual);
     65    protected override void Manipulate(IRandom random, IScheduleEncoding encoding) {
     66      var solution = encoding as JSMEncoding;
     67      if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
     68      Apply(random, solution);
    6969    }
    7070  }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMSwapManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2627
    2728namespace HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix {
    28 
    2929  [Item("JSMSwapManipulator", "Represents a manipulation operation swapping parts of the individual.")]
    3030  [StorableClass]
    3131  public class JSMSwapManipulator : JSMManipulator {
     32
    3233    [StorableConstructor]
    3334    protected JSMSwapManipulator(bool deserializing) : base(deserializing) { }
    34     protected JSMSwapManipulator(JSMSwapManipulator original, Cloner cloner)
    35       : base(original, cloner) {
    36     }
     35    protected JSMSwapManipulator(JSMSwapManipulator original, Cloner cloner) : base(original, cloner) { }
     36    public JSMSwapManipulator() : base() { }
     37
    3738    public override IDeepCloneable Clone(Cloner cloner) {
    3839      return new JSMSwapManipulator(this, cloner);
    3940    }
    40 
    41     public JSMSwapManipulator() : base() { }
    42 
    4341
    4442    public static void Apply(IRandom random, JSMEncoding individual) {
     
    5250    }
    5351
    54     protected override void Manipulate(IRandom random, JSMEncoding individual) {
    55       Apply(random, individual);
     52    protected override void Manipulate(IRandom random, IScheduleEncoding individual) {
     53      var solution = individual as JSMEncoding;
     54      if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding");
     55      Apply(random, solution);
    5656    }
    5757  }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRCrossover.cs

    r8603 r8887  
    2727  [Item("PWRCrossover", "An operator which crosses two JSM representations.")]
    2828  [StorableClass]
    29   public abstract class PWRCrossover : ScheduleCrossover<PWREncoding>, IPWROperator {
     29  public abstract class PWRCrossover : ScheduleCrossover, IPWROperator {
    3030
    3131    [StorableConstructor]
     
    4141
    4242    public override IOperation Apply() {
    43       ItemArray<PWREncoding> parents = ParentsParameter.ActualValue;
     43      var parents = ParentsParameter.ActualValue;
    4444
    4545      ChildParameter.ActualValue =
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRGOXCrossover.cs

    r8603 r8887  
    3131  [StorableClass]
    3232  public class PWRGOXCrossover : PWRCrossover {
     33
    3334    [StorableConstructor]
    3435    protected PWRGOXCrossover(bool deserializing) : base(deserializing) { }
    35     protected PWRGOXCrossover(PWRGOXCrossover original, Cloner cloner)
    36       : base(original, cloner) {
    37     }
     36    protected PWRGOXCrossover(PWRGOXCrossover original, Cloner cloner) : base(original, cloner) { }
     37    public PWRGOXCrossover() : base() { }
     38
    3839    public override IDeepCloneable Clone(Cloner cloner) {
    3940      return new PWRGOXCrossover(this, cloner);
    4041    }
    41     public PWRGOXCrossover() : base() { }
    4242
    4343    private static int[] GetLookUpForIndividual(List<int> p) {
    44       int[] result = new int[p.Count];
    45       Dictionary<int, int> lookUpTable = new Dictionary<int, int>();
     44      var result = new int[p.Count];
     45      var lookUpTable = new Dictionary<int, int>();
    4646
    4747      for (int i = 0; i < p.Count; i++) {
     
    5454      return result;
    5555    }
     56
    5657    public static PWREncoding Apply(IRandom random, PWREncoding parent1, PWREncoding parent2) {
    57       PWREncoding result = new PWREncoding();
     58      var result = new PWREncoding();
    5859
    59       List<int> p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList<int>();
    60       List<int> p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList<int>();
    61       List<int> child = new List<int>();
     60      var p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList();
     61      var p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList();
     62      var child = new List<int>();
    6263
    6364      int[] lookUpArrayP1 = GetLookUpForIndividual(p1);
     
    9091    }
    9192
    92 
    93 
    94 
    9593  }
    9694}
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRPPXCrossover.cs

    r8603 r8887  
    3131  [StorableClass]
    3232  public class PWRPPXCrossover : PWRCrossover {
     33
    3334    [StorableConstructor]
    3435    protected PWRPPXCrossover(bool deserializing) : base(deserializing) { }
    35     protected PWRPPXCrossover(PWRPPXCrossover original, Cloner cloner)
    36       : base(original, cloner) {
    37     }
     36    protected PWRPPXCrossover(PWRPPXCrossover original, Cloner cloner) : base(original, cloner) { }
     37    public PWRPPXCrossover() : base() { }
     38
    3839    public override IDeepCloneable Clone(Cloner cloner) {
    3940      return new PWRPPXCrossover(this, cloner);
    4041    }
    41     public PWRPPXCrossover() : base() { }
    4242
    4343    public static PWREncoding Apply(IRandom random, PWREncoding parent1, PWREncoding parent2) {
    44       PWREncoding result = new PWREncoding();
    45       List<int> p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList<int>();
    46       List<int> p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList<int>();
    47       List<int> child = new List<int>();
     44      var result = new PWREncoding();
     45      var p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList();
     46      var p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList();
     47      var child = new List<int>();
    4848
    49       bool[] lookUpTable = new bool[parent1.PermutationWithRepetition.Length];
     49      var lookUpTable = new bool[parent1.PermutationWithRepetition.Length];
    5050      for (int i = 0; i < lookUpTable.Length; i++) {
    5151        lookUpTable[i] = random.Next(2) == 1;
     
    7373    }
    7474
    75 
    7675  }
    7776}
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Manipulators/PWRInsertionManipulator.cs

    r8603 r8887  
    2828
    2929namespace HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition {
    30 
    3130  [Item("PWRInsertionManipulator", "Represents a manipulation operation inserting parts of the individual at another position.")]
    3231  [StorableClass]
     
    3433    [StorableConstructor]
    3534    protected PWRInsertionManipulator(bool deserializing) : base(deserializing) { }
    36     protected PWRInsertionManipulator(PWRInsertionManipulator original, Cloner cloner)
    37       : base(original, cloner) {
    38     }
     35    protected PWRInsertionManipulator(PWRInsertionManipulator original, Cloner cloner) : base(original, cloner) { }
     36    public PWRInsertionManipulator() : base() { }
     37
    3938    public override IDeepCloneable Clone(Cloner cloner) {
    4039      return new PWRInsertionManipulator(this, cloner);
    4140    }
    42     public PWRInsertionManipulator() : base() { }
    4341
    4442    public static void Apply(IRandom random, PWREncoding individual) {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Manipulators/PWRManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2728  [Item("PWRManipulator", "An operator which manipulates a PWR representation.")]
    2829  [StorableClass]
    29   public abstract class PWRManipulator : ScheduleManipulator<PWREncoding>, IPWROperator {
     30  public abstract class PWRManipulator : ScheduleManipulator, IPWROperator {
     31
    3032    [StorableConstructor]
    3133    protected PWRManipulator(bool deserializing) : base(deserializing) { }
     
    3840    protected abstract void Manipulate(IRandom random, PWREncoding individual);
    3941
    40 
    4142    public override IOperation Apply() {
    42       PWREncoding solution = ScheduleEncodingParameter.ActualValue;
     43      var solution = ScheduleEncodingParameter.ActualValue as PWREncoding;
     44      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type PWREncoding.");
    4345      Manipulate(RandomParameter.ActualValue, solution);
    4446      return base.Apply();
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWREncoding.cs

    r8603 r8887  
    3030  [StorableClass]
    3131  public class PWREncoding : Item, IScheduleEncoding {
     32
    3233    [Storable]
    3334    public IntegerVector PermutationWithRepetition { get; set; }
    34 
    3535
    3636    [StorableConstructor]
     
    4040      this.PermutationWithRepetition = cloner.Clone(original.PermutationWithRepetition);
    4141    }
    42     public override IDeepCloneable Clone(Cloner cloner) {
    43       return new PWREncoding(this, cloner);
    44     }
    4542    public PWREncoding()
    4643      : base() {
    4744      PermutationWithRepetition = new IntegerVector();
     45    }
     46
     47    public override IDeepCloneable Clone(Cloner cloner) {
     48      return new PWREncoding(this, cloner);
    4849    }
    4950
     
    8182        return base.Equals(obj);
    8283    }
     84
    8385    public override int GetHashCode() {
    8486      if (PermutationWithRepetition.Length == 1)
     
    8890      return 0;
    8991    }
     92
    9093    private bool AreEqual(PWREncoding pWREncoding1, PWREncoding pWREncoding2) {
    9194      if (pWREncoding1.PermutationWithRepetition.Length != pWREncoding2.PermutationWithRepetition.Length)
     
    97100      return true;
    98101    }
    99 
    100 
    101102  }
    102103}
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWRRandomCreator.cs

    r8603 r8887  
    3030  [Item("PermutationWithRepetitionRandomCreator", "Creates PWR-individuals at random.")]
    3131  [StorableClass]
    32   public class PWRRandomCreator : ScheduleCreator<PWREncoding>, IStochasticOperator {
    33     public IRandom Random {
    34       get { return RandomParameter.ActualValue; }
    35     }
     32  public class PWRRandomCreator : ScheduleCreator, IStochasticOperator {
    3633
    3734    public ILookupParameter<IRandom> RandomParameter {
     
    4744    [StorableConstructor]
    4845    protected PWRRandomCreator(bool deserializing) : base(deserializing) { }
    49     protected PWRRandomCreator(PWRRandomCreator original, Cloner cloner)
    50       : base(original, cloner) {
    51     }
    52     public override IDeepCloneable Clone(Cloner cloner) {
    53       return new PWRRandomCreator(this, cloner);
    54     }
    55 
     46    protected PWRRandomCreator(PWRRandomCreator original, Cloner cloner) : base(original, cloner) { }
    5647    public PWRRandomCreator()
    5748      : base() {
     
    6354    }
    6455
     56    public override IDeepCloneable Clone(Cloner cloner) {
     57      return new PWRRandomCreator(this, cloner);
     58    }
     59
    6560    public static PWREncoding Apply(int jobs, int resources, IRandom random) {
    6661      return new PWREncoding(jobs, resources, random);
    6762    }
    6863
    69 
    70     protected override PWREncoding CreateSolution() {
    71       return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, Random);
     64    protected override IScheduleEncoding CreateSolution() {
     65      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue);
    7266    }
    7367  }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Plugin.cs.frame

    r8603 r8887  
    2323
    2424namespace HeuristicLab.Encodings.ScheduleEncoding {
    25   [Plugin("HeuristicLab.Encodings.ScheduleEncoding", "3.3.3.$WCREV$")]
     25  [Plugin("HeuristicLab.Encodings.ScheduleEncoding", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Encodings.ScheduleEncoding-3.3.dll", PluginFileType.Assembly)]
    2727  [PluginDependency("HeuristicLab.Collections", "3.3")]
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVCrossover.cs

    r8603 r8887  
    2727  [Item("PRVCrossover", "An operator which crosses two PRV representations.")]
    2828  [StorableClass]
    29   public abstract class PRVCrossover : ScheduleCrossover<PRVEncoding>, IPRVOperator {
     29  public abstract class PRVCrossover : ScheduleCrossover, IPRVOperator {
     30
    3031    [StorableConstructor]
    3132    protected PRVCrossover(bool deserializing) : base(deserializing) { }
     
    3738    }
    3839
    39 
    4040    public abstract PRVEncoding Cross(IRandom random, PRVEncoding parent1, PRVEncoding parent2);
    4141
    4242    public override IOperation Apply() {
    43       ItemArray<PRVEncoding> parents = ParentsParameter.ActualValue;
     43      var parents = ParentsParameter.ActualValue;
    4444      ChildParameter.ActualValue =
    4545        Cross(RandomParameter.ActualValue, parents[0] as PRVEncoding, parents[1] as PRVEncoding);
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVDiscreteCrossover.cs

    r8603 r8887  
    2929  [StorableClass]
    3030  public class PRVDiscreteCrossover : PRVCrossover {
     31
    3132    [StorableConstructor]
    3233    protected PRVDiscreteCrossover(bool deserializing) : base(deserializing) { }
    33     protected PRVDiscreteCrossover(PRVDiscreteCrossover original, Cloner cloner)
    34       : base(original, cloner) {
    35     }
     34    protected PRVDiscreteCrossover(PRVDiscreteCrossover original, Cloner cloner) : base(original, cloner) { }
     35    public PRVDiscreteCrossover() : base() { }
     36
    3637    public override IDeepCloneable Clone(Cloner cloner) {
    3738      return new PRVDiscreteCrossover(this, cloner);
    3839    }
    39     public PRVDiscreteCrossover() : base() { }
    40 
    4140
    4241    public static PRVEncoding Apply(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {
    4342      return new PRVEncoding(DiscreteCrossover.Apply(random, new ItemArray<IntegerVector>(new IntegerVector[] { parent1.PriorityRulesVector, parent2.PriorityRulesVector })), parent1.NrOfRules);
    4443    }
     44
    4545    public override PRVEncoding Cross(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {
    4646      return Apply(random, parent1, parent2);
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVSinglePointCrossover.cs

    r8603 r8887  
    2929  [StorableClass]
    3030  public class PRVSinglePointCrossover : PRVCrossover {
     31
    3132    [StorableConstructor]
    3233    protected PRVSinglePointCrossover(bool deserializing) : base(deserializing) { }
    33     protected PRVSinglePointCrossover(PRVSinglePointCrossover original, Cloner cloner)
    34       : base(original, cloner) {
    35     }
     34    protected PRVSinglePointCrossover(PRVSinglePointCrossover original, Cloner cloner) : base(original, cloner) { }
     35    public PRVSinglePointCrossover() : base() { }
     36
    3637    public override IDeepCloneable Clone(Cloner cloner) {
    3738      return new PRVSinglePointCrossover(this, cloner);
    3839    }
    39     public PRVSinglePointCrossover() : base() { }
    4040
    4141    public static PRVEncoding Apply(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Manipulators/PRVManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2728  [Item("PRVManipulator", "An operator which manipulates a PRV representation.")]
    2829  [StorableClass]
    29   public abstract class PRVManipulator : ScheduleManipulator<PRVEncoding>, IPRVOperator {
     30  public abstract class PRVManipulator : ScheduleManipulator, IPRVOperator {
    3031    [StorableConstructor]
    3132    protected PRVManipulator(bool deserializing) : base(deserializing) { }
     
    3637    }
    3738
     39    protected abstract void Manipulate(IRandom random, PRVEncoding individual);
    3840
    39     protected abstract void Manipulate(IRandom random, PRVEncoding individual);
    4041    public override IOperation Apply() {
    41       PRVEncoding solution = ScheduleEncodingParameter.ActualValue;
     42      var solution = ScheduleEncodingParameter.ActualValue as PRVEncoding;
     43      if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type PRVEncoding.");
    4244      Manipulate(RandomParameter.ActualValue, solution);
    4345      return base.Apply();
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Manipulators/PRVUniformOnePositionManipulator.cs

    r8882 r8887  
    2727
    2828namespace HeuristicLab.Encodings.ScheduleEncoding.PriorityRulesVector {
    29 
    3029  [Item("PRVUniformOnePositionManipulator", "Represents a manipulation operation inserting parts of the individual at another position.")]
    3130  [StorableClass]
    3231  public class PRVUniformOnePositionManipulator : PRVManipulator {
     32
    3333    [StorableConstructor]
    3434    protected PRVUniformOnePositionManipulator(bool deserializing) : base(deserializing) { }
    35     protected PRVUniformOnePositionManipulator(PRVUniformOnePositionManipulator original, Cloner cloner)
    36       : base(original, cloner) {
    37     }
     35    protected PRVUniformOnePositionManipulator(PRVUniformOnePositionManipulator original, Cloner cloner) : base(original, cloner) { }
     36    public PRVUniformOnePositionManipulator() : base() { }
     37
    3838    public override IDeepCloneable Clone(Cloner cloner) {
    3939      return new PRVUniformOnePositionManipulator(this, cloner);
    4040    }
    41     public PRVUniformOnePositionManipulator() : base() { }
    42 
    4341
    4442    public static void Apply(IRandom random, PRVEncoding individual) {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVEncoding.cs

    r8603 r8887  
    4242    }
    4343
    44 
    4544    [StorableConstructor]
    4645    protected PRVEncoding(bool deserializing) : base(deserializing) { }
     
    4948      this.nrOfRules = cloner.Clone(original.NrOfRules);
    5049      this.PriorityRulesVector = cloner.Clone(original.PriorityRulesVector);
    51     }
    52     public override IDeepCloneable Clone(Cloner cloner) {
    53       return new PRVEncoding(this, cloner);
    5450    }
    5551    public PRVEncoding(int nrOfRules)
     
    6965    }
    7066
     67    public override IDeepCloneable Clone(Cloner cloner) {
     68      return new PRVEncoding(this, cloner);
     69    }
    7170
    7271    public override string ToString() {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVRandomCreator.cs

    r8603 r8887  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 
    3029namespace HeuristicLab.Encodings.ScheduleEncoding.PriorityRulesVector {
    3130  [Item("PriorityRulesRandomCreator", "Creator class used to create PRV encoding objects for scheduling problems.")]
    3231  [StorableClass]
    33   public class PRVRandomCreator : ScheduleCreator<PRVEncoding>, IStochasticOperator {
     32  public class PRVRandomCreator : ScheduleCreator, IStochasticOperator {
     33
    3434    [Storable]
    3535    public IntValue NrOfRules { get; set; }
     
    4545    }
    4646
    47 
    4847    [StorableConstructor]
    4948    protected PRVRandomCreator(bool deserializing) : base(deserializing) { }
     
    5150      : base(original, cloner) {
    5251      this.NrOfRules = cloner.Clone(original.NrOfRules);
    53     }
    54     public override IDeepCloneable Clone(Cloner cloner) {
    55       return new PRVRandomCreator(this, cloner);
    5652    }
    5753    public PRVRandomCreator()
     
    6460    }
    6561
     62    public override IDeepCloneable Clone(Cloner cloner) {
     63      return new PRVRandomCreator(this, cloner);
     64    }
     65
    6666    public static PRVEncoding Apply(int jobs, int resources, IRandom random, IntValue nrOfRules) {
    6767      return new PRVEncoding(jobs * resources, random, 0, nrOfRules.Value, nrOfRules);
    6868    }
    6969
    70     protected override PRVEncoding CreateSolution() {
     70    protected override IScheduleEncoding CreateSolution() {
    7171      return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue, NrOfRules);
    7272    }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Properties/AssemblyInfo.cs.frame

    r8759 r8887  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    5555// [assembly: AssemblyVersion("1.0.*")]
    5656[assembly: AssemblyVersion("3.3.0.0")]
    57 [assembly: AssemblyFileVersion("3.3.3.$WCREV$")]
     57[assembly: AssemblyFileVersion("3.3.7.$WCREV$")]
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleCreator.cs

    r8603 r8887  
    2929  [Item("ScheduleCreator", "Represents the generalized form of creators for Scheduling Problems.")]
    3030  [StorableClass]
    31   public abstract class ScheduleCreator<T> : SingleSuccessorOperator, IScheduleCreator where T : Item {
    32     public ILookupParameter<T> ScheduleEncodingParameter {
    33       get { return (ILookupParameter<T>)Parameters["ScheduleEncoding"]; }
     31  public abstract class ScheduleCreator : SingleSuccessorOperator, IScheduleCreator {
     32
     33    public ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter {
     34      get { return (ILookupParameter<IScheduleEncoding>)Parameters["ScheduleEncoding"]; }
    3435    }
    35 
    3636
    3737    [StorableConstructor]
    3838    protected ScheduleCreator(bool deserializing) : base(deserializing) { }
    39     protected ScheduleCreator(ScheduleCreator<T> original, Cloner cloner)
    40       : base(original, cloner) {
    41     }
     39    protected ScheduleCreator(ScheduleCreator original, Cloner cloner) : base(original, cloner) { }
    4240    public ScheduleCreator()
    4341      : base() {
    44       Parameters.Add(new LookupParameter<T>("ScheduleEncoding", "The new scheduling solutioncandidate."));
     42      Parameters.Add(new LookupParameter<IScheduleEncoding>("ScheduleEncoding", "The new scheduling solutioncandidate."));
    4543    }
    46 
    4744
    4845    public override IOperation Apply() {
     
    5047      return base.Apply();
    5148    }
    52     protected abstract T CreateSolution();
     49
     50    protected abstract IScheduleEncoding CreateSolution();
    5351  }
    5452}
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleCrossover.cs

    r8603 r8887  
    3030  [Item("ScheduleCrossover", "A scheduling crossover operation.")]
    3131  [StorableClass]
    32   public abstract class ScheduleCrossover<T> : SingleSuccessorOperator, IScheduleCrossover, IStochasticOperator where T : Item {
    33     #region IScheduleCrossover Members
    34     public ILookupParameter<ItemArray<T>> ParentsParameter {
    35       get { return (ScopeTreeLookupParameter<T>)Parameters["Parents"]; }
     32  public abstract class ScheduleCrossover : SingleSuccessorOperator, IScheduleCrossover, IStochasticOperator {
     33
     34    public ILookupParameter<IScheduleEncoding> ChildParameter {
     35      get { return (ILookupParameter<IScheduleEncoding>)Parameters["Child"]; }
    3636    }
    37 
    38     public ILookupParameter<T> ChildParameter {
    39       get { return (ILookupParameter<T>)Parameters["Child"]; }
     37    public IScopeTreeLookupParameter<IScheduleEncoding> ParentsParameter {
     38      get { return (IScopeTreeLookupParameter<IScheduleEncoding>)Parameters["Parents"]; }
    4039    }
    41     #endregion
    42 
    4340    public ILookupParameter<IRandom> RandomParameter {
    4441      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     
    4744    [StorableConstructor]
    4845    protected ScheduleCrossover(bool deserializing) : base(deserializing) { }
    49     protected ScheduleCrossover(ScheduleCrossover<T> original, Cloner cloner)
    50       : base(original, cloner) {
    51     }
     46    protected ScheduleCrossover(ScheduleCrossover original, Cloner cloner) : base(original, cloner) { }
    5247    public ScheduleCrossover()
    5348      : base() {
    5449      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    55       Parameters.Add(new ScopeTreeLookupParameter<T>("Parents", "The parent solution which should be crossed."));
     50      Parameters.Add(new LookupParameter<IScheduleEncoding>("Child", "The child solution resulting from the crossover."));
     51      ChildParameter.ActualName = "SchedulingSolution";
     52      Parameters.Add(new ScopeTreeLookupParameter<IScheduleEncoding>("Parents", "The parent solution which should be crossed."));
    5653      ParentsParameter.ActualName = "SchedulingSolution";
    57       Parameters.Add(new LookupParameter<T>("Child", "The child solution resulting from the crossover."));
    58       ChildParameter.ActualName = "SchedulingSolution";
    5954    }
    6055  }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers/DirectScheduleCrossover.cs

    r8603 r8887  
    2828  [Item("DirectScheduleCrossover", "An operator which crosses two schedule representations.")]
    2929  [StorableClass]
    30   public abstract class DirectScheduleCrossover : ScheduleCrossover<Schedule>, IDirectScheduleOperator {
     30  public abstract class DirectScheduleCrossover : ScheduleCrossover, IDirectScheduleOperator {
    3131    [StorableConstructor]
    3232    protected DirectScheduleCrossover(bool deserializing) : base(deserializing) { }
     
    3939    }
    4040
    41 
    4241    public ILookupParameter<ItemList<Job>> JobDataParameter {
    4342      get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }
     
    4746
    4847    public override IOperation Apply() {
    49       ItemArray<Schedule> parents = ParentsParameter.ActualValue;
     48      var parents = ParentsParameter.ActualValue;
    5049      ChildParameter.ActualValue =
    5150        Cross(RandomParameter.ActualValue, parents[0] as Schedule, parents[1] as Schedule);
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers/DirectScheduleGTCrossover.cs

    r8603 r8887  
    3030  [StorableClass]
    3131  public class DirectScheduleGTCrossover : DirectScheduleCrossover {
     32
     33    public IValueLookupParameter<DoubleValue> MutationProbabilityParameter {
     34      get { return (IValueLookupParameter<DoubleValue>)Parameters["MutationProbability"]; }
     35    }
     36
    3237    [StorableConstructor]
    3338    protected DirectScheduleGTCrossover(bool deserializing) : base(deserializing) { }
    34     protected DirectScheduleGTCrossover(DirectScheduleGTCrossover original, Cloner cloner)
    35       : base(original, cloner) {
     39    protected DirectScheduleGTCrossover(DirectScheduleGTCrossover original, Cloner cloner) : base(original, cloner) { }
     40    public DirectScheduleGTCrossover()
     41      : base() {
     42      Parameters.Add(new ValueLookupParameter<DoubleValue>("MutationProbability", "The probability that a task from the conflict set is chosen randomly instead of from one of the parents."));
    3643    }
     44
    3745    public override IDeepCloneable Clone(Cloner cloner) {
    3846      return new DirectScheduleGTCrossover(this, cloner);
    3947    }
    40     public DirectScheduleGTCrossover()
    41       : base() {
    42       Parameters.Add(new LookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
    43     }
    44 
    45 
    46     private LookupParameter<PercentValue> MutationProbabilityParameter {
    47       get { return (LookupParameter<PercentValue>)Parameters["MutationProbability"]; }
    48     }
    49 
    5048
    5149    public static Schedule Apply(IRandom random, Schedule parent1, Schedule parent2, ItemList<Job> jobData, double mutProp) {
    52       Schedule child = new Schedule(parent1.Resources.Count);
    53 
     50      var child = new Schedule(parent1.Resources.Count);
    5451
    5552      //Reset scheduled tasks in result
     
    7572        int progressOnResource = conflictedResource.Tasks.Count;
    7673        Task selectedTask = null;
    77         if (random.Next(100) < mutProp) {
     74        if (random.NextDouble() < mutProp) {
    7875          //Mutation
    7976          selectedTask = conflictSet[random.Next(conflictSet.Count)];
     
    9592    }
    9693
    97 
    9894    private static Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, Schedule usedParent, int conflictedResourceNr, int progressOnResource) {
    9995      //Apply Crossover
     
    109105
    110106    public override Schedule Cross(IRandom random, Schedule parent1, Schedule parent2) {
    111       ItemList<Job> jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
    112       PercentValue mutProp = MutationProbabilityParameter.ActualValue;
     107      var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
     108      var mutProp = MutationProbabilityParameter.ActualValue;
    113109      return Apply(random, parent1, parent2, jobData, mutProp.Value);
    114110    }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleRandomCreator.cs

    r8603 r8887  
    3333  [Item("DirectScheduleRandomCreator", "Creator class used to create schedule encoding objects.")]
    3434  [StorableClass]
    35   public class DirectScheduleRandomCreator : ScheduleCreator<Schedule>, IStochasticOperator {
     35  public class DirectScheduleRandomCreator : ScheduleCreator, IStochasticOperator {
    3636
    3737    public ILookupParameter<IRandom> RandomParameter {
     
    6868
    6969    public static Schedule Apply(int jobs, int resources, PWREncoding pwr, ItemList<Job> jobData) {
    70       Schedule resultingSchedule = new Schedule(jobData[0].Tasks.Count);
     70      var resultingSchedule = new Schedule(jobData[0].Tasks.Count);
    7171      foreach (int jobNr in pwr.PermutationWithRepetition) {
    7272        int i = 0;
     
    8282
    8383
    84     protected override Schedule CreateSolution() {
     84    protected override IScheduleEncoding CreateSolution() {
    8585      try {
    86         ItemList<Job> jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
     86        var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();
    8787        return Apply(JobsParameter.ActualValue.Value,
    8888          ResourcesParameter.ActualValue.Value,
    8989          new PWREncoding(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue),
    9090          jobData);
    91       }
    92       catch {
     91      } catch {
    9392        throw new Exception("ScheduleRandomCreator needs JobData parameter from a JSSP-Instance to create Schedule-Instances!");
    9493      }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Job.cs

    r8886 r8887  
    3030  [StorableClass]
    3131  public class Job : Item, INotifyPropertyChanged {
    32     [Storable(Name = "DueDate")] private double dueDate;
     32
     33    [Storable(Name = "DueDate")]
     34    private double dueDate;
    3335    public double DueDate {
    3436      get { return dueDate; }
     
    5254
    5355    [Storable(Name = "Tasks")]
    54     private ItemList<Task> tasks; 
     56    private ItemList<Task> tasks;
    5557    public ItemList<Task> Tasks {
    5658      get { return tasks; }
     
    7072      this.Tasks = cloner.Clone(original.Tasks);
    7173    }
    72     public override IDeepCloneable Clone(Cloner cloner) {
    73       return new Job(this, cloner);
    74     }
     74    public Job() : this(-1, double.MaxValue) { }
    7575    public Job(int index, double dueDate)
    7676      : base() {
     
    7878      Index = index;
    7979      Tasks = new ItemList<Task>();
     80    }
     81
     82    public override IDeepCloneable Clone(Cloner cloner) {
     83      return new Job(this, cloner);
    8084    }
    8185
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Manipulators/DirectScheduleManipulator.cs

    r8603 r8887  
    2020#endregion
    2121
     22using System;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
     
    2728  [Item("DirectScheduleManipulator", "An operator which manipulates a direct schedule representation.")]
    2829  [StorableClass]
    29   public abstract class DirectScheduleManipulator : ScheduleManipulator<Schedule>, IDirectScheduleOperator {
     30  public abstract class DirectScheduleManipulator : ScheduleManipulator, IDirectScheduleOperator {
     31
    3032    [StorableConstructor]
    3133    protected DirectScheduleManipulator(bool deserializing) : base(deserializing) { }
     
    3638    }
    3739
     40    protected abstract void Manipulate(IRandom random, Schedule individual);
    3841
    39     protected abstract void Manipulate(IRandom random, Schedule individual);
    4042    public override IOperation Apply() {
    41       Schedule solution = ScheduleEncodingParameter.ActualValue;
    42       Manipulate(RandomParameter.ActualValue, solution);
     43      var schedule = ScheduleEncodingParameter.ActualValue as Schedule;
     44      if (schedule == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type Schedule.");
     45      Manipulate(RandomParameter.ActualValue, schedule);
    4346      return base.Apply();
    4447    }
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Resource.cs

    r8603 r8887  
    2929  [StorableClass]
    3030  public class Resource : Item {
    31     public Resource(int index)
    32       : base() {
    33       Index = index;
    34       Tasks = new ItemList<ScheduledTask>();
    35     }
     31
    3632    [Storable]
    3733    public int Index {
     
    4440      set;
    4541    }
     42
     43    [StorableConstructor]
     44    protected Resource(bool deserializing) : base(deserializing) { }
     45    protected Resource(Resource original, Cloner cloner)
     46      : base(original, cloner) {
     47      this.Index = original.Index;
     48      this.Tasks = cloner.Clone(original.Tasks);
     49    }
     50    public Resource(int index)
     51      : base() {
     52      Index = index;
     53      Tasks = new ItemList<ScheduledTask>();
     54    }
     55
     56    public override IDeepCloneable Clone(Cloner cloner) {
     57      return new Resource(this, cloner);
     58    }
     59
    4660    public double TotalDuration {
    4761      get {
     
    5367        return result;
    5468      }
    55     }
    56 
    57     [StorableConstructor]
    58     protected Resource(bool deserializing) : base(deserializing) { }
    59     protected Resource(Resource original, Cloner cloner)
    60       : base(original, cloner) {
    61       this.Index = original.Index;
    62       this.Tasks = cloner.Clone(original.Tasks);
    63     }
    64     public override IDeepCloneable Clone(Cloner cloner) {
    65       return new Resource(this, cloner);
    6669    }
    6770
     
    8386        return false;
    8487    }
     88
    8589    public override int GetHashCode() {
    8690      if (Tasks.Count == 1)
     
    9094      return 0;
    9195    }
     96
    9297    private static bool AreEqual(Resource res1, Resource res2) {
    9398      if (res1.Tasks.Count != res2.Tasks.Count)
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Schedule.cs

    r8603 r8887  
    3232  [StorableClass]
    3333  public class Schedule : NamedItem, IScheduleEncoding {
     34
    3435    #region Properties
    3536    [Storable]
     
    6970      this.lastScheduledTaskOfJob = new Dictionary<int, ScheduledTask>(original.lastScheduledTaskOfJob);
    7071    }
    71     public override IDeepCloneable Clone(Cloner cloner) {
    72       return new Schedule(this, cloner);
    73     }
    7472    public Schedule(int nrOfResources) {
    7573      Resources = new ItemList<Resource>();
     
    8078    }
    8179
    82 
     80    public override IDeepCloneable Clone(Cloner cloner) {
     81      return new Schedule(this, cloner);
     82    }
    8383
    8484    #region Events
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/ScheduledTask.cs

    r8603 r8887  
    2929  [StorableClass]
    3030  public class ScheduledTask : Item {
     31
    3132    #region Properties
    3233    [Storable]
     
    5758      this.JobNr = original.JobNr;
    5859    }
    59     public override IDeepCloneable Clone(Cloner cloner) {
    60       return new ScheduledTask(this, cloner);
    61     }
    62 
    6360    public ScheduledTask(int resNr, double startTime, double duration, int jobNr)
    6461      : base() {
     
    6966    }
    7067
     68    public override IDeepCloneable Clone(Cloner cloner) {
     69      return new ScheduledTask(this, cloner);
     70    }
     71
    7172    public override string ToString() {
    7273      StringBuilder sb = new StringBuilder();
     
    7475      return sb.ToString();
    7576    }
    76 
    7777
    7878    public override bool Equals(object obj) {
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Task.cs

    r8886 r8887  
    3030  [StorableClass]
    3131  public class Task : Item, INotifyPropertyChanged {
     32
    3233    [Storable(Name = "TaskNr")]
    3334    private int taskNr;
     
    9495      this.IsScheduled = original.IsScheduled;
    9596    }
    96     public override IDeepCloneable Clone(Cloner cloner) {
    97       return new Task(this, cloner);
    98     }
    99 
    100 
     97    public Task() : this(-1, -1, -1, 0) { }
    10198    public Task(int taskNr, int resNr, int jobNr, double duration)
    10299      : base() {
     
    106103      TaskNr = taskNr;
    107104      IsScheduled = false;
     105    }
     106
     107    public override IDeepCloneable Clone(Cloner cloner) {
     108      return new Task(this, cloner);
    108109    }
    109110
     
    120121        return false;
    121122    }
     123
    122124    public override int GetHashCode() {
    123125      return TaskNr ^ JobNr;
    124126    }
     127
    125128    public static bool AreEqual(Task task1, Task task2) {
    126129      return (task1.Duration == task2.Duration &&
  • trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleManipulator.cs

    r8603 r8887  
    3030  [Item("ScheduleManipulator", "A scheduling manipulation operation.")]
    3131  [StorableClass]
    32   public abstract class ScheduleManipulator<T> : SingleSuccessorOperator, IScheduleManipulator, IStochasticOperator where T : Item {
    33     #region IScheduleManipulator Members
     32  public abstract class ScheduleManipulator : SingleSuccessorOperator, IScheduleManipulator, IStochasticOperator {
    3433
    35     public ILookupParameter<T> ScheduleEncodingParameter {
    36       get { return (ILookupParameter<T>)Parameters["ScheduleEncoding"]; }
     34    public ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter {
     35      get { return (ILookupParameter<IScheduleEncoding>)Parameters["ScheduleEncoding"]; }
    3736    }
    38 
    39     #endregion
    4037
    4138    public ILookupParameter<IRandom> RandomParameter {
     
    4542    [StorableConstructor]
    4643    protected ScheduleManipulator(bool deserializing) : base(deserializing) { }
    47     protected ScheduleManipulator(ScheduleManipulator<T> original, Cloner cloner)
    48       : base(original, cloner) {
    49     }
     44    protected ScheduleManipulator(ScheduleManipulator original, Cloner cloner) : base(original, cloner) { }
    5045    public ScheduleManipulator()
    5146      : base() {
    52       Parameters.Add(new LookupParameter<T>("ScheduleEncoding", "The scheduling solution to be manipulated."));
     47      Parameters.Add(new LookupParameter<IScheduleEncoding>("ScheduleEncoding", "The scheduling solution to be manipulated."));
    5348      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    5449    }
  • trunk/sources/HeuristicLab.Problems.Scheduling.Views/3.3/HeuristicLab.Problems.Scheduling.Views-3.3.csproj

    r8886 r8887  
    109109  </ItemGroup>
    110110  <ItemGroup>
     111    <Compile Include="JSMForcingStrategyView.cs">
     112      <SubType>UserControl</SubType>
     113    </Compile>
     114    <Compile Include="JSMForcingStrategyView.Designer.cs">
     115      <DependentUpon>JSMForcingStrategyView.cs</DependentUpon>
     116    </Compile>
    111117    <Compile Include="JobShopSchedulingProblemView.cs">
    112118      <SubType>UserControl</SubType>
     
    114120    <Compile Include="JobShopSchedulingProblemView.Designer.cs">
    115121      <DependentUpon>JobShopSchedulingProblemView.cs</DependentUpon>
     122    </Compile>
     123    <Compile Include="JSMDecodingErrorPolicyView.cs">
     124      <SubType>UserControl</SubType>
     125    </Compile>
     126    <Compile Include="JSMDecodingErrorPolicyView.Designer.cs">
     127      <DependentUpon>JSMDecodingErrorPolicyView.cs</DependentUpon>
    116128    </Compile>
    117129    <Compile Include="Plugin.cs" />
     
    143155      <Name>HeuristicLab.Core-3.3</Name>
    144156      <Private>False</Private>
     157    </ProjectReference>
     158    <ProjectReference Include="..\..\HeuristicLab.Data\3.3\HeuristicLab.Data-3.3.csproj">
     159      <Project>{bbab9df5-5ef3-4ba8-ade9-b36e82114937}</Project>
     160      <Name>HeuristicLab.Data-3.3</Name>
    145161    </ProjectReference>
    146162    <ProjectReference Include="..\..\HeuristicLab.Encodings.ScheduleEncoding.Views\3.3\HeuristicLab.Encodings.ScheduleEncoding.Views-3.3.csproj">
  • trunk/sources/HeuristicLab.Problems.Scheduling.Views/3.3/Plugin.cs.frame

    r8882 r8887  
    2828  [PluginDependency("HeuristicLab.Core", "3.3")]
    2929  [PluginDependency("HeuristicLab.Core.Views", "3.3")]
     30  [PluginDependency("HeuristicLab.Data", "3.3")]
    3031  [PluginDependency("HeuristicLab.Encodings.ScheduleEncoding", "3.3")]
    3132  [PluginDependency("HeuristicLab.Encodings.ScheduleEncoding.Views", "3.3")]
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/Decoders/JSMDecoder.cs

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

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

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

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

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

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

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

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

    r6475 r8887  
    1 using HeuristicLab.Core;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using HeuristicLab.Core;
    223using HeuristicLab.Encodings.ScheduleEncoding;
    324
  • trunk/sources/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs

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

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

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

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