protected PotvinVehicleAssignmentMoveAttribute(PotvinVehicleAssignmentMoveAttribute original, Cloner cloner)
   : base(original, cloner) {
   this.Tour = original.Tour;
   this.Vehicle = original.Vehicle;
   this.Distance = original.Distance;
   this.Overload = original.Overload;
   this.Tardiness = original.Tardiness;
 }
예제 #2
0
 protected PotvinVehicleAssignmentMoveAttribute(PotvinVehicleAssignmentMoveAttribute original, Cloner cloner)
     : base(original, cloner)
 {
     this.Tour      = original.Tour;
     this.Vehicle   = original.Vehicle;
     this.Distance  = original.Distance;
     this.Overload  = original.Overload;
     this.Tardiness = original.Tardiness;
 }
예제 #3
0
        public override bool Equals(object obj)
        {
            if (obj is PotvinVehicleAssignmentMoveAttribute)
            {
                PotvinVehicleAssignmentMoveAttribute other = obj as PotvinVehicleAssignmentMoveAttribute;

                return(Tour == other.Tour && Vehicle == other.Vehicle);
            }
            else
            {
                return(base.Equals(obj));
            }
        }
        public override IOperation Apply()
        {
            ItemList <IItem>            tabuList      = TabuListParameter.ActualValue;
            double                      moveQuality   = MoveQualityParameter.ActualValue.Value;
            bool                        useAspiration = UseAspirationCriterion.Value;
            bool                        isTabu        = false;
            PotvinVehicleAssignmentMove move          = VehicleAssignmentMoveParameter.ActualValue;

            foreach (IItem tabuMove in tabuList)
            {
                PotvinVehicleAssignmentMoveAttribute attribute = tabuMove as PotvinVehicleAssignmentMoveAttribute;

                if (attribute != null)
                {
                    double distance = 0;
                    if (MoveDistanceParameter.ActualValue != null)
                    {
                        distance = MoveDistanceParameter.ActualValue.Value;
                    }

                    double overload = 0;
                    if (MoveOverloadParameter.ActualValue != null)
                    {
                        overload = MoveOverloadParameter.ActualValue.Value;
                    }

                    double tardiness = 0;
                    if (MoveTardinessParameter.ActualValue != null)
                    {
                        tardiness = MoveTardinessParameter.ActualValue.Value;
                    }

                    IVRPProblemInstance instance = ProblemInstanceParameter.ActualValue;
                    double quality = attribute.Distance * instance.DistanceFactor.Value;

                    IHomogenousCapacitatedProblemInstance cvrp = instance as IHomogenousCapacitatedProblemInstance;
                    if (cvrp != null)
                    {
                        quality += attribute.Overload * cvrp.OverloadPenalty.Value;
                    }

                    ITimeWindowedProblemInstance vrptw = instance as ITimeWindowedProblemInstance;
                    if (vrptw != null)
                    {
                        quality += attribute.Tardiness * vrptw.TardinessPenalty.Value;
                    }

                    if (!useAspiration || moveQuality >= quality)
                    {
                        if (attribute.Tour == move.Tour1 && attribute.Vehicle == move.Individual.GetVehicleAssignment(move.Tour2))
                        {
                            isTabu = true;
                            break;
                        }

                        if (attribute.Tour == move.Tour2 && attribute.Vehicle == move.Individual.GetVehicleAssignment(move.Tour1))
                        {
                            isTabu = true;
                            break;
                        }

                        if (attribute.Distance == distance && attribute.Overload == overload && attribute.Tardiness == tardiness)
                        {
                            isTabu = true;
                            break;
                        }
                    }
                }
            }

            MoveTabuParameter.ActualValue = new BoolValue(isTabu);
            return(base.Apply());
        }