Esempio n. 1
1
 protected AdditiveMove(AdditiveMove original, Cloner cloner)
   : base(original, cloner) {
   this.Dimension = original.Dimension;
   this.MoveDistance = original.MoveDistance;
   if (original.RealVector != null)
     this.RealVector = cloner.Clone(original.RealVector);
 }
 protected override double Evaluate(double quality, RealVector point, AdditiveMove move) {
   RealVectorAdditiveMoveWrapper wrapper = new RealVectorAdditiveMoveWrapper(move, point);
   var eval = EvaluatorParameter.ActualValue as MultinormalEvaluator;
   if (eval != null)
     return eval.Evaluate(wrapper);
   throw new InvalidOperationException("evaluator is not a multinormal evaluator");
 }
        public override IOperation Apply()
        {
            ItemList <IItem> tabuList      = TabuListParameter.ActualValue;
            AdditiveMove     move          = AdditiveMoveParameter.ActualValue;
            RealVector       vector        = RealVectorParameter.ActualValue;
            double           moveQuality   = MoveQualityParameter.ActualValue.Value;
            bool             maximization  = MaximizationParameter.ActualValue.Value;
            bool             useAspiration = UseAspirationCriterion.Value;
            bool             isTabu        = false;

            foreach (IItem tabuMove in tabuList)
            {
                AdditiveMoveTabuAttribute attribute = (tabuMove as AdditiveMoveTabuAttribute);
                if (attribute != null && attribute.Dimension == move.Dimension)
                {
                    if (!useAspiration ||
                        maximization && moveQuality <= attribute.MoveQuality ||
                        !maximization && moveQuality >= attribute.MoveQuality)
                    {
                        double newPos = vector[move.Dimension] + move.MoveDistance;
                        if (Math.Min(attribute.MovedPosition, attribute.OriginalPosition) < newPos &&
                            newPos < Math.Max(attribute.MovedPosition, attribute.OriginalPosition))
                        {
                            isTabu = true;
                            break;
                        }
                    }
                }
            }
            MoveTabuParameter.ActualValue = new BoolValue(isTabu);
            return(base.Apply());
        }
Esempio n. 4
0
 protected AdditiveMove(AdditiveMove original, Cloner cloner)
     : base(original, cloner)
 {
     this.Dimension    = original.Dimension;
     this.MoveDistance = original.MoveDistance;
     if (original.RealVector != null)
     {
         this.RealVector = cloner.Clone(original.RealVector);
     }
 }
Esempio n. 5
0
        protected override IItem GetTabuAttribute(bool maximization, double quality, double moveQuality)
        {
            AdditiveMove move        = AdditiveMoveParameter.ActualValue;
            RealVector   vector      = RealVectorParameter.ActualValue;
            double       baseQuality = moveQuality;

            if (maximization && quality > moveQuality || !maximization && quality < moveQuality)
            {
                baseQuality = quality;
            }
            return(new AdditiveMoveTabuAttribute(move.Dimension, vector[move.Dimension], vector[move.Dimension] + move.MoveDistance, baseQuality));
        }
Esempio n. 6
0
        public override IOperation Apply()
        {
            AdditiveMove move        = AdditiveMoveParameter.ActualValue;
            RealVector   realVector  = RealVectorParameter.ActualValue;
            DoubleValue  moveQuality = MoveQualityParameter.ActualValue;
            DoubleValue  quality     = QualityParameter.ActualValue;

            realVector[move.Dimension] += move.MoveDistance;
            quality.Value = moveQuality.Value;

            return(base.Apply());
        }
 public static AdditiveMove[] Apply(IRandom random, RealVector vector, double contiguity, int sampleSize, double maxManipulation, DoubleMatrix bounds) {
   AdditiveMove[] moves = new AdditiveMove[sampleSize];
   for (int i = 0; i < sampleSize; i++) {
     int index = random.Next(vector.Length);
     double strength = 0, min = bounds[index % bounds.Rows, 0], max = bounds[index % bounds.Rows, 1];
     do {
       strength = PolynomialOnePositionManipulator.Apply(random, contiguity) * maxManipulation;
     } while (vector[index] + strength < min || vector[index] + strength > max);
     moves[i] = new AdditiveMove(index, strength);
   }
   return moves;
 }
 public static AdditiveMove[] Apply(IRandom random, RealVector vector, double sigma, int sampleSize, DoubleMatrix bounds) {
   AdditiveMove[] moves = new AdditiveMove[sampleSize];
   NormalDistributedRandom N = new NormalDistributedRandom(random, 0, sigma);
   for (int i = 0; i < sampleSize; i++) {
     int index = random.Next(vector.Length);
     double strength = 0, min = bounds[index % bounds.Rows, 0], max = bounds[index % bounds.Rows, 1];
     do {
       strength = N.NextDouble();
     } while (vector[index] + strength < min || vector[index] + strength > max);
     moves[i] = new AdditiveMove(index, strength);
   }
   return moves;
 }
 public static AdditiveMove[] Apply(IRandom random, RealVector vector, double contiguity, int sampleSize, double maxManipulation, DoubleMatrix bounds)
 {
     AdditiveMove[] moves = new AdditiveMove[sampleSize];
     for (int i = 0; i < sampleSize; i++)
     {
         int    index = random.Next(vector.Length);
         double strength = 0, min = bounds[index % bounds.Rows, 0], max = bounds[index % bounds.Rows, 1];
         do
         {
             strength = PolynomialOnePositionManipulator.Apply(random, contiguity) * maxManipulation;
         } while (vector[index] + strength <min || vector[index] + strength> max);
         moves[i] = new AdditiveMove(index, strength);
     }
     return(moves);
 }
Esempio n. 10
0
        public static AdditiveMove[] Apply(IRandom random, RealVector vector, double sigma, int sampleSize, DoubleMatrix bounds)
        {
            AdditiveMove[]          moves = new AdditiveMove[sampleSize];
            NormalDistributedRandom N     = new NormalDistributedRandom(random, 0, sigma);

            for (int i = 0; i < sampleSize; i++)
            {
                int    index = random.Next(vector.Length);
                double strength = 0, min = bounds[index % bounds.Rows, 0], max = bounds[index % bounds.Rows, 1];
                do
                {
                    strength = N.NextDouble();
                } while (vector[index] + strength <min || vector[index] + strength> max);
                moves[i] = new AdditiveMove(index, strength);
            }
            return(moves);
        }
 protected override double Evaluate(double quality, RealVector point, AdditiveMove move) {
   RealVectorAdditiveMoveWrapper wrapper = new RealVectorAdditiveMoveWrapper(move, point);
   return RastriginEvaluator.Apply(wrapper, A.Value);
 }
 protected override double Evaluate(double quality, RealVector point, AdditiveMove move) {
   RealVectorAdditiveMoveWrapper wrapper = new RealVectorAdditiveMoveWrapper(move, point);
   return BoothEvaluator.Apply(wrapper);
 }
 public RealVectorAdditiveMoveWrapper(AdditiveMove move, RealVector vector) {
   dimension = move.Dimension;
   moveDistance = move.MoveDistance;
   this.vector = vector;
 }
 protected abstract double Evaluate(double quality, RealVector point, AdditiveMove move);
 protected override double Evaluate(double quality, RealVector point, AdditiveMove move) {
   return RandomParameter.ActualValue.NextDouble();
 }
 protected override double Evaluate(double quality, RealVector point, AdditiveMove move) {
   RealVectorAdditiveMoveWrapper wrapper = new RealVectorAdditiveMoveWrapper(move, point);
   return SphereEvaluator.Apply(wrapper, C.Value, Alpha.Value);
 }