- Timestamp:
- 02/28/20 16:23:01 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 7 added
- 9 deleted
- 50 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab 3.3.sln
r17260 r17461 458 458 EndProject 459 459 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.PTSP.Views-3.3", "HeuristicLab.Problems.PTSP.Views\3.3\HeuristicLab.Problems.PTSP.Views-3.3.csproj", "{90B6CA12-9791-4430-B2D7-CD3ED7F75E2B}" 460 EndProject 461 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.Scheduling-3.3", "HeuristicLab.Problems.Scheduling\3.3\HeuristicLab.Problems.Scheduling-3.3.csproj", "{2BF1D639-1A74-44ED-AAAD-41ECD395AD93}" 462 EndProject 463 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.Scheduling.Views-3.3", "HeuristicLab.Problems.Scheduling.Views\3.3\HeuristicLab.Problems.Scheduling.Views-3.3.csproj", "{78763A4E-E163-48C2-98EB-709760D06F25}" 460 464 EndProject 461 465 Global … … 2229 2233 {90B6CA12-9791-4430-B2D7-CD3ED7F75E2B}.Release|x86.ActiveCfg = Release|x86 2230 2234 {90B6CA12-9791-4430-B2D7-CD3ED7F75E2B}.Release|x86.Build.0 = Release|x86 2235 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 2236 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|Any CPU.Build.0 = Debug|Any CPU 2237 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|x64.ActiveCfg = Debug|x64 2238 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|x64.Build.0 = Debug|x64 2239 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|x86.ActiveCfg = Debug|x86 2240 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Debug|x86.Build.0 = Debug|x86 2241 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|Any CPU.ActiveCfg = Release|Any CPU 2242 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|Any CPU.Build.0 = Release|Any CPU 2243 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|x64.ActiveCfg = Release|x64 2244 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|x64.Build.0 = Release|x64 2245 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|x86.ActiveCfg = Release|x86 2246 {2BF1D639-1A74-44ED-AAAD-41ECD395AD93}.Release|x86.Build.0 = Release|x86 2247 {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 2248 {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|Any CPU.Build.0 = Debug|Any CPU 2249 {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|x64.ActiveCfg = Debug|x64 2250 {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|x64.Build.0 = Debug|x64 2251 {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|x86.ActiveCfg = Debug|x86 2252 {78763A4E-E163-48C2-98EB-709760D06F25}.Debug|x86.Build.0 = Debug|x86 2253 {78763A4E-E163-48C2-98EB-709760D06F25}.Release|Any CPU.ActiveCfg = Release|Any CPU 2254 {78763A4E-E163-48C2-98EB-709760D06F25}.Release|Any CPU.Build.0 = Release|Any CPU 2255 {78763A4E-E163-48C2-98EB-709760D06F25}.Release|x64.ActiveCfg = Release|x64 2256 {78763A4E-E163-48C2-98EB-709760D06F25}.Release|x64.Build.0 = Release|x64 2257 {78763A4E-E163-48C2-98EB-709760D06F25}.Release|x86.ActiveCfg = Release|x86 2258 {78763A4E-E163-48C2-98EB-709760D06F25}.Release|x86.Build.0 = Release|x86 2231 2259 EndGlobalSection 2232 2260 GlobalSection(SolutionProperties) = preSolution -
branches/2521_ProblemRefactoring/HeuristicLab.Collections/3.3/IObservableCollection.cs
r17226 r17461 26 26 namespace HeuristicLab.Collections { 27 27 [StorableType("289d81e9-a167-416c-aaa8-c40aa1ea96f9")] 28 public interface IObservableCollection<T> : ICollection<T>, INotifyObservableCollectionItemsChanged<T>, INotifyPropertyChanged { } 28 public interface IObservableCollection<T> : ICollection<T>, INotifyObservableCollectionItemsChanged<T>, INotifyPropertyChanged { 29 } 29 30 } -
branches/2521_ProblemRefactoring/HeuristicLab.Collections/3.3/ObservableCollection.cs
r17226 r17461 20 20 #endregion 21 21 22 using HEAL.Attic;23 22 using System; 24 23 using System.Collections; … … 26 25 using System.ComponentModel; 27 26 using System.Linq; 27 using HEAL.Attic; 28 28 29 29 namespace HeuristicLab.Collections { … … 97 97 public void AddRange(IEnumerable<T> collection) { 98 98 int capacity = list.Capacity; 99 ICollection<T>items = collection as ICollection<T> ?? collection.ToList();99 var items = collection as ICollection<T> ?? collection.ToList(); 100 100 list.AddRange(items); 101 101 if (items.Count > 0) { 102 OnItemsAdded(items); 102 103 if (list.Capacity != capacity) 103 104 OnPropertyChanged("Capacity"); 104 OnPropertyChanged(" Count");105 On ItemsAdded(items);105 OnPropertyChanged("Item[]"); 106 OnPropertyChanged("Count"); 106 107 } 107 108 } -
branches/2521_ProblemRefactoring/HeuristicLab.Core/3.3/Interfaces/IConstrainedValueParameter.cs
r17226 r17461 1 using System.Collections.Generic; 1 2 using HEAL.Attic; 2 3 #region License Information … … 26 27 public interface IConstrainedValueParameter<T> : IValueParameter<T> where T : class, IItem { 27 28 IItemSet<T> ValidValues { get; } 29 30 void Populate(IEnumerable<IItem> items); 28 31 } 29 32 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/HeuristicLab.Encodings.ScheduleEncoding-3.3.csproj
r16723 r17461 128 128 <Compile Include="Interfaces\IScheduleCreator.cs" /> 129 129 <Compile Include="Interfaces\IScheduleCrossover.cs" /> 130 <Compile Include="Interfaces\ISchedule .cs" />130 <Compile Include="Interfaces\IScheduleSolution.cs" /> 131 131 <Compile Include="Interfaces\IScheduleDecoder.cs" /> 132 132 <Compile Include="Interfaces\IScheduleEncoding.cs" /> … … 138 138 <Compile Include="JobSequenceMatrix\Crossovers\JSMSXXCrossover.cs" /> 139 139 <Compile Include="JobSequenceMatrix\JobSequenceMatrixEncoding.cs" /> 140 <Compile Include="JobSequenceMatrix\JSM Encoding.cs" />140 <Compile Include="JobSequenceMatrix\JSM.cs" /> 141 141 <Compile Include="JobSequenceMatrix\JSMRandomCreator.cs" /> 142 142 <Compile Include="JobSequenceMatrix\Manipulators\JSMManipulator.cs" /> … … 149 149 <Compile Include="PermutationWithRepetition\Manipulators\PWRInsertionManipulator.cs" /> 150 150 <Compile Include="PermutationWithRepetition\PermutationWithRepetitionEncoding.cs" /> 151 <Compile Include="PermutationWithRepetition\PWR Encoding.cs" />151 <Compile Include="PermutationWithRepetition\PWR.cs" /> 152 152 <Compile Include="PermutationWithRepetition\PWRRandomCreator.cs" /> 153 153 <Compile Include="Plugin.cs" /> … … 158 158 <Compile Include="PriorityRulesVector\Manipulators\PRVUniformOnePositionManipulator.cs" /> 159 159 <Compile Include="PriorityRulesVector\PriorityRulesVectorEncoding.cs" /> 160 <Compile Include="PriorityRulesVector\PRV Encoding.cs" />160 <Compile Include="PriorityRulesVector\PRV.cs" /> 161 161 <Compile Include="PriorityRulesVector\PRVRandomCreator.cs" /> 162 162 <Compile Include="Properties\AssemblyInfo.cs" /> -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleCreator.cs
r17226 r17461 28 28 [StorableType("d6738639-c5fc-46af-8997-7527ea718759")] 29 29 public interface IScheduleCreator<TSchedule> : ISolutionCreator<TSchedule>, IScheduleOperator 30 where TSchedule : class, ISchedule{30 where TSchedule : class, IScheduleSolution { 31 31 ILookupParameter<TSchedule> ScheduleParameter { get; } 32 32 IValueLookupParameter<IntValue> JobsParameter { get; } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleCrossover.cs
r17226 r17461 27 27 [StorableType("809a6136-3a7a-4389-9119-2bb48f6d650a")] 28 28 public interface IScheduleCrossover : ICrossover, IScheduleOperator { 29 ILookupParameter<ISchedule > ChildParameter { get; }30 IScopeTreeLookupParameter<ISchedule > ParentsParameter { get; }29 ILookupParameter<IScheduleSolution> ChildParameter { get; } 30 IScopeTreeLookupParameter<IScheduleSolution> ParentsParameter { get; } 31 31 } 32 32 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleDecoder.cs
r16723 r17461 26 26 [StorableType("010C752F-0F5E-4B93-8695-8DD74903DBE7")] 27 27 public interface IScheduleDecoder : IScheduleOperator { 28 ILookupParameter<ISchedule > ScheduleEncodingParameter { get; }28 ILookupParameter<IScheduleSolution> ScheduleEncodingParameter { get; } 29 29 ILookupParameter<Schedule> ScheduleParameter { get; } 30 30 ILookupParameter<ItemList<Job>> JobDataParameter { get; } 31 31 32 Schedule DecodeSchedule(ISchedule solution, ItemList<Job> jobData);32 Schedule DecodeSchedule(IScheduleSolution solution, ItemList<Job> jobData); 33 33 } 34 34 35 35 public interface IScheduleDecoder<TSchedule> : IScheduleDecoder 36 where TSchedule : class, ISchedule {36 where TSchedule : class, IScheduleSolution { 37 37 Schedule DecodeSchedule(TSchedule solution, ItemList<Job> jobData); 38 38 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleEncoding.cs
r17226 r17461 22 22 #endregion 23 23 24 using HEAL.Attic; 24 25 using HeuristicLab.Core; 25 26 using HeuristicLab.Data; 26 27 using HeuristicLab.Optimization; 27 using HEAL.Attic;28 28 29 29 namespace HeuristicLab.Encodings.ScheduleEncoding { 30 30 [StorableType("09b9d24c-2576-495a-b06c-338d095cba0d")] 31 public interface IScheduleEncoding : IEncoding<ISchedule > {32 I FixedValueParameter<ItemList<Job>> JobDataParameter { get; set; }31 public interface IScheduleEncoding : IEncoding<IScheduleSolution> { 32 IValueParameter<ItemList<Job>> JobDataParameter { get; set; } 33 33 IFixedValueParameter<IntValue> JobsParameter { get; set; } 34 34 IFixedValueParameter<IntValue> ResourcesParameter { get; set; } … … 39 39 40 40 41 Schedule Decode(ISchedule schedule, ItemList<Job> jobData);41 Schedule Decode(IScheduleSolution schedule, ItemList<Job> jobData); 42 42 } 43 43 44 44 public interface IScheduleEncoding<TSchedule> : IEncoding<TSchedule> 45 where TSchedule : class, ISchedule {45 where TSchedule : class, IScheduleSolution { 46 46 47 47 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleManipulator.cs
r17226 r17461 27 27 [StorableType("aa89fd6f-db49-457d-abc9-5600aa8f24e5")] 28 28 public interface IScheduleManipulator : IManipulator, IScheduleOperator { 29 ILookupParameter<ISchedule > ScheduleParameter { get; }29 ILookupParameter<IScheduleSolution> ScheduleParameter { get; } 30 30 } 31 31 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMCrossover.cs
r17226 r17461 35 35 public JSMCrossover() : base() { } 36 36 37 public abstract JSM Encoding Cross(IRandom random, JSMEncoding parent1, JSMEncodingparent2);37 public abstract JSM Cross(IRandom random, JSM parent1, JSM parent2); 38 38 39 39 public override IOperation InstrumentedApply() { … … 41 41 42 42 ChildParameter.ActualValue = 43 Cross(RandomParameter.ActualValue, parents[0] as JSM Encoding, parents[1] as JSMEncoding);43 Cross(RandomParameter.ActualValue, parents[0] as JSM, parents[1] as JSM); 44 44 45 45 return base.InstrumentedApply(); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMJOXCrossover.cs
r17226 r17461 40 40 } 41 41 42 public static JSM Encoding Apply(IRandom random, JSMEncoding p1, JSMEncodingp2) {43 var result = new JSM Encoding(random.Next());42 public static JSM Apply(IRandom random, JSM p1, JSM p2) { 43 var result = new JSM(random.Next()); 44 44 45 45 int nrOfResources = p1.JobSequenceMatrix.Count; … … 53 53 54 54 bool dominantParent = random.Next(2) == 1; 55 JSM Encodingparent1 = dominantParent ? p1 : p2;56 JSM Encodingparent2 = dominantParent ? p2 : p1;55 JSM parent1 = dominantParent ? p1 : p2; 56 JSM parent2 = dominantParent ? p2 : p1; 57 57 58 58 //Fill childmatrix with values … … 75 75 } 76 76 77 public override JSM Encoding Cross(IRandom random, JSMEncoding parent1, JSMEncodingparent2) {77 public override JSM Cross(IRandom random, JSM parent1, JSM parent2) { 78 78 return Apply(random, parent1, parent2); 79 79 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMOXCrossover.cs
r17226 r17461 38 38 } 39 39 40 public static JSM Encoding Apply(IRandom random, JSMEncoding parent1, JSMEncodingparent2) {41 var result = new JSM Encoding(random.Next());40 public static JSM Apply(IRandom random, JSM parent1, JSM parent2) { 41 var result = new JSM(random.Next()); 42 42 43 43 for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) { … … 50 50 } 51 51 52 public override JSM Encoding Cross(IRandom random, JSMEncoding parent1, JSMEncodingparent2) {52 public override JSM Cross(IRandom random, JSM parent1, JSM parent2) { 53 53 return Apply(random, parent1, parent2); 54 54 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Crossovers/JSMSXXCrossover.cs
r17226 r17461 39 39 } 40 40 41 public static JSM Encoding Apply(IRandom random, JSMEncoding parent1, JSMEncodingparent2) {42 var result = new JSM Encoding(random.Next());41 public static JSM Apply(IRandom random, JSM parent1, JSM parent2) { 42 var result = new JSM(random.Next()); 43 43 int subSequenceLength = random.Next(parent1.JobSequenceMatrix[0].Length); 44 44 for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) { … … 91 91 } 92 92 93 public override JSM Encoding Cross(IRandom random, JSMEncoding parent1, JSMEncodingparent2) {93 public override JSM Cross(IRandom random, JSM parent1, JSM parent2) { 94 94 return Apply(random, parent1, parent2); 95 95 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Decoder/JSMDecoder.cs
r16725 r17461 34 34 [Item("JobSequenceMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequence Matrix.")] 35 35 [StorableType("BBE354C2-7599-43CC-ACDC-F8F0F65BE3F5")] 36 public class JSMDecoder : ScheduleDecoder<JSM Encoding>{36 public class JSMDecoder : ScheduleDecoder<JSM>, IJSMOperator { 37 37 38 38 public IFixedValueParameter<EnumValue<JSMDecodingErrorPolicy>> DecodingErrorPolicyParameter { … … 64 64 } 65 65 66 private static Task SelectTaskFromConflictSet(JSM Encodingsolution, JSMDecodingErrorPolicy decodingErrorPolicy, JSMForcingStrategy forcingStrategy, int conflictedResourceNr, int progressOnConflictedResource, ItemList<Task> conflictSet, IRandom random) {66 private static Task SelectTaskFromConflictSet(JSM solution, JSMDecodingErrorPolicy decodingErrorPolicy, JSMForcingStrategy forcingStrategy, int conflictedResourceNr, int progressOnConflictedResource, ItemList<Task> conflictSet, IRandom random) { 67 67 if (conflictSet.Count == 1) 68 68 return conflictSet[0]; … … 108 108 } 109 109 110 private static void ApplyForcingStrategy(JSMForcingStrategy forcingStrategy, JSM Encodingsolution, int conflictedResource, int newResolutionIndex, int progressOnResource, int newResolution) {110 private static void ApplyForcingStrategy(JSMForcingStrategy forcingStrategy, JSM solution, int conflictedResource, int newResolutionIndex, int progressOnResource, int newResolution) { 111 111 var jsm = solution.JobSequenceMatrix; 112 112 if (forcingStrategy == JSMForcingStrategy.SwapForcing) { … … 130 130 } 131 131 132 public override Schedule DecodeSchedule(JSM Encodingencoding, ItemList<Job> jobData) {132 public override Schedule DecodeSchedule(JSM encoding, ItemList<Job> jobData) { 133 133 return Decode(encoding, jobData, DecodingErrorPolicy, ForcingStrategy); 134 134 } 135 135 136 public static Schedule Decode(JSM Encodingsolution, ItemList<Job> jobData, JSMDecodingErrorPolicy decodingErrorPolicy, JSMForcingStrategy forcingStrategy) {136 public static Schedule Decode(JSM solution, ItemList<Job> jobData, JSMDecodingErrorPolicy decodingErrorPolicy, JSMForcingStrategy forcingStrategy) { 137 137 var random = new FastRandom(solution.RandomSeed); 138 138 var jobs = (ItemList<Job>)jobData.Clone(); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMRandomCreator.cs
r17226 r17461 30 30 [Item("JobSequenceMatrixCreator", "Creator class used to create Job Sequence Matrix solutions for standard JobShop scheduling problems.")] 31 31 [StorableType("F8053C69-31C2-4E05-8FA0-5AED15FAF804")] 32 public class JSMRandomCreator : ScheduleCreator<JSM Encoding>, IStochasticOperator {32 public class JSMRandomCreator : ScheduleCreator<JSM>, IStochasticOperator { 33 33 34 34 public ILookupParameter<IRandom> RandomParameter { … … 48 48 } 49 49 50 public static JSM EncodingApply(int jobs, int resources, IRandom random) {51 var solution = new JSM Encoding(random.Next());50 public static JSM Apply(int jobs, int resources, IRandom random) { 51 var solution = new JSM(random.Next()); 52 52 for (int i = 0; i < resources; i++) { 53 53 solution.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, jobs, random)); … … 56 56 } 57 57 58 protected override JSM EncodingCreateSolution() {58 protected override JSM CreateSolution() { 59 59 return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue); 60 60 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JobSequenceMatrixEncoding.cs
r16725 r17461 31 31 32 32 namespace HeuristicLab.Encodings.ScheduleEncoding { 33 [Item("Job Sequence Matrix Encoding", "Represents an encoding of schedules in form of a job sequence per resource.")] 33 34 [StorableType("9C090369-0214-42E6-8C3E-369751F5A9E1")] 34 public sealed class JobSequenceMatrixEncoding : ScheduleEncoding<JSM Encoding> {35 public sealed class JobSequenceMatrixEncoding : ScheduleEncoding<JSM> { 35 36 [StorableConstructor] 36 37 private JobSequenceMatrixEncoding(StorableConstructorFlag _) : base(_) { } … … 41 42 42 43 public JobSequenceMatrixEncoding() 43 : base( ) {44 : base("JSM") { 44 45 SolutionCreator = new JSMRandomCreator(); 45 46 Decoder = new JSMDecoder(); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMManipulator.cs
r17226 r17461 34 34 public JSMManipulator() : base() { } 35 35 36 protected abstract void Manipulate(IRandom random, ISchedule individual);36 protected abstract void Manipulate(IRandom random, IScheduleSolution individual); 37 37 38 38 public override IOperation InstrumentedApply() { 39 var solution = ScheduleParameter.ActualValue as JSM Encoding;39 var solution = ScheduleParameter.ActualValue as JSM; 40 40 if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type JSMEncoding."); 41 41 Manipulate(RandomParameter.ActualValue, solution); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMShiftChangeManipulator.cs
r17226 r17461 42 42 } 43 43 44 public static void Apply(IRandom random, JSM Encodingindividual) {44 public static void Apply(IRandom random, JSM individual) { 45 45 int nrOfJobs = individual.JobSequenceMatrix[0].Length; 46 46 int jobIndex = random.Next(nrOfJobs); … … 63 63 } 64 64 65 protected override void Manipulate(IRandom random, ISchedule encoding) {66 var solution = encoding as JSM Encoding;65 protected override void Manipulate(IRandom random, IScheduleSolution encoding) { 66 var solution = encoding as JSM; 67 67 if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding"); 68 68 Apply(random, solution); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Manipulators/JSMSwapManipulator.cs
r17226 r17461 40 40 } 41 41 42 public static void Apply(IRandom random, JSM Encodingindividual) {42 public static void Apply(IRandom random, JSM individual) { 43 43 int resourceIndex = random.Next(individual.JobSequenceMatrix.Count); 44 44 Permutation p = individual.JobSequenceMatrix[resourceIndex]; … … 50 50 } 51 51 52 protected override void Manipulate(IRandom random, ISchedule individual) {53 var solution = individual as JSM Encoding;52 protected override void Manipulate(IRandom random, IScheduleSolution individual) { 53 var solution = individual as JSM; 54 54 if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding"); 55 55 Apply(random, solution); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRCrossover.cs
r17226 r17461 38 38 } 39 39 40 public abstract PWR Encoding Cross(IRandom random, PWREncoding parent1, PWREncodingparent2);40 public abstract PWR Cross(IRandom random, PWR parent1, PWR parent2); 41 41 42 42 public override IOperation InstrumentedApply() { … … 44 44 45 45 ChildParameter.ActualValue = 46 Cross(RandomParameter.ActualValue, parents[0] as PWR Encoding, parents[1] as PWREncoding);46 Cross(RandomParameter.ActualValue, parents[0] as PWR, parents[1] as PWR); 47 47 48 48 return base.InstrumentedApply(); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRGOXCrossover.cs
r17226 r17461 55 55 } 56 56 57 public static PWR Encoding Apply(IRandom random, PWREncoding parent1, PWREncodingparent2) {58 var result = new PWR Encoding();57 public static PWR Apply(IRandom random, PWR parent1, PWR parent2) { 58 var result = new PWR(); 59 59 60 60 var p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList(); … … 87 87 } 88 88 89 public override PWR Encoding Cross(IRandom random, PWREncoding parent1, PWREncodingparent2) {89 public override PWR Cross(IRandom random, PWR parent1, PWR parent2) { 90 90 return Apply(random, parent1, parent2); 91 91 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Crossovers/PWRPPXCrossover.cs
r17226 r17461 41 41 } 42 42 43 public static PWR Encoding Apply(IRandom random, PWREncoding parent1, PWREncodingparent2) {44 var result = new PWR Encoding();43 public static PWR Apply(IRandom random, PWR parent1, PWR parent2) { 44 var result = new PWR(); 45 45 var p1 = ((IntegerVector)(parent1.PermutationWithRepetition.Clone())).ToList(); 46 46 var p2 = ((IntegerVector)(parent2.PermutationWithRepetition.Clone())).ToList(); … … 69 69 } 70 70 71 public override PWR Encoding Cross(IRandom random, PWREncoding parent1, PWREncodingparent2) {71 public override PWR Cross(IRandom random, PWR parent1, PWR parent2) { 72 72 return Apply(random, parent1, parent2); 73 73 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Decoder/PWRDecoder.cs
r16725 r17461 27 27 [Item("PWRDecoder", "An item used to convert a PWR-individual into a generalized schedule.")] 28 28 [StorableType("60D171BE-9704-40E1-9C63-0E56D95403CD")] 29 public class PWRDecoder : ScheduleDecoder<PWR Encoding>{29 public class PWRDecoder : ScheduleDecoder<PWR>, IPWROperator { 30 30 [StorableConstructor] 31 31 protected PWRDecoder(StorableConstructorFlag _) : base(_) { } … … 37 37 } 38 38 39 public override Schedule DecodeSchedule(PWR Encodingsolution, ItemList<Job> jobData) {39 public override Schedule DecodeSchedule(PWR solution, ItemList<Job> jobData) { 40 40 return Decode(solution, jobData); 41 41 } 42 42 43 public static Schedule Decode(PWR Encodingsolution, ItemList<Job> jobData) {43 public static Schedule Decode(PWR solution, ItemList<Job> jobData) { 44 44 var jobs = (ItemList<Job>)jobData.Clone(); 45 45 var resultingSchedule = new Schedule(jobs[0].Tasks.Count); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Manipulators/PWRInsertionManipulator.cs
r17226 r17461 40 40 } 41 41 42 public static void Apply(IRandom random, PWR Encodingindividual) {42 public static void Apply(IRandom random, PWR individual) { 43 43 int cutIndex = random.Next(individual.PermutationWithRepetition.Length); 44 44 int insertIndex = random.Next(individual.PermutationWithRepetition.Length); … … 55 55 } 56 56 57 protected override void Manipulate(IRandom random, PWR Encodingindividual) {57 protected override void Manipulate(IRandom random, PWR individual) { 58 58 Apply(random, individual); 59 59 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Manipulators/PWRManipulator.cs
r17226 r17461 35 35 public PWRManipulator() : base() { } 36 36 37 protected abstract void Manipulate(IRandom random, PWR Encodingindividual);37 protected abstract void Manipulate(IRandom random, PWR individual); 38 38 39 39 public override IOperation InstrumentedApply() { 40 var solution = ScheduleParameter.ActualValue as PWR Encoding;40 var solution = ScheduleParameter.ActualValue as PWR; 41 41 if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type PWREncoding."); 42 42 Manipulate(RandomParameter.ActualValue, solution); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWRRandomCreator.cs
r17226 r17461 29 29 [Item("PermutationWithRepetitionRandomCreator", "Creates PWR-individuals at random.")] 30 30 [StorableType("6E753916-C0FD-4585-B6A6-47FD66ED098F")] 31 public class PWRRandomCreator : ScheduleCreator<PWR Encoding>, IStochasticOperator {31 public class PWRRandomCreator : ScheduleCreator<PWR>, IStochasticOperator { 32 32 33 33 public ILookupParameter<IRandom> RandomParameter { … … 47 47 } 48 48 49 public static PWR EncodingApply(int jobs, int resources, IRandom random) {50 return new PWR Encoding(jobs, resources, random);49 public static PWR Apply(int jobs, int resources, IRandom random) { 50 return new PWR(jobs, resources, random); 51 51 } 52 52 53 protected override PWR EncodingCreateSolution() {53 protected override PWR CreateSolution() { 54 54 return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue); 55 55 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PermutationWithRepetitionEncoding.cs
r16725 r17461 32 32 namespace HeuristicLab.Encodings.ScheduleEncoding { 33 33 [StorableType("468EF506-0749-469B-B9B9-36655AA0178D")] 34 public sealed class PermutationWithRepetitionEncoding : ScheduleEncoding<PWR Encoding> {34 public sealed class PermutationWithRepetitionEncoding : ScheduleEncoding<PWR> { 35 35 [StorableConstructor] 36 36 private PermutationWithRepetitionEncoding(StorableConstructorFlag _) : base(_) { } … … 41 41 42 42 public PermutationWithRepetitionEncoding() 43 : base( ) {43 : base("PWR") { 44 44 SolutionCreator = new PWRRandomCreator(); 45 45 Decoder = new PWRDecoder(); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVCrossover.cs
r17226 r17461 34 34 public PRVCrossover() : base() { } 35 35 36 public abstract PRV Encoding Cross(IRandom random, PRVEncoding parent1, PRVEncodingparent2);36 public abstract PRV Cross(IRandom random, PRV parent1, PRV parent2); 37 37 38 38 public override IOperation InstrumentedApply() { 39 39 var parents = ParentsParameter.ActualValue; 40 40 ChildParameter.ActualValue = 41 Cross(RandomParameter.ActualValue, parents[0] as PRV Encoding, parents[1] as PRVEncoding);41 Cross(RandomParameter.ActualValue, parents[0] as PRV, parents[1] as PRV); 42 42 return base.InstrumentedApply(); 43 43 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVDiscreteCrossover.cs
r17226 r17461 39 39 } 40 40 41 public static PRV Encoding Apply(IRandom random, PRVEncoding parent1, PRVEncodingparent2) {41 public static PRV Apply(IRandom random, PRV parent1, PRV parent2) { 42 42 var randomSeed = random.Next(); 43 43 var integerVector = DiscreteCrossover.Apply(random, new ItemArray<IntegerVector>(new[] { parent1.PriorityRulesVector, parent2.PriorityRulesVector })); 44 return new PRV Encoding(integerVector, randomSeed);44 return new PRV(integerVector, randomSeed); 45 45 } 46 46 47 public override PRV Encoding Cross(IRandom random, PRVEncoding parent1, PRVEncodingparent2) {47 public override PRV Cross(IRandom random, PRV parent1, PRV parent2) { 48 48 return Apply(random, parent1, parent2); 49 49 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Crossovers/PRVSinglePointCrossover.cs
r17226 r17461 39 39 } 40 40 41 public static PRV Encoding Apply(IRandom random, PRVEncoding parent1, PRVEncodingparent2) {41 public static PRV Apply(IRandom random, PRV parent1, PRV parent2) { 42 42 var randomSeed = random.Next(); 43 43 var integerVector = SinglePointCrossover.Apply(random, parent1.PriorityRulesVector, parent2.PriorityRulesVector); 44 return new PRV Encoding(integerVector, randomSeed);44 return new PRV(integerVector, randomSeed); 45 45 } 46 46 47 public override PRV Encoding Cross(IRandom random, PRVEncoding parent1, PRVEncodingparent2) {47 public override PRV Cross(IRandom random, PRV parent1, PRV parent2) { 48 48 return Apply(random, parent1, parent2); 49 49 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Decoder/PRVDecoder.cs
r16725 r17461 29 29 [Item("JobSequencingMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")] 30 30 [StorableType("2D059957-AC7C-4B33-BADE-96706AEBAF29")] 31 public class PRVDecoder : ScheduleDecoder<PRV Encoding>{31 public class PRVDecoder : ScheduleDecoder<PRV>, IPRVOperator { 32 32 #region Priority Rules 33 33 //smallest number of remaining tasks … … 187 187 } 188 188 189 public override Schedule DecodeSchedule(PRV Encodingencoding, ItemList<Job> jobData) {189 public override Schedule DecodeSchedule(PRV encoding, ItemList<Job> jobData) { 190 190 return Decode(encoding, jobData); 191 191 } 192 192 193 public static Schedule Decode(PRV Encodingsolution, ItemList<Job> jobData) {193 public static Schedule Decode(PRV solution, ItemList<Job> jobData) { 194 194 var random = new FastRandom(solution.RandomSeed); 195 195 var jobs = (ItemList<Job>)jobData.Clone(); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Manipulators/PRVManipulator.cs
r17226 r17461 46 46 } 47 47 48 protected abstract void Manipulate(IRandom random, PRV Encodingindividual, int numberOfRules);48 protected abstract void Manipulate(IRandom random, PRV individual, int numberOfRules); 49 49 50 50 public override IOperation InstrumentedApply() { 51 var solution = ScheduleParameter.ActualValue as PRV Encoding;51 var solution = ScheduleParameter.ActualValue as PRV; 52 52 if (solution == null) throw new InvalidOperationException("ScheduleEncoding was not found or is not of type PRVEncoding."); 53 53 Manipulate(RandomParameter.ActualValue, solution, NumberOfRulesParameter.ActualValue.Value); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Manipulators/PRVUniformOnePositionManipulator.cs
r17226 r17461 40 40 } 41 41 42 public static void Apply(IRandom random, PRV Encodingindividual, int numberOfRules) {42 public static void Apply(IRandom random, PRV individual, int numberOfRules) { 43 43 UniformOnePositionManipulator.Apply(random, individual.PriorityRulesVector, new IntMatrix(new int[,] { { 0, numberOfRules } })); 44 44 } 45 45 46 protected override void Manipulate(IRandom random, PRV Encodingindividual, int numberOfRules) {46 protected override void Manipulate(IRandom random, PRV individual, int numberOfRules) { 47 47 Apply(random, individual, numberOfRules); 48 48 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVRandomCreator.cs
r17226 r17461 29 29 [Item("PriorityRulesRandomCreator", "Creator class used to create PRV encoding objects for scheduling problems.")] 30 30 [StorableType("5FF2A11E-86F9-4A8B-8E1C-713D6801506C")] 31 public class PRVRandomCreator : ScheduleCreator<PRV Encoding>, IStochasticOperator {31 public class PRVRandomCreator : ScheduleCreator<PRV>, IStochasticOperator { 32 32 33 33 [Storable] … … 54 54 } 55 55 56 public static PRV EncodingApply(int jobs, int resources, IRandom random, int nrOfRules) {57 return new PRV Encoding(jobs * resources, random, 0, nrOfRules);56 public static PRV Apply(int jobs, int resources, IRandom random, int nrOfRules) { 57 return new PRV(jobs * resources, random, 0, nrOfRules); 58 58 } 59 59 60 protected override PRV EncodingCreateSolution() {60 protected override PRV CreateSolution() { 61 61 return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue, NrOfRules); 62 62 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PriorityRulesVectorEncoding.cs
r16725 r17461 34 34 namespace HeuristicLab.Encodings.ScheduleEncoding { 35 35 [StorableType("9C419EE5-F3A8-4F06-8263-7D37D3AE1C72")] 36 public sealed class PriorityRulesVectorEncoding : ScheduleEncoding<PRV Encoding> {36 public sealed class PriorityRulesVectorEncoding : ScheduleEncoding<PRV> { 37 37 38 38 private IFixedValueParameter<IntValue> numberOfRulesParameter; … … 60 60 61 61 public PriorityRulesVectorEncoding() 62 : base( ) {62 : base("PRV") { 63 63 //TODO change to meaningful value 64 64 numberOfRulesParameter = new FixedValueParameter<IntValue>(Name + ".NumberOfRules", new IntValue(10)); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleCreator.cs
r17226 r17461 31 31 [StorableType("3DDA1485-4518-4F1D-A475-795FFE63C98E")] 32 32 public abstract class ScheduleCreator<TSchedule> : InstrumentedOperator, IScheduleCreator<TSchedule> 33 where TSchedule : class,ISchedule {33 where TSchedule : class,IScheduleSolution { 34 34 35 35 public ILookupParameter<TSchedule> ScheduleParameter { -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleCrossover.cs
r17226 r17461 32 32 public abstract class ScheduleCrossover : InstrumentedOperator, IScheduleCrossover, IStochasticOperator { 33 33 34 public ILookupParameter<ISchedule > ChildParameter {35 get { return (ILookupParameter<ISchedule >)Parameters["Child"]; }34 public ILookupParameter<IScheduleSolution> ChildParameter { 35 get { return (ILookupParameter<IScheduleSolution>)Parameters["Child"]; } 36 36 } 37 public IScopeTreeLookupParameter<ISchedule > ParentsParameter {38 get { return (IScopeTreeLookupParameter<ISchedule >)Parameters["Parents"]; }37 public IScopeTreeLookupParameter<IScheduleSolution> ParentsParameter { 38 get { return (IScopeTreeLookupParameter<IScheduleSolution>)Parameters["Parents"]; } 39 39 } 40 40 public ILookupParameter<IRandom> RandomParameter { … … 48 48 : base() { 49 49 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 50 Parameters.Add(new LookupParameter<ISchedule >("Child", "The child solution resulting from the crossover."));50 Parameters.Add(new LookupParameter<IScheduleSolution>("Child", "The child solution resulting from the crossover.")); 51 51 ChildParameter.ActualName = "Schedule"; 52 Parameters.Add(new ScopeTreeLookupParameter<ISchedule >("Parents", "The parent solution which should be crossed."));52 Parameters.Add(new ScopeTreeLookupParameter<IScheduleSolution>("Parents", "The parent solution which should be crossed.")); 53 53 ParentsParameter.ActualName = "Schedule"; 54 54 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleDecoder.cs
r17226 r17461 31 31 [StorableType("57A68F4B-4B35-4DB4-9B5E-D5154DD46E45")] 32 32 public abstract class ScheduleDecoder<TSchedule> : SingleSuccessorOperator, IScheduleDecoder<TSchedule> 33 where TSchedule : class, ISchedule {33 where TSchedule : class, IScheduleSolution { 34 34 35 public ILookupParameter<ISchedule > ScheduleEncodingParameter {36 get { return (ILookupParameter<ISchedule >)Parameters["EncodedSchedule"]; }35 public ILookupParameter<IScheduleSolution> ScheduleEncodingParameter { 36 get { return (ILookupParameter<IScheduleSolution>)Parameters["EncodedSchedule"]; } 37 37 } 38 38 public ILookupParameter<Schedule> ScheduleParameter { … … 48 48 public ScheduleDecoder() 49 49 : base() { 50 Parameters.Add(new LookupParameter<ISchedule >("EncodedSchedule", "The new scheduling solution represented as encoding."));50 Parameters.Add(new LookupParameter<IScheduleSolution>("EncodedSchedule", "The new scheduling solution represented as encoding.")); 51 51 Parameters.Add(new LookupParameter<Schedule>("Schedule", "The decoded scheduling solution represented as generalized schedule.")); 52 52 Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance.")); 53 53 } 54 54 55 public Schedule DecodeSchedule(ISchedule schedule, ItemList<Job> jobData) {55 public Schedule DecodeSchedule(IScheduleSolution schedule, ItemList<Job> jobData) { 56 56 TSchedule solution = schedule as TSchedule; 57 57 if (solution == null) throw new InvalidOperationException("Encoding is not of type " + typeof(TSchedule).GetPrettyName()); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding.cs
r17226 r17461 33 33 [StorableType("D2FB1AF9-EF13-4ED2-B3E9-D5BE4E5772EA")] 34 34 public abstract class ScheduleEncoding<TSchedule> : Encoding<TSchedule>, IScheduleEncoding 35 where TSchedule : class, ISchedule {35 where TSchedule : class, IScheduleSolution { 36 36 #region Encoding Parameters 37 37 [Storable] 38 private I FixedValueParameter<ItemList<Job>> jobDataParameter;39 public I FixedValueParameter<ItemList<Job>> JobDataParameter {38 private IValueParameter<ItemList<Job>> jobDataParameter; 39 public IValueParameter<ItemList<Job>> JobDataParameter { 40 40 get { return jobDataParameter; } 41 41 set { … … 126 126 } 127 127 128 protected ScheduleEncoding() : this("Schedule") { }129 128 protected ScheduleEncoding(string name) : this(name, Enumerable.Empty<Job>()) { } 130 129 protected ScheduleEncoding(string name, IEnumerable<Job> jobData) … … 133 132 int resources = jobData.SelectMany(j => j.Tasks).Select(t => t.ResourceNr).Distinct().Count(); 134 133 135 jobDataParameter = new FixedValueParameter<ItemList<Job>>(Name + ".JobData", new ItemList<Job>(jobData));134 jobDataParameter = new ValueParameter<ItemList<Job>>(Name + ".JobData", new ItemList<Job>(jobData)); 136 135 jobsParameter = new FixedValueParameter<IntValue>(Name + ".Jobs", new IntValue(jobs)); 137 136 resourcesParameter = new FixedValueParameter<IntValue>(Name + ".Resources", new IntValue(resources)); … … 144 143 } 145 144 146 public Schedule Decode(ISchedule schedule, ItemList<Job> jobData) {145 public Schedule Decode(IScheduleSolution schedule, ItemList<Job> jobData) { 147 146 return Decoder.DecodeSchedule(schedule, jobData); 148 147 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Decoder/DirectScheduleDecoder.cs
r16725 r17461 27 27 [Item("DirectScheduleDecoder", "An item used to convert a direct schedule into a generalized schedule.")] 28 28 [StorableType("151C772B-6E6C-40D9-B171-F5626C676A5F")] 29 public class DirectScheduleDecoder : ScheduleDecoder<Schedule> {29 public class DirectScheduleDecoder : ScheduleDecoder<Schedule>, IDirectScheduleOperator { 30 30 [StorableConstructor] 31 31 protected DirectScheduleDecoder(StorableConstructorFlag _) : base(_) { } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleEncoding.cs
r16725 r17461 31 31 32 32 namespace HeuristicLab.Encodings.ScheduleEncoding { 33 [Item("Direct Schedule Encoding", "Encodes a solution by directly assigning start and end types to the tasks.")] 33 34 [StorableType("BB1BD851-3E77-4357-942C-EAF5BE6760B4")] 34 35 public sealed class DirectScheduleEncoding : ScheduleEncoding<Schedule> { … … 41 42 42 43 public DirectScheduleEncoding() 43 : base( ) {44 : base("Schedule") { 44 45 SolutionCreator = new DirectScheduleRandomCreator(); 45 46 Decoder = new DirectScheduleDecoder(); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleRandomCreator.cs
r17226 r17461 54 54 55 55 56 public static Schedule Apply(PWR Encodingpwr, ItemList<Job> jobData) {56 public static Schedule Apply(PWR pwr, ItemList<Job> jobData) { 57 57 var resultingSchedule = new Schedule(jobData[0].Tasks.Count); 58 58 foreach (int jobNr in pwr.PermutationWithRepetition) { … … 70 70 protected override Schedule CreateSolution() { 71 71 var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone(); 72 var pwrEncoding = new PWR Encoding(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value,72 var pwrEncoding = new PWR(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, 73 73 RandomParameter.ActualValue); 74 74 return Apply(pwrEncoding, jobData); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Schedule.cs
r17360 r17461 31 31 [Item("Schedule", "Represents the general solution for scheduling problems.")] 32 32 [StorableType("EA6D14A3-7FA6-4B4B-B7F6-40B42657D398")] 33 public class Schedule : NamedItem, ISchedule {33 public class Schedule : NamedItem, IScheduleSolution { 34 34 35 35 #region Properties -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleManipulator.cs
r17226 r17461 32 32 public abstract class ScheduleManipulator : InstrumentedOperator, IScheduleManipulator, IStochasticOperator { 33 33 34 public ILookupParameter<ISchedule > ScheduleParameter {35 get { return (ILookupParameter<ISchedule >)Parameters["Schedule"]; }34 public ILookupParameter<IScheduleSolution> ScheduleParameter { 35 get { return (ILookupParameter<IScheduleSolution>)Parameters["Schedule"]; } 36 36 } 37 37 … … 45 45 public ScheduleManipulator() 46 46 : base() { 47 Parameters.Add(new LookupParameter<ISchedule >("Schedule", "The scheduling solution to be manipulated."));47 Parameters.Add(new LookupParameter<IScheduleSolution>("Schedule", "The scheduling solution to be manipulated.")); 48 48 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 49 49 } -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs
r17317 r17461 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Drawing; 25 using System.Linq; 24 26 using HEAL.Attic; 25 27 using HeuristicLab.Collections; … … 168 170 #endregion 169 171 172 public void Populate(IEnumerable<IItem> items) { 173 ValidValues.Clear(); 174 ValidValues.UnionWith(items.OfType<T>()); 175 } 176 170 177 [StorableHook(HookType.AfterDeserialization)] 171 178 private void AfterDeserialization() { -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling.Views/3.3/HeuristicLab.Problems.Scheduling.Views-3.3.csproj
r16723 r17461 116 116 </ItemGroup> 117 117 <ItemGroup> 118 <Compile Include="JobShopSchedulingProblemView.cs" /> 118 <Compile Include="JobShopSchedulingProblemView.cs"> 119 <SubType>UserControl</SubType> 120 </Compile> 119 121 <Compile Include="JobShopSchedulingProblemView.Designer.cs"> 120 122 <DependentUpon>JobShopSchedulingProblemView.cs</DependentUpon> -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs
r17226 r17461 20 20 #endregion 21 21 22 //using System;23 //using System.Windows.Forms;24 //using HeuristicLab.Collections;25 //using HeuristicLab.Encodings.ScheduleEncoding;26 //using HeuristicLab.MainForm;27 //using HeuristicLab.Optimization.Views;22 using System; 23 using System.Windows.Forms; 24 using HeuristicLab.Collections; 25 using HeuristicLab.Encodings.ScheduleEncoding; 26 using HeuristicLab.MainForm; 27 using HeuristicLab.Optimization.Views; 28 28 29 //namespace HeuristicLab.Problems.Scheduling.Views {30 //[View("JobShop Scheduling Problem View")]31 //[Content(typeof(JobShopSchedulingProblem), true)]32 //public partial class JobShopSchedulingProblemView : ProblemView {29 namespace HeuristicLab.Problems.Scheduling.Views { 30 [View("JobShop Scheduling Problem View")] 31 [Content(typeof(JobShopSchedulingProblem), true)] 32 public partial class JobShopSchedulingProblemView : ProblemView { 33 33 34 //public new JobShopSchedulingProblem Content {35 //get { return (JobShopSchedulingProblem)base.Content; }36 //set { base.Content = value; }37 //}34 public new JobShopSchedulingProblem Content { 35 get { return (JobShopSchedulingProblem)base.Content; } 36 set { base.Content = value; } 37 } 38 38 39 //public JobShopSchedulingProblemView() {40 //InitializeComponent();41 //Controls.Remove(parameterCollectionView);42 //parameterCollectionView.Dock = DockStyle.Fill;43 //problemTabPage.Controls.Add(parameterCollectionView);44 //}39 public JobShopSchedulingProblemView() { 40 InitializeComponent(); 41 Controls.Remove(parameterCollectionView); 42 parameterCollectionView.Dock = DockStyle.Fill; 43 problemTabPage.Controls.Add(parameterCollectionView); 44 } 45 45 46 //protected override void OnContentChanged() {47 //base.OnContentChanged();48 //FillGanttChart();49 //}46 protected override void OnContentChanged() { 47 base.OnContentChanged(); 48 FillGanttChart(); 49 } 50 50 51 //protected override void DeregisterContentEvents() {52 //Content.JobDataParameter.ValueChanged -= JobDataParameterOnValueChanged;53 //Content.JobData.ItemsAdded -= JobsOnChanged;54 //Content.JobData.ItemsRemoved -= JobsOnRemoved;55 //Content.JobData.ItemsReplaced -= JobsOnChanged;56 //Content.JobData.CollectionReset -= JobsOnChanged;57 //foreach (var job in Content.JobData) {58 //job.TasksChanged -= JobOnTasksChanged;59 //}60 //base.DeregisterContentEvents();61 //}62 //protected override void RegisterContentEvents() {63 //base.RegisterContentEvents();64 //Content.JobDataParameter.ValueChanged += JobDataParameterOnValueChanged;65 //Content.JobData.ItemsAdded += JobsOnChanged;66 //Content.JobData.ItemsRemoved += JobsOnRemoved;67 //Content.JobData.ItemsReplaced += JobsOnChanged;68 //Content.JobData.CollectionReset += JobsOnChanged;69 //foreach (var job in Content.JobData) {70 //job.TasksChanged += JobOnTasksChanged;71 //}72 //}51 protected override void DeregisterContentEvents() { 52 Content.JobDataParameter.ValueChanged -= JobDataParameterOnValueChanged; 53 Content.JobData.ItemsAdded -= JobsOnChanged; 54 Content.JobData.ItemsRemoved -= JobsOnRemoved; 55 Content.JobData.ItemsReplaced -= JobsOnChanged; 56 Content.JobData.CollectionReset -= JobsOnChanged; 57 foreach (var job in Content.JobData) { 58 job.TasksChanged -= JobOnTasksChanged; 59 } 60 base.DeregisterContentEvents(); 61 } 62 protected override void RegisterContentEvents() { 63 base.RegisterContentEvents(); 64 Content.JobDataParameter.ValueChanged += JobDataParameterOnValueChanged; 65 Content.JobData.ItemsAdded += JobsOnChanged; 66 Content.JobData.ItemsRemoved += JobsOnRemoved; 67 Content.JobData.ItemsReplaced += JobsOnChanged; 68 Content.JobData.CollectionReset += JobsOnChanged; 69 foreach (var job in Content.JobData) { 70 job.TasksChanged += JobOnTasksChanged; 71 } 72 } 73 73 74 //private void JobsOnChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) {75 //foreach (var job in e.OldItems)76 //job.Value.TasksChanged -= JobOnTasksChanged;77 //foreach (var job in e.Items)78 //job.Value.TasksChanged += JobOnTasksChanged;79 //FillGanttChart();80 //}74 private void JobsOnChanged(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) { 75 foreach (var job in e.OldItems) 76 job.Value.TasksChanged -= JobOnTasksChanged; 77 foreach (var job in e.Items) 78 job.Value.TasksChanged += JobOnTasksChanged; 79 FillGanttChart(); 80 } 81 81 82 //private void JobsOnRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) {83 //foreach (var job in e.Items)84 //job.Value.TasksChanged -= JobOnTasksChanged;85 //FillGanttChart();86 //}82 private void JobsOnRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Job>> e) { 83 foreach (var job in e.Items) 84 job.Value.TasksChanged -= JobOnTasksChanged; 85 FillGanttChart(); 86 } 87 87 88 //private void JobDataParameterOnValueChanged(object sender, EventArgs e) {89 //Content.JobData.ItemsAdded += JobsOnChanged;90 //Content.JobData.ItemsRemoved += JobsOnRemoved;91 //Content.JobData.ItemsReplaced += JobsOnChanged;92 //Content.JobData.CollectionReset += JobsOnChanged;93 //foreach (var job in Content.JobData) {94 //job.TasksChanged += JobOnTasksChanged;95 //}96 //FillGanttChart();97 //}88 private void JobDataParameterOnValueChanged(object sender, EventArgs e) { 89 Content.JobData.ItemsAdded += JobsOnChanged; 90 Content.JobData.ItemsRemoved += JobsOnRemoved; 91 Content.JobData.ItemsReplaced += JobsOnChanged; 92 Content.JobData.CollectionReset += JobsOnChanged; 93 foreach (var job in Content.JobData) { 94 job.TasksChanged += JobOnTasksChanged; 95 } 96 FillGanttChart(); 97 } 98 98 99 //private void JobOnTasksChanged(object sender, EventArgs e) {100 //FillGanttChart();101 //}99 private void JobOnTasksChanged(object sender, EventArgs e) { 100 FillGanttChart(); 101 } 102 102 103 //private void FillGanttChart() {104 //ganttChart.Reset();105 //if (Content == null) return;106 //int jobCount = 0;107 //foreach (var j in Content.JobData) {108 //double lastEndTime = 0;109 //foreach (var t in Content.JobData[jobCount].Tasks) {110 //int categoryNr = t.JobNr;111 //string categoryName = "Job" + categoryNr;112 //ganttChart.AddData(categoryName,113 //categoryNr,114 //t.TaskNr,115 //lastEndTime + 1,116 //lastEndTime + t.Duration,117 //"Job" + t.JobNr + " - " + "Task#" + t.TaskNr);118 //lastEndTime += t.Duration;119 //}120 //jobCount++;121 //}122 //}123 //}124 //}103 private void FillGanttChart() { 104 ganttChart.Reset(); 105 if (Content == null) return; 106 int jobCount = 0; 107 foreach (var j in Content.JobData) { 108 double lastEndTime = 0; 109 foreach (var t in Content.JobData[jobCount].Tasks) { 110 int categoryNr = t.JobNr; 111 string categoryName = "Job" + categoryNr; 112 ganttChart.AddData(categoryName, 113 categoryNr, 114 t.TaskNr, 115 lastEndTime + 1, 116 lastEndTime + t.Duration, 117 "Job" + t.JobNr + " - " + "Task#" + t.TaskNr); 118 lastEndTime += t.Duration; 119 } 120 jobCount++; 121 } 122 } 123 } 124 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/HeuristicLab.Problems.Scheduling-3.3.csproj
r16723 r17461 112 112 </ItemGroup> 113 113 <ItemGroup> 114 <Compile Include="Analyzers\BestSchedulingSolutionAnalyzer.cs" /> 115 <Compile Include="Analyzers\SchedulingAnalyzer.cs" /> 116 <Compile Include="Evaluators\MeanTardinessEvaluator.cs" /> 117 <Compile Include="Evaluators\MakespanEvaluator.cs" /> 118 <Compile Include="Evaluators\ScheduleEvaluator.cs" /> 119 <Compile Include="Interfaces\IJSSPOperator.cs" /> 120 <Compile Include="Interfaces\IScheduleEvaluator.cs" /> 121 <Compile Include="Interfaces\ISchedulingEvaluator.cs" /> 122 <Compile Include="JobShopSchedulingProblem new.cs" /> 114 <Compile Include="Objectives\MeanTardiness.cs" /> 115 <Compile Include="Objectives\Makespan.cs" /> 123 116 <Compile Include="JobShopSchedulingProblem.cs" /> 124 <Compile Include="Evaluators\SchedulingEvaluator.cs" />125 117 <Compile Include="Plugin.cs" /> 126 118 <Compile Include="Properties\AssemblyInfo.cs" /> 127 <Compile Include="SchedulingProblem.cs" />128 119 </ItemGroup> 129 120 <ItemGroup> -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs
r17226 r17461 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 21 21 22 22 using System; 23 using System.ComponentModel; 23 24 using System.Drawing; 24 25 using System.Linq; 26 using System.Threading; 27 using HEAL.Attic; 25 28 using HeuristicLab.Common; 26 29 using HeuristicLab.Core; … … 28 31 using HeuristicLab.Encodings.PermutationEncoding; 29 32 using HeuristicLab.Encodings.ScheduleEncoding; 30 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix; 31 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition; 32 using HeuristicLab.Encodings.ScheduleEncoding.PriorityRulesVector; 33 using HeuristicLab.Optimization; 33 34 using HeuristicLab.Parameters; 34 using HEAL.Attic;35 using HeuristicLab.PluginInfrastructure;36 35 using HeuristicLab.Problems.Instances; 37 36 38 37 namespace HeuristicLab.Problems.Scheduling { 38 public enum JSSPObjective { Makespan, Tardiness } 39 39 40 [Item("Job Shop Scheduling Problem (JSSP)", "Represents a standard Job Shop Scheduling Problem")] 40 41 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 120)] 41 [StorableType(" BB12CCEC-A109-4A26-A1C7-5A0703AB7687")]42 public sealed class JobShopSchedulingProblem : S chedulingProblem, IProblemInstanceConsumer<JSSPData>, IProblemInstanceExporter<JSSPData>, IStorableContent {42 [StorableType("d6c72bd1-c6cc-4efb-9cc5-b73bb3845799")] 43 public sealed class JobShopSchedulingProblem : SingleObjectiveProblem<IScheduleEncoding, IScheduleSolution>, IProblemInstanceConsumer<JSSPData>, IProblemInstanceExporter<JSSPData>, IStorableContent { 43 44 #region Default Instance 44 45 private static readonly JSSPData DefaultInstance = new JSSPData() { 45 Name = "Job Shop Scheduling Problem (JSSP)",46 Description = "The default instance of the JSSP problem in HeuristicLab",47 46 Jobs = 10, 48 47 Resources = 10, … … 75 74 #endregion 76 75 77 public string Filename { get; set; }78 76 public override Image ItemImage { 79 77 get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; } 80 78 } 81 79 82 80 #region Parameter Properties 83 public IValueParameter<ItemList<Job>> JobDataParameter { 84 get { return (IValueParameter<ItemList<Job>>)Parameters["JobData"]; } 85 } 86 public OptionalValueParameter<Schedule> BestKnownSolutionParameter { 87 get { return (OptionalValueParameter<Schedule>)Parameters["BestKnownSolution"]; } 88 } 89 90 public IFixedValueParameter<IntValue> JobsParameter { 91 get { return (IFixedValueParameter<IntValue>)Parameters["Jobs"]; } 92 } 93 public IFixedValueParameter<IntValue> ResourcesParameter { 94 get { return (IFixedValueParameter<IntValue>)Parameters["Resources"]; } 95 } 96 public IValueParameter<IScheduleEvaluator> ScheduleEvaluatorParameter { 97 get { return (IValueParameter<IScheduleEvaluator>)Parameters["ScheduleEvaluator"]; } 98 } 99 public OptionalValueParameter<IScheduleDecoder> ScheduleDecoderParameter { 100 get { return (OptionalValueParameter<IScheduleDecoder>)Parameters["ScheduleDecoder"]; } 101 } 81 [Storable] public IValueParameter<ItemList<Job>> JobDataParameter { get; private set; } 82 [Storable] public OptionalValueParameter<Schedule> BestKnownSolutionParameter { get; private set; } 83 [Storable] public IFixedValueParameter<IntValue> JobsParameter { get; private set; } 84 [Storable] public IFixedValueParameter<IntValue> ResourcesParameter { get; private set; } 85 [Storable] public IFixedValueParameter<EnumValue<JSSPObjective>> ObjectiveParameter { get; private set; } 102 86 #endregion 103 87 … … 119 103 set { ResourcesParameter.Value.Value = value; } 120 104 } 121 public IScheduleEvaluator ScheduleEvaluator { 122 get { return ScheduleEvaluatorParameter.Value; } 123 set { ScheduleEvaluatorParameter.Value = value; } 124 } 125 public IScheduleDecoder ScheduleDecoder { 126 get { return ScheduleDecoderParameter.Value; } 127 set { ScheduleDecoderParameter.Value = value; } 105 public JSSPObjective Objective { 106 get { return ObjectiveParameter.Value.Value; } 107 set { ObjectiveParameter.Value.Value = value; } 128 108 } 129 109 #endregion … … 131 111 [StorableConstructor] 132 112 private JobShopSchedulingProblem(StorableConstructorFlag _) : base(_) { } 133 private JobShopSchedulingProblem(JobShopSchedulingProblem original, Cloner cloner)134 : base(original, cloner) {135 RegisterEventHandlers();136 }137 public JobShopSchedulingProblem()138 : base(new SchedulingEvaluator(), new JSMRandomCreator()) {139 Parameters.Add(new ValueParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance.", new ItemList<Job>()));140 Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));141 142 Parameters.Add(new FixedValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue()));143 Parameters.Add(new FixedValueParameter<IntValue>("Resources", "The number of resources used in this JSSP instance.", new IntValue()));144 Parameters.Add(new ValueParameter<IScheduleEvaluator>("ScheduleEvaluator", "The evaluator used to determine the quality of a solution.", new MakespanEvaluator()));145 Parameters.Add(new OptionalValueParameter<IScheduleDecoder>("ScheduleDecoder", "The operator that decodes the representation and creates a schedule.", new JSMDecoder()));146 147 EvaluatorParameter.GetsCollected = false;148 EvaluatorParameter.Hidden = true;149 ScheduleDecoderParameter.Hidden = true;150 151 InitializeOperators();152 Load(DefaultInstance);153 RegisterEventHandlers();154 }155 156 public override IDeepCloneable Clone(Cloner cloner) {157 return new JobShopSchedulingProblem(this, cloner);158 }159 160 113 [StorableHook(HookType.AfterDeserialization)] 161 114 private void AfterDeserialization() { … … 163 116 } 164 117 118 private JobShopSchedulingProblem(JobShopSchedulingProblem original, Cloner cloner) 119 : base(original, cloner) { 120 JobDataParameter = cloner.Clone(original.JobDataParameter); 121 BestKnownSolutionParameter = cloner.Clone(original.BestKnownSolutionParameter); 122 JobsParameter = cloner.Clone(original.JobsParameter); 123 ResourcesParameter = cloner.Clone(original.ResourcesParameter); 124 ObjectiveParameter = cloner.Clone(original.ObjectiveParameter); 125 126 RegisterEventHandlers(); 127 } 128 public override IDeepCloneable Clone(Cloner cloner) { 129 return new JobShopSchedulingProblem(this, cloner); 130 } 131 132 public JobShopSchedulingProblem() 133 : base(new JobSequenceMatrixEncoding()) { 134 Parameters.Add(JobDataParameter = new ValueParameter<ItemList<Job>>("JobData", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance.", new ItemList<Job>())); 135 Parameters.Add(BestKnownSolutionParameter = new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance.")); 136 Parameters.Add(JobsParameter = new FixedValueParameter<IntValue>("Jobs", "The number of jobs used in this JSSP instance.", new IntValue())); 137 Parameters.Add(ResourcesParameter = new FixedValueParameter<IntValue>("Resources", "The number of resources used in this JSSP instance.", new IntValue())); 138 Parameters.Add(ObjectiveParameter = new FixedValueParameter<EnumValue<JSSPObjective>>("Objective", "The objective to use in the evaluation of a schedule.", new EnumValue<JSSPObjective>(JSSPObjective.Makespan))); 139 EncodingParameter.Hidden = false; 140 141 Encoding.ResourcesParameter = ResourcesParameter; 142 Encoding.JobsParameter = JobsParameter; 143 Encoding.JobDataParameter = JobDataParameter; 144 145 Load(DefaultInstance); 146 RegisterEventHandlers(); 147 } 148 149 public override ISingleObjectiveEvaluationResult Evaluate(IScheduleSolution solution, IRandom random, CancellationToken cancellationToken) { 150 var schedule = Encoding.Decode(solution, JobData); 151 switch (Objective) { 152 case JSSPObjective.Makespan: 153 return new SingleObjectiveEvaluationResult(Makespan.Calculate(schedule)); 154 case JSSPObjective.Tardiness: 155 return new SingleObjectiveEvaluationResult(MeanTardiness.Calculate(schedule, JobData)); 156 default: 157 throw new InvalidOperationException("Objective " + Objective + " unknown"); 158 } 159 } 160 161 public override void Analyze(IScheduleSolution[] solutions, double[] qualities, ResultCollection results, IRandom random) { 162 base.Analyze(solutions, qualities, results, random); 163 164 bool max = Maximization; 165 166 int i = -1; 167 if (!max) 168 i = qualities.Select((x, index) => new { index, x }).OrderBy(x => x.x).First().index; 169 else i = qualities.Select((x, index) => new { index, x }).OrderByDescending(x => x.x).First().index; 170 171 if (double.IsNaN(BestKnownQuality) || 172 max && qualities[i] > BestKnownQuality || 173 !max && qualities[i] < BestKnownQuality) { 174 BestKnownQuality = qualities[i]; 175 BestKnownSolution = Encoding.Decode(solutions[i], JobData); 176 } 177 Schedule bestSolution; 178 if (results.TryGetValue("Best Scheduling Solution", out var result)) { 179 bestSolution = result.Value as Schedule; 180 } else bestSolution = null; 181 182 if (bestSolution == null || IsBetter(bestSolution.Quality, qualities[i])) 183 results.AddOrUpdateResult("Best Scheduling Solution", Encoding.Decode(solutions[i], JobData)); 184 } 185 186 protected override void OnEncodingChanged() { 187 base.OnEncodingChanged(); 188 Encoding.ResourcesParameter = ResourcesParameter; 189 Encoding.JobsParameter = JobsParameter; 190 Encoding.JobDataParameter = JobDataParameter; 191 } 192 193 165 194 private void RegisterEventHandlers() { 166 ScheduleEvaluatorParameter.ValueChanged += ScheduleEvaluatorParameter_ValueChanged; 167 ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged; 168 SolutionCreator.ScheduleEncodingParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged; 169 ScheduleDecoderParameter.ValueChanged += ScheduleDecoderParameter_ValueChanged; 170 if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged; 171 } 172 173 #region Events 174 protected override void OnSolutionCreatorChanged() { 175 base.OnSolutionCreatorChanged(); 176 SolutionCreator.ScheduleEncodingParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged; 177 InitializeOperators(); 178 } 179 protected override void OnEvaluatorChanged() { 180 base.OnEvaluatorChanged(); 181 ParameterizeOperators(); 182 } 183 private void ScheduleEvaluatorParameter_ValueChanged(object sender, EventArgs eventArgs) { 184 ScheduleEvaluator.QualityParameter.ActualNameChanged += ScheduleEvaluator_QualityParameter_ActualNameChanged; 185 ParameterizeOperators(); 186 } 187 private void ScheduleEvaluator_QualityParameter_ActualNameChanged(object sender, EventArgs eventArgs) { 188 ParameterizeOperators(); 189 } 190 191 private void SolutionCreator_SchedulingEncodingParameter_ActualNameChanged(object sender, EventArgs eventArgs) { 192 ParameterizeOperators(); 193 } 194 private void ScheduleDecoderParameter_ValueChanged(object sender, EventArgs eventArgs) { 195 if (ScheduleDecoder != null) ScheduleDecoder.ScheduleParameter.ActualNameChanged += ScheduleDecoder_ScheduleParameter_ActualNameChanged; 196 ParameterizeOperators(); 197 } 198 private void ScheduleDecoder_ScheduleParameter_ActualNameChanged(object sender, EventArgs eventArgs) { 199 ParameterizeOperators(); 200 } 201 #endregion 195 JobDataParameter.ValueChanged += JobDataParameterOnValueChanged; 196 JobData.PropertyChanged += JobDataOnPropertyChanged; 197 } 198 199 private void JobDataParameterOnValueChanged(object sender, EventArgs e) { 200 JobData.PropertyChanged += JobDataOnPropertyChanged; 201 Jobs = JobData.Count; 202 } 203 204 private void JobDataOnPropertyChanged(object sender, PropertyChangedEventArgs e) { 205 if (e.PropertyName == nameof(JobData.Count)) { 206 Jobs = JobData.Count; 207 } 208 } 202 209 203 210 #region Problem Instance Handling … … 212 219 } 213 220 214 BestKnownQuality = data.BestKnownQuality .HasValue ? new DoubleValue(data.BestKnownQuality.Value) : null;221 BestKnownQuality = data.BestKnownQuality ?? double.NaN; 215 222 if (data.BestKnownSchedule != null) { 216 var enc = new JSMEncoding(); 217 enc.JobSequenceMatrix = new ItemList<Permutation>(data.Resources); 223 var enc = new JSM(0); 218 224 for (int i = 0; i < data.Resources; i++) { 219 enc.JobSequenceMatrix [i] = new Permutation(PermutationTypes.Absolute, new int[data.Jobs]);225 enc.JobSequenceMatrix.Add(new Permutation(PermutationTypes.Absolute, new int[data.Jobs])); 220 226 for (int j = 0; j < data.Jobs; j++) { 221 227 enc.JobSequenceMatrix[i][j] = data.BestKnownSchedule[i, j]; 222 228 } 223 229 } 224 BestKnownSolution = new JSMDecoder().CreateScheduleFromEncoding(enc, jobData); 225 if (ScheduleEvaluator is MeanTardinessEvaluator) 226 BestKnownQuality = new DoubleValue(MeanTardinessEvaluator.GetMeanTardiness(BestKnownSolution, jobData)); 227 else if (ScheduleEvaluator is MakespanEvaluator) 228 BestKnownQuality = new DoubleValue(MakespanEvaluator.GetMakespan(BestKnownSolution)); 229 } 230 Name = data.Name; 231 Description = data.Description; 230 BestKnownSolution = JSMDecoder.Decode(enc, jobData, JSMDecodingErrorPolicy.RandomPolicy, JSMForcingStrategy.SwapForcing); 231 switch (Objective) { 232 case JSSPObjective.Makespan: 233 BestKnownQuality = Makespan.Calculate(BestKnownSolution); 234 break; 235 case JSSPObjective.Tardiness: 236 BestKnownQuality = MeanTardiness.Calculate(BestKnownSolution, jobData); 237 break; 238 } 239 } 240 232 241 JobData = jobData; 233 Jobs = data.Jobs;234 242 Resources = data.Resources; 235 243 } … … 259 267 #endregion 260 268 261 #region Helpers262 private void InitializeOperators() {263 Operators.Clear();264 ApplyEncoding();265 Operators.Add(new BestSchedulingSolutionAnalyzer());266 ParameterizeOperators();267 }268 269 private void ApplyEncoding() {270 if (SolutionCreator.GetType() == typeof(JSMRandomCreator)) {271 Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>());272 ScheduleDecoder = new JSMDecoder();273 } else if (SolutionCreator.GetType() == typeof(PRVRandomCreator)) {274 Operators.AddRange(ApplicationManager.Manager.GetInstances<IPRVOperator>());275 ScheduleDecoder = new PRVDecoder();276 } else if (SolutionCreator.GetType() == typeof(PWRRandomCreator)) {277 Operators.AddRange(ApplicationManager.Manager.GetInstances<IPWROperator>());278 ScheduleDecoder = new PWRDecoder();279 } else if (SolutionCreator.GetType() == typeof(DirectScheduleRandomCreator)) {280 Operators.AddRange(ApplicationManager.Manager.GetInstances<IDirectScheduleOperator>());281 ScheduleDecoder = null;282 }283 }284 285 private void ParameterizeOperators() {286 Evaluator.ScheduleDecoderParameter.ActualName = ScheduleDecoderParameter.Name;287 Evaluator.ScheduleDecoderParameter.Hidden = true;288 Evaluator.ScheduleEvaluatorParameter.ActualName = ScheduleEvaluatorParameter.Name;289 Evaluator.ScheduleEvaluatorParameter.Hidden = true;290 Evaluator.QualityParameter.ActualName = ScheduleEvaluator.QualityParameter.ActualName;291 Evaluator.QualityParameter.Hidden = true;292 293 if (ScheduleDecoder != null)294 ScheduleDecoder.ScheduleEncodingParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;295 296 if (ScheduleDecoder != null) {297 ScheduleEvaluator.ScheduleParameter.ActualName = ScheduleDecoder.ScheduleParameter.ActualName;298 ScheduleEvaluator.ScheduleParameter.Hidden = true;299 } else if (SolutionCreator is DirectScheduleRandomCreator) {300 var directEvaluator = (DirectScheduleRandomCreator)SolutionCreator;301 ScheduleEvaluator.ScheduleParameter.ActualName = directEvaluator.ScheduleEncodingParameter.ActualName;302 ScheduleEvaluator.ScheduleParameter.Hidden = true;303 } else {304 ScheduleEvaluator.ScheduleParameter.ActualName = ScheduleEvaluator.ScheduleParameter.Name;305 ScheduleEvaluator.ScheduleParameter.Hidden = false;306 }307 308 foreach (var op in Operators.OfType<IScheduleManipulator>()) {309 op.ScheduleEncodingParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;310 op.ScheduleEncodingParameter.Hidden = true;311 }312 313 foreach (var op in Operators.OfType<IScheduleCrossover>()) {314 op.ChildParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;315 op.ChildParameter.Hidden = true;316 op.ParentsParameter.ActualName = SolutionCreator.ScheduleEncodingParameter.ActualName;317 op.ParentsParameter.Hidden = true;318 }319 320 foreach (var op in Operators.OfType<BestSchedulingSolutionAnalyzer>()) {321 op.QualityParameter.ActualName = ScheduleEvaluator.QualityParameter.ActualName;322 if (ScheduleDecoder != null) {323 op.ScheduleParameter.ActualName = ScheduleDecoder.ScheduleParameter.ActualName;324 op.ScheduleParameter.Hidden = true;325 } else if (SolutionCreator is DirectScheduleRandomCreator) {326 op.ScheduleParameter.ActualName = ((DirectScheduleRandomCreator)SolutionCreator).ScheduleEncodingParameter.ActualName;327 op.ScheduleParameter.Hidden = true;328 } else {329 op.ScheduleParameter.ActualName = op.ScheduleParameter.Name;330 op.ScheduleParameter.Hidden = false;331 }332 }333 }334 #endregion335 336 269 } 337 270 }
Note: See TracChangeset
for help on using the changeset viewer.