---
name: "PGASetUserFunction"
section: "3"
platform: "linux"
package: "pgapack"
version: "1.0.0.1-3"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/PGASetUserFunction/3"
---

# PGASetUserFunction(3)

specifies the name of a user-written function call to provide a specific GA capability (e.g., crossover, mutation, etc.). This function MUST be used when using a non-native datatype and must be called once for each of: PGA\_USERFUNCTION\_CREATESTRING -- String creation PGA\_USERFUNCTION\_MUTATION -- Mutation PGA\_USERFUNCTION\_CROSSOVER -- Crossover PGA\_USERFUNCTION\_PRINTSTRING -- String Output PGA\_USERFUNCTION\_COPYSTRING -- Duplication PGA\_USERFUNCTION\_DUPLICATE -- Duplicate Checking PGA\_USERFUNCTION\_INITSTRING -- Initialization PGA\_USERFUNCTION\_BUILDDATATYPE -- MPI Datatype creation PGA\_USERFUNCTION\_STOPCOND -- Stopping conditions PGA\_USERFUNCTION\_ENDOFGEN -- Auxiliary functions at the end of each generation 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 the user guide and the examples in the examples directory for more details.

## NAME

PGASetUserFunction - specifies the name of a user-written function call to provide a specific GA capability (e.g., crossover, mutation, etc.).  This function MUST be used when using a non-native datatype and must be called once for each of: PGA\_USERFUNCTION\_CREATESTRING     -- String creation PGA\_USERFUNCTION\_MUTATION         -- Mutation PGA\_USERFUNCTION\_CROSSOVER        -- Crossover PGA\_USERFUNCTION\_PRINTSTRING      -- String Output PGA\_USERFUNCTION\_COPYSTRING       -- Duplication PGA\_USERFUNCTION\_DUPLICATE        -- Duplicate Checking PGA\_USERFUNCTION\_INITSTRING       -- Initialization PGA\_USERFUNCTION\_BUILDDATATYPE    -- MPI Datatype creation PGA\_USERFUNCTION\_STOPCOND         -- Stopping conditions PGA\_USERFUNCTION\_ENDOFGEN         -- Auxiliary functions at the end of each generation 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 the user guide and the examples in the examples directory for more details.

## INPUT PARAMETERS

- ctx

  \- context variable

- constant

  \- symbolic constant of the user function to set

- f

  \- name of the function to use

## OUTPUT PARAMETERS

- none

  ## SYNOPSIS

```
#include "pgapack.h"
void  PGASetUserFunction(ctx, constant, f)
PGAContext *ctx
int constant
void *f
```

## LOCATION

user.c

## EXAMPLE

```
Example:
void MyStringInit(PGAContext *, void *);
PGAContext *ctx;
:
PGASetUserFunction(ctx, PGA_USERFUNCTION_INITSTRING, MyStringInit);
```
