コード例 #1
0
 protected PotvinTwoOptStarMoveAttribute(PotvinTwoOptStarMoveAttribute original, Cloner cloner)
   : base(original, cloner) {
   this.Tour = original.Tour;
   this.City = original.City;
   this.Distance = original.Distance;
   this.Overload = original.Overload;
   this.Tardiness = original.Tardiness;
 }
コード例 #2
0
 protected PotvinTwoOptStarMoveAttribute(PotvinTwoOptStarMoveAttribute original, Cloner cloner)
     : base(original, cloner)
 {
     this.Tour      = original.Tour;
     this.City      = original.City;
     this.Distance  = original.Distance;
     this.Overload  = original.Overload;
     this.Tardiness = original.Tardiness;
 }
コード例 #3
0
        public override bool Equals(object obj)
        {
            if (obj is PotvinTwoOptStarMoveAttribute)
            {
                PotvinTwoOptStarMoveAttribute other = obj as PotvinTwoOptStarMoveAttribute;

                return(Tour == other.Tour && City == other.City);
            }
            else
            {
                return(base.Equals(obj));
            }
        }
コード例 #4
0
        public override IOperation Apply()
        {
            ItemList <IItem>     tabuList      = TabuListParameter.ActualValue;
            double               moveQuality   = MoveQualityParameter.ActualValue.Value;
            bool                 useAspiration = UseAspirationCriterion.Value;
            bool                 isTabu        = false;
            PotvinTwoOptStarMove move          = TwoOptStarMoveParameter.ActualValue;

            List <int> segmentX1;
            List <int> segmentX2;

            PotvinTwoOptStarMoveMaker.GetSegments(move, out segmentX1, out segmentX2);

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

                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 && segmentX2.Contains(attribute.City) ||
                            attribute.Tour == move.Tour2 && segmentX1.Contains(attribute.City))
                        {
                            isTabu = true;
                            break;
                        }

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

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