Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17567 for branches


Ignore:
Timestamp:
05/28/20 14:41:43 (4 years ago)
Author:
abeham
Message:

#2521: work in progress

Location:
branches/2521_ProblemRefactoring
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Core/3.3/Interfaces/IValueParameter.cs

    r17317 r17567  
    3737  public interface IValueParameter<T> : IValueParameter where T : class, IItem {
    3838    new T Value { get; set; }
    39 
    40     /// <summary>
    41     /// Sets property <see cref="Value"/> regardless of ReadOnly state
    42     /// </summary>
    43     /// <param name="value">The value to set.</param>
    44     void ForceValue(T value);
    4539  }
    4640}
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorEncoding.cs

    r17546 r17567  
    4444      set {
    4545        if (Length == value) return;
    46         LengthParameter.ForceValue(new IntValue(value, @readonly: LengthParameter.Value.ReadOnly));
     46        LengthParameter.Value = new IntValue(value, @readonly: LengthParameter.Value.ReadOnly);
    4747      }
    4848    }
     
    107107
    108108    public override void ConfigureOperators(IEnumerable<IItem> operators) {
     109      base.ConfigureOperators(operators);
    109110      ConfigureCreators(operators.OfType<IBinaryVectorCreator>());
    110111      ConfigureCrossovers(operators.OfType<IBinaryVectorCrossover>());
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorMultiObjectiveProblem.cs

    r17545 r17567  
    3737
    3838    public int Dimension {
    39       get { return Encoding.Length; }
    40       set { Encoding.Length = value; }
     39      get { return DimensionRefParameter.Value.Value; }
    4140    }
    4241
     
    9089
    9190    private void RegisterEventHandlers() {
    92       Encoding.PropertyChanged += (sender, args) => {
    93         if (args.PropertyName == nameof(Encoding.Length))
    94           DimensionOnChanged();
    95       };
     91      IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged);
    9692    }
    9793
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs

    r17544 r17567  
    1 
    2 #region License Information
     1#region License Information
    32/* HeuristicLab
    43 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     
    3938
    4039    public int Dimension {
    41       get { return Encoding.Length; }
    42       set { Encoding.Length = value; }
     40      get { return DimensionRefParameter.Value.Value; }
    4341    }
    4442
     
    8684
    8785    private void RegisterEventHandlers() {
    88       Encoding.PropertyChanged += (sender, args) => {
    89         if (args.PropertyName == nameof(Encoding.Length))
    90           DimensionOnChanged();
    91       };
     86      IntValueParameterChangeHandler.Create(DimensionRefParameter, DimensionOnChanged);
    9287    }
    9388
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorEncoding.cs

    r17226 r17567  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.Parameters;
    30 using HEAL.Attic;
    3131using HeuristicLab.PluginInfrastructure;
    3232
     
    188188
    189189    public override void ConfigureOperators(IEnumerable<IItem> operators) {
     190      base.ConfigureOperators(operators);
    190191      ConfigureBoundedOperators(operators.OfType<IBoundedIntegerVectorOperator>());
    191192      ConfigureCreators(operators.OfType<IIntegerVectorCreator>());
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageEncoding.cs

    r17226 r17567  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.Parameters;
    30 using HEAL.Attic;
    3131using HeuristicLab.PluginInfrastructure;
    3232
     
    124124
    125125    public override void ConfigureOperators(IEnumerable<IItem> operators) {
     126      base.ConfigureOperators(operators);
    126127      ConfigureCreators(operators.OfType<ILinearLinkageCreator>());
    127128      ConfigureCrossovers(operators.OfType<ILinearLinkageCrossover>());
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.PermutationEncoding/3.3/PermutationEncoding.cs

    r17226 r17567  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.Parameters;
    30 using HEAL.Attic;
    3131using HeuristicLab.PluginInfrastructure;
    3232
     
    164164
    165165    public override void ConfigureOperators(IEnumerable<IItem> operators) {
     166      base.ConfigureOperators(operators);
    166167      ConfigureCreators(operators.OfType<IPermutationCreator>());
    167168      ConfigureCrossovers(operators.OfType<IPermutationCrossover>());
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorEncoding.cs

    r17226 r17567  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.Parameters;
    30 using HEAL.Attic;
    3131using HeuristicLab.PluginInfrastructure;
    3232
     
    201201
    202202    public override void ConfigureOperators(IEnumerable<IItem> operators) {
     203      base.ConfigureOperators(operators);
    203204      ConfigureCreators(operators.OfType<IRealVectorCreator>());
    204205      ConfigureCrossovers(operators.OfType<IRealVectorCrossover>());
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding.cs

    r17461 r17567  
    163163
    164164    public override void ConfigureOperators(IEnumerable<IItem> operators) {
     165      base.ConfigureOperators(operators);
    165166      ConfigureCreators(operators.OfType<IScheduleCreator<TSchedule>>());
    166167      ConfigureCrossovers(operators.OfType<IScheduleCrossover>());
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs

    r17226 r17567  
    116116
    117117    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    }
    119127
    120128    public event EventHandler SolutionCreatorChanged;
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs

    r17320 r17567  
    9595      protected set {
    9696        if (MaximizationParameter.Value.SequenceEqual(value)) return;
    97         MaximizationParameter.ForceValue(new BoolArray(value, @readonly: true));
     97        MaximizationParameter.Value = new BoolArray(value, @readonly: true);
    9898        OnMaximizationChanged();
    9999      }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs

    r17546 r17567  
    6161      protected set {
    6262        if (Maximization == value) return;
    63         MaximizationParameter.ForceValue(new BoolValue(value, @readonly: true));
     63        MaximizationParameter.Value = new BoolValue(value, @readonly: true);
    6464      }
    6565    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/FixedValueParameter.cs

    r17532 r17567  
    3939    }
    4040
    41     public override void ForceValue(T value) {
    42       throw new NotSupportedException("FixedValueParameters do not support setting their value.");
    43     }
    44 
    4541    [StorableConstructor]
    4642    protected FixedValueParameter(StorableConstructorFlag _) : base(_) { }
  • branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs

    r17317 r17567  
    4949      }
    5050    }
    51     public virtual void ForceValue(T value) {
    52       DoSetValue(value);
    53     }
    5451    private void DoSetValue(T value) {
    5552      if (value != this.value) {
  • branches/2521_ProblemRefactoring/HeuristicLab.Parameters/3.3/ReferenceParameter.cs

    r17566 r17567  
    166166      return new ReferenceParameter<T>(this, cloner);
    167167    }
    168 
    169     public void ForceValue(T value) { ReferencedParameter.ForceValue(value); }
    170168  }
    171169
     
    195193      return new ReferenceParameter<T, U>(this, cloner);
    196194    }
    197 
    198     public void ForceValue(T value) { ReferencedParameter.ForceValue(value); }
    199195  }
    200196}
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Binary/3.3/DeceptiveTrapProblem.cs

    r17546 r17567  
    4040    [Storable] public IFixedValueParameter<IntValue> NumberOfTrapsParameter { get; private set; }
    4141
     42    public new int Dimension {
     43      get { return base.Dimension; }
     44      set { DimensionRefParameter.Value.Value = value; }
     45    }
     46
    4247    public int TrapSize {
    4348      get { return TrapSizeParameter.Value.Value; }
     
    5863      Parameters.Add(TrapSizeParameter = new FixedValueParameter<IntValue>("Trap Size", "", new IntValue(7)));
    5964      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);
    6166
    6267      RegisterEventHandlers();
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Binary/3.3/HIFFProblem.cs

    r17545 r17567  
    3535  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 220)]
    3636  public class HIFFProblem : BinaryVectorProblem {
     37
     38    public new int Dimension {
     39      get { return base.Dimension; }
     40      set { DimensionRefParameter.Value.Value = value; }
     41    }
    3742
    3843    public HIFFProblem() : base() {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Binary/3.3/OneMaxProblem.cs

    r17545 r17567  
    3434  public class OneMaxProblem : BinaryVectorProblem {
    3535
     36    public new int Dimension {
     37      get { return base.Dimension; }
     38      set { DimensionRefParameter.Value.Value = value; }
     39    }
     40
    3641    public OneMaxProblem() : base() {
    3742      Maximization = true;
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/ExternalEvaluationProblemInstances.cs

    r17544 r17567  
    5959      : base(new BinaryVectorEncoding()) {
    6060      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);
    6262      // TODO: Add and parameterize additional operators,
    6363    }
     
    277277      : base(new BinaryVectorEncoding()) {
    278278      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);
    280280      // TODO: Add and parameterize additional operators,
    281281    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/SingleObjectiveExternalEvaluationProblem.cs

    r17546 r17567  
    9393    public ExternalEvaluationProblem(TEncoding encoding)
    9494      : base(encoding) {
    95       MaximizationParameter.ForceValue(new BoolValue()); // is a read-only bool value in base class
     95      MaximizationParameter.Value = new BoolValue(); // is a read-only bool value in base class TODO: change to set ReadOnly false
    9696      Parameters.Add(new OptionalValueParameter<EvaluationCache>("Cache", "Cache of previously evaluated solutions."));
    9797      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  
    5656
    5757    #region Properties
     58    public new int Dimension {
     59      get { return base.Dimension; }
     60      set { DimensionRefParameter.Value.Value = value; }
     61    }
    5862    public int KnapsackCapacity {
    5963      get { return KnapsackCapacityParameter.Value.Value; }
     
    9195      Parameters.Add(new OptionalValueParameter<BinaryVector>("BestKnownSolution", "The best known solution of this Knapsack instance."));
    9296
    93       DimensionRefParameter.ForceValue(new IntValue(Weights.Length, @readonly: true));
     97      DimensionRefParameter.Value = new IntValue(Weights.Length, @readonly: true);
    9498      InitializeRandomKnapsackInstance();
    9599
Note: See TracChangeset for help on using the changeset viewer.