Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17545


Ignore:
Timestamp:
05/19/20 09:59:57 (4 years ago)
Author:
abeham
Message:

#2521: Reverse behavior, parameters are not readonly by default, can be readonly if computed automatically

Location:
branches/2521_ProblemRefactoring
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorEncoding.cs

    r17544 r17545  
    6767    public BinaryVectorEncoding(string name, int length)
    6868      : base(name) {
    69       Parameters.Add(LengthParameter = new ValueParameter<IntValue>(Name + ".Length", new IntValue(length, @readonly: true)) { ReadOnly = true });
     69      Parameters.Add(LengthParameter = new ValueParameter<IntValue>(Name + ".Length", new IntValue(length)) { ReadOnly = true });
    7070     
    7171      SolutionCreator = new RandomBinaryVectorCreator();
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorMultiObjectiveProblem.cs

    r17544 r17545  
    2020#endregion
    2121
    22 using System;
    2322using System.Linq;
    2423using HEAL.Attic;
     
    3635    public IResultDefinition<ParetoFrontScatterPlot<BinaryVector>> BestResult { get { return BestResultParameter; } }
    3736    [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; }
    38     public IValueParameter<IntValue> DimensionParameter => DimensionRefParameter;
    3937
    4038    public int Dimension {
    41       get { return DimensionRefParameter.Value.Value; }
    42       set { DimensionRefParameter.Value.Value = value; }
     39      get { return Encoding.Length; }
     40      set { Encoding.Length = value; }
    4341    }
    4442
     
    9290
    9391    private void RegisterEventHandlers() {
    94       DimensionRefParameter.Value.ValueChanged += DimensionParameter_Value_ValueChanged;
    95     }
    96 
    97     private void DimensionParameter_Value_ValueChanged(object sender, EventArgs e) {
    98       DimensionOnChanged();
     92      Encoding.PropertyChanged += (sender, args) => {
     93        if (args.PropertyName == nameof(Encoding.Length))
     94          DimensionOnChanged();
     95      };
    9996    }
    10097
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Binary/3.3/DeceptiveTrapProblem.cs

    r17544 r17545  
    5858      Parameters.Add(TrapSizeParameter = new FixedValueParameter<IntValue>("Trap Size", "", new IntValue(7)));
    5959      Parameters.Add(NumberOfTrapsParameter = new FixedValueParameter<IntValue>("Number of Traps", "", new IntValue(7)));
    60       Dimension = TrapSize * NumberOfTraps;
     60      DimensionRefParameter.ForceValue(new IntValue(TrapSize * NumberOfTraps, @readonly: true));
    6161
    6262      RegisterEventHandlers();
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Binary/3.3/HIFFProblem.cs

    r17544 r17545  
    2727using HeuristicLab.Common;
    2828using HeuristicLab.Core;
    29 using HeuristicLab.Data;
    3029using HeuristicLab.Encodings.BinaryVectorEncoding;
    3130using HeuristicLab.Optimization;
     
    3938    public HIFFProblem() : base() {
    4039      Maximization = true;
    41       DimensionRefParameter.ForceValue(new IntValue(64, @readonly: false));
     40      Dimension = 64;
    4241    }
    4342
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Binary/3.3/OneMaxProblem.cs

    r17544 r17545  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
    27 using HeuristicLab.Data;
    2827using HeuristicLab.Encodings.BinaryVectorEncoding;
    2928using HeuristicLab.Optimization;
     
    3736    public OneMaxProblem() : base() {
    3837      Maximization = true;
    39       DimensionRefParameter.ForceValue(new IntValue(10, @readonly: false));
     38      Dimension = 10;
    4039      BestKnownQuality = Dimension;
    4140    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs

    r17544 r17545  
    9191      Parameters.Add(new OptionalValueParameter<BinaryVector>("BestKnownSolution", "The best known solution of this Knapsack instance."));
    9292
    93       Dimension = Weights.Length;
     93      DimensionRefParameter.ForceValue(new IntValue(Weights.Length, @readonly: true));
    9494      InitializeRandomKnapsackInstance();
    9595
Note: See TracChangeset for help on using the changeset viewer.