EnsureBounds function

Altering vector of doubles to satisfy boundary constraints

Altering vector of doubles to satisfy boundary constraints

Byte based crossover and mutation operators can generate variables out of bounds of the decision variables. This function controls if variables are between their lower and upper bounds and if not, draws random numbers between these ranges. This function directly modifies the argument doubles and does not return a value.

EnsureBounds(doubles, mins, maxs)

Arguments

  • doubles: A vector of doubles
  • mins: A vector of lower bounds of decision variables
  • maxs: A vector of upper bounds of decision variables

Returns

Function directly modifies the argument doubles and does not return a result.

Examples

set.seed(1234) x <- runif(10) print(x) # [1] 0.113703411 0.622299405 0.609274733 0.623379442 0.860915384 0.640310605 # [7] 0.009495756 0.232550506 0.666083758 0.514251141 EnsureBounds(x, mins=rep(0,10), maxs=rep(0.2,10)) print(x) # [1] 0.113703411 0.138718258 0.108994967 0.056546717 0.184686697 0.058463168 # [7] 0.009495756 0.167459126 0.057244657 0.053364156

Author(s)

Mehmet Hakan Satman - mhsatman@istanbul.edu.tr

See Also

byte_crossover

byte_mutation

mcga2

  • Maintainer: Mehmet Hakan Satman
  • License: GPL (>= 2)
  • Last published: 2023-11-27

Useful links