Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/24/12 15:04:37 (12 years ago)
Author:
jkarder
Message:

#1331:

  • applied some of the changes suggested by ascheibe in comment:32:ticket:1331
  • restructured path relinking and improvement operators and similarity calculators
  • fixed bug in TSPMultipleGuidesPathRelinker
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.Knapsack/3.3/Improvers/KnapsackImprovementOperator.cs

    r8086 r8319  
    3535  /// An operator that improves knapsack solutions.
    3636  /// </summary>
     37  /// <remarks>
     38  /// It is implemented as described in Laguna, M. and Martí, R. (2003). Scatter Search: Methodology and Implementations in C. Operations Research/Computer Science Interfaces Series, Vol. 24. Springer.<br />
     39  /// The operator first orders the elements of the knapsack according to their value-to-weight ratio, then, if the solution is not feasible, removes the element with the lowest ratio until the solution is feasible and tries to add new elements with the best ratio that are not already included yet until the knapsack is full.
     40  /// </remarks>
    3741  [Item("KnapsackImprovementOperator", "An operator that improves knapsack solutions.")]
    3842  [StorableClass]
    39   public sealed class KnapsackImprovementOperator : SingleSuccessorOperator, IImprovementOperator {
     43  public sealed class KnapsackImprovementOperator : SingleSuccessorOperator, ISingleObjectiveImprovementOperator {
    4044    #region Parameter properties
    4145    public ScopeParameter CurrentScopeParameter {
     
    4852      get { return (ILookupParameter<DoubleValue>)Parameters["Penalty"]; }
    4953    }
    50     public IValueLookupParameter<IItem> TargetParameter {
    51       get { return (IValueLookupParameter<IItem>)Parameters["Target"]; }
     54    public IValueLookupParameter<IItem> SolutionParameter {
     55      get { return (IValueLookupParameter<IItem>)Parameters["Solution"]; }
    5256    }
    5357    public ILookupParameter<IntArray> ValuesParameter {
     
    9094      Parameters.Add(new LookupParameter<IntValue>("KnapsackCapacity", "Capacity of the Knapsack."));
    9195      Parameters.Add(new LookupParameter<DoubleValue>("Penalty", "The penalty value for each unit of overweight."));
    92       Parameters.Add(new ValueLookupParameter<IItem>("Target", "This parameter is used for name translation only."));
     96      Parameters.Add(new ValueLookupParameter<IItem>("Solution", "The solution to be improved. This parameter is used for name translation only."));
    9397      Parameters.Add(new LookupParameter<IntArray>("Values", "The values of the items."));
    9498      Parameters.Add(new LookupParameter<IntArray>("Weights", "The weights of the items."));
     
    101105
    102106    public override IOperation Apply() {
    103       BinaryVector sol = CurrentScope.Variables[TargetParameter.ActualName].Value as BinaryVector;
     107      BinaryVector sol = CurrentScope.Variables[SolutionParameter.ActualName].Value as BinaryVector;
    104108      if (sol == null)
    105109        throw new ArgumentException("Cannot improve solution because it has the wrong type.");
     
    143147      }
    144148
    145       CurrentScope.Variables[TargetParameter.ActualName].Value = sol;
     149      CurrentScope.Variables[SolutionParameter.ActualName].Value = sol;
    146150      CurrentScope.Variables.Add(new Variable("LocalEvaluatedSolutions", new IntValue(evaluatedSolutions)));
    147151
Note: See TracChangeset for help on using the changeset viewer.