Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/19 15:38:16 (5 years ago)
Author:
gkronber
Message:

#2994: merged r16839:16910 from trunk to branch

Location:
branches/2994-AutoDiffForIntervals
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2994-AutoDiffForIntervals

  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization

  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/Algorithms/BasicAlgorithm.cs

    r16565 r16911  
    3636
    3737    public abstract bool SupportsPause { get; }
     38    public virtual bool SupportsStop {
     39      get { return true; }
     40    }
    3841
    3942    [Storable]
     
    106109      // CancellationToken.ThrowIfCancellationRequested() must be called from within the Run method, otherwise stop does nothing
    107110      // alternatively check the IsCancellationRequested property of the cancellation token
     111      if (!SupportsStop)
     112        throw new NotSupportedException("Stop is not supported by this algorithm.");
     113
    108114      base.Stop();
    109115      if (ExecutionState == ExecutionState.Paused) OnStopped();
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/BasicProblems/BasicProblem.cs

    r16565 r16911  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
     28using HeuristicLab.Data;
    2729using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2930
    3031namespace HeuristicLab.Optimization {
     
    157158      OnOperatorsChanged();
    158159    }
     160
     161    protected override IEnumerable<KeyValuePair<string, IItem>> GetCollectedValues(IValueParameter param) {
     162      if (param.Value == null) yield break;
     163      if (param.GetsCollected) {
     164        if (param == EncodingParameter) // store only the name of the encoding
     165          yield return new KeyValuePair<string, IItem>(String.Empty, new StringValue(EncodingParameter.Value.Name));
     166        else yield return new KeyValuePair<string, IItem>(String.Empty, param.Value);
     167      }
     168      var parameterizedItem = param.Value as IParameterizedItem;
     169      if (parameterizedItem != null) {
     170        var children = new Dictionary<string, IItem>();
     171        parameterizedItem.CollectParameterValues(children);
     172        foreach (var child in children) yield return child;
     173      }
     174    }
    159175  }
    160176}
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs

    r16565 r16911  
    2323using System.Collections.Generic;
    2424using System.Linq;
     25using HEAL.Attic;
    2526using HeuristicLab.Common;
    2627using HeuristicLab.Core;
    2728using HeuristicLab.Parameters;
    28 using HEAL.Attic;
    2929
    3030namespace HeuristicLab.Optimization {
     
    9292    protected Encoding(string name)
    9393      : base(name) {
    94       Parameters.Add(new FixedValueParameter<ReadOnlyItemSet<IOperator>>(name + ".Operators", "The operators that the encoding specifies.", encodingOperators.AsReadOnly()));
     94      Parameters.Add(new FixedValueParameter<ReadOnlyItemSet<IOperator>>(name + ".Operators", "The operators that the encoding specifies.", encodingOperators.AsReadOnly()) {
     95        GetsCollected = false
     96      });
    9597    }
    9698
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/Problems/Problem.cs

    r16829 r16911  
    2323using System.Collections.Generic;
    2424using System.Drawing;
     25using HEAL.Attic;
    2526using HeuristicLab.Collections;
    2627using HeuristicLab.Common;
     
    2829using HeuristicLab.Data;
    2930using HeuristicLab.Parameters;
    30 using HEAL.Attic;
    3131
    3232namespace HeuristicLab.Optimization {
     
    5252    protected Problem()
    5353      : base() {
    54       Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>(), false));
     54      Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>()) { GetsCollected = false });
    5555      OperatorsParameter.Hidden = true;
    5656      RegisterEventHandlers();
     
    6666        if (operators != null) {
    6767          Parameters.Remove(OperatorsParameterName);
    68           Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>(operators), false));
     68          Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>(operators)) { GetsCollected = false });
    6969          OperatorsParameter.Hidden = true;
    7070        }
     
    9595        //necessary to convert old experiments files where no parameter was used for saving the operators
    9696        if (!Parameters.ContainsKey(OperatorsParameterName)) {
    97           Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>(), false));
     97          Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>()) { GetsCollected = false });
    9898          OperatorsParameter.Hidden = true;
    9999        }
     
    107107        #region Backwards compatible code, remove with 3.4
    108108        if (!Parameters.ContainsKey(OperatorsParameterName)) {
    109           Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>(), false));
     109          Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>()) { GetsCollected = false });
    110110          OperatorsParameter.Hidden = true;
    111111        }
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Optimization/3.3/Problems/UserDefinedProblem.cs

    r16565 r16911  
    2525using System.Linq;
    2626using System.Threading;
     27using HEAL.Attic;
    2728using HeuristicLab.Collections;
    2829using HeuristicLab.Common;
     
    3031using HeuristicLab.Data;
    3132using HeuristicLab.Parameters;
    32 using HEAL.Attic;
    3333using HeuristicLab.PluginInfrastructure;
    3434
     
    130130        ItemList<IOperator> tmp = ((ValueParameter<ItemList<IOperator>>)Parameters["Operators"]).Value;
    131131        Parameters.Remove("Operators");
    132         Parameters.Add(new ValueParameter<ItemList<IItem>>("Operators", "The operators and items that the problem provides to the algorithms.", new ItemList<IItem>(tmp), false));
     132        Parameters.Add(new ValueParameter<ItemList<IItem>>("Operators", "The operators and items that the problem provides to the algorithms.", new ItemList<IItem>(tmp)) { GetsCollected = false });
    133133      }
    134134      #endregion
Note: See TracChangeset for help on using the changeset viewer.