Changeset 13437 for branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding
- Timestamp:
- 12/06/15 15:33:25 (9 years ago)
- Location:
- branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers/DirectScheduleCrossover.cs
r12012 r13437 29 29 [StorableClass] 30 30 public abstract class DirectScheduleCrossover : ScheduleCrossover, IDirectScheduleOperator { 31 public ILookupParameter<ItemList<Job>> JobDataParameter { 32 get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; } 33 } 34 31 35 [StorableConstructor] 32 36 protected DirectScheduleCrossover(bool deserializing) : base(deserializing) { } … … 34 38 public DirectScheduleCrossover() 35 39 : base() { 36 ParentsParameter.ActualName = "Schedule";37 ChildParameter.ActualName = "Schedule";38 40 Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance.")); 39 }40 41 public ILookupParameter<ItemList<Job>> JobDataParameter {42 get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; }43 41 } 44 42 -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers/DirectScheduleGTCrossover.cs
r12012 r13437 64 64 Task minimal = GTAlgorithmUtils.GetTaskWithMinimalEC(earliestTasksList, child); 65 65 int conflictedResourceNr = minimal.ResourceNr; 66 Resource conflictedResource = child.Resources[conflictedResourceNr];67 66 68 67 //STEP 2 - Compute a conflict set of all operations that can be scheduled on the conflicted resource 69 ItemList<Task> conflictSet = GTAlgorithmUtils.GetConflictSetForTask(minimal, earliestTasksList, jobData,child);68 ItemList<Task> conflictSet = GTAlgorithmUtils.GetConflictSetForTask(minimal, earliestTasksList, child); 70 69 71 70 //STEP 3 - Select a task from the conflict set 72 int progressOnResource = conflictedResource.Tasks.Count;73 71 Task selectedTask = null; 74 72 if (random.NextDouble() < mutProp) { … … 77 75 } else { 78 76 //Crossover 79 selectedTask = SelectTaskFromConflictSet(conflictSet, ((random.Next(2) == 0) ? parent1 : parent2), conflictedResourceNr , progressOnResource);77 selectedTask = SelectTaskFromConflictSet(conflictSet, ((random.Next(2) == 0) ? parent1 : parent2), conflictedResourceNr); 80 78 } 81 79 … … 92 90 } 93 91 94 private static Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, Schedule usedParent, int conflictedResourceNr , int progressOnResource) {92 private static Task SelectTaskFromConflictSet(ItemList<Task> conflictSet, Schedule usedParent, int conflictedResourceNr) { 95 93 //Apply Crossover 96 94 foreach (ScheduledTask st in usedParent.Resources[conflictedResourceNr].Tasks) { -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleRandomCreator.cs
r13435 r13437 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Data;26 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;27 25 using HeuristicLab.Optimization; 28 26 using HeuristicLab.Parameters; … … 33 31 [Item("DirectScheduleRandomCreator", "Creator class used to create schedule encoding objects.")] 34 32 [StorableClass] 35 public class DirectScheduleRandomCreator : ScheduleCreator, IStochasticOperator {33 public class DirectScheduleRandomCreator : ScheduleCreator, IStochasticOperator, IDirectScheduleOperator { 36 34 37 35 public ILookupParameter<IRandom> RandomParameter { 38 36 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 39 37 } 40 public IValueLookupParameter<IntValue> JobsParameter {41 get { return (IValueLookupParameter<IntValue>)Parameters["Jobs"]; }42 }43 public IValueLookupParameter<IntValue> ResourcesParameter {44 get { return (IValueLookupParameter<IntValue>)Parameters["Resources"]; }45 }46 38 public ILookupParameter<ItemList<Job>> JobDataParameter { 47 39 get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; } 48 40 } 49 50 41 51 42 [StorableConstructor] … … 60 51 : base() { 61 52 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator.")); 62 Parameters.Add(new ValueLookupParameter<IntValue>("Jobs", "The number of jobs handled in this problem instance."));63 Parameters.Add(new ValueLookupParameter<IntValue>("Resources", "The number of resources used in this problem instance."));64 53 Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance.")); 65 ScheduleParameter.ActualName = "Schedule";66 54 } 67 55 … … 89 77 new PWREncoding(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue), 90 78 jobData); 91 } catch { 79 } 80 catch { 92 81 throw new Exception("ScheduleRandomCreator needs JobData parameter from a JSSP-Instance to create Schedule-Instances!"); 93 82 } -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Manipulators/DirectScheduleManipulator.cs
r13435 r13437 23 23 using HeuristicLab.Common; 24 24 using HeuristicLab.Core; 25 using HeuristicLab.Parameters; 25 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 27 … … 29 30 [StorableClass] 30 31 public abstract class DirectScheduleManipulator : ScheduleManipulator, IDirectScheduleOperator { 32 public ILookupParameter<ItemList<Job>> JobDataParameter { 33 get { return (LookupParameter<ItemList<Job>>)Parameters["JobData"]; } 34 } 31 35 32 36 [StorableConstructor] 33 37 protected DirectScheduleManipulator(bool deserializing) : base(deserializing) { } 34 38 protected DirectScheduleManipulator(DirectScheduleManipulator original, Cloner cloner) : base(original, cloner) { } 39 35 40 public DirectScheduleManipulator() 36 41 : base() { 37 ScheduleParameter.ActualName = "Schedule";42 Parameters.Add(new LookupParameter<ItemList<Job>>("JobData", "Job data taken from the JSSP - Instance.")); 38 43 } 39 44 … … 42 47 public override IOperation InstrumentedApply() { 43 48 var schedule = ScheduleParameter.ActualValue as Schedule; 44 if (schedule == null) throw new InvalidOperationException("Schedule Encodingwas not found or is not of type Schedule.");49 if (schedule == null) throw new InvalidOperationException("Schedule was not found or is not of type Schedule."); 45 50 Manipulate(RandomParameter.ActualValue, schedule); 46 51 return base.InstrumentedApply();
Note: See TracChangeset
for help on using the changeset viewer.