| Genetic Algorithms |
IML enables you to employ user modules for crossover and mutation operators, or you may choose from the operators provided by IML. The IML operators are tied to the problem encoding options, and IML will check to make sure a specified operator is appropriate to the problem encoding. You can also turn off crossover, in which case the current population will pass on to the next generation subject only to mutation. Mutation can be turned off by setting the mutation probability to 0.
The IML-supplied genetic operators are described below, beginning with the crossover operators:
c1= p1[1,1:k] || p2[1,k+1:n]; c2= p2[1,1:k] || p1[1,k+1:n];For real fixed-length vector encoding, you can specify an additional parameter,
x2 = a * p2 + (1-a) * p1; c1 = p1[1,1:k] || x2[1,k+1:n]; x1 = a * p1 + (1-a) * p2 c2 = p2[1,1:k] || x1[1,k+1:n];Note that for
c1 = p1[1,1:k1] || p2[1,k1+1:k2] || p1[1,k2+1:n]; c2 = p2[1,1:k1] || p1[1,k1+1:k2] || p2[1,k2+1:n];For real vector encoding you can specify an additional parameter,
x2 = a * p2 + (1-a) * p1; c1 = p1[1,1:k1] || x2[1,k1+1:k2] || p1[1,k2+1:n]; x1 = a * p1 + (1-a) * p2; c2 = p2[1,1:k1] || x1[1,k1+1:k2] || p2[1,k2+1:n];Note that for
c1 = a * p1 + (1-a) * p2; c2 = a * p2 + (1-a) * p1;where a is a random number between 0 and 1. For integer encoding, each component is rounded off to the nearest integer. It has the advantage that it will always produce feasible offspring for a convex solution space. A disadvantage of this operator is that it will tend to produce offspring toward the interior of the search region, so that it may be less effective if the optimum lies on or near the search region boundary.
c1 = a * (p2 - p1) + p2;
where p2 is the parent with the better objective value, and a is a random
number between 0 and 1. The second offspring is
computed as in the arithmetic operator:
c2 = (1 - a) * p1 + a * p2;
This operator is unusual in that it uses the
objective value. It has the advantage of directing
the search in a promising direction, and automatically fine-tuning
the search in an area where solutions are clustered. If the solution
space has upper and lower bound constraints the offspring will be
checked against the bounds, and any component outside its bound will
be set equal to that bound. The heuristic operator will
perform best when the objective function is smooth, and
may not work well if the objective function or its first derivative is
discontinuous.
p1 = {1 2|3 4 5 6|7 8 9};
p2 = {8 7|9 3 4 1|2 5 6};
The first step is to cross the selected segments ( . indicates
positions yet to be determined):
c1 = {. . 9 3 4 1 . . .};
c2 = {. . 3 4 5 6 . . .};
Next, define a mapping according to the two selected segments:
9-3, 3-4, 4-5, 1-6
Next, fill in the positions where there is no conflict from the
corresponding parent:
c1 = {. 2 9 3 4 1 7 8 .};
c2 = {8 7 3 4 5 6 2 . .};
Last, fill in the remaining positions from the subsequence
mapping. In this case, for the first child
c1 = {6 2 9 3 4 1 7 8 5};
c2 = {8 7 3 4 5 6 2 9 1};
This operator will tend to maintain similarity of both the absolute
position and relative ordering of the sequence elements, and is useful for
a wide range of sequencing problems.
p1 = {1 2|3 4 5 6|7 8 9};
p2 = {8 7|9 3 4 1|2 5 6};
c1 = {. . 3 4 5 6 . . .};
c2 = {. . 9 3 4 1 . . .};
Starting at the second cutpoint, the elements of p2
in order are (cycling back to the beginning)
2 5 6 8 7 9 3 4 1
After removing 3, 4, 5 and 6, which have already been placed in
c1, we have
2 8 7 9 1
Placing these back in order starting at the second cutpoint yields
c1 = {9 1 3 4 5 6 2 8 7};
Applying this logic to c2 yields
c2 = {5 6 9 3 4 1 7 8 2};
This operator maintains the similarity of the relative
order, or adjacency, of the sequence elements of the parents.
It is especially effective for circular path-oriented optimizations,
such as the traveling salesman problem.
p1 = {1 2 3 4 5 6 7 8 9};
p2 = {8 7 9 3 4 1 2 5 6};
For the first child, pick the first element from the first parent:
c1 = {1 . . . . . . . .};
To maintain the condition that the position of each
element value must come from one of the parents,
the position of the '8' value must come from p1,
because the '8' position in p2 is already taken by the '1'
in c1:
c1 = {1 . . . . . . 8 .};
Now the position of '5' must come from p1, and so on until the
process returns to the first position:
c1 = {1 . 3 4 5 6 . 8 9};
At this point, choose the remaining element positions from p2:
c1 = {1 7 3 4 5 6 2 8 9};
For the second child, starting with the first element from
the second parent, similar logic produces
c2 = {8 2 9 3 4 1 7 5 6};
This operator is most useful when the absolute position
of the elements is of most importance to the objective value.
v[k] = v[k] + delta[k]; /* with probability 0.5 */
or
v[k] = v[k] - delta[k];
If upper and lower bounds are specified for the problem, then v[k]
is adjusted as necessary to fit within the bounds.
This operator gives you the ability to control the scope of the search
with the delta vector. One possible strategy is to start with a larger
delta value, and then reduce it as the
search progresses and begins to converge to an optimum. This operator is
also useful if the optimum is known to be on or near a boundary, in which
case delta can be set large enough to always perturb the solution
element to a boundary.
The IML-supplied crossover and mutation operators that are allowed for each problem encoding are summarized in the following table.
Table 17.1: Valid Genetic Operators for Each Encoding| Encoding | Crossover | Mutation |
| general | user module | user module |
| fixed-length real vector | user module | user module |
| simple | uniform | |
| two-point | delta | |
| arithmetic | ||
| heuristic | ||
| fixed-length integer vector | user module | user module |
| simple | uniform | |
| two-point | delta | |
| arithmetic | ||
| fixed-length integer sequence | user module | user module |
| pmatch | swap | |
| order | invert | |
| cycle |
A user module specified as a crossover operator must be a subroutine with four parameters. The module should compute and return two new offspring solutions in the first two parameters, based on the two parent solutions, which will be passed into the module in the last two parameters. The module should not modify the parent solutions passed into it. A global clause can be used to pass in any additional information that the module might use.
A user module specified as a mutation operator must be a subroutine with exactly one parameter. When the module is called, the parameter will contain the solution that is to be mutated. The module will be expected to update the parameter with the new mutated value for the solution. As with crossover, a global clause can be used to pass in any additional information that the module might use.
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.