Function PGAMapRealToInteger

Function Documentation

static int PGAMapRealToInteger(PGAContext *ctx, double r, double l, double u, int a, int b)

Map the value r defined on [l,u] to v defined on [a,b].

Description

In the context of PGAPack \([a,b]\) is the discrete interval \([0,2^{nbits}-1]\) (i.e., the number of bits in a binary string) and \([l,u]\) represent the range of possible values of the real number \(r\).

Example

Map the value r on the interval [0, 3.14] to a five bit integer v.

PGAContext *ctx;
double r;
int v;

...
v = PGAMapRealToInteger (ctx, r, 0.0, 3.14, 0, 31);

Parameters
  • ctx – context variable

  • r – real value defined on [l,u]

  • l – lower bound of real interval

  • u – upper bound of real interval

  • a – lower bound of integer interval

  • b – upper bound of integer interval

Returns

Scaled value of r defined on [a,b]