Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4287 for branches


Ignore:
Timestamp:
08/23/10 14:06:43 (14 years ago)
Author:
svonolfe
Message:

Made intra route inversion and lamda interchange moves work with the SA algorithm (#1039)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/IntraRouteInversion/IntraRouteInversionMove.cs

    r4268 r4287  
    3131  [StorableClass]
    3232  public class IntraRouteInversionMove : TwoIndexMove, IVRPMove {
     33    public IVRPEncoding Individual { get { return Permutation as AlbaEncoding; } }
     34   
    3335    public IntraRouteInversionMove()
    3436      : base() {
     
    4143    public IntraRouteInversionMove(int index1, int index2, AlbaEncoding permutation)
    4244      : base(index1, index2, permutation) {
     45        this.Permutation = permutation.Clone() as AlbaEncoding;
    4346    }
    4447
     
    5760
    5861    public TourEvaluation GetMoveQuality(
    59       IVRPEncoding individual, IntValue vehicles,
     62      IntValue vehicles,
    6063      DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray,
    6164      DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates,
     
    6366      DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
    6467      ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) {
    65         return IntraRouteInversionMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this, vehicles,
     68        return IntraRouteInversionMoveEvaluator.GetMoveQuality(Permutation as AlbaEncoding, this, vehicles,
    6669          dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
    6770          coordinates, fleetUsageFactor, timeFactor, distanceFactor,
     
    6972    }
    7073
    71     public void MakeMove(IRandom random, IVRPEncoding individual) {
    72       IntraRouteInversionMoveMaker.Apply(individual as AlbaEncoding, this);
     74    public IVRPEncoding MakeMove(IRandom random) {
     75      IntraRouteInversionMoveMaker.Apply(Individual as AlbaEncoding, this);
     76
     77      return Individual;
    7378    }
    7479
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/ExhaustiveLambdaInterchangeMoveGenerator.cs

    r4230 r4287  
    5555                  for(int index2 = 0; index2 < tour2.Cities.Count - length2 + 1; index2++) {
    5656                    moves.Add(new LambdaInterchangeMove(tour1Index, index1, length1,
    57                       tour2Index, index2, length2));
     57                      tour2Index, index2, length2, individual));
    5858                  }
    5959                }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/LambdaInterchangeMove.cs

    r4268 r4287  
    3333  public class LambdaInterchangeMove: Item, IVRPMove {
    3434    [Storable]
     35    public IVRPEncoding Individual { get; protected set; }
     36   
     37    [Storable]
    3538    public int Tour1 { get; protected set; }
    3639
     
    5861      Position2 = -1;
    5962      Length2 = -1;
     63
     64      Individual = null;
    6065    }
    6166
    6267    public LambdaInterchangeMove(int tour1, int position1, int length1,
    63       int tour2, int position2, int length2) {
     68      int tour2, int position2, int length2, AlbaEncoding permutation) {
    6469        Tour1 = tour1;
    6570        Position1 = position1;
     
    6974        Position2 = position2;
    7075        Length2 = length2;
     76
     77        this.Individual = permutation.Clone() as AlbaEncoding;
    7178    }
    7279
     
    8289      clone.Length2 = Length2;
    8390
     91      if (Individual != null)
     92        clone.Individual = (AlbaEncoding)cloner.Clone(Individual);
     93
    8494      cloner.RegisterClonedObject(this, clone);
    8595      return clone;
     
    8999
    90100    public TourEvaluation GetMoveQuality(
    91       IVRPEncoding individual, IntValue vehicles,
     101      IntValue vehicles,
    92102      DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray,
    93103      DoubleArray demandArray, DoubleValue capacity, DoubleMatrix coordinates,
     
    95105      DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
    96106      ILookupParameter<DoubleMatrix> distanceMatrix, Data.BoolValue useDistanceMatrix) {
    97         return LambdaInterchangeMoveEvaluator.GetMoveQuality(individual as AlbaEncoding, this, vehicles,
     107        return LambdaInterchangeMoveEvaluator.GetMoveQuality(Individual as AlbaEncoding, this, vehicles,
    98108          dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
    99109          coordinates, fleetUsageFactor, timeFactor, distanceFactor,
     
    101111    }
    102112
    103     public void MakeMove(IRandom random, IVRPEncoding individual) {
    104       LambdaInterchangeMoveMaker.Apply(individual as AlbaEncoding, this);
     113    public IVRPEncoding MakeMove(IRandom random) {
     114      LambdaInterchangeMoveMaker.Apply(Individual as AlbaEncoding, this);
     115
     116      return Individual;
    105117    }
    106118
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/LambdaInterchange/StochasticLambdaInterchangeSingleMoveGenerator.cs

    r4286 r4287  
    7474      int index2 = rand.Next(route2.Cities.Count - length2 + 1);
    7575
    76       return new LambdaInterchangeMove(route1Index, index1, length1, route2Index, index2, length2);
     76      return new LambdaInterchangeMove(route1Index, index1, length1, route2Index, index2, length2, individual);
    7777    }
    7878
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/Interfaces/IVRPMove.cs

    r4268 r4287  
    2727namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
    2828  public interface IVRPMove : IItem {
    29     TourEvaluation GetMoveQuality(IVRPEncoding individual,  IntValue vehicles,
     29    TourEvaluation GetMoveQuality(IntValue vehicles,
    3030        DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray,
    3131        DoubleValue capacity,DoubleMatrix coordinates,
     
    3434      ILookupParameter<DoubleMatrix> distanceMatrix, BoolValue useDistanceMatrix);
    3535
    36     void MakeMove(IRandom random, IVRPEncoding individual);
     36    IVRPEncoding MakeMove(IRandom random);
    3737  }
    3838}
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveEvaluator.cs

    r4268 r4287  
    4646
    4747      return move.GetMoveQuality(
    48         VRPToursParameter.ActualValue,
    4948        VehiclesParameter.ActualValue,
    5049        DueTimeParameter.ActualValue,
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveMaker.cs

    r4205 r4287  
    114114     
    115115      //perform move
    116       move.MakeMove(RandomParameter.ActualValue, VRPToursParameter.ActualValue);
     116      VRPToursParameter.ActualValue = move.MakeMove(RandomParameter.ActualValue);
    117117
    118118      quality.Value = moveQuality.Value;
Note: See TracChangeset for help on using the changeset viewer.