Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/13/15 15:00:15 (10 years ago)
Author:
abeham
Message:

#2174, #2282: merged revisions r11961,r11963,r11967,r11970,r11971,r11982,r11984,r11998,r12001,r12002,r12003,r12004,r11939,r11945,r11956,r11958,r11959,r11960,r11983,r11987,r11988,r11990,r11993,r11994,r11996,r11999,r12000 to stable

Location:
stable
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Optimization

  • stable/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs

    r11949 r12005  
    3333    ISingleObjectiveProblemDefinition, ISingleObjectiveHeuristicOptimizationProblem
    3434  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
    3551    [StorableConstructor]
    3652    protected SingleObjectiveBasicProblem(bool deserializing) : base(deserializing) { }
     
    4359    protected SingleObjectiveBasicProblem()
    4460      : 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 });
    4662      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem."));
    4763
     
    6884    }
    6985
     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    }
    7098
    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();
    75102    }
    76103
Note: See TracChangeset for help on using the changeset viewer.