Changeset 8887 for trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers
- Timestamp:
- 11/11/12 22:57:09 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Crossovers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.