- Timestamp:
- 09/26/19 10:02:47 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs
r17226 r17270 38 38 where TEncodedSolution : class, IEncodedSolution { 39 39 40 protected IValueParameter<DoubleValue> BestKnownQualityParameter { 41 get { return (IValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 42 } 43 44 protected IFixedValueParameter<BoolValue> MaximizationParameter { 45 get { return (IFixedValueParameter<BoolValue>)Parameters["Maximization"]; } 46 } 40 [Storable] protected IValueParameter<DoubleValue> BestKnownQualityParameter { get; set; } 41 [Storable] protected IValueParameter<BoolValue> MaximizationParameter { get; set; } 47 42 48 43 public double BestKnownQuality { … … 61 56 } 62 57 58 public bool Maximization { 59 get { return MaximizationParameter.Value.Value; } 60 protected set { 61 if (MaximizationParameter.Value.Value == value) return; 62 MaximizationParameter.Value = new BoolValue(value).AsReadOnly(); 63 } 64 } 65 63 66 [StorableConstructor] 64 67 protected SingleObjectiveProblem(StorableConstructorFlag _) : base(_) { } … … 66 69 protected SingleObjectiveProblem(SingleObjectiveProblem<TEncoding, TEncodedSolution> original, Cloner cloner) 67 70 : base(original, cloner) { 71 BestKnownQualityParameter = cloner.Clone(original.BestKnownQualityParameter); 72 MaximizationParameter = cloner.Clone(original.MaximizationParameter); 68 73 ParameterizeOperators(); 69 74 } 70 75 71 76 protected SingleObjectiveProblem() : base() { 72 Parameters.Add( new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden= true });73 Parameters.Add( new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem."));77 Parameters.Add(MaximizationParameter = new ValueParameter<BoolValue>("Maximization", "Whether the problem should be maximized (True) or minimized (False).", new BoolValue(false).AsReadOnly()) { Hidden = true, ReadOnly = true }); 78 Parameters.Add(BestKnownQualityParameter = new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem.")); 74 79 75 80 Operators.Add(Evaluator); … … 84 89 85 90 protected SingleObjectiveProblem(TEncoding encoding) : base(encoding) { 86 Parameters.Add( new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden= true });87 Parameters.Add( new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem."));91 Parameters.Add(MaximizationParameter = new ValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", new BoolValue(false).AsReadOnly()) { Hidden = true, ReadOnly = true }); 92 Parameters.Add(BestKnownQualityParameter = new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem.")); 88 93 89 94 Operators.Add(Evaluator); … … 102 107 } 103 108 104 public abstract bool Maximization { get; }105 109 public abstract double Evaluate(TEncodedSolution solution, IRandom random); 106 110 public virtual void Analyze(TEncodedSolution[] solutions, double[] qualities, ResultCollection results, IRandom random) { }
Note: See TracChangeset
for help on using the changeset viewer.