Changeset 8887 for trunk/sources/HeuristicLab.Encodings.ScheduleEncoding
- Timestamp:
- 11/11/12 22:57:09 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3
- Files:
-
- 5 deleted
- 46 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/HeuristicLab.Encodings.ScheduleEncoding-3.3.csproj
r8806 r8887 110 110 <ItemGroup> 111 111 <Compile Include="Interfaces\IDirectScheduleOperator.cs" /> 112 <Compile Include="Interfaces\IScheduleEvaluationAlgorithm.cs" />113 112 <Compile Include="Interfaces\IJSMOperator.cs" /> 114 113 <Compile Include="Interfaces\IPRVOperator.cs" /> … … 116 115 <Compile Include="Interfaces\IScheduleCreator.cs" /> 117 116 <Compile Include="Interfaces\IScheduleCrossover.cs" /> 118 <Compile Include="Interfaces\IScheduleDecoder.cs" />119 117 <Compile Include="Interfaces\IScheduleEncoding.cs" /> 120 <Compile Include="Interfaces\IScheduleEvaluator.cs" />121 118 <Compile Include="Interfaces\IScheduleManipulator.cs" /> 122 119 <Compile Include="Interfaces\IScheduleOperator.cs" /> … … 151 148 <Compile Include="ScheduleEncoding\Job.cs" /> 152 149 <Compile Include="ScheduleEncoding\Manipulators\DirectScheduleManipulator.cs" /> 153 <Compile Include="ScheduleEncoding\Manipulators\ConcreteScheduleManipulator.cs" />154 150 <Compile Include="ScheduleEncoding\DirectScheduleRandomCreator.cs" /> 155 151 <Compile Include="ScheduleEncoding\Resource.cs" /> … … 158 154 <Compile Include="ScheduleCreator.cs" /> 159 155 <Compile Include="ScheduleCrossover.cs" /> 160 <Compile Include="ScheduleDecoder.cs" />161 156 <Compile Include="ScheduleEncoding\Task.cs" /> 162 157 <Compile Include="ScheduleManipulator.cs" /> -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IDirectScheduleOperator.cs
r8603 r8887 21 21 22 22 using HeuristicLab.Core; 23 23 24 namespace HeuristicLab.Encodings.ScheduleEncoding { 24 25 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 22 using HeuristicLab.Core; 2 23 3 24 namespace 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 22 using HeuristicLab.Core; 2 23 3 24 namespace 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 22 using HeuristicLab.Core; 2 23 3 24 namespace 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 22 using HeuristicLab.Core; 23 using HeuristicLab.Optimization; 2 24 3 25 namespace HeuristicLab.Encodings.ScheduleEncoding { 4 26 public interface IScheduleCreator : ISolutionCreator, IScheduleOperator { 27 ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter { get; } 5 28 } 6 29 } -
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 22 using HeuristicLab.Core; 23 using HeuristicLab.Optimization; 2 24 3 25 namespace HeuristicLab.Encodings.ScheduleEncoding { 4 26 public interface IScheduleCrossover : ICrossover, IScheduleOperator { 27 ILookupParameter<IScheduleEncoding> ChildParameter { get; } 28 IScopeTreeLookupParameter<IScheduleEncoding> ParentsParameter { get; } 5 29 } 6 30 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleManipulator.cs
r8603 r8887 20 20 #endregion 21 21 22 using HeuristicLab.Core; 22 23 using HeuristicLab.Optimization; 23 24 24 25 namespace HeuristicLab.Encodings.ScheduleEncoding { 25 26 public interface IScheduleManipulator : IManipulator, IScheduleOperator { 27 ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter { get; } 26 28 } 27 29 } -
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 22 using HeuristicLab.Core; 2 23 3 24 namespace HeuristicLab.Encodings.ScheduleEncoding { -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMCrossover.cs
r8603 r8887 27 27 [Item("JSMCrossover", "An operator which crosses two JSM representations.")] 28 28 [StorableClass] 29 public abstract class JSMCrossover : ScheduleCrossover <JSMEncoding>, IJSMOperator {29 public abstract class JSMCrossover : ScheduleCrossover, IJSMOperator { 30 30 31 31 [StorableConstructor] … … 41 41 42 42 public override IOperation Apply() { 43 ItemArray<JSMEncoding>parents = ParentsParameter.ActualValue;43 var parents = ParentsParameter.ActualValue; 44 44 45 45 ChildParameter.ActualValue = -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMJOXCrossover.cs
r8603 r8887 30 30 [StorableClass] 31 31 public class JSMJOXCrossover : JSMCrossover { 32 32 33 [StorableConstructor] 33 34 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 37 38 public override IDeepCloneable Clone(Cloner cloner) { 38 39 return new JSMJOXCrossover(this, cloner); 39 40 } 40 public JSMJOXCrossover() : base() { }41 42 41 43 42 public static JSMEncoding Apply(IRandom random, JSMEncoding p1, JSMEncoding p2) { 44 JSMEncodingresult = new JSMEncoding();43 var result = new JSMEncoding(); 45 44 46 45 int nrOfResources = p1.JobSequenceMatrix.Count; … … 48 47 49 48 //Determine randomly which jobindexes persist 50 BoolArraypersist = new BoolArray(nrOfJobs);49 var persist = new BoolArray(nrOfJobs); 51 50 for (int i = 0; i < persist.Length; i++) { 52 51 persist[i] = random.Next(2) == 1; -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMOXCrossover.cs
r8603 r8887 28 28 [StorableClass] 29 29 public class JSMOXCrossover : JSMCrossover { 30 30 31 [StorableConstructor] 31 32 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 35 36 public override IDeepCloneable Clone(Cloner cloner) { 36 37 return new JSMOXCrossover(this, cloner); 37 38 } 38 public JSMOXCrossover() : base() { }39 40 39 41 40 public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) { 42 JSMEncodingresult = new JSMEncoding();41 var result = new JSMEncoding(); 43 42 44 43 for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) { -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMSXXCrossover.cs
r8603 r8887 29 29 [StorableClass] 30 30 public class JSMSXXCrossover : JSMCrossover { 31 31 32 [StorableConstructor] 32 33 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 36 37 public override IDeepCloneable Clone(Cloner cloner) { 37 38 return new JSMSXXCrossover(this, cloner); 38 39 } 39 public JSMSXXCrossover() : base() { }40 41 40 42 41 public static JSMEncoding Apply(IRandom random, JSMEncoding parent1, JSMEncoding parent2) { 43 JSMEncodingresult = new JSMEncoding();42 var result = new JSMEncoding(); 44 43 int subSequenceLength = random.Next(parent1.JobSequenceMatrix[0].Length); 45 44 for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) { 46 Permutationp1 = (Permutation)parent1.JobSequenceMatrix[i].Clone();47 Permutationp2 = (Permutation)parent2.JobSequenceMatrix[i].Clone();45 var p1 = (Permutation)parent1.JobSequenceMatrix[i].Clone(); 46 var p2 = (Permutation)parent2.JobSequenceMatrix[i].Clone(); 48 47 FindAndExchangeSubsequences(p1, p2, subSequenceLength); 49 48 result.JobSequenceMatrix.Add(p1); … … 51 50 return result; 52 51 } 52 53 53 private static void FindAndExchangeSubsequences(Permutation p1, Permutation p2, int subSequenceLength) { 54 54 for (int i = 0; i <= p1.Length - subSequenceLength; i++) { … … 63 63 } 64 64 } 65 65 66 private static void ExchangeSubsequences(Permutation p1, int index1, Permutation p2, int index2, int subSequenceLength) { 66 Permutationaux = (Permutation)p1.Clone();67 var aux = (Permutation)p1.Clone(); 67 68 for (int i = 0; i < subSequenceLength; i++) { 68 69 p1[i + index1] = p2[i + index2]; … … 70 71 } 71 72 } 73 72 74 private static bool AreEqualSubsequences(int[] ss1, int[] ss2) { 73 75 int counter = 0; … … 80 82 return counter == ss1.Length; 81 83 } 84 82 85 private static int[] GetSubSequenceAtPosition(Permutation p1, int index, int subSequenceLength) { 83 int[]result = new int[subSequenceLength];86 var result = new int[subSequenceLength]; 84 87 for (int i = 0; i < subSequenceLength; i++) 85 88 result[i] = p1[i + index]; -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMEncoding.cs
r8603 r8887 30 30 [StorableClass] 31 31 public class JSMEncoding : Item, IScheduleEncoding { 32 32 33 [Storable] 33 34 public ItemList<Permutation> JobSequenceMatrix { get; set; } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMRandomCreator.cs
r8603 r8887 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 29 30 31 30 namespace HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix { 32 31 [Item("JobSequenceMatrixCreator", "Creator class used to create Job Sequence Matrix solutions for standard JobShop scheduling problems.")] 33 32 [StorableClass] 34 public class JSMRandomCreator : ScheduleCreator <JSMEncoding>, IStochasticOperator {35 #region Parameter Properties 33 public class JSMRandomCreator : ScheduleCreator, IStochasticOperator { 34 36 35 public ILookupParameter<IRandom> RandomParameter { 37 36 get { return (LookupParameter<IRandom>)Parameters["Random"]; } … … 43 42 get { return (IValueLookupParameter<IntValue>)Parameters["Resources"]; } 44 43 } 45 #endregion46 47 44 48 45 [StorableConstructor] 49 46 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) { } 56 48 public JSMRandomCreator() 57 49 : base() { … … 63 55 } 64 56 57 public override IDeepCloneable Clone(Cloner cloner) { 58 return new JSMRandomCreator(this, cloner); 59 } 65 60 66 61 public static JSMEncoding Apply(int jobs, int resources, IRandom random) { 67 JSMEncoding solution = new JSMEncoding(); 68 62 var solution = new JSMEncoding(); 69 63 for (int i = 0; i < resources; i++) { 70 64 solution.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, jobs, random)); 71 65 } 72 73 66 return solution; 74 67 } 75 68 76 77 protected override JSMEncoding CreateSolution() { 69 protected override IScheduleEncoding CreateSolution() { 78 70 return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue); 79 71 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMManipulator.cs
r8603 r8887 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 27 28 [Item("JSMManipulator", "An operator which manipulates a JSM representation.")] 28 29 [StorableClass] 29 public abstract class JSMManipulator : ScheduleManipulator <JSMEncoding>, IJSMOperator {30 public abstract class JSMManipulator : ScheduleManipulator, IJSMOperator { 30 31 [StorableConstructor] 31 32 protected JSMManipulator(bool deserializing) : base(deserializing) { } … … 36 37 } 37 38 38 protected abstract void Manipulate(IRandom random, JSMEncoding individual); 39 39 protected abstract void Manipulate(IRandom random, IScheduleEncoding individual); 40 40 41 41 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."); 43 44 Manipulate(RandomParameter.ActualValue, solution); 44 45 return base.Apply(); -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMShiftChangeManipulator.cs
r8603 r8887 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 28 29 29 30 namespace HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix { 30 31 31 [Item("JSMShiftChangeManipulator", "Represents a manipulation operation where the operations of a randomly determined job are shifted in one direction for all resources.")] 32 32 [StorableClass] 33 33 public class JSMShiftChangeManipulator : JSMManipulator { 34 34 35 [StorableConstructor] 35 36 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 39 40 public override IDeepCloneable Clone(Cloner cloner) { 40 41 return new JSMShiftChangeManipulator(this, cloner); 41 42 } 42 43 public JSMShiftChangeManipulator() : base() { }44 45 43 46 44 public static void Apply(IRandom random, JSMEncoding individual) { … … 65 63 } 66 64 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); 69 69 } 70 70 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMSwapManipulator.cs
r8603 r8887 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 26 27 27 28 namespace HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix { 28 29 29 [Item("JSMSwapManipulator", "Represents a manipulation operation swapping parts of the individual.")] 30 30 [StorableClass] 31 31 public class JSMSwapManipulator : JSMManipulator { 32 32 33 [StorableConstructor] 33 34 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 37 38 public override IDeepCloneable Clone(Cloner cloner) { 38 39 return new JSMSwapManipulator(this, cloner); 39 40 } 40 41 public JSMSwapManipulator() : base() { }42 43 41 44 42 public static void Apply(IRandom random, JSMEncoding individual) { … … 52 50 } 53 51 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); 56 56 } 57 57 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRCrossover.cs
r8603 r8887 27 27 [Item("PWRCrossover", "An operator which crosses two JSM representations.")] 28 28 [StorableClass] 29 public abstract class PWRCrossover : ScheduleCrossover <PWREncoding>, IPWROperator {29 public abstract class PWRCrossover : ScheduleCrossover, IPWROperator { 30 30 31 31 [StorableConstructor] … … 41 41 42 42 public override IOperation Apply() { 43 ItemArray<PWREncoding>parents = ParentsParameter.ActualValue;43 var parents = ParentsParameter.ActualValue; 44 44 45 45 ChildParameter.ActualValue = -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRGOXCrossover.cs
r8603 r8887 31 31 [StorableClass] 32 32 public class PWRGOXCrossover : PWRCrossover { 33 33 34 [StorableConstructor] 34 35 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 38 39 public override IDeepCloneable Clone(Cloner cloner) { 39 40 return new PWRGOXCrossover(this, cloner); 40 41 } 41 public PWRGOXCrossover() : base() { }42 42 43 43 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>(); 46 46 47 47 for (int i = 0; i < p.Count; i++) { … … 54 54 return result; 55 55 } 56 56 57 public static PWREncoding Apply(IRandom random, PWREncoding parent1, PWREncoding parent2) { 57 PWREncodingresult = new PWREncoding();58 var result = new PWREncoding(); 58 59 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>(); 62 63 63 64 int[] lookUpArrayP1 = GetLookUpForIndividual(p1); … … 90 91 } 91 92 92 93 94 95 93 } 96 94 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRPPXCrossover.cs
r8603 r8887 31 31 [StorableClass] 32 32 public class PWRPPXCrossover : PWRCrossover { 33 33 34 [StorableConstructor] 34 35 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 38 39 public override IDeepCloneable Clone(Cloner cloner) { 39 40 return new PWRPPXCrossover(this, cloner); 40 41 } 41 public PWRPPXCrossover() : base() { }42 42 43 43 public static PWREncoding Apply(IRandom random, PWREncoding parent1, PWREncoding parent2) { 44 PWREncodingresult = 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>(); 48 48 49 bool[]lookUpTable = new bool[parent1.PermutationWithRepetition.Length];49 var lookUpTable = new bool[parent1.PermutationWithRepetition.Length]; 50 50 for (int i = 0; i < lookUpTable.Length; i++) { 51 51 lookUpTable[i] = random.Next(2) == 1; … … 73 73 } 74 74 75 76 75 } 77 76 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Manipulators/PWRInsertionManipulator.cs
r8603 r8887 28 28 29 29 namespace HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition { 30 31 30 [Item("PWRInsertionManipulator", "Represents a manipulation operation inserting parts of the individual at another position.")] 32 31 [StorableClass] … … 34 33 [StorableConstructor] 35 34 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 39 38 public override IDeepCloneable Clone(Cloner cloner) { 40 39 return new PWRInsertionManipulator(this, cloner); 41 40 } 42 public PWRInsertionManipulator() : base() { }43 41 44 42 public static void Apply(IRandom random, PWREncoding individual) { -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Manipulators/PWRManipulator.cs
r8603 r8887 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 27 28 [Item("PWRManipulator", "An operator which manipulates a PWR representation.")] 28 29 [StorableClass] 29 public abstract class PWRManipulator : ScheduleManipulator<PWREncoding>, IPWROperator { 30 public abstract class PWRManipulator : ScheduleManipulator, IPWROperator { 31 30 32 [StorableConstructor] 31 33 protected PWRManipulator(bool deserializing) : base(deserializing) { } … … 38 40 protected abstract void Manipulate(IRandom random, PWREncoding individual); 39 41 40 41 42 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."); 43 45 Manipulate(RandomParameter.ActualValue, solution); 44 46 return base.Apply(); -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWREncoding.cs
r8603 r8887 30 30 [StorableClass] 31 31 public class PWREncoding : Item, IScheduleEncoding { 32 32 33 [Storable] 33 34 public IntegerVector PermutationWithRepetition { get; set; } 34 35 35 36 36 [StorableConstructor] … … 40 40 this.PermutationWithRepetition = cloner.Clone(original.PermutationWithRepetition); 41 41 } 42 public override IDeepCloneable Clone(Cloner cloner) {43 return new PWREncoding(this, cloner);44 }45 42 public PWREncoding() 46 43 : base() { 47 44 PermutationWithRepetition = new IntegerVector(); 45 } 46 47 public override IDeepCloneable Clone(Cloner cloner) { 48 return new PWREncoding(this, cloner); 48 49 } 49 50 … … 81 82 return base.Equals(obj); 82 83 } 84 83 85 public override int GetHashCode() { 84 86 if (PermutationWithRepetition.Length == 1) … … 88 90 return 0; 89 91 } 92 90 93 private bool AreEqual(PWREncoding pWREncoding1, PWREncoding pWREncoding2) { 91 94 if (pWREncoding1.PermutationWithRepetition.Length != pWREncoding2.PermutationWithRepetition.Length) … … 97 100 return true; 98 101 } 99 100 101 102 } 102 103 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWRRandomCreator.cs
r8603 r8887 30 30 [Item("PermutationWithRepetitionRandomCreator", "Creates PWR-individuals at random.")] 31 31 [StorableClass] 32 public class PWRRandomCreator : ScheduleCreator<PWREncoding>, IStochasticOperator { 33 public IRandom Random { 34 get { return RandomParameter.ActualValue; } 35 } 32 public class PWRRandomCreator : ScheduleCreator, IStochasticOperator { 36 33 37 34 public ILookupParameter<IRandom> RandomParameter { … … 47 44 [StorableConstructor] 48 45 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) { } 56 47 public PWRRandomCreator() 57 48 : base() { … … 63 54 } 64 55 56 public override IDeepCloneable Clone(Cloner cloner) { 57 return new PWRRandomCreator(this, cloner); 58 } 59 65 60 public static PWREncoding Apply(int jobs, int resources, IRandom random) { 66 61 return new PWREncoding(jobs, resources, random); 67 62 } 68 63 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); 72 66 } 73 67 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Plugin.cs.frame
r8603 r8887 23 23 24 24 namespace HeuristicLab.Encodings.ScheduleEncoding { 25 [Plugin("HeuristicLab.Encodings.ScheduleEncoding", "3.3. 3.$WCREV$")]25 [Plugin("HeuristicLab.Encodings.ScheduleEncoding", "3.3.7.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Encodings.ScheduleEncoding-3.3.dll", PluginFileType.Assembly)] 27 27 [PluginDependency("HeuristicLab.Collections", "3.3")] -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVCrossover.cs
r8603 r8887 27 27 [Item("PRVCrossover", "An operator which crosses two PRV representations.")] 28 28 [StorableClass] 29 public abstract class PRVCrossover : ScheduleCrossover<PRVEncoding>, IPRVOperator { 29 public abstract class PRVCrossover : ScheduleCrossover, IPRVOperator { 30 30 31 [StorableConstructor] 31 32 protected PRVCrossover(bool deserializing) : base(deserializing) { } … … 37 38 } 38 39 39 40 40 public abstract PRVEncoding Cross(IRandom random, PRVEncoding parent1, PRVEncoding parent2); 41 41 42 42 public override IOperation Apply() { 43 ItemArray<PRVEncoding>parents = ParentsParameter.ActualValue;43 var parents = ParentsParameter.ActualValue; 44 44 ChildParameter.ActualValue = 45 45 Cross(RandomParameter.ActualValue, parents[0] as PRVEncoding, parents[1] as PRVEncoding); -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVDiscreteCrossover.cs
r8603 r8887 29 29 [StorableClass] 30 30 public class PRVDiscreteCrossover : PRVCrossover { 31 31 32 [StorableConstructor] 32 33 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 36 37 public override IDeepCloneable Clone(Cloner cloner) { 37 38 return new PRVDiscreteCrossover(this, cloner); 38 39 } 39 public PRVDiscreteCrossover() : base() { }40 41 40 42 41 public static PRVEncoding Apply(IRandom random, PRVEncoding parent1, PRVEncoding parent2) { 43 42 return new PRVEncoding(DiscreteCrossover.Apply(random, new ItemArray<IntegerVector>(new IntegerVector[] { parent1.PriorityRulesVector, parent2.PriorityRulesVector })), parent1.NrOfRules); 44 43 } 44 45 45 public override PRVEncoding Cross(IRandom random, PRVEncoding parent1, PRVEncoding parent2) { 46 46 return Apply(random, parent1, parent2); -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVSinglePointCrossover.cs
r8603 r8887 29 29 [StorableClass] 30 30 public class PRVSinglePointCrossover : PRVCrossover { 31 31 32 [StorableConstructor] 32 33 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 36 37 public override IDeepCloneable Clone(Cloner cloner) { 37 38 return new PRVSinglePointCrossover(this, cloner); 38 39 } 39 public PRVSinglePointCrossover() : base() { }40 40 41 41 public static PRVEncoding Apply(IRandom random, PRVEncoding parent1, PRVEncoding parent2) { -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Manipulators/PRVManipulator.cs
r8603 r8887 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 27 28 [Item("PRVManipulator", "An operator which manipulates a PRV representation.")] 28 29 [StorableClass] 29 public abstract class PRVManipulator : ScheduleManipulator <PRVEncoding>, IPRVOperator {30 public abstract class PRVManipulator : ScheduleManipulator, IPRVOperator { 30 31 [StorableConstructor] 31 32 protected PRVManipulator(bool deserializing) : base(deserializing) { } … … 36 37 } 37 38 39 protected abstract void Manipulate(IRandom random, PRVEncoding individual); 38 40 39 protected abstract void Manipulate(IRandom random, PRVEncoding individual);40 41 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."); 42 44 Manipulate(RandomParameter.ActualValue, solution); 43 45 return base.Apply(); -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Manipulators/PRVUniformOnePositionManipulator.cs
r8882 r8887 27 27 28 28 namespace HeuristicLab.Encodings.ScheduleEncoding.PriorityRulesVector { 29 30 29 [Item("PRVUniformOnePositionManipulator", "Represents a manipulation operation inserting parts of the individual at another position.")] 31 30 [StorableClass] 32 31 public class PRVUniformOnePositionManipulator : PRVManipulator { 32 33 33 [StorableConstructor] 34 34 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 38 38 public override IDeepCloneable Clone(Cloner cloner) { 39 39 return new PRVUniformOnePositionManipulator(this, cloner); 40 40 } 41 public PRVUniformOnePositionManipulator() : base() { }42 43 41 44 42 public static void Apply(IRandom random, PRVEncoding individual) { -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVEncoding.cs
r8603 r8887 42 42 } 43 43 44 45 44 [StorableConstructor] 46 45 protected PRVEncoding(bool deserializing) : base(deserializing) { } … … 49 48 this.nrOfRules = cloner.Clone(original.NrOfRules); 50 49 this.PriorityRulesVector = cloner.Clone(original.PriorityRulesVector); 51 }52 public override IDeepCloneable Clone(Cloner cloner) {53 return new PRVEncoding(this, cloner);54 50 } 55 51 public PRVEncoding(int nrOfRules) … … 69 65 } 70 66 67 public override IDeepCloneable Clone(Cloner cloner) { 68 return new PRVEncoding(this, cloner); 69 } 71 70 72 71 public override string ToString() { -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVRandomCreator.cs
r8603 r8887 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 29 30 29 namespace HeuristicLab.Encodings.ScheduleEncoding.PriorityRulesVector { 31 30 [Item("PriorityRulesRandomCreator", "Creator class used to create PRV encoding objects for scheduling problems.")] 32 31 [StorableClass] 33 public class PRVRandomCreator : ScheduleCreator<PRVEncoding>, IStochasticOperator { 32 public class PRVRandomCreator : ScheduleCreator, IStochasticOperator { 33 34 34 [Storable] 35 35 public IntValue NrOfRules { get; set; } … … 45 45 } 46 46 47 48 47 [StorableConstructor] 49 48 protected PRVRandomCreator(bool deserializing) : base(deserializing) { } … … 51 50 : base(original, cloner) { 52 51 this.NrOfRules = cloner.Clone(original.NrOfRules); 53 }54 public override IDeepCloneable Clone(Cloner cloner) {55 return new PRVRandomCreator(this, cloner);56 52 } 57 53 public PRVRandomCreator() … … 64 60 } 65 61 62 public override IDeepCloneable Clone(Cloner cloner) { 63 return new PRVRandomCreator(this, cloner); 64 } 65 66 66 public static PRVEncoding Apply(int jobs, int resources, IRandom random, IntValue nrOfRules) { 67 67 return new PRVEncoding(jobs * resources, random, 0, nrOfRules.Value, nrOfRules); 68 68 } 69 69 70 protected override PRVEncoding CreateSolution() {70 protected override IScheduleEncoding CreateSolution() { 71 71 return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue, NrOfRules); 72 72 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/Properties/AssemblyInfo.cs.frame
r8759 r8887 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-20 08Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 55 55 // [assembly: AssemblyVersion("1.0.*")] 56 56 [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 29 29 [Item("ScheduleCreator", "Represents the generalized form of creators for Scheduling Problems.")] 30 30 [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"]; } 34 35 } 35 36 36 37 37 [StorableConstructor] 38 38 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) { } 42 40 public ScheduleCreator() 43 41 : base() { 44 Parameters.Add(new LookupParameter< T>("ScheduleEncoding", "The new scheduling solutioncandidate."));42 Parameters.Add(new LookupParameter<IScheduleEncoding>("ScheduleEncoding", "The new scheduling solutioncandidate.")); 45 43 } 46 47 44 48 45 public override IOperation Apply() { … … 50 47 return base.Apply(); 51 48 } 52 protected abstract T CreateSolution(); 49 50 protected abstract IScheduleEncoding CreateSolution(); 53 51 } 54 52 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleCrossover.cs
r8603 r8887 30 30 [Item("ScheduleCrossover", "A scheduling crossover operation.")] 31 31 [StorableClass] 32 public abstract class ScheduleCrossover <T> : SingleSuccessorOperator, IScheduleCrossover, IStochasticOperator where T : Item{33 #region IScheduleCrossover Members 34 public ILookupParameter<I temArray<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"]; } 36 36 } 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"]; } 40 39 } 41 #endregion42 43 40 public ILookupParameter<IRandom> RandomParameter { 44 41 get { return (LookupParameter<IRandom>)Parameters["Random"]; } … … 47 44 [StorableConstructor] 48 45 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) { } 52 47 public ScheduleCrossover() 53 48 : base() { 54 49 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.")); 56 53 ParentsParameter.ActualName = "SchedulingSolution"; 57 Parameters.Add(new LookupParameter<T>("Child", "The child solution resulting from the crossover."));58 ChildParameter.ActualName = "SchedulingSolution";59 54 } 60 55 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers/DirectScheduleCrossover.cs
r8603 r8887 28 28 [Item("DirectScheduleCrossover", "An operator which crosses two schedule representations.")] 29 29 [StorableClass] 30 public abstract class DirectScheduleCrossover : ScheduleCrossover <Schedule>, IDirectScheduleOperator {30 public abstract class DirectScheduleCrossover : ScheduleCrossover, IDirectScheduleOperator { 31 31 [StorableConstructor] 32 32 protected DirectScheduleCrossover(bool deserializing) : base(deserializing) { } … … 39 39 } 40 40 41 42 41 public ILookupParameter<ItemList<Job>> JobDataParameter { 43 42 get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; } … … 47 46 48 47 public override IOperation Apply() { 49 ItemArray<Schedule>parents = ParentsParameter.ActualValue;48 var parents = ParentsParameter.ActualValue; 50 49 ChildParameter.ActualValue = 51 50 Cross(RandomParameter.ActualValue, parents[0] as Schedule, parents[1] as Schedule); -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers/DirectScheduleGTCrossover.cs
r8603 r8887 30 30 [StorableClass] 31 31 public class DirectScheduleGTCrossover : DirectScheduleCrossover { 32 33 public IValueLookupParameter<DoubleValue> MutationProbabilityParameter { 34 get { return (IValueLookupParameter<DoubleValue>)Parameters["MutationProbability"]; } 35 } 36 32 37 [StorableConstructor] 33 38 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.")); 36 43 } 44 37 45 public override IDeepCloneable Clone(Cloner cloner) { 38 46 return new DirectScheduleGTCrossover(this, cloner); 39 47 } 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 50 48 51 49 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); 54 51 55 52 //Reset scheduled tasks in result … … 75 72 int progressOnResource = conflictedResource.Tasks.Count; 76 73 Task selectedTask = null; 77 if (random.Next (100) < mutProp) {74 if (random.NextDouble() < mutProp) { 78 75 //Mutation 79 76 selectedTask = conflictSet[random.Next(conflictSet.Count)]; … … 95 92 } 96 93 97 98 94 private static Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, Schedule usedParent, int conflictedResourceNr, int progressOnResource) { 99 95 //Apply Crossover … … 109 105 110 106 public override Schedule Cross(IRandom random, Schedule parent1, Schedule parent2) { 111 ItemList<Job>jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();112 PercentValuemutProp = MutationProbabilityParameter.ActualValue;107 var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone(); 108 var mutProp = MutationProbabilityParameter.ActualValue; 113 109 return Apply(random, parent1, parent2, jobData, mutProp.Value); 114 110 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleRandomCreator.cs
r8603 r8887 33 33 [Item("DirectScheduleRandomCreator", "Creator class used to create schedule encoding objects.")] 34 34 [StorableClass] 35 public class DirectScheduleRandomCreator : ScheduleCreator <Schedule>, IStochasticOperator {35 public class DirectScheduleRandomCreator : ScheduleCreator, IStochasticOperator { 36 36 37 37 public ILookupParameter<IRandom> RandomParameter { … … 68 68 69 69 public static Schedule Apply(int jobs, int resources, PWREncoding pwr, ItemList<Job> jobData) { 70 ScheduleresultingSchedule = new Schedule(jobData[0].Tasks.Count);70 var resultingSchedule = new Schedule(jobData[0].Tasks.Count); 71 71 foreach (int jobNr in pwr.PermutationWithRepetition) { 72 72 int i = 0; … … 82 82 83 83 84 protected override ScheduleCreateSolution() {84 protected override IScheduleEncoding CreateSolution() { 85 85 try { 86 ItemList<Job>jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone();86 var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone(); 87 87 return Apply(JobsParameter.ActualValue.Value, 88 88 ResourcesParameter.ActualValue.Value, 89 89 new PWREncoding(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue), 90 90 jobData); 91 } 92 catch { 91 } catch { 93 92 throw new Exception("ScheduleRandomCreator needs JobData parameter from a JSSP-Instance to create Schedule-Instances!"); 94 93 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Job.cs
r8886 r8887 30 30 [StorableClass] 31 31 public class Job : Item, INotifyPropertyChanged { 32 [Storable(Name = "DueDate")] private double dueDate; 32 33 [Storable(Name = "DueDate")] 34 private double dueDate; 33 35 public double DueDate { 34 36 get { return dueDate; } … … 52 54 53 55 [Storable(Name = "Tasks")] 54 private ItemList<Task> tasks; 56 private ItemList<Task> tasks; 55 57 public ItemList<Task> Tasks { 56 58 get { return tasks; } … … 70 72 this.Tasks = cloner.Clone(original.Tasks); 71 73 } 72 public override IDeepCloneable Clone(Cloner cloner) { 73 return new Job(this, cloner); 74 } 74 public Job() : this(-1, double.MaxValue) { } 75 75 public Job(int index, double dueDate) 76 76 : base() { … … 78 78 Index = index; 79 79 Tasks = new ItemList<Task>(); 80 } 81 82 public override IDeepCloneable Clone(Cloner cloner) { 83 return new Job(this, cloner); 80 84 } 81 85 -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Manipulators/DirectScheduleManipulator.cs
r8603 r8887 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 27 28 [Item("DirectScheduleManipulator", "An operator which manipulates a direct schedule representation.")] 28 29 [StorableClass] 29 public abstract class DirectScheduleManipulator : ScheduleManipulator<Schedule>, IDirectScheduleOperator { 30 public abstract class DirectScheduleManipulator : ScheduleManipulator, IDirectScheduleOperator { 31 30 32 [StorableConstructor] 31 33 protected DirectScheduleManipulator(bool deserializing) : base(deserializing) { } … … 36 38 } 37 39 40 protected abstract void Manipulate(IRandom random, Schedule individual); 38 41 39 protected abstract void Manipulate(IRandom random, Schedule individual);40 42 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); 43 46 return base.Apply(); 44 47 } -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Resource.cs
r8603 r8887 29 29 [StorableClass] 30 30 public class Resource : Item { 31 public Resource(int index) 32 : base() { 33 Index = index; 34 Tasks = new ItemList<ScheduledTask>(); 35 } 31 36 32 [Storable] 37 33 public int Index { … … 44 40 set; 45 41 } 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 46 60 public double TotalDuration { 47 61 get { … … 53 67 return result; 54 68 } 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);66 69 } 67 70 … … 83 86 return false; 84 87 } 88 85 89 public override int GetHashCode() { 86 90 if (Tasks.Count == 1) … … 90 94 return 0; 91 95 } 96 92 97 private static bool AreEqual(Resource res1, Resource res2) { 93 98 if (res1.Tasks.Count != res2.Tasks.Count) -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Schedule.cs
r8603 r8887 32 32 [StorableClass] 33 33 public class Schedule : NamedItem, IScheduleEncoding { 34 34 35 #region Properties 35 36 [Storable] … … 69 70 this.lastScheduledTaskOfJob = new Dictionary<int, ScheduledTask>(original.lastScheduledTaskOfJob); 70 71 } 71 public override IDeepCloneable Clone(Cloner cloner) {72 return new Schedule(this, cloner);73 }74 72 public Schedule(int nrOfResources) { 75 73 Resources = new ItemList<Resource>(); … … 80 78 } 81 79 82 80 public override IDeepCloneable Clone(Cloner cloner) { 81 return new Schedule(this, cloner); 82 } 83 83 84 84 #region Events -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/ScheduledTask.cs
r8603 r8887 29 29 [StorableClass] 30 30 public class ScheduledTask : Item { 31 31 32 #region Properties 32 33 [Storable] … … 57 58 this.JobNr = original.JobNr; 58 59 } 59 public override IDeepCloneable Clone(Cloner cloner) {60 return new ScheduledTask(this, cloner);61 }62 63 60 public ScheduledTask(int resNr, double startTime, double duration, int jobNr) 64 61 : base() { … … 69 66 } 70 67 68 public override IDeepCloneable Clone(Cloner cloner) { 69 return new ScheduledTask(this, cloner); 70 } 71 71 72 public override string ToString() { 72 73 StringBuilder sb = new StringBuilder(); … … 74 75 return sb.ToString(); 75 76 } 76 77 77 78 78 public override bool Equals(object obj) { -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Task.cs
r8886 r8887 30 30 [StorableClass] 31 31 public class Task : Item, INotifyPropertyChanged { 32 32 33 [Storable(Name = "TaskNr")] 33 34 private int taskNr; … … 94 95 this.IsScheduled = original.IsScheduled; 95 96 } 96 public override IDeepCloneable Clone(Cloner cloner) { 97 return new Task(this, cloner); 98 } 99 100 97 public Task() : this(-1, -1, -1, 0) { } 101 98 public Task(int taskNr, int resNr, int jobNr, double duration) 102 99 : base() { … … 106 103 TaskNr = taskNr; 107 104 IsScheduled = false; 105 } 106 107 public override IDeepCloneable Clone(Cloner cloner) { 108 return new Task(this, cloner); 108 109 } 109 110 … … 120 121 return false; 121 122 } 123 122 124 public override int GetHashCode() { 123 125 return TaskNr ^ JobNr; 124 126 } 127 125 128 public static bool AreEqual(Task task1, Task task2) { 126 129 return (task1.Duration == task2.Duration && -
trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleManipulator.cs
r8603 r8887 30 30 [Item("ScheduleManipulator", "A scheduling manipulation operation.")] 31 31 [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 { 34 33 35 public ILookupParameter< T> ScheduleEncodingParameter {36 get { return (ILookupParameter< T>)Parameters["ScheduleEncoding"]; }34 public ILookupParameter<IScheduleEncoding> ScheduleEncodingParameter { 35 get { return (ILookupParameter<IScheduleEncoding>)Parameters["ScheduleEncoding"]; } 37 36 } 38 39 #endregion40 37 41 38 public ILookupParameter<IRandom> RandomParameter { … … 45 42 [StorableConstructor] 46 43 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) { } 50 45 public ScheduleManipulator() 51 46 : 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.")); 53 48 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 54 49 }
Note: See TracChangeset
for help on using the changeset viewer.