- Timestamp:
- 02/07/15 13:52:48 (10 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization/3.3/BasicProblems
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization/3.3/BasicProblems/BasicProblem.cs
r11949 r11970 86 86 private void RegisterEvents() { 87 87 EncodingParameter.ValueChanged += (o, e) => OnEncodingChanged(); 88 var multiEncoding = Encoding as MultiEncoding; 89 if (multiEncoding != null) multiEncoding.EncodingsChanged += MultiEncodingOnEncodingsChanged; 88 90 } 89 91 90 92 protected virtual void OnEncodingChanged() { 91 if (oldEncoding != null) AdaptEncodingOperators(oldEncoding, Encoding); 93 if (oldEncoding != null) { 94 AdaptEncodingOperators(oldEncoding, Encoding); 95 var oldMultiEncoding = oldEncoding as MultiEncoding; 96 if (oldMultiEncoding != null) 97 oldMultiEncoding.EncodingsChanged -= MultiEncodingOnEncodingsChanged; 98 } 92 99 oldEncoding = Encoding; 93 100 … … 104 111 //TODO register solution creator changed event, change access modifier to private 105 112 //((IValueParameter)solutionCreatorParam).ValueChanged += SolutionCreatorParameter_ValueChanged; 113 114 var multiEncoding = Encoding as MultiEncoding; 115 if (multiEncoding != null) multiEncoding.EncodingsChanged += MultiEncodingOnEncodingsChanged; 106 116 107 117 OnOperatorsChanged(); … … 141 151 } 142 152 153 protected virtual void MultiEncodingOnEncodingsChanged(object sender, EventArgs e) { 154 OnOperatorsChanged(); 155 } 143 156 } 144 157 } -
trunk/sources/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveMoveOperator.cs
r11961 r11970 21 21 22 22 namespace HeuristicLab.Optimization { 23 public interface ISingleObjectiveMoveOperator : IMoveOperator {23 public interface ISingleObjectiveMoveOperator : IMoveOperator, ISingleObjectiveOperator { 24 24 } 25 25 } -
trunk/sources/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/IMultiObjectiveAnalysisOperator.cs
r11949 r11970 24 24 25 25 namespace HeuristicLab.Optimization { 26 internal interface IMultiObjectiveAnalysisOperator : IEncodingOperator, IAnalyzer {26 internal interface IMultiObjectiveAnalysisOperator : IEncodingOperator, IAnalyzer, IMultiObjectiveOperator { 27 27 Action<Individual[], double[][], ResultCollection, IRandom> AnalyzeAction { get; set; } 28 28 } -
trunk/sources/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/internal/ISingleObjectiveAnalysisOperator.cs
r11961 r11970 24 24 25 25 namespace HeuristicLab.Optimization { 26 internal interface ISingleObjectiveAnalysisOperator : IEncodingOperator {26 internal interface ISingleObjectiveAnalysisOperator : IEncodingOperator, ISingleObjectiveOperator { 27 27 Action<Individual[], double[], ResultCollection, IRandom> AnalyzeAction { get; set; } 28 28 } -
trunk/sources/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveBasicProblem.cs
r11949 r11970 63 63 } 64 64 65 protected override void OnOperatorsChanged() { 66 base.OnOperatorsChanged(); 67 if (Encoding != null) { 68 PruneSingleObjectiveOperators(Encoding); 69 var multiEncoding = Encoding as MultiEncoding; 70 if (multiEncoding != null) { 71 foreach (var encoding in multiEncoding.Encodings.ToList()) { 72 PruneSingleObjectiveOperators(encoding); 73 } 74 } 75 } 76 } 77 78 private void PruneSingleObjectiveOperators(IEncoding encoding) { 79 if (encoding != null && encoding.Operators.Any(x => x is ISingleObjectiveOperator && !(x is IMultiObjectiveOperator))) 80 encoding.Operators = encoding.Operators.Where(x => !(x is ISingleObjectiveOperator) || x is IMultiObjectiveOperator).ToList(); 81 } 82 65 83 protected override void OnEvaluatorChanged() { 66 84 base.OnEvaluatorChanged(); -
trunk/sources/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs
r11949 r11970 75 75 } 76 76 77 protected override void OnOperatorsChanged() { 78 base.OnOperatorsChanged(); 79 if (Encoding != null) { 80 PruneMultiObjectiveOperators(Encoding); 81 var multiEncoding = Encoding as MultiEncoding; 82 if (multiEncoding != null) { 83 foreach (var encoding in multiEncoding.Encodings.ToList()) { 84 PruneMultiObjectiveOperators(encoding); 85 } 86 } 87 } 88 } 89 90 private void PruneMultiObjectiveOperators(IEncoding encoding) { 91 if (encoding.Operators.Any(x => x is IMultiObjectiveOperator && !(x is ISingleObjectiveOperator))) 92 encoding.Operators = encoding.Operators.Where(x => !(x is IMultiObjectiveOperator) || x is ISingleObjectiveOperator).ToList(); 93 } 94 77 95 protected override void OnEvaluatorChanged() { 78 96 base.OnEvaluatorChanged();
Note: See TracChangeset
for help on using the changeset viewer.