The GA Procedure |
reads a segment from a selected child solution into an array, within a user crossover operator
The inputs to the ReadChild subroutine are as follows:
selected | specifies the family (parents and children) obtained from the selection process. |
seg | specifies the solution segment to be read. |
n | specifies the child in the family from which to read the solution segment. |
values | specifies an array to receive the solution elements. |
The ReadChild call is used to obtain the solution values for manipulation within a user crossover operator subroutine. Normally it is needed only if you need to augment the action of a GA procedure-supplied crossover operator. You might need to make modifications to satisfy constraints, for example. The selected parameter is passed into the user subroutine by the GA procedure. The seg parameter is the desired segment of the solution to be obtained. Segments, which correspond to different encodings in the encoding string, are numbered, starting from 1 as the first segment. The parameter n should be 1 to get the first child and 2 for the second. The parameter values is an array, which should be dimensioned large enough to contain the segment's encoding. For example, the following subroutine illustrates how you could use the Read/WriteChild calls to modify offspring generated with a standard genetic operator:
call SetEncoding('R5'); subroutine cross(selected[*]); /* generate offspring with arithmetic crossover operator */ call CrossArithmetic(selected, 1); /* here 1 refers to segment 1*/ array child1[5]; array child2[5]; /* get elements of first child solution */ call ReadChild(selected, 1, 1, child1); /* get elements of second child solution values */ call ReadChild(selected, 1, 2, child2); ... /* code to modify elements in child1 and child2 */ ... call WriteChild(selected,1,1,child1); call WriteChild(selected,1,2,child2);
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.