protected override void EvaluateMove()
        {
            PotvinCustomerRelocationMove move = CustomerRelocationMoveParameter.ActualValue;

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

            PotvinCustomerRelocationMoveMaker.Apply(newSolution, move, ProblemInstance);

            UpdateEvaluation(newSolution);

            //Apply memory, only if move is worse
            if (MoveQualityParameter.ActualValue.Value >= QualityParameter.ActualValue.Value)
            {
                VariableCollection memory = MemoriesParameter.ActualValue;
                string             key    = AdditionFrequencyMemoryKeyParameter.Value.Value;

                if (memory != null && memory.ContainsKey(key))
                {
                    ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency =
                        memory[key].Value as ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue>;
                    PotvinCustomerRelocationMoveAttribute attr = new PotvinCustomerRelocationMoveAttribute(0, move.Tour, move.City);
                    if (additionFrequency.ContainsKey(attr))
                    {
                        int    frequency = additionFrequency[attr].Value;
                        double quality   = MoveQualityParameter.ActualValue.Value;

                        MoveQualityParameter.ActualValue.Value +=
                            LambdaParameter.Value.Value * quality * frequency;
                    }
                }
            }
        }
Esempio n. 2
0
        public override bool Equals(object obj)
        {
            if (obj is PotvinCustomerRelocationMoveAttribute)
            {
                PotvinCustomerRelocationMoveAttribute other = obj as PotvinCustomerRelocationMoveAttribute;

                return(Tour == other.Tour && City == other.City);
            }
            else
            {
                return(base.Equals(obj));
            }
        }
        protected override void PerformMove()
        {
            PotvinCustomerRelocationMove move = CustomerRelocationMoveParameter.ActualValue;

            PotvinEncoding newSolution = move.Individual.Clone() as PotvinEncoding;

            Apply(newSolution, move, ProblemInstance);
            newSolution.Repair();
            VRPToursParameter.ActualValue = newSolution;

            //reset move quality
            VRPEvaluation eval = ProblemInstance.Evaluate(newSolution);

            MoveQualityParameter.ActualValue.Value = eval.Quality;

            //update memory
            VariableCollection memory = MemoriesParameter.ActualValue;
            string             key    = AdditionFrequencyMemoryKeyParameter.Value.Value;

            if (memory != null)
            {
                if (!memory.ContainsKey(key))
                {
                    memory.Add(new Variable(key,
                                            new ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue>()));
                }
                ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency =
                    memory[key].Value as ItemDictionary <PotvinCustomerRelocationMoveAttribute, IntValue>;

                PotvinCustomerRelocationMoveAttribute attr = new PotvinCustomerRelocationMoveAttribute(0, move.Tour, move.City);
                if (!additionFrequency.ContainsKey(attr))
                {
                    additionFrequency[attr] = new IntValue(0);
                }

                additionFrequency[attr].Value++;
            }
        }
    protected override void PerformMove() {
      PotvinCustomerRelocationMove move = CustomerRelocationMoveParameter.ActualValue;

      PotvinEncoding newSolution = move.Individual.Clone() as PotvinEncoding;
      Apply(newSolution, move, ProblemInstance);
      newSolution.Repair();
      VRPToursParameter.ActualValue = newSolution;

      //reset move quality
      VRPEvaluation eval = ProblemInstance.Evaluate(newSolution);
      MoveQualityParameter.ActualValue.Value = eval.Quality;

      //update memory
      VariableCollection memory = MemoriesParameter.ActualValue;
      string key = AdditionFrequencyMemoryKeyParameter.Value.Value;

      if (memory != null) {
        if (!memory.ContainsKey(key)) {
          memory.Add(new Variable(key,
              new ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>()));
        }
        ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency =
          memory[key].Value as ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>;

        PotvinCustomerRelocationMoveAttribute attr = new PotvinCustomerRelocationMoveAttribute(0, move.Tour, move.City);
        if (!additionFrequency.ContainsKey(attr))
          additionFrequency[attr] = new IntValue(0);

        additionFrequency[attr].Value++;
      }
    }
 protected PotvinCustomerRelocationMoveAttribute(PotvinCustomerRelocationMoveAttribute original, Cloner cloner)
   : base(original, cloner) {
   this.Tour = original.Tour;
   this.City = original.City;
 }
Esempio n. 6
0
 protected PotvinCustomerRelocationMoveAttribute(PotvinCustomerRelocationMoveAttribute original, Cloner cloner)
     : base(original, cloner)
 {
     this.Tour = original.Tour;
     this.City = original.City;
 }
    protected override void EvaluateMove() {
      PotvinCustomerRelocationMove move = CustomerRelocationMoveParameter.ActualValue;

      PotvinEncoding newSolution = CustomerRelocationMoveParameter.ActualValue.Individual.Clone() as PotvinEncoding;
      PotvinCustomerRelocationMoveMaker.Apply(newSolution, move, ProblemInstance);

      UpdateEvaluation(newSolution);

      //Apply memory, only if move is worse
      if (MoveQualityParameter.ActualValue.Value >= QualityParameter.ActualValue.Value) {
        VariableCollection memory = MemoriesParameter.ActualValue;
        string key = AdditionFrequencyMemoryKeyParameter.Value.Value;

        if (memory != null && memory.ContainsKey(key)) {
          ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue> additionFrequency =
               memory[key].Value as ItemDictionary<PotvinCustomerRelocationMoveAttribute, IntValue>;
          PotvinCustomerRelocationMoveAttribute attr = new PotvinCustomerRelocationMoveAttribute(0, move.Tour, move.City);
          if (additionFrequency.ContainsKey(attr)) {
            int frequency = additionFrequency[attr].Value;
            double quality = MoveQualityParameter.ActualValue.Value;

            MoveQualityParameter.ActualValue.Value +=
              LambdaParameter.Value.Value * quality * frequency;
          }
        }
      }
    }