Changeset 12005 for stable/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs
- Timestamp:
- 02/13/15 15:00:15 (10 years ago)
- Location:
- stable
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 11939,11945,11956,11958-11961,11963,11967,11970-11971,11982-11984,11987-11988,11990,11993-11994,11996,11998-12004
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs
r11949 r12005 33 33 ISingleObjectiveProblemDefinition, ISingleObjectiveHeuristicOptimizationProblem 34 34 where TEncoding : class, IEncoding { 35 36 protected IValueParameter<DoubleValue> BestKnownQualityParameter { 37 get { return (IValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 38 } 39 40 public double BestKnownQuality { 41 get { 42 if (BestKnownQualityParameter.Value == null) return double.NaN; 43 return BestKnownQualityParameter.Value.Value; 44 } 45 set { 46 if (BestKnownQualityParameter.Value == null) BestKnownQualityParameter.Value = new DoubleValue(value); 47 else BestKnownQualityParameter.Value.Value = value; 48 } 49 } 50 35 51 [StorableConstructor] 36 52 protected SingleObjectiveBasicProblem(bool deserializing) : base(deserializing) { } … … 43 59 protected SingleObjectiveBasicProblem() 44 60 : base() { 45 Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", new BoolValue()));61 Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden = true }); 46 62 Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem.")); 47 63 … … 68 84 } 69 85 86 protected override void OnOperatorsChanged() { 87 base.OnOperatorsChanged(); 88 if (Encoding != null) { 89 PruneMultiObjectiveOperators(Encoding); 90 var multiEncoding = Encoding as MultiEncoding; 91 if (multiEncoding != null) { 92 foreach (var encoding in multiEncoding.Encodings.ToList()) { 93 PruneMultiObjectiveOperators(encoding); 94 } 95 } 96 } 97 } 70 98 71 protected override void OnEncodingChanged() { 72 base.OnEncodingChanged(); 73 var max = (BoolValue)Parameters["Maximization"].ActualValue; 74 max.Value = Maximization; 99 private void PruneMultiObjectiveOperators(IEncoding encoding) { 100 if (encoding.Operators.Any(x => x is IMultiObjectiveOperator && !(x is ISingleObjectiveOperator))) 101 encoding.Operators = encoding.Operators.Where(x => !(x is IMultiObjectiveOperator) || x is ISingleObjectiveOperator).ToList(); 75 102 } 76 103
Note: See TracChangeset
for help on using the changeset viewer.