Changeset 17567 for branches/2521_ProblemRefactoring
- Timestamp:
- 05/28/20 14:41:43 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Core/3.3/Interfaces/IValueParameter.cs
r17317 r17567 37 37 public interface IValueParameter<T> : IValueParameter where T : class, IItem { 38 38 new T Value { get; set; } 39 40 /// <summary>41 /// Sets property <see cref="Value"/> regardless of ReadOnly state42 /// </summary>43 /// <param name="value">The value to set.</param>44 void ForceValue(T value);45 39 } 46 40 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorEncoding.cs
r17546 r17567 44 44 set { 45 45 if (Length == value) return; 46 LengthParameter. ForceValue(new IntValue(value, @readonly: LengthParameter.Value.ReadOnly));46 LengthParameter.Value = new IntValue(value, @readonly: LengthParameter.Value.ReadOnly); 47 47 } 48 48 } … … 107 107 108 108 public override void ConfigureOperators(IEnumerable<IItem> operators) { 109 base.ConfigureOperators(operators); 109 110 ConfigureCreators(operators.OfType<IBinaryVectorCreator>()); 110 111 ConfigureCrossovers(operators.OfType<IBinaryVectorCrossover>()); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorMultiObjectiveProblem.cs
r17545 r17567 37 37 38 38 public int Dimension { 39 get { return Encoding.Length; } 40 set { Encoding.Length = value; } 39 get { return DimensionRefParameter.Value.Value; } 41 40 } 42 41 … … 90 89 91 90 private void RegisterEventHandlers() { 92 Encoding.PropertyChanged += (sender, args) => { 93 if (args.PropertyName == nameof(Encoding.Length)) 94 DimensionOnChanged(); 95 }; 91 IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged); 96 92 } 97 93 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs
r17544 r17567 1 2 #region License Information 1 #region License Information 3 2 /* HeuristicLab 4 3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL) … … 39 38 40 39 public int Dimension { 41 get { return Encoding.Length; } 42 set { Encoding.Length = value; } 40 get { return DimensionRefParameter.Value.Value; } 43 41 } 44 42 … … 86 84 87 85 private void RegisterEventHandlers() { 88 Encoding.PropertyChanged += (sender, args) => { 89 if (args.PropertyName == nameof(Encoding.Length)) 90 DimensionOnChanged(); 91 }; 86 IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged); 92 87 } 93 88 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorEncoding.cs
r17226 r17567 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Parameters; 30 using HEAL.Attic;31 31 using HeuristicLab.PluginInfrastructure; 32 32 … … 188 188 189 189 public override void ConfigureOperators(IEnumerable<IItem> operators) { 190 base.ConfigureOperators(operators); 190 191 ConfigureBoundedOperators(operators.OfType<IBoundedIntegerVectorOperator>()); 191 192 ConfigureCreators(operators.OfType<IIntegerVectorCreator>()); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageEncoding.cs
r17226 r17567 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Parameters; 30 using HEAL.Attic;31 31 using HeuristicLab.PluginInfrastructure; 32 32 … … 124 124 125 125 public override void ConfigureOperators(IEnumerable<IItem> operators) { 126 base.ConfigureOperators(operators); 126 127 ConfigureCreators(operators.OfType<ILinearLinkageCreator>()); 127 128 ConfigureCrossovers(operators.OfType<ILinearLinkageCrossover>()); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEncoding.cs
r17226 r17567 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Parameters; 30 using HEAL.Attic;31 31 using HeuristicLab.PluginInfrastructure; 32 32 … … 164 164 165 165 public override void ConfigureOperators(IEnumerable<IItem> operators) { 166 base.ConfigureOperators(operators); 166 167 ConfigureCreators(operators.OfType<IPermutationCreator>()); 167 168 ConfigureCrossovers(operators.OfType<IPermutationCrossover>()); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorEncoding.cs
r17226 r17567 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Parameters; 30 using HEAL.Attic;31 31 using HeuristicLab.PluginInfrastructure; 32 32 … … 201 201 202 202 public override void ConfigureOperators(IEnumerable<IItem> operators) { 203 base.ConfigureOperators(operators); 203 204 ConfigureCreators(operators.OfType<IRealVectorCreator>()); 204 205 ConfigureCrossovers(operators.OfType<IRealVectorCrossover>()); -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding.cs
r17461 r17567 163 163 164 164 public override void ConfigureOperators(IEnumerable<IItem> operators) { 165 base.ConfigureOperators(operators); 165 166 ConfigureCreators(operators.OfType<IScheduleCreator<TSchedule>>()); 166 167 ConfigureCrossovers(operators.OfType<IScheduleCrossover>()); -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs
r17226 r17567 116 116 117 117 public void ConfigureOperator(IItem @operator) { ConfigureOperators(new[] { @operator }); } 118 public abstract void ConfigureOperators(IEnumerable<IItem> operators); 118 public virtual void ConfigureOperators(IEnumerable<IItem> operators) { 119 ConfigureSingleObjectiveImprovementOperators(operators.OfType<ISingleObjectiveImprovementOperator>()); 120 } 121 122 protected virtual void ConfigureSingleObjectiveImprovementOperators(IEnumerable<ISingleObjectiveImprovementOperator> operators) { 123 foreach (var op in operators) { 124 op.SolutionParameter.ActualName = Name; 125 } 126 } 119 127 120 128 public event EventHandler SolutionCreatorChanged; -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs
r17320 r17567 95 95 protected set { 96 96 if (MaximizationParameter.Value.SequenceEqual(value)) return; 97 MaximizationParameter. ForceValue(new BoolArray(value, @readonly: true));97 MaximizationParameter.Value = new BoolArray(value, @readonly: true); 98 98 OnMaximizationChanged(); 99 99 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs
r17546 r17567 61 61 protected set { 62 62 if (Maximization == value) return; 63 MaximizationParameter. ForceValue(new BoolValue(value, @readonly: true));63 MaximizationParameter.Value = new BoolValue(value, @readonly: true); 64 64 } 65 65 } -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/FixedValueParameter.cs
r17532 r17567 39 39 } 40 40 41 public override void ForceValue(T value) {42 throw new NotSupportedException("FixedValueParameters do not support setting their value.");43 }44 45 41 [StorableConstructor] 46 42 protected FixedValueParameter(StorableConstructorFlag _) : base(_) { } -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs
r17317 r17567 49 49 } 50 50 } 51 public virtual void ForceValue(T value) {52 DoSetValue(value);53 }54 51 private void DoSetValue(T value) { 55 52 if (value != this.value) { -
branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ReferenceParameter.cs
r17566 r17567 166 166 return new ReferenceParameter<T>(this, cloner); 167 167 } 168 169 public void ForceValue(T value) { ReferencedParameter.ForceValue(value); }170 168 } 171 169 … … 195 193 return new ReferenceParameter<T, U>(this, cloner); 196 194 } 197 198 public void ForceValue(T value) { ReferencedParameter.ForceValue(value); }199 195 } 200 196 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Binary/3.3/DeceptiveTrapProblem.cs
r17546 r17567 40 40 [Storable] public IFixedValueParameter<IntValue> NumberOfTrapsParameter { get; private set; } 41 41 42 public new int Dimension { 43 get { return base.Dimension; } 44 set { DimensionRefParameter.Value.Value = value; } 45 } 46 42 47 public int TrapSize { 43 48 get { return TrapSizeParameter.Value.Value; } … … 58 63 Parameters.Add(TrapSizeParameter = new FixedValueParameter<IntValue>("Trap Size", "", new IntValue(7))); 59 64 Parameters.Add(NumberOfTrapsParameter = new FixedValueParameter<IntValue>("Number of Traps", "", new IntValue(7))); 60 DimensionRefParameter. ForceValue(new IntValue(TrapSize * NumberOfTraps, @readonly: true));65 DimensionRefParameter.Value = new IntValue(TrapSize * NumberOfTraps); 61 66 62 67 RegisterEventHandlers(); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Binary/3.3/HIFFProblem.cs
r17545 r17567 35 35 [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 220)] 36 36 public class HIFFProblem : BinaryVectorProblem { 37 38 public new int Dimension { 39 get { return base.Dimension; } 40 set { DimensionRefParameter.Value.Value = value; } 41 } 37 42 38 43 public HIFFProblem() : base() { -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Binary/3.3/OneMaxProblem.cs
r17545 r17567 34 34 public class OneMaxProblem : BinaryVectorProblem { 35 35 36 public new int Dimension { 37 get { return base.Dimension; } 38 set { DimensionRefParameter.Value.Value = value; } 39 } 40 36 41 public OneMaxProblem() : base() { 37 42 Maximization = true; -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/ExternalEvaluationProblemInstances.cs
r17544 r17567 59 59 : base(new BinaryVectorEncoding()) { 60 60 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the vector.", Encoding.LengthParameter)); 61 DimensionRefParameter. ForceValue(new IntValue(Dimension, @readonly: false));61 DimensionRefParameter.Value = new IntValue(Dimension, @readonly: false); 62 62 // TODO: Add and parameterize additional operators, 63 63 } … … 277 277 : base(new BinaryVectorEncoding()) { 278 278 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the vector.", Encoding.LengthParameter)); 279 DimensionRefParameter. ForceValue(new IntValue(Dimension, @readonly: false));279 DimensionRefParameter.Value = new IntValue(Dimension, @readonly: false); 280 280 // TODO: Add and parameterize additional operators, 281 281 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/SingleObjectiveExternalEvaluationProblem.cs
r17546 r17567 93 93 public ExternalEvaluationProblem(TEncoding encoding) 94 94 : base(encoding) { 95 MaximizationParameter. ForceValue(new BoolValue()); // is a read-only bool value in base class95 MaximizationParameter.Value = new BoolValue(); // is a read-only bool value in base class TODO: change to set ReadOnly false 96 96 Parameters.Add(new OptionalValueParameter<EvaluationCache>("Cache", "Cache of previously evaluated solutions.")); 97 97 Parameters.Add(new ValueParameter<CheckedItemCollection<IEvaluationServiceClient>>("Clients", "The clients that are used to communicate with the external application.", new CheckedItemCollection<IEvaluationServiceClient>() { new EvaluationServiceClient() })); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs
r17545 r17567 56 56 57 57 #region Properties 58 public new int Dimension { 59 get { return base.Dimension; } 60 set { DimensionRefParameter.Value.Value = value; } 61 } 58 62 public int KnapsackCapacity { 59 63 get { return KnapsackCapacityParameter.Value.Value; } … … 91 95 Parameters.Add(new OptionalValueParameter<BinaryVector>("BestKnownSolution", "The best known solution of this Knapsack instance.")); 92 96 93 DimensionRefParameter. ForceValue(new IntValue(Weights.Length, @readonly: true));97 DimensionRefParameter.Value = new IntValue(Weights.Length, @readonly: true); 94 98 InitializeRandomKnapsackInstance(); 95 99
Note: See TracChangeset
for help on using the changeset viewer.