- Timestamp:
- 02/06/15 15:22:27 (9 years ago)
- Location:
- branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/BasicProblems
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs
r11949 r11952 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.Optimization; 28 using HeuristicLab.Parameters; 28 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 30 … … 37 38 } 38 39 39 pr otected HashSet<IOperator> encodingOperators = new HashSet<IOperator>(new TypeEqualityComparer<IOperator>());40 private ItemSet<IOperator> encodingOperators = new ItemSet<IOperator>(new TypeEqualityComparer<IOperator>()); 40 41 41 42 [Storable(Name = "Operators")] 42 43 private IEnumerable<IOperator> StorableOperators { 43 44 get { return encodingOperators; } 44 set { encodingOperators = new HashSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); ; }45 set { encodingOperators = new ItemSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); ; } 45 46 } 46 47 … … 50 51 if (!value.OfType<T>().Any()) 51 52 throw new ArgumentException("The provided operators contain no suitable solution creator"); 52 encodingOperators = new HashSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); 53 encodingOperators.Clear(); 54 foreach (var op in value) encodingOperators.Add(op); 53 55 54 56 T newSolutionCreator = (T)encodingOperators.FirstOrDefault(o => o.GetType() == solutionCreator.GetType()) ?? … … 85 87 protected Encoding(Encoding<T> original, Cloner cloner) 86 88 : base(original, cloner) { 87 encodingOperators = new HashSet<IOperator>(original.Operators.Select(cloner.Clone), new TypeEqualityComparer<IOperator>());89 encodingOperators = cloner.Clone(original.encodingOperators); 88 90 solutionCreator = cloner.Clone(original.solutionCreator); 89 91 } 90 protected Encoding(string name) : base(name) { } 92 protected Encoding(string name) 93 : base(name) { 94 Parameters.Add(new FixedValueParameter<ReadOnlyItemSet<IOperator>>(name + ".Operators", "The operators that the encoding specifies.", encodingOperators.AsReadOnly())); 95 } 91 96 92 97 public virtual Individual GetIndividual(IScope scope) { 93 98 return new SingleEncodingIndividual(this, scope); 99 } 100 101 protected bool AddOperator(IOperator @operator) { 102 return encodingOperators.Add(@operator); 103 } 104 105 protected bool RemoveOperator(IOperator @operator) { 106 return encodingOperators.Remove(@operator); 94 107 } 95 108 -
branches/ProgrammableProblem/HeuristicLab.Optimization/3.3/BasicProblems/MultiEncoding.cs
r11949 r11952 56 56 57 57 foreach (var @operator in ApplicationManager.Manager.GetInstances<IMultiEncodingOperator>()) 58 encodingOperators.Add(@operator);58 AddOperator(@operator); 59 59 } 60 60
Note: See TracChangeset
for help on using the changeset viewer.