Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/22/12 22:43:09 (12 years ago)
Author:
abeham
Message:

#1614

  • added instances of Cordeau et al. as given by L. Moccia
  • added operators for tabu search
Location:
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluators/GQAPNMoveEvaluator.cs

    r7419 r7505  
    2020#endregion
    2121
    22 using System.Collections.Generic;
    2322using System.Linq;
    2423using HeuristicLab.Common;
     
    3231
    3332namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
    34   [Item("GQAPNMoveEvaluator", "Evaluates an n-move.")]
     33  [Item("N-Move Evaluator", "Evaluates an N-Move.")]
    3534  [StorableClass]
    3635  public class GQAPNMoveEvaluator : SingleSuccessorOperator, IGQAPNMoveEvaluator, IAssignmentAwareGQAPOperator,
     
    159158      var slack = (DoubleArray)capacities.Clone();
    160159      var oldSlack = (DoubleArray)slack.Clone();
    161       Dictionary<int, int> moving = new Dictionary<int, int>();
    162       for (int i = 0; i < moves; i++) moving.Add(move.Equipments[i], move.Locations[i]);
    163 
    164       for (int i = 0; i < moves; i++) {
    165         int equip = move.Equipments[i];
    166         int newLoc = move.Locations[i];
     160      bool first = true;
     161      foreach (var kvp in move.NewAssignments) {
     162        int equip = kvp.Key;
     163        int newLoc = kvp.Value;
    167164        moveInstallationQuality -= installationCosts[equip, assignment[equip]];
    168165        moveInstallationQuality += installationCosts[equip, newLoc];
    169166        for (int j = 0; j < assignment.Length; j++) {
    170           if (!moving.ContainsKey(j)) {
     167          if (!move.NewAssignments.ContainsKey(j)) {
    171168            moveFlowDistanceQuality += weights[equip, j] * distances[newLoc, assignment[j]];
    172169            moveFlowDistanceQuality -= weights[equip, j] * distances[assignment[equip], assignment[j]];
    173170            moveFlowDistanceQuality += weights[j, equip] * distances[assignment[j], newLoc];
    174171            moveFlowDistanceQuality -= weights[j, equip] * distances[assignment[j], assignment[equip]];
    175             if (i == 0) { // only once for each untouched equipment deduct the demand from the capacity
     172            if (first) { // only once for each untouched equipment deduct the demand from the capacity
    176173              slack[assignment[j]] -= demands[j];
    177174              oldSlack[assignment[j]] -= demands[j];
    178175            }
    179176          } else {
    180             moveFlowDistanceQuality += weights[equip, j] * distances[newLoc, moving[j]];
     177            moveFlowDistanceQuality += weights[equip, j] * distances[newLoc, move.NewAssignments[j]];
    181178            moveFlowDistanceQuality -= weights[equip, j] * distances[assignment[equip], assignment[j]];
    182179          }
    183180        }
     181        first = false;
    184182        slack[newLoc] -= demands[equip];
    185183        oldSlack[assignment[equip]] -= demands[equip];
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment-3.3.csproj

    r7478 r7505  
    134134    <Compile Include="Moves\GQAPMoveGenerator.cs" />
    135135    <Compile Include="Moves\GQAPNMoveGenerator.cs" />
     136    <Compile Include="Moves\NMoveAbsoluteAttribute.cs" />
    136137    <Compile Include="Moves\NMoveMaker.cs" />
     138    <Compile Include="Moves\NMoveTabuChecker.cs" />
     139    <Compile Include="Moves\NMoveTabuMaker.cs" />
    137140    <Compile Include="Moves\StochasticNMoveMultiMoveGenerator.cs" />
    138141    <Compile Include="Moves\StochasticNMoveSingleMoveGenerator.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Moves/GQAPNMoveGenerator.cs

    r7419 r7505  
    3030
    3131namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
    32   [Item("GQAPNMoveGenerator", "Base class for move operators that generate n-move moves.")]
     32  [Item("N-Move Generator", "Base class for move operators that generate N-Move moves.")]
    3333  [StorableClass]
    3434  public abstract class GQAPNMoveGenerator : GQAPMoveGenerator, IGQAPNMoveOperator {
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Moves/NMove.cs

    r7407 r7505  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     
    2728
    2829namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
    29   [Item("n-move", "An n-move describes moving n equipments to n locations.")]
     30  [Item("N-Move", "An N-Move describes the relocation of n equipments to n different locations.")]
    3031  [StorableClass]
    3132  public class NMove : Item {
    3233    [Storable]
    33     public int[] Equipments { get; private set; }
    34     [Storable]
    35     public int[] Locations { get; private set; }
     34    public Dictionary<int, int> NewAssignments { get; private set; }
    3635    [Storable]
    3736    public IntegerVector OriginalVector { get; private set; }
    3837
    39     public int N { get { return Equipments.Length; } }
     38    public int N { get { return NewAssignments.Count; } }
    4039
    4140    [StorableConstructor]
     
    4342    protected NMove(NMove original, Cloner cloner)
    4443      : base(original, cloner) {
    45       Equipments = (int[])original.Equipments.Clone();
    46       Locations = (int[])original.Locations.Clone();
     44      NewAssignments = new Dictionary<int, int>(original.NewAssignments);
    4745      if (original.OriginalVector != null)
    4846        OriginalVector = cloner.Clone(original.OriginalVector);
     
    5553      if (locations == null) throw new ArgumentNullException("locations", "NMove: Locations must not be null.");
    5654      if (equipments.Length != locations.Length) throw new ArgumentException("NMove: Length of equipments and locations is not identical.");
    57       Equipments = equipments;
    58       Locations = locations;
     55      NewAssignments = new Dictionary<int, int>();
     56      for (int i = 0; i < equipments.Length; i++)
     57        NewAssignments[equipments[i]] = locations[i];
    5958      OriginalVector = originalVector;
    6059    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Moves/NMoveMaker.cs

    r7419 r7505  
    3030
    3131namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
    32   [Item("NMoveMaker", "Performs an n-move.")]
     32  [Item("N-Move Maker", "Performs an N-Move.")]
    3333  [StorableClass]
    3434  public class NMoveMaker : SingleSuccessorOperator, IAssignmentAwareGQAPOperator, IQualityAwareGQAPOperator, IMoveQualityAwareGQAPOperator, IGQAPNMoveOperator, IMoveMaker {
     
    9797
    9898    public static void Apply(IntegerVector vector, NMove move) {
    99       for (int i = 0; i < move.N; i++) {
    100         vector[move.Equipments[i]] = move.Locations[i];
    101       }
     99      foreach (var kvp in move.NewAssignments)
     100        vector[kvp.Key] = kvp.Value;
    102101    }
    103102
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Moves/StochasticNMoveMultiMoveGenerator.cs

    r7419 r7505  
    3030
    3131namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
    32   [Item("Stochastic n-move MultiMoveGenerator", "Randomly samples a number of n-moves.")]
     32  [Item("Stochastic N-Move MultiMoveGenerator", "Randomly samples a number of N-Moves.")]
    3333  [StorableClass]
    3434  public class StochasticNMoveMultiMoveGenerator : GQAPNMoveGenerator, ICapacitiesAwareGQAPOperator, IStochasticOperator, IMultiMoveGenerator {
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Moves/StochasticNMoveSingleMoveGenerator.cs

    r7419 r7505  
    3030
    3131namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
    32   [Item("Stochastic n-move SingleMoveGenerator", "Randomly samples a single n-move.")]
     32  [Item("Stochastic N-Move SingleMoveGenerator", "Randomly samples a single N-Move.")]
    3333  [StorableClass]
    3434  public class StochasticNMoveSingleMoveGenerator : GQAPNMoveGenerator, ICapacitiesAwareGQAPOperator, IStochasticOperator, ISingleMoveGenerator {
Note: See TracChangeset for help on using the changeset viewer.