Changeset 10347 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators
- Timestamp:
- 01/16/14 16:37:56 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/AfterCrossoverOperator.cs
r10300 r10347 20 20 #endregion 21 21 22 using System.Linq;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; … … 29 28 [StorableClass] 30 29 [Item("AfterCrossoverOperator", "A generic operator that can record genealogical relationships between crossover parents and children.")] 31 public class AfterCrossoverOperator<T> : EvolutionTrackingOperator 32 where T : class,IItem { 30 public class AfterCrossoverOperator<T> : EvolutionTrackingOperator, ICrossoverOperator<T> where T : class,IItem { 33 31 private const string defaultParentsParameterName = "Parents"; 34 32 private const string defaultChildParameterName = "Child"; 35 public IScopeTreeLookupParameter<T> ParentsParameter ;36 public ILookupParameter<T> ChildParameter ;33 public IScopeTreeLookupParameter<T> ParentsParameter { get; set; } 34 public ILookupParameter<T> ChildParameter { get; set; } 37 35 38 36 protected AfterCrossoverOperator(AfterCrossoverOperator<T> original, Cloner cloner) … … 51 49 52 50 public override IOperation Apply() { 53 // var parentVertices = ParentsParameter.ActualValue.Select(x => GenealogyGraph[x].Last()).ToList();54 var lastGen = GenealogyGraph.Ranks[Generations.Value].ToList();55 var parentVertices = ExecutionContext.Scope.SubScopes.Select(s => lastGen[int.Parse(s.Name)]).ToList(); // because the individuals in the execution scope are copies of the ones in the graph56 57 var childVertex = new GenealogyGraphNode<T> {58 Content = ChildParameter.ActualValue,59 Rank = parentVertices[0].Rank + 160 };61 GenealogyGraph.AddVertex(childVertex);62 foreach (var v in parentVertices) {63 childVertex.AddReverseArc(v);64 v.AddForwardArc(childVertex);65 }66 // if (parentVertices[0].Content == parentVertices[1].Content)67 // throw new Exception("Self-crossover");68 51 return base.Apply(); 69 52 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/AfterManipulatorOperator.cs
r10300 r10347 28 28 [StorableClass] 29 29 [Item("AfterCrossoverOperator", "Performs an action after the crossover operator is applied.")] 30 public class AfterManipulatorOperator<T> : EvolutionTrackingOperator 31 where T : class,IItem { 30 public class AfterManipulatorOperator<T> : EvolutionTrackingOperator, IManipulatorOperator<T> where T : class,IItem { 32 31 33 32 private const string ChildParameterName = "Child"; 34 public ILookupParameter<T> ChildParameter ;33 public ILookupParameter<T> ChildParameter { get; set; } 35 34 36 35 protected AfterManipulatorOperator(AfterManipulatorOperator<T> original, Cloner cloner) -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/AfterSolutionCreatorOperator.cs
r10300 r10347 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Parameters; 23 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 25 … … 29 30 where T : class,IItem { 30 31 32 private const string CurrentScopeParameterName = "CurrentScope"; 33 34 public ScopeParameter CurrentScopeParameter { 35 get { return (ScopeParameter)Parameters[CurrentScopeParameterName]; } 36 } 37 public IScope CurrentScope { get { return CurrentScopeParameter.ActualValue; } } 38 31 39 public override IOperation Apply() { 32 40 return base.Apply(); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Operators/BeforeManipulatorOperator.cs
r10300 r10347 29 29 [StorableClass] 30 30 [Item("AfterCrossoverOperator", "Performs an action after the crossover operator is applied.")] 31 public class BeforeManipulatorOperator<T> : EvolutionTrackingOperator 32 where T : class,IItem { 31 public class BeforeManipulatorOperator<T> : EvolutionTrackingOperator, IManipulatorOperator<T> where T : class,IItem { 33 32 34 33 private const string ChildParameterName = "Child"; 35 public ILookupParameter<T> ChildParameter ;34 public ILookupParameter<T> ChildParameter { get; set; } 36 35 37 36 protected BeforeManipulatorOperator(BeforeManipulatorOperator<T> original, Cloner cloner)
Note: See TracChangeset
for help on using the changeset viewer.