Function PGASetUserFunction

Function Documentation

void PGASetUserFunction(PGAContext *ctx, int constant, void *f)

Specify the name of a user-written function to provide a specific GA capability (e.g., crossover, mutation, etc.).

Description

This function must be used when using a non-native datatype and must be called once for each of:

It may be called when using a native datatype to replace the built-in functions PGAPack has for that datatype (For example, if the Integer data type is used for a traveling salesperson problem, the user may want to provide their own custom crossover operator). See Constants for User Functions for the constants and chapters Custom Usage: Native Data Types and Custom Usage: New Data Types in the user guide and the examples in the examples directory for more details.

Example

void MyStringInit (PGAContext *, void *);
PGAContext *ctx;

...
PGASetUserFunction (ctx, PGA_USERFUNCTION_INITSTRING, MyStringInit);

Parameters
  • ctx – context variable

  • constant – symbolic constant of the user function to set

  • f – name of the function to use

Returns

None