Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/22/12 11:11:38 (13 years ago)
Author:
jkarder
Message:

#1331:

  • synced branch with trunk
  • added custom interface (ISimilarityBasedOperator) to mark operators that conduct similarity calculation
  • similarity calculators are now parameterized by the algorithm
  • deleted SolutionPool2TierUpdateMethod
  • deleted KnapsackMultipleGuidesPathRelinker
  • moved IImprovementOperator, IPathRelinker and ISimilarityCalculator to HeuristicLab.Optimization
  • added parameter descriptions
  • fixed plugin references
  • fixed count of EvaluatedSolutions
  • fixed check for duplicate solutions
  • minor code improvements
Location:
branches/ScatterSearch (trunk integration)
Files:
8 edited
3 moved

Legend:

Unmodified
Added
Removed
  • branches/ScatterSearch (trunk integration)

  • branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization/3.3/Experiment.cs

    r7576 r8086  
    179179      experimentStopped = false;
    180180      foreach (IOptimizer optimizer in Optimizers.Where(x => x.ExecutionState != ExecutionState.Started))
    181         if (clearRuns || optimizer.ExecutionState != ExecutionState.Prepared)
     181        //if (clearRuns || optimizer.ExecutionState != ExecutionState.Prepared)
    182182          optimizer.Prepare(clearRuns);
    183183    }
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r7228 r8086  
    114114  </ItemGroup>
    115115  <ItemGroup>
     116    <Compile Include="Interfaces\IImprovementOperator.cs" />
     117    <Compile Include="Interfaces\IPathRelinker.cs" />
     118    <Compile Include="Interfaces\ISimilarityBasedOperator.cs" />
     119    <Compile Include="Interfaces\ISimilarityCalculator.cs" />
    116120    <Compile Include="RunCollectionModification\RunCollectionRunRemover.cs" />
    117121    <Compile Include="Plugin.cs" />
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization/3.3/Interfaces/IImprovementOperator.cs

    r7967 r8086  
    2020#endregion
    2121
    22 using System;
    23 using HeuristicLab.Common;
    2422using HeuristicLab.Core;
    2523
    26 namespace HeuristicLab.Optimization.Operators {
     24namespace HeuristicLab.Optimization {
    2725  /// <summary>
    2826  /// An interface which represents an operator for improvement.
    2927  /// </summary>
    30   public interface IImprovementOperator : IOperator, IParameterizedNamedItem, IDeepCloneable, ICloneable {
     28  public interface IImprovementOperator : IOperator {
    3129    IValueLookupParameter<IItem> TargetParameter { get; }
    3230  }
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization/3.3/Interfaces/IPathRelinker.cs

    r7967 r8086  
    2020#endregion
    2121
    22 using System;
    23 using HeuristicLab.Common;
    2422using HeuristicLab.Core;
    2523
    26 namespace HeuristicLab.Optimization.Operators {
     24namespace HeuristicLab.Optimization {
    2725  /// <summary>
    2826  /// An interface which represents an operator for path relinking.
    2927  /// </summary>
    30   public interface IPathRelinker : IOperator, IParameterizedNamedItem, IDeepCloneable, ICloneable {
     28  public interface IPathRelinker : IOperator {
    3129    ILookupParameter<ItemArray<IItem>> ParentsParameter { get; }
    3230  }
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization/3.3/Interfaces/IProblem.cs

    r7259 r8086  
    2929  /// </summary>
    3030  public interface IProblem : IParameterizedNamedItem {
    31     IEnumerable<IOperator> Operators { get; }
     31    IEnumerable<IItem> Operators { get; }
    3232
    3333    event EventHandler OperatorsChanged;
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization/3.3/Interfaces/ISimilarityCalculator.cs

    r7967 r8086  
    2020#endregion
    2121
    22 using System;
    23 using HeuristicLab.Common;
    2422using HeuristicLab.Core;
    2523
    26 namespace HeuristicLab.Optimization.Operators {
     24namespace HeuristicLab.Optimization {
    2725  /// <summary>
    2826  /// An interface which represents an operator for similarity calculation.
    2927  /// </summary>
    30   public interface ISimilarityCalculator : IOperator, IParameterizedNamedItem, IDeepCloneable, ICloneable {
    31     IValueLookupParameter<IItem> TargetParameter { get; }
     28  public interface ISimilarityCalculator : IItem {
     29    string Target { get; set; }
     30
     31    double ExecuteCalculation(IScope left, IScope right);
    3232  }
    3333}
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization/3.3/Problems/Problem.cs

    r7706 r8086  
    3434  [StorableClass]
    3535  public abstract class Problem : ParameterizedNamedItem, IProblem {
    36     private static readonly string OperatorsParameterName = "Operators";
    37 
    38     public IFixedValueParameter<OperatorCollection> OperatorsParameter {
    39       get { return (IFixedValueParameter<OperatorCollection>)Parameters[OperatorsParameterName]; }
     36    private const string OperatorsParameterName = "Operators";
     37    public IFixedValueParameter<ItemCollection<IItem>> OperatorsParameter {
     38      get { return (IFixedValueParameter<ItemCollection<IItem>>)Parameters[OperatorsParameterName]; }
    4039    }
    4140
     
    5352    protected Problem()
    5453      : base() {
    55       Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", new OperatorCollection(), false));
     54      Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>(), false));
    5655      OperatorsParameter.Hidden = true;
    5756      RegisterEventHandlers();
     
    6059    [StorableHook(HookType.AfterDeserialization)]
    6160    private void AfterDeserialization() {
     61      // BackwardsCompatibility3.3
     62      #region Backwards compatible code, remove with 3.4
     63      IParameter operatorsParam;
     64      if (Parameters.TryGetValue(OperatorsParameterName, out operatorsParam)) {
     65        var operators = operatorsParam.ActualValue as OperatorCollection;
     66        if (operators != null) {
     67          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));
     69          OperatorsParameter.Hidden = true;
     70        }
     71      }
     72      #endregion
     73
    6274      RegisterEventHandlers();
    6375    }
    6476
    6577    private void RegisterEventHandlers() {
    66       Operators.ItemsAdded += new CollectionItemsChangedEventHandler<IOperator>(Operators_Changed);
    67       Operators.ItemsRemoved += new CollectionItemsChangedEventHandler<IOperator>(Operators_Changed);
    68       Operators.CollectionReset += new CollectionItemsChangedEventHandler<IOperator>(Operators_Changed);
     78      Operators.ItemsAdded += new CollectionItemsChangedEventHandler<IItem>(Operators_Changed);
     79      Operators.ItemsRemoved += new CollectionItemsChangedEventHandler<IItem>(Operators_Changed);
     80      Operators.CollectionReset += new CollectionItemsChangedEventHandler<IItem>(Operators_Changed);
    6981    }
    7082
     
    7284    // BackwardsCompatibility3.3
    7385    #region Backwards compatible code, remove with 3.4
    74     [Storable(Name = "Operators")]
     86    [Storable(Name = "Operators", AllowOneWay = true)]
    7587    private IEnumerable<IOperator> StorableOperators {
    76       get { return null; }
    7788      set {
     89        IParameter operatorsParam;
     90        if (Parameters.TryGetValue(OperatorsParameterName, out operatorsParam)) {
     91          var items = operatorsParam.ActualValue as ItemCollection<IItem>;
     92          if (items == null) Parameters.Remove(operatorsParam);
     93        }
     94
     95        //necessary to convert old experiments files where no parameter was used for saving the operators
    7896        if (!Parameters.ContainsKey(OperatorsParameterName)) {
    79           Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", new OperatorCollection(value), false));
     97          Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>(), false));
    8098          OperatorsParameter.Hidden = true;
    8199        }
     100        if (value != null) Operators.AddRange(value);
    82101      }
    83102    }
    84103    #endregion
    85     protected OperatorCollection Operators {
     104    protected ItemCollection<IItem> Operators {
    86105      get {
    87106        // BackwardsCompatibility3.3
    88107        #region Backwards compatible code, remove with 3.4
    89108        if (!Parameters.ContainsKey(OperatorsParameterName)) {
    90           Parameters.Add(new FixedValueParameter<OperatorCollection>(OperatorsParameterName, "The operators that the problem provides to the algorithms.", new OperatorCollection(), false));
     109          Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>(), false));
    91110          OperatorsParameter.Hidden = true;
    92111        }
     
    95114      }
    96115    }
    97     IEnumerable<IOperator> IProblem.Operators { get { return Operators; } }
     116    IEnumerable<IItem> IProblem.Operators { get { return Operators; } }
    98117    #endregion
    99118
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization/3.3/Problems/SingleObjectiveHeuristicOptimizationProblem.cs

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization/3.3/Problems/UserDefinedProblem.cs

    r7351 r8086  
    8181      get { return (OptionalValueParameter<IScope>)Parameters["BestKnownSolution"]; }
    8282    }
    83     public ValueParameter<ItemList<IOperator>> OperatorsParameter {
    84       get { return (ValueParameter<ItemList<IOperator>>)Parameters["Operators"]; }
     83    public ValueParameter<ItemList<IItem>> OperatorsParameter {
     84      get { return (ValueParameter<ItemList<IItem>>)Parameters["Operators"]; }
    8585    }
    8686    #endregion
     
    112112      set { BestKnownQualityParameter.Value = value; }
    113113    }
    114     public IEnumerable<IOperator> Operators {
     114    public IEnumerable<IItem> Operators {
    115115      get { return OperatorsParameter.Value; }
    116116    }
     
    121121    [StorableHook(HookType.AfterDeserialization)]
    122122    private void AfterDeserialization() {
     123      // BackwardsCompatibility3.3
     124      #region Backwards compatible code, remove with 3.4
     125      if (Parameters.ContainsKey("Operators") && Parameters["Operators"] is ValueParameter<ItemList<IOperator>>) {
     126        ItemList<IOperator> tmp = ((ValueParameter<ItemList<IOperator>>)Parameters["Operators"]).Value;
     127        Parameters.Remove("Operators");
     128        Parameters.Add(new ValueParameter<ItemList<IItem>>("Operators", "The operators and items that the problem provides to the algorithms.", new ItemList<IItem>(tmp), false));
     129      }
     130      #endregion
     131
    123132      RegisterEventHandlers();
    124133    }
     
    130139      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem."));
    131140      Parameters.Add(new OptionalValueParameter<IScope>("BestKnownSolution", "The best known solution for this external evaluation problem."));
    132       Parameters.Add(new ValueParameter<ItemList<IOperator>>("Operators", "The operators that are passed to the algorithm.", new ItemList<IOperator>()));
     141      Parameters.Add(new ValueParameter<ItemList<IItem>>("Operators", "The operators and items that the problem provides to the algorithms.", new ItemList<IItem>()));
    133142
    134143      RegisterEventHandlers();
     
    200209        Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    201210      OperatorsParameter.ValueChanged += new EventHandler(OperatorsParameter_ValueChanged);
    202       OperatorsParameter.Value.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(OperatorsParameter_Value_ItemsAdded);
    203       OperatorsParameter.Value.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(OperatorsParameter_Value_ItemsRemoved);
    204       OperatorsParameter.Value.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<IOperator>>(OperatorsParameter_Value_CollectionReset);
     211      OperatorsParameter.Value.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IItem>>(OperatorsParameter_Value_ItemsAdded);
     212      OperatorsParameter.Value.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IItem>>(OperatorsParameter_Value_ItemsRemoved);
     213      OperatorsParameter.Value.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<IItem>>(OperatorsParameter_Value_CollectionReset);
    205214    }
    206215
     
    209218      if (Evaluator != null) {
    210219        string qualityName = Evaluator.QualityParameter.ActualName;
    211         foreach (IOperator op in OperatorsParameter.Value) {
     220        foreach (IOperator op in OperatorsParameter.Value.OfType<IOperator>()) {
    212221          foreach (ILookupParameter<DoubleValue> param in op.Parameters.OfType<ILookupParameter<DoubleValue>>()) {
    213222            if (param.Name.Equals("Quality")) param.ActualName = qualityName;
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Optimization/3.3/RunCollection.cs

    r7259 r8086  
    126126      parameterNames.Clear();
    127127      resultNames.Clear();
     128      dataTypes.Clear();
    128129      foreach (IRun run in items) {
    129130        foreach (KeyValuePair<string, IItem> parameter in run.Parameters)
Note: See TracChangeset for help on using the changeset viewer.