Language Reference


GASETOBJ Call

CALL GASETOBJ (id, type <, parm> );

The GASETOBJ subroutine sets the objective function for a genetic algorithm optimization. The input arguments to the GASETOBJ call are as follows:

id

is the identifier for the genetic algorithm optimization problem, which was returned by the GASETUP function .

type

specifies the type of objective function to be used.

parm

is a matrix whose interpretation depends on the value of type, as described in the following list.

You can specify that a user-written module be used to compute the value of the objective function, or you can specify a standard preset function. This is specified with the type and parm parameters. The following list specifies the valid values of the type parameter:

0

specifies that a user-written function module is to be minimized. The name of the module is supplied in the parm parameter. The specified module should take a single parameter that represents a given solution, and return a scalar numeric value for the objective function.

1

specifies that a user-written function module be maximized. The name of the module is supplied in the parm parameter. The specified module should take a single parameter that represents a given solution, and return a scalar numeric value for the objective function.

2

specifies an objective function from the traveling salesman problem, which is minimized. This option is valid only if three conditions are met: sequence encoding was specified in the GASETUP function call, the solution vector is to be interpreted as a circular route, and each element represents a location. The parm parameter should be a square cost matrix, such that parm[i, j] is the cost of going from location i to location j. The dimension of the matrix should be the same as the size parameter of the corresponding GASETUP function call.

The specified objective function is called once for each solution to evaluate the objective values for the GAREGEN call , GAINIT call , and GAREEVAL call . Also, the objective values for the current solution population are reevaluated if GASETOBJ is called after a GAINIT call .

See the GASETUP function for an example.