Class RandomValueChangeMutation<T extends IntegerValued>
 java.lang.Object

 org.cicirello.search.operators.integers.RandomValueChangeMutation<T>

 Type Parameters:
T
 The specific IntegerValued type.
 All Implemented Interfaces:
Splittable<MutationOperator<T>>
,MutationOperator<T>
 Direct Known Subclasses:
UndoableRandomValueChangeMutation
public class RandomValueChangeMutation<T extends IntegerValued> extends Object implements MutationOperator<T>
This mutation operator is for integer valued representations, and replaces an integer value with a different random integer value from the domain. The domain is specified with an interval: [a, b]. The parameter p specifies the probability of mutating an integer. E.g., if theIntegerValued
object undergoing mutation has n integers, then on average themutate(T)
method will mutate k=n*p of those integers. The k integers chosen for mutation are chosen uniformly at random. For each of those k integers, the new value is chosen uniformly at random from [a, b] but excluding its current value. For example, let [a, b]=[0,4], and consider mutating an integer v whose value is currently v=3. The new value for v will be chosen uniformly at random from the set {0, 1, 2, 4}. Note that when a=0 and b=1, this mutation operator becomes equivalent to the traditional bitflip mutation commonly used in genetic algorithms when solutions are represented as bit strings, although use of this class and theIntegerValued
class for that purpose is not recommended as there are much more efficient ways of representing strings of bits (e.g., using bit level operators).


Constructor Summary
Constructors Constructor Description RandomValueChangeMutation(int a, int b)
Constructs a RandomValueChangeMutation operator that always mutates exactly one integer from the IntegerValued.RandomValueChangeMutation(int a, int b, double p)
Constructs a RandomValueChangeMutation operator.RandomValueChangeMutation(int a, int b, double p, int k)
Constructs a RandomValueChangeMutation operator.

Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object other)
Indicates whether some other object is equal to this one.int
hashCode()
Returns a hash code value for the object.void
mutate(T c)
Mutates a candidate solution to a problem, by randomly modifying its state.RandomValueChangeMutation<T>
split()
Generates a functionally identical copy of this object, for use in multithreaded implementations of search algorithms.



Constructor Detail

RandomValueChangeMutation
public RandomValueChangeMutation(int a, int b)
Constructs a RandomValueChangeMutation operator that always mutates exactly one integer from the IntegerValued. If the IntegerValued is a univariate, then it mutates the one and only one integer. If it is a multivariate, then one integer parameter is chosen for mutation uniformly at random. Parameters:
a
 The lower bound of the domain from which to choose random values.b
 The upper bound of the domain from which to choose random values. b must be greater than a (i.e., there must be at least 2 values in the domain). Throws:
IllegalArgumentException
 if a ≥ b.

RandomValueChangeMutation
public RandomValueChangeMutation(int a, int b, double p)
Constructs a RandomValueChangeMutation operator. If the IntegerValued undergoing mutation contains n integer parameters, then this mutation operator will mutate n*p of those integers on average during calls tomutate(T)
. Since this is a randomized process, it is possible that no integers will be mutated during a call to mutate (e.g., if p is low relative to n). Parameters:
a
 The lower bound of the domain from which to choose random values.b
 The upper bound of the domain from which to choose random values. b must be greater than a (i.e., there must be at least 2 values in the domain).p
 The probability of mutating an individual integer. Negative p are treated as p=0. If p is greater than 1, it is treated as p=1.

RandomValueChangeMutation
public RandomValueChangeMutation(int a, int b, double p, int k)
Constructs a RandomValueChangeMutation operator. If the IntegerValued undergoing mutation contains n integer parameters, then this mutation operator will mutate n*p of those integers on average during calls tomutate(T)
, but will definitely mutate at least k of them. Use this constructor if you want to insure that every call tomutate(T)
changes the IntegerValued undergoing mutation by specifying a minimum k to mutate. Parameters:
a
 The lower bound of the domain from which to choose random values.b
 The upper bound of the domain from which to choose random values. b must be greater than a (i.e., there must be at least 2 values in the domain).p
 The probability of mutating an individual integer. Negative p are treated as p=0. If p is greater than 1, it is treated as p=1.k
 The minimum number of integer parameters of the IntegerValued undergoing mutation to mutate during calls to themutate(T)
method. Negative k are treated as k=0. Throws:
IllegalArgumentException
 if a ≥ b or if p is negative.


Method Detail

mutate
public void mutate(T c)
Description copied from interface:MutationOperator
Mutates a candidate solution to a problem, by randomly modifying its state. The mutant that is produced is in the local neighborhood of the original candidate solution. Specified by:
mutate
in interfaceMutationOperator<T extends IntegerValued>
 Parameters:
c
 The candidate solution subject to the mutation. This method changes the state of c.

split
public RandomValueChangeMutation<T> split()
Description copied from interface:Splittable
Generates a functionally identical copy of this object, for use in multithreaded implementations of search algorithms. The state of the object that is returned may or may not be identical to that of the original. Thus, this is a distinct concept from the functionality of theCopyable
interface. Classes that implement this interface must ensure that the object returned performs the same functionality, and that it does not share any state data that would be either unsafe or inefficient for concurrent access by multiple threads. The split method is allowed to simply return the this reference, provided that it is both safe and efficient for multiple threads to share a single copy of the Splittable object. The intention is to provide a multithreaded search with the capability to provide spawned threads with their own distinct search operators. Such multithreaded algorithms can call the split method for each thread it spawns to generate a functionally identical copy of the operator, but with independent state. Specified by:
split
in interfaceSplittable<T extends IntegerValued>
 Returns:
 A functionally identical copy of the object, or a reference to this if it is both safe and efficient for multiple threads to share a single instance of this Splittable object.

equals
public boolean equals(Object other)
Indicates whether some other object is equal to this one. The objects are equal if they are the same type of operator with the same parameters.

