Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/19/19 09:09:45 (6 years ago)
Author:
gkronber
Message:

#2994: merged changesets r16740:16822 from trunk to branch

Location:
branches/2994-AutoDiffForIntervals
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • branches/2994-AutoDiffForIntervals

  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization

  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveBasicProblem.cs

    r16565 r16829  
    2121
    2222using System.Linq;
     23using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.Data;
    2627using HeuristicLab.Parameters;
    27 using HEAL.Attic;
    2828
    2929namespace HeuristicLab.Optimization {
     
    5959   
    6060    protected override void OnOperatorsChanged() {
    61       base.OnOperatorsChanged();
    6261      if (Encoding != null) {
    6362        PruneSingleObjectiveOperators(Encoding);
     
    6968        }
    7069      }
     70      base.OnOperatorsChanged();
    7171    }
    7272
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingCreator.cs

    r16565 r16829  
    2222using System;
    2323using System.Linq;
     24using HEAL.Attic;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    26 using HEAL.Attic;
     27using HeuristicLab.Parameters;
    2728
    2829namespace HeuristicLab.Optimization {
    2930  [Item("MultiEncodingCreator", "Contains solution creators that together create a multi-encoding.")]
    3031  [StorableType("E261B506-6F74-4BC4-8164-5ACE20FBC319")]
    31   public sealed class MultiEncodingCreator : MultiEncodingOperator<ISolutionCreator>, ISolutionCreator {
     32  public sealed class MultiEncodingCreator : MultiEncodingOperator<ISolutionCreator>, ISolutionCreator, IStochasticOperator {
     33    public ILookupParameter<IRandom> RandomParameter {
     34      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
     35    }
     36
     37    public override string OperatorPrefix => "Creator";
     38
    3239    [StorableConstructor]
    3340    private MultiEncodingCreator(StorableConstructorFlag _) : base(_) { }
    3441
    3542    private MultiEncodingCreator(MultiEncodingCreator original, Cloner cloner) : base(original, cloner) { }
    36     public MultiEncodingCreator() { }
     43    public MultiEncodingCreator() {
     44      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator used by the individual operators."));
     45    }
    3746
    3847    public override IDeepCloneable Clone(Cloner cloner) {
    3948      return new MultiEncodingCreator(this, cloner);
     49    }
     50
     51    [StorableHook(HookType.AfterDeserialization)]
     52    private void AfterDeserialization() {
     53      if (!Parameters.ContainsKey("Random")) {
     54        Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator used by the individual operators."));
     55      }
    4056    }
    4157
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingCrossover.cs

    r16565 r16829  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    24 using HEAL.Attic;
     25using HeuristicLab.Parameters;
    2526
    2627namespace HeuristicLab.Optimization {
    2728  [Item("MultiEncoding Crossover", "Applies different crossovers to cross a multi-encoding.")]
    2829  [StorableType("BB0A04E2-899D-460C-82A2-5E4CEEDE8996")]
    29   public sealed class MultiEncodingCrossover : MultiEncodingOperator<ICrossover>, ICrossover {
     30  public sealed class MultiEncodingCrossover : MultiEncodingOperator<ICrossover>, ICrossover, IStochasticOperator {
     31    public ILookupParameter<IRandom> RandomParameter {
     32      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
     33    }
     34
     35    public override string OperatorPrefix => "Crossover";
     36
    3037    [StorableConstructor]
    3138    private MultiEncodingCrossover(StorableConstructorFlag _) : base(_) { }
    3239    private MultiEncodingCrossover(MultiEncodingCrossover original, Cloner cloner) : base(original, cloner) { }
    33     public MultiEncodingCrossover() { }
     40    public MultiEncodingCrossover() {
     41      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator used by the individual operators."));
     42    }
    3443
    3544    public override IDeepCloneable Clone(Cloner cloner) { return new MultiEncodingCrossover(this, cloner); }
     45
     46    [StorableHook(HookType.AfterDeserialization)]
     47    private void AfterDeserialization() {
     48      if (!Parameters.ContainsKey("Random")) {
     49        Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator used by the individual operators."));
     50      }
     51    }
    3652  }
    3753}
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingManipulator.cs

    r16565 r16829  
    2020#endregion
    2121
     22using HEAL.Attic;
    2223using HeuristicLab.Common;
    2324using HeuristicLab.Core;
    24 using HEAL.Attic;
     25using HeuristicLab.Parameters;
    2526
    2627namespace HeuristicLab.Optimization {
    2728  [Item("MultiEncoding Manipulator", "Applies different manipulators to change a multi-encoding.")]
    2829  [StorableType("574D0530-47E8-4FD9-8AC8-B8EA2DE3C203")]
    29   public sealed class MultiEncodingManipulator : MultiEncodingOperator<IManipulator>, IManipulator {
     30  public sealed class MultiEncodingManipulator : MultiEncodingOperator<IManipulator>, IManipulator, IStochasticOperator {
     31    public ILookupParameter<IRandom> RandomParameter {
     32      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
     33    }
     34
     35    public override string OperatorPrefix => "Manipulator";
     36
    3037    [StorableConstructor]
    3138    private MultiEncodingManipulator(StorableConstructorFlag _) : base(_) { }
    3239    private MultiEncodingManipulator(MultiEncodingManipulator original, Cloner cloner)
    3340      : base(original, cloner) { }
    34     public MultiEncodingManipulator() { }
     41    public MultiEncodingManipulator() {
     42      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator used by the individual operators."));
     43    }
    3544
    3645    public override IDeepCloneable Clone(Cloner cloner) { return new MultiEncodingManipulator(this, cloner); }
    3746
     47    [StorableHook(HookType.AfterDeserialization)]
     48    private void AfterDeserialization() {
     49      if (!Parameters.ContainsKey("Random")) {
     50        Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator used by the individual operators."));
     51      }
     52    }
     53
    3854  }
    3955}
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/BasicProblems/Operators/MultiEncodingOperator.cs

    r16565 r16829  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Operators;
    2829using HeuristicLab.Parameters;
    29 using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Optimization {
     
    3939    }
    4040
     41    public abstract string OperatorPrefix { get; }
     42
    4143    [StorableConstructor]
    42     protected MultiEncodingOperator(StorableConstructorFlag _) : base(_) {
    43     }
    44 
     44    protected MultiEncodingOperator(StorableConstructorFlag _) : base(_) { }
    4545    protected MultiEncodingOperator(MultiEncodingOperator<T> original, Cloner cloner)
    4646      : base(original, cloner) {
     
    4949        encoding.OperatorsChanged += Encoding_OperatorsChanged;
    5050    }
    51 
    5251    protected MultiEncodingOperator() : base() { }
    5352
    5453    [StorableHook(HookType.AfterDeserialization)]
    5554    private void AfterDeserialization() {
    56       foreach (var encoding in encodings)
     55      foreach (var encoding in encodings) {
     56        // BackwardsCompatibility3.3
     57        #region Backwards compatible code, remove with 3.4
     58        if (Parameters.ContainsKey(encoding.Name) && !Parameters.ContainsKey(OperatorPrefix + "." + encoding.Name)) {
     59          var oldParam = (IConstrainedValueParameter<T>)Parameters[encoding.Name];
     60          var selected = oldParam.Value;
     61          Parameters.Remove(oldParam);
     62          var newParam = new ConstrainedValueParameter<T>(OperatorPrefix + "." + encoding.Name, new ItemSet<T>(oldParam.ValidValues));
     63          newParam.Value = selected;
     64          Parameters.Add(newParam);
     65          oldParam.ValidValues.Clear();
     66        }
     67        #endregion
    5768        encoding.OperatorsChanged += Encoding_OperatorsChanged;
     69      }
    5870    }
    5971
    60 
    6172    public override IOperation Apply() {
    62       var operations = Parameters.Select(p => p.ActualValue).OfType<IOperator>().Select(op => ExecutionContext.CreateOperation(op));
     73      var operations = Parameters.Select(p => p.ActualValue).OfType<IOperator>().Select(op => ExecutionContext.CreateChildOperation(op));
    6374      return new OperationCollection(operations);
    6475    }
    6576
    6677    public virtual void AddEncoding(IEncoding encoding) {
    67       if (Parameters.ContainsKey(encoding.Name)) throw new ArgumentException(string.Format("Encoding {0} was already added.", encoding.Name));
     78      if (Parameters.ContainsKey(OperatorPrefix + "." + encoding.Name)) throw new ArgumentException(string.Format("Encoding {0} was already added.", encoding.Name));
    6879
    6980      encodings.Add(encoding);
    7081      encoding.OperatorsChanged += Encoding_OperatorsChanged;
    7182
    72       var param = new ConstrainedValueParameter<T>(encoding.Name, new ItemSet<T>(encoding.Operators.OfType<T>()));
     83      var param = new ConstrainedValueParameter<T>(OperatorPrefix + "." + encoding.Name, new ItemSet<T>(encoding.Operators.OfType<T>()));
    7384      param.Value = param.ValidValues.First();
    7485      Parameters.Add(param);
     
    7889      if (!encodings.Remove(encoding)) throw new ArgumentException(string.Format("Encoding {0} was not added to the MultiEncoding.", encoding.Name));
    7990      encoding.OperatorsChanged -= Encoding_OperatorsChanged;
    80       return Parameters.Remove(encoding.Name);
     91      return Parameters.Remove(OperatorPrefix + "." + encoding.Name);
    8192    }
    8293
    8394    protected IConstrainedValueParameter<T> GetParameter(IEncoding encoding) {
    84       if (!Parameters.ContainsKey(encoding.Name)) throw new ArgumentException(string.Format("Encoding {0} was not added to the MultiEncoding.", encoding.Name));
     95      if (!Parameters.ContainsKey(OperatorPrefix + "." + encoding.Name)) throw new ArgumentException(string.Format("Encoding {0} was not added to the MultiEncoding.", encoding.Name));
    8596
    86       return (IConstrainedValueParameter<T>)Parameters[encoding.Name];
     97      return (IConstrainedValueParameter<T>)Parameters[OperatorPrefix + "." + encoding.Name];
    8798    }
    8899
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveBasicProblem.cs

    r16565 r16829  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Data;
    2829using HeuristicLab.Parameters;
    29 using HEAL.Attic;
    3030
    3131namespace HeuristicLab.Optimization {
     
    9595
    9696    protected override void OnOperatorsChanged() {
    97       base.OnOperatorsChanged();
    9897      if (Encoding != null) {
    9998        PruneMultiObjectiveOperators(Encoding);
     
    105104        }
    106105      }
     106      base.OnOperatorsChanged();
    107107    }
    108108
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/MetaOptimizers/BatchRun.cs

    r16565 r16829  
    112112    // BackwardsCompatibility3.3
    113113    #region Backwards compatible code (remove with 3.4)
    114     [Storable(AllowOneWay = true)]
     114    [Storable(OldName = "algorithm")]
    115115    private IAlgorithm algorithm {
    116116      set { optimizer = value; }
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/Problems/Problem.cs

    r16565 r16829  
    8484    // BackwardsCompatibility3.3
    8585    #region Backwards compatible code, remove with 3.4
    86     [Storable(Name = "Operators", AllowOneWay = true)]
     86    [Storable(OldName = "Operators")]
    8787    private IEnumerable<IOperator> StorableOperators {
    8888      set {
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/RunCollection.cs

    r16565 r16829  
    125125    // BackwardsCompatibility3.3
    126126    #region Backwards compatible code, remove with 3.4
    127     [Storable(AllowOneWay = true)]
     127    [Storable(OldName = "AlgorithmName")]
    128128    private string AlgorithmName {
    129129      set { optimizerName = value; }
Note: See TracChangeset for help on using the changeset viewer.