Changeset 11587 for branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/Encoding.cs
- Timestamp:
- 11/26/14 13:24:20 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/Encoding.cs
r11582 r11587 37 37 } 38 38 39 public virtual IEnumerable<IValueParameter> Parameters { 40 get { return Enumerable.Empty<IValueParameter>(); } 41 } 39 public abstract IEnumerable<IValueParameter> Parameters { get; } 42 40 43 protected List<IOperator> encodingOperators = new List<IOperator>();41 protected HashSet<IOperator> encodingOperators = new HashSet<IOperator>(new TypeEqualityComparer<IOperator>()); 44 42 [Storable] 45 43 public IEnumerable<IOperator> Operators { 46 44 get { return encodingOperators; } 47 pr otected set { encodingOperators = new List<IOperator>(value); }45 private set { encodingOperators = new HashSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); } 48 46 } 49 50 47 51 48 ISolutionCreator IEncoding.SolutionCreator { 52 49 get { return SolutionCreator; } 53 50 set { 54 if (!(value is T)) throw new ArgumentException( "???");51 if (!(value is T)) throw new ArgumentException(string.Format("Cannot assign the solution creator {0} to the encoding {1}.", value.GetType().GetPrettyName(), GetType().GetPrettyName())); 55 52 SolutionCreator = (T)value; 56 53 } … … 64 61 if (value == null) throw new ArgumentNullException("SolutionCreator must not be null."); 65 62 if (solutionCreator == value) return; 63 encodingOperators.Remove(solutionCreator); 64 encodingOperators.Add(value); 66 65 solutionCreator = value; 67 66 OnSolutionCreatorChanged(); … … 74 73 protected Encoding(Encoding<T> original, Cloner cloner) 75 74 : base(original, cloner) { 76 encodingOperators = original.Operators.Select(cloner.Clone).ToList();75 encodingOperators = new HashSet<IOperator>(original.Operators.Select(cloner.Clone)); 77 76 solutionCreator = cloner.Clone(original.solutionCreator); 78 77 } … … 80 79 81 80 81 public abstract void ConfigureOperators(IEnumerable<IOperator> operators); 82 public void ConfigureOperator(IOperator @operator) { ConfigureOperators(new[] { @operator }); } 82 83 83 public void ConfigureOperator(IOperator @operator) { 84 ConfigureOperators(new[] { @operator }); 85 } 86 public virtual void ConfigureOperators(IEnumerable<IOperator> operators) { 87 88 } 89 84 public event EventHandler SolutionCreatorChanged; 90 85 protected virtual void OnSolutionCreatorChanged() { 91 86 ConfigureOperator(SolutionCreator); 87 var handler = SolutionCreatorChanged; 88 if (handler != null) handler(this, EventArgs.Empty); 92 89 } 93 90
Note: See TracChangeset
for help on using the changeset viewer.