Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/27/12 13:24:36 (13 years ago)
Author:
abeham
Message:

#1614

  • reworked parameterization (one interface for every parameter resp. parameter group)
  • unified parameter descriptions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/ApproximateLocalSearch.cs

    r7412 r7419  
    3333
    3434namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment.Operators {
    35   [Item("ApproximateLocalSearch", @"The approximate local search is described in Mateus, G., Resende, M., and Silva, R. 2011. GRASP with path-relinking for the generalized quadratic assignment problem. Journal of Heuristics 17, Springer Netherlands, pp. 527-565.
    36 
    37 The implementation differs slightly from Mateus et al. in that the maximumIterations parameter defines a cap on the number of steps that the local search can perform. While the maxSampleSize parameter corresponds to the maxItr parameter defined by Mateus et al.")]
     35  [Item("ApproximateLocalSearch", "The approximate local search is described in Mateus, G., Resende, M., and Silva, R. 2011. GRASP with path-relinking for the generalized quadratic assignment problem. Journal of Heuristics 17, Springer Netherlands, pp. 527-565.")]
    3836  [StorableClass]
    39   public class ApproximateLocalSearch : SingleSuccessorOperator, IGQAPLocalImprovementOperator, IStochasticOperator {
     37  public class ApproximateLocalSearch : SingleSuccessorOperator, IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator,
     38    IWeightsAwareGQAPOperator, IDistancesAwareGQAPOperator, IInstallationCostsAwareGQAPOperator,
     39    ITransportationCostsAwareGQAPOperator, IOverbookedCapacityPenaltyAwareGQAPOperator,
     40    IAssignmentAwareGQAPOperator, IQualityAwareGQAPOperator, IGQAPLocalImprovementOperator, IStochasticOperator {
    4041    public IProblem Problem { get; set; }
    4142    public Type ProblemType {
     
    4344    }
    4445
     46    public ILookupParameter<DoubleArray> DemandsParameter {
     47      get { return (ILookupParameter<DoubleArray>)Parameters["Demands"]; }
     48    }
     49    public ILookupParameter<DoubleArray> CapacitiesParameter {
     50      get { return (ILookupParameter<DoubleArray>)Parameters["Capacities"]; }
     51    }
     52    public ILookupParameter<DoubleMatrix> WeightsParameter {
     53      get { return (ILookupParameter<DoubleMatrix>)Parameters["Weights"]; }
     54    }
     55    public ILookupParameter<DoubleMatrix> DistancesParameter {
     56      get { return (ILookupParameter<DoubleMatrix>)Parameters["Distances"]; }
     57    }
     58    public ILookupParameter<DoubleMatrix> InstallationCostsParameter {
     59      get { return (ILookupParameter<DoubleMatrix>)Parameters["InstallationCosts"]; }
     60    }
     61    public IValueLookupParameter<DoubleValue> TransportationCostsParameter {
     62      get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; }
     63    }
     64    public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {
     65      get { return (IValueLookupParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
     66    }
     67    public ILookupParameter<IntegerVector> AssignmentParameter {
     68      get { return (ILookupParameter<IntegerVector>)Parameters["Assignment"]; }
     69    }
     70    public ILookupParameter<BoolValue> MaximizationParameter {
     71      get { return (ILookupParameter<BoolValue>)Parameters["Maximization"]; }
     72    }
     73    public ILookupParameter<DoubleValue> QualityParameter {
     74      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
     75    }
     76    public ILookupParameter<DoubleValue> FlowDistanceQualityParameter {
     77      get { return (ILookupParameter<DoubleValue>)Parameters["FlowDistanceQuality"]; }
     78    }
     79    public ILookupParameter<DoubleValue> InstallationQualityParameter {
     80      get { return (ILookupParameter<DoubleValue>)Parameters["InstallationQuality"]; }
     81    }
     82    public ILookupParameter<DoubleValue> OverbookedCapacityParameter {
     83      get { return (ILookupParameter<DoubleValue>)Parameters["OverbookedCapacity"]; }
     84    }
     85    public IValueLookupParameter<IntValue> MaximumIterationsParameter {
     86      get { return (IValueLookupParameter<IntValue>)Parameters["MaximumIterations"]; }
     87    }
     88    public ILookupParameter<IntValue> EvaluatedSolutionsParameter {
     89      get { return (ILookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
     90    }
    4591    public ILookupParameter<IRandom> RandomParameter {
    4692      get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
    4793    }
    48     public IValueLookupParameter<IntValue> MaximumIterationsParameter {
    49       get { return (IValueLookupParameter<IntValue>)Parameters["MaximumIterations"]; }
    50     }
    51     public ILookupParameter<IntValue> EvaluatedSolutionsParameter {
    52       get { return (ILookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
    53     }
    54     public ILookupParameter<DoubleValue> QualityParameter {
    55       get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
    56     }
    57     public ILookupParameter<DoubleValue> FlowDistanceQualityParameter {
    58       get { return (ILookupParameter<DoubleValue>)Parameters["FlowDistanceQuality"]; }
    59     }
    60     public ILookupParameter<DoubleValue> InstallationQualityParameter {
    61       get { return (ILookupParameter<DoubleValue>)Parameters["InstallationQuality"]; }
    62     }
    63     public ILookupParameter<DoubleValue> OverbookedCapacityParameter {
    64       get { return (ILookupParameter<DoubleValue>)Parameters["OverbookedCapacity"]; }
     94    public IValueLookupParameter<IntValue> MaximumCandidateListSizeParameter {
     95      get { return (IValueLookupParameter<IntValue>)Parameters["MaximumCandidateListSize"]; }
     96    }
     97    public IValueLookupParameter<PercentValue> OneMoveProbabilityParameter {
     98      get { return (IValueLookupParameter<PercentValue>)Parameters["OneMoveProbability"]; }
    6599    }
    66100    public ILookupParameter<ResultCollection> ResultsParameter {
    67101      get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; }
    68     }
    69     public IValueLookupParameter<IntValue> MaximumCandidateListSizeParameter {
    70       get { return (IValueLookupParameter<IntValue>)Parameters["MaximumCandidateListSize"]; }
    71     }
    72     public IValueLookupParameter<IntValue> MaximumSampleSizeParameter {
    73       get { return (IValueLookupParameter<IntValue>)Parameters["MaximumSampleSize"]; }
    74     }
    75     public ILookupParameter<IntegerVector> AssignmentParameter {
    76       get { return (ILookupParameter<IntegerVector>)Parameters["Assignment"]; }
    77     }
    78     public ILookupParameter<DoubleMatrix> WeightsParameter {
    79       get { return (ILookupParameter<DoubleMatrix>)Parameters["Weights"]; }
    80     }
    81     public ILookupParameter<DoubleMatrix> DistancesParameter {
    82       get { return (ILookupParameter<DoubleMatrix>)Parameters["Distances"]; }
    83     }
    84     public ILookupParameter<DoubleMatrix> InstallationCostsParameter {
    85       get { return (ILookupParameter<DoubleMatrix>)Parameters["InstallationCosts"]; }
    86     }
    87     public ILookupParameter<DoubleArray> DemandsParameter {
    88       get { return (ILookupParameter<DoubleArray>)Parameters["Demands"]; }
    89     }
    90     public ILookupParameter<DoubleArray> CapacitiesParameter {
    91       get { return (ILookupParameter<DoubleArray>)Parameters["Capacities"]; }
    92     }
    93     public IValueLookupParameter<DoubleValue> TransportationCostsParameter {
    94       get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; }
    95     }
    96     public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {
    97       get { return (IValueLookupParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; }
    98     }
    99     public IValueLookupParameter<PercentValue> OneMoveProbabilityParameter {
    100       get { return (IValueLookupParameter<PercentValue>)Parameters["OneMoveProbability"]; }
    101102    }
    102103
     
    106107    public ApproximateLocalSearch()
    107108      : base() {
    108       Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
     109      Parameters.Add(new LookupParameter<DoubleArray>("Demands", GeneralizedQuadraticAssignmentProblem.DemandsDescription));
     110      Parameters.Add(new LookupParameter<DoubleArray>("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription));
     111      Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", GeneralizedQuadraticAssignmentProblem.WeightsDescription));
     112      Parameters.Add(new LookupParameter<DoubleMatrix>("Distances", GeneralizedQuadraticAssignmentProblem.DistancesDescription));
     113      Parameters.Add(new LookupParameter<DoubleMatrix>("InstallationCosts", GeneralizedQuadraticAssignmentProblem.InstallationCostsDescription));
     114      Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription));
     115      Parameters.Add(new ValueLookupParameter<DoubleValue>("OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription));
     116      Parameters.Add(new LookupParameter<IntegerVector>("Assignment", GQAPSolutionCreator.AssignmentDescription));
     117      Parameters.Add(new LookupParameter<BoolValue>("Maximization", GeneralizedQuadraticAssignmentProblem.MaximizationDescription));
     118      Parameters.Add(new LookupParameter<DoubleValue>("Quality", GQAPEvaluator.QualityDescription));
     119      Parameters.Add(new LookupParameter<DoubleValue>("FlowDistanceQuality", GQAPEvaluator.FlowDistanceQualityDescription));
     120      Parameters.Add(new LookupParameter<DoubleValue>("InstallationQuality", GQAPEvaluator.InstallationQualityDescription));
     121      Parameters.Add(new LookupParameter<DoubleValue>("OverbookedCapacity", GQAPEvaluator.OverbookedCapacityDescription));
    109122      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of iterations that should be performed."));
    110123      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated solution equivalents."));
    111       Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The solution quality."));
    112       Parameters.Add(new LookupParameter<DoubleValue>("FlowDistanceQuality", "The quality regarding the flow-distance criteria."));
    113       Parameters.Add(new LookupParameter<DoubleValue>("InstallationQuality", "The quality regarding the installation costs."));
    114       Parameters.Add(new LookupParameter<DoubleValue>("OverbookedCapacity", "The sum of the overbooked capacities relative to the capacity of each location."));
     124      Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
     125      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumCandidateListSize", "The maximum number of candidates that should be found in each step.", new IntValue(10)));
     126      Parameters.Add(new ValueLookupParameter<PercentValue>("OneMoveProbability", "The probability for performing a 1-move, which is the opposite of performing a 2-move.", new PercentValue(.5)));
    115127      Parameters.Add(new LookupParameter<ResultCollection>("Results", "The result collection that stores the results."));
    116       Parameters.Add(new ValueLookupParameter<IntValue>("MaximumCandidateListSize", "The maximum number of candidates that should be found in each step.", new IntValue(10)));
    117       Parameters.Add(new ValueLookupParameter<IntValue>("MaximumSampleSize", "The maximum number of candidates that should be sampled in each step.", new IntValue(100)));
    118       Parameters.Add(new LookupParameter<IntegerVector>("Assignment", "The equipment-location assignment vector."));
    119       Parameters.Add(new LookupParameter<DoubleMatrix>("Weights", "The weights matrix describes the flows between the equipments."));
    120       Parameters.Add(new LookupParameter<DoubleMatrix>("Distances", "The distances matrix describes the distances between the locations at which the equipment can be installed."));
    121       Parameters.Add(new LookupParameter<DoubleMatrix>("InstallationCosts", "The installation costs matrix describes the installation costs of installing equipment i at location j."));
    122       Parameters.Add(new LookupParameter<DoubleArray>("Demands", "The demands vector describes the space requirements of the equipments."));
    123       Parameters.Add(new LookupParameter<DoubleArray>("Capacities", "The capacities vector describes the available space at the locations."));
    124       Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", "The transportation cost represents the flow-unit per distance-unit cost factor. This value can also be set to 1 if these costs are factored into the weights matrix already."));
    125       Parameters.Add(new ValueLookupParameter<DoubleValue>("OverbookedCapacityPenalty", "The multiplier for the constraint violation when added to the quality."));
    126       Parameters.Add(new ValueLookupParameter<PercentValue>("OneMoveProbability", "The probability for performing a 1-move, which is the opposite of performing a 2-move.", new PercentValue(.5)));
    127128    }
    128129
     
    143144    /// <param name="overbookedCapacity">The sum of the overbooked capacities relative to the capacity of each location.</param>
    144145    /// <param name="maxCLS">The maximum number of candidates that should be found in each step.</param>
    145     /// <param name="maxSampleSize">The maximum number of candidates that should be sampled in each step.</param>
    146     /// <param name="maximumIterations">The maximum number of iterations that should be performed.</param>
     146    /// <param name="maximumIterations">The maximum number of iterations that should be performed each time the candidate list is generated.</param>
    147147    /// <param name="weights">The weights matrix describes the flows between the equipments.</param>
    148148    /// <param name="distances">The distances matrix describes the distances between the locations at which the equipment can be installed.</param>
     
    155155    public static void Apply(IRandom random, IntegerVector assignment,
    156156      DoubleValue quality, DoubleValue flowDistanceQuality, DoubleValue installationQuality, DoubleValue overbookedCapacity,
    157       IntValue maxCLS, IntValue maxSampleSize, IntValue maximumIterations,
     157      IntValue maxCLS, IntValue maximumIterations,
    158158      DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities,
    159159      DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty, PercentValue oneMoveProbability) {
    160160
    161       for (int i = 0; i < maximumIterations.Value; i++) {
     161      while (true) {
    162162        int count = 0;
    163163        var CLS = new List<Tuple<NMove, double, double, double, double>>();
     
    180180          }
    181181          count++;
    182         } while (CLS.Count < maxCLS.Value && count < maxSampleSize.Value);
     182        } while (CLS.Count < maxCLS.Value && count < maximumIterations.Value);
    183183
    184184        if (CLS.Count == 0)
     
    211211        OverbookedCapacityParameter.ActualValue,
    212212        MaximumCandidateListSizeParameter.ActualValue,
    213         MaximumSampleSizeParameter.ActualValue,
    214213        MaximumIterationsParameter.ActualValue,
    215214        WeightsParameter.ActualValue, DistancesParameter.ActualValue,
Note: See TracChangeset for help on using the changeset viewer.