- Timestamp:
- 01/13/15 18:47:19 (10 years ago)
- Location:
- branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/Encoding.cs
r11737 r11753 38 38 39 39 protected HashSet<IOperator> encodingOperators = new HashSet<IOperator>(new TypeEqualityComparer<IOperator>()); 40 [Storable] 40 41 [Storable(Name = "Operators")] 42 private IEnumerable<IOperator> StorableOperators { 43 get { return encodingOperators; } 44 set { encodingOperators = new HashSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); ; } 45 } 46 41 47 public IEnumerable<IOperator> Operators { 42 48 get { return encodingOperators; } 43 private set { encodingOperators = new HashSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); } 49 set { 50 if (!value.OfType<T>().Any()) 51 throw new ArgumentException("The provided operators contain no suitable solution creator"); 52 encodingOperators = new HashSet<IOperator>(value, new TypeEqualityComparer<IOperator>()); 53 54 T newSolutionCreator = (T)encodingOperators.FirstOrDefault(o => o.GetType() == solutionCreator.GetType()); 55 if (newSolutionCreator == null) newSolutionCreator = encodingOperators.OfType<T>().First(); 56 SolutionCreator = newSolutionCreator; 57 OnOperatorsChanged(); 58 } 44 59 } 45 60 … … 90 105 if (handler != null) handler(this, EventArgs.Empty); 91 106 } 107 108 public event EventHandler OperatorsChanged; 109 protected virtual void OnOperatorsChanged() { 110 ConfigureOperators(Operators); 111 var handler = OperatorsChanged; 112 if (handler != null) handler(this, EventArgs.Empty); 113 } 92 114 } 93 115 } -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/IntegerEncoding.cs
r11746 r11753 174 174 } 175 175 private void DiscoverOperators() { 176 var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, true, false, false); 176 var pluginDescription = ApplicationManager.Manager.GetDeclaringPlugin(typeof(IIntegerVectorOperator)); 177 var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, pluginDescription, true, false, false); 177 178 var operators = discoveredTypes.Select(t => (IOperator)Activator.CreateInstance(t)); 178 179 var newOperators = operators.Except(Operators, new TypeEqualityComparer<IOperator>()).ToList(); -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/MultiEncoding.cs
r11619 r11753 89 89 90 90 public override void ConfigureOperators(IEnumerable<IOperator> operators) { 91 92 91 } 93 92 } -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/PermutationEncoding.cs
r11746 r11753 148 148 } 149 149 private void DiscoverOperators() { 150 var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, true, false, false); 150 var pluginDescription = ApplicationManager.Manager.GetDeclaringPlugin(typeof(IPermutationOperator)); 151 var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, pluginDescription, true, false, false); 151 152 var operators = discoveredTypes.Select(t => (IOperator)Activator.CreateInstance(t)); 152 153 var newOperators = operators.Except(Operators, new TypeEqualityComparer<IOperator>()).ToList(); -
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/RealEncoding.cs
r11739 r11753 173 173 } 174 174 private void DiscoverOperators() { 175 var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, true, false, false); 175 var pluginDescription = ApplicationManager.Manager.GetDeclaringPlugin(typeof(IRealVectorOperator)); 176 var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, pluginDescription, true, false, false); 176 177 var operators = discoveredTypes.Select(t => (IOperator)Activator.CreateInstance(t)); 177 178 var newOperators = operators.Except(Operators, new TypeEqualityComparer<IOperator>()).ToList();
Note: See TracChangeset
for help on using the changeset viewer.