Пример #1
0
        protected override void EvaluateMove()
        {
            PotvinTwoOptStarMove move = TwoOptStarMoveParameter.ActualValue;

            PotvinEncoding newSolution = TwoOptStarMoveParameter.ActualValue.Individual.Clone() as PotvinEncoding;

            PotvinTwoOptStarMoveMaker.Apply(newSolution, move, ProblemInstance);

            UpdateEvaluation(newSolution);
        }
Пример #2
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());
        }
        public override IOperation Apply()
        {
            ItemList <IItem> tabuList = TabuListParameter.ActualValue;
            int tabuTenure            = TabuTenureParameter.ActualValue.Value;

            int overlength = tabuList.Count - tabuTenure;

            if (overlength >= 0)
            {
                for (int i = 0; i < tabuTenure - 1; i++)
                {
                    tabuList[i] = tabuList[i + overlength + 1];
                }
                while (tabuList.Count >= tabuTenure)
                {
                    tabuList.RemoveAt(tabuList.Count - 1);
                }
            }

            double distance = 0;

            if (DistanceParameter.ActualValue != null)
            {
                distance = DistanceParameter.ActualValue.Value;
            }

            double overload = 0;

            if (OverloadParameter.ActualValue != null)
            {
                overload = OverloadParameter.ActualValue.Value;
            }

            double tardiness = 0;

            if (TardinessParameter.ActualValue != null)
            {
                tardiness = TardinessParameter.ActualValue.Value;
            }

            PotvinTwoOptStarMove move = TwoOptStarMoveParameter.ActualValue;
            double moveQuality        = MoveQualityParameter.ActualValue.Value;
            double quality            = QualityParameter.ActualValue.Value;
            double baseQuality        = moveQuality;

            if (quality < moveQuality)
            {
                baseQuality = quality;                  // we make an uphill move, the lower bound is the solution quality
            }
            List <int> segmentX1;
            List <int> segmentX2;

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

            foreach (int city in segmentX1)
            {
                tabuList.Add(new PotvinTwoOptStarMoveAttribute(baseQuality, move.Tour1, city, distance, overload, tardiness));
            }

            foreach (int city in segmentX2)
            {
                tabuList.Add(new PotvinTwoOptStarMoveAttribute(baseQuality, move.Tour2, city, distance, overload, tardiness));
            }

            return(base.Apply());
        }
 protected PotvinTwoOptStarMoveMaker(PotvinTwoOptStarMoveMaker original, Cloner cloner)
   : base(original, cloner) {
 }
Пример #5
0
 protected PotvinTwoOptStarMoveMaker(PotvinTwoOptStarMoveMaker original, Cloner cloner)
     : base(original, cloner)
 {
 }