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

# PGACreate(3)

creates an uninitialized context variable. The Fortran version of this function call contains only the last three arguments

## NAME

PGACreate - creates an uninitialized context variable.  The Fortran version of this function call contains only the last three arguments

## INPUT PARAMETERS

- argc

  \- address of the count of the number of command line arguments.

- argv

  \- array of command line arguments.

- datatype

  \- the data type used for the strings.  Must be one of PGA\_DATATYPE\_BINARY, PGA\_DATATYPE\_CHARACTER, PGA\_DATATYPE\_INTEGER, PGA\_DATATYPE\_REAL, or PGA\_DATATYPE\_USER

- binary

  \-valued, character-valued, integer-valued,

- real

  \-valued, or a user-defined datatype, respectively.

- len

  \- the string length (number of genes).

- maxormin

  \- the direction of optimization. Must be one of PGA\_MAXIMIZE or PGA\_MINIMIZE for maximization or minimization, respectively.

## OUTPUT PARAMETERS

- none

  ## SYNOPSIS

```
#include "pgapack.h"
PGAContext * PGACreate(argc, argv, datatype, len, maxormin)
int *argc
char **argv
int datatype
int len
int maxormin
```

## LOCATION

create.c

## EXAMPLE

```
Example:
In C:
void main(int argc, char **argv) {
PGAContext *ctx;
:
ctx = PGACreate(&argc, argv, PGA_DATATYPE_BINARY, 100, PGA_MAXIMIZE);
:
//  Set options here
:
PGASetUp(ctx);
:
//  Run the GA here
:
PGADestroy(ctx);
}
In FORTRAN:
integer ctx
:
ctx = PGACreate(PGA_DATATYPE_BINARY, 100, PGA_MAXIMIZE)
:
c       Set options here
:
call PGASetUp(ctx)
:
c       Run the GA here
:
call PGADestroy(ctx)
stop
end
```
