LibCudaOptimize  1.0
SolutionSet Class Reference

Set(s) of solutions. More...

#include <SolutionSet.h>

List of all members.

Public Member Functions

 SolutionSet (unsigned int dn, unsigned int sn, unsigned int pn)
 Instantiate a SolutionSet.
FitnessSetgetFitnessSet ()
 get the fitnesses of SolutionSet. It must be used during the fitness evaluation
void init (LOG_LEVEL verbosity, std::string loggerFile)
 Initialize the SolutionSet.
void free ()
 Release both device and host memory.
void findBests (bool maximize=false)
 Updates global best fitnesses, indexes in device memory.
void setSetNumber (unsigned int sn)
 Set number of sets SolutionSet will use.
void setSolutionNumber (unsigned int pn)
 Set number of solutions SolutionSet will use in each set.
void setProblemDimension (unsigned int dn)
 Set problem dimension of the SolutionSet.
void setParams (unsigned int sn, unsigned int pn, unsigned int dn)
 Set number of sets, number of solutions, and problem dimension SolutionSet will use.
void setParams (const SolutionSet &src)
 Set number of sets, number of solutions, and problem dimension SolutionSet will use.
void setDevicePositions (float *ptr, POINTER_LOCATION location=HOST_POINTER, unsigned int sid=ALL_SETS)
 Set all device positions of the SolutionSet.
void setDevicePositionsPtr (float *ptr)
 Set device positions pointer.
void setDeviceFitnesses (float *ptr, POINTER_LOCATION location=HOST_POINTER, unsigned int sid=ALL_SETS)
 Set all device fitnesses of the SolutionSet.
void setDeviceFitnessesPtr (float *ptr)
 Set device fitnesses pointer.
void setDeviceFitnesses (FitnessSet fitn)
 Set all device fitnesses using a FitnessSet.
unsigned int getSetNumber () const
 Get number of sets SolutionSet is using.
unsigned int getSolutionNumber () const
 Get number of solutions SolutionSet is using for each set.
unsigned int getProblemDimension () const
 Get problem dimension (number of dimension) SolutionSet is using.
unsigned int getActualSolutionSize () const
 Get size of a single solution in memory (iAlignUp(problemDimension, 16))
float * getDevicePositions ()
 Get device pointer to all solutions of the SolutionSet.
const float * getDevicePositionsConst () const
 see getDevicePositionsConst
float * getDeviceFitnesses ()
 Get device pointer to all fitnesses of the SolutionSet.
const float * getDeviceFitnessesConst () const
 see getDeviceFitnesses
float * getDeviceBestFitnesses ()
 Get device pointer to best fitnesses of all sets of the SolutionSet.
const float * getDeviceBestFitnessesConst () const
 see getDeviceBestFitnesses
uint32_t * getDeviceBestIDs ()
 Get device pointer to indexes of the best element for all sets of the SolutionSet.
const uint32_t * getDeviceBestIDsConst () const
 see getDeviceBestIDs
float * getDevicePositions (unsigned int sid)
 Get device pointer to all solutions of a set.
const float * getDevicePositionsConst (unsigned int sid) const
 see getDevicePositions
float * getDeviceFitnesses (unsigned int sid)
 Get device pointer to all fitnesses of a set.
const float * getDeviceFitnessesConst (unsigned int sid) const
 see getDeviceFitnesses
float * getDeviceBestFitnesses (unsigned int sid)
 Get device pointer to the best fitness of a set.
const float * getDeviceBestFitnessesConst (unsigned int sid) const
 see getDeviceBestFitnesses
uint32_t * getDeviceBestIDs (unsigned int sid)
 Get device pointer to index of the best element for a single set.
const uint32_t * getDeviceBestIDsConst (unsigned int sid) const
 see getDeviceBestIDs
float * getDevicePositions (unsigned int sid, unsigned int pid)
 Get device pointer to a single solution pid in the set sid.
const float * getDevicePositionsConst (unsigned int sid, unsigned int pid) const
 see getDevicePositions
float * getDeviceFitnesses (unsigned int sid, unsigned int pid)
 Get device pointer to a fitness of a solution pid in the set sid.
const float * getDeviceFitnessesConst (unsigned int sid, unsigned int pid) const
 see getDeviceFitnesses
float * getHostFitnesses ()
 Get host pointer to all fitnesses of the SolutionSet.
float * getHostBestFitnesses ()
 Get host pointer to best fitnesses of all sets of the SolutionSet.
float * getHostBestPositions ()
 Get host pointer to best elements of all sets of the SolutionSet.
float * getHostFitnesses (unsigned int sid)
 Get host pointer to fitnesses of a set.
float getHostBestFitnesses (unsigned int sid)
 Get value of the best fitness of a set.
float * getHostBestPositions (unsigned int sid)
 Get host pointer to the position of the best solution found in a set.
void copyPositionsToHost ()
 copy all solutions from device to host
const float * getHostPositions (unsigned int sid=ALL_SETS, unsigned int pid=ALL_SOLUTIONS)
 Get updated host pointer to solutions of the SolutionSet.
const float * getHostPositionsConst (unsigned int sid=ALL_SETS, unsigned int pid=ALL_SOLUTIONS) const
 Get a host pointer to all solutions of the SolutionSet, without copying it from the device.
float getHostFitnesses (unsigned int sid, unsigned int pid)
 Get host pointer to actual fitnesses of the SolutionSet.

Detailed Description

Set(s) of solutions.

An instance of this class represents a multi-set of solutions used inside a IOptimizer

Definition at line 31 of file SolutionSet.h.


Constructor & Destructor Documentation

SolutionSet::SolutionSet ( unsigned int  dn,
unsigned int  sn,
unsigned int  pn 
)

Instantiate a SolutionSet.

Parameters:
dnproblem dimension: number of elements in a solution
snnumber of sets
pnnumber of solutions in a set

Member Function Documentation

void SolutionSet::findBests ( bool  maximize = false)

Updates global best fitnesses, indexes in device memory.

Parameters:
maximizetrue if a higher fitness represents a better result, false (default) otherwise
unsigned int SolutionSet::getActualSolutionSize ( ) const [inline]

Get size of a single solution in memory (iAlignUp(problemDimension, 16))

Returns:
number of actual solution size

Definition at line 152 of file SolutionSet.h.

Get device pointer to best fitnesses of all sets of the SolutionSet.

Returns:
device pointer to best fitnesses

Definition at line 165 of file SolutionSet.h.

float* SolutionSet::getDeviceBestFitnesses ( unsigned int  sid) [inline]

Get device pointer to the best fitness of a set.

Parameters:
sidindex of the set
Returns:
device pointer to best fitness

Definition at line 188 of file SolutionSet.h.

uint32_t* SolutionSet::getDeviceBestIDs ( ) [inline]

Get device pointer to indexes of the best element for all sets of the SolutionSet.

Returns:
device pointer to best indexes

Definition at line 170 of file SolutionSet.h.

uint32_t* SolutionSet::getDeviceBestIDs ( unsigned int  sid) [inline]

Get device pointer to index of the best element for a single set.

Parameters:
sidindex of the set
Returns:
device pointer to the index

Definition at line 194 of file SolutionSet.h.

float* SolutionSet::getDeviceFitnesses ( ) [inline]

Get device pointer to all fitnesses of the SolutionSet.

Returns:
device pointer to fitnesses

Definition at line 160 of file SolutionSet.h.

References FitnessSet::get().

Here is the call graph for this function:

float* SolutionSet::getDeviceFitnesses ( unsigned int  sid) [inline]

Get device pointer to all fitnesses of a set.

Parameters:
sidindex of the set
Returns:
device pointer to fitnesses

Definition at line 182 of file SolutionSet.h.

References FitnessSet::get().

Here is the call graph for this function:

float* SolutionSet::getDeviceFitnesses ( unsigned int  sid,
unsigned int  pid 
) [inline]

Get device pointer to a fitness of a solution pid in the set sid.

Parameters:
sidindex of the set
pidindex of the solution
Returns:
device pointer to the fitness

Definition at line 208 of file SolutionSet.h.

References FitnessSet::get().

Here is the call graph for this function:

float* SolutionSet::getDevicePositions ( ) [inline]

Get device pointer to all solutions of the SolutionSet.

Returns:
device pointer to positions

Definition at line 155 of file SolutionSet.h.

float* SolutionSet::getDevicePositions ( unsigned int  sid) [inline]

Get device pointer to all solutions of a set.

Parameters:
sidindex of the set
Returns:
device pointer to the solutions

Definition at line 176 of file SolutionSet.h.

float* SolutionSet::getDevicePositions ( unsigned int  sid,
unsigned int  pid 
) [inline]

Get device pointer to a single solution pid in the set sid.

Parameters:
sidindex of the set
pidindex of the solution
Returns:
device pointer to the solution

Definition at line 201 of file SolutionSet.h.

get the fitnesses of SolutionSet. It must be used during the fitness evaluation

Returns:
pointer to the FitnessSet

Definition at line 89 of file SolutionSet.h.

Get host pointer to best fitnesses of all sets of the SolutionSet.

Returns:
host pointer to best fitnesses
float SolutionSet::getHostBestFitnesses ( unsigned int  sid)

Get value of the best fitness of a set.

Parameters:
sidnumber of the set
Returns:
best set fitness

Get host pointer to best elements of all sets of the SolutionSet.

Returns:
host pointer to best elements
float* SolutionSet::getHostBestPositions ( unsigned int  sid)

Get host pointer to the position of the best solution found in a set.

Parameters:
sidnumber of the set
Returns:
host pointer to position

Get host pointer to all fitnesses of the SolutionSet.

Returns:
host pointer to fitnesses
float* SolutionSet::getHostFitnesses ( unsigned int  sid)

Get host pointer to fitnesses of a set.

Parameters:
sidnumber of the set
Returns:
host pointer to fitnesses
float SolutionSet::getHostFitnesses ( unsigned int  sid,
unsigned int  pid 
)

Get host pointer to actual fitnesses of the SolutionSet.

Parameters:
sidindex of the swarm (default is ALL_SETS)
pidindex of the solution (default is ALL_SOLUTIONS)
Returns:
host pointer to fitnesses
const float* SolutionSet::getHostPositions ( unsigned int  sid = ALL_SETS,
unsigned int  pid = ALL_SOLUTIONS 
)

Get updated host pointer to solutions of the SolutionSet.

Parameters:
sidindex of the swarm (default is ALL_SETS)
pidindex of the solution (default is ALL_SOLUTIONS)
Returns:
host pointer to positions
const float* SolutionSet::getHostPositionsConst ( unsigned int  sid = ALL_SETS,
unsigned int  pid = ALL_SOLUTIONS 
) const

Get a host pointer to all solutions of the SolutionSet, without copying it from the device.

Parameters:
sidindex of the swarm (default is ALL_SETS)
pidindex of the solution (default is ALL_SOLUTIONS)
Returns:
host pointer to positions
unsigned int SolutionSet::getProblemDimension ( ) const [inline]

Get problem dimension (number of dimension) SolutionSet is using.

Returns:
problem dimension

Definition at line 149 of file SolutionSet.h.

Referenced by setParams().

Here is the caller graph for this function:

unsigned int SolutionSet::getSetNumber ( ) const [inline]

Get number of sets SolutionSet is using.

Returns:
number of sets

Definition at line 143 of file SolutionSet.h.

Referenced by setParams().

Here is the caller graph for this function:

unsigned int SolutionSet::getSolutionNumber ( ) const [inline]

Get number of solutions SolutionSet is using for each set.

Returns:
number of solutions

Definition at line 146 of file SolutionSet.h.

Referenced by setParams().

Here is the caller graph for this function:

void SolutionSet::init ( LOG_LEVEL  verbosity,
std::string  loggerFile 
)

Initialize the SolutionSet.

Parameters:
verbosityverbosity level (see OptimizerLog.h)
loggerFilefile used for logging (if empty, stderr will be used)
void SolutionSet::setDeviceFitnesses ( float *  ptr,
POINTER_LOCATION  location = HOST_POINTER,
unsigned int  sid = ALL_SETS 
)

Set all device fitnesses of the SolutionSet.

Parameters:
ptrdevice pointer to an array
locationwhether ptr resides in device or host memory
sidnumber of set whose fitness should be changed (default ALL_SETS)

Set all device fitnesses using a FitnessSet.

Parameters:
fitnthe FitnessSet used to update the fitnesses
void SolutionSet::setDeviceFitnessesPtr ( float *  ptr) [inline]

Set device fitnesses pointer.

Parameters:
ptrpointer to an array on the device

Definition at line 136 of file SolutionSet.h.

References FitnessSet::setPtr().

Here is the call graph for this function:

void SolutionSet::setDevicePositions ( float *  ptr,
POINTER_LOCATION  location = HOST_POINTER,
unsigned int  sid = ALL_SETS 
)

Set all device positions of the SolutionSet.

Parameters:
ptrpointer to an array
locationwhether ptr resides in device or host memory
sidnumber of set whose fitness should be changed (default ALL_SETS)
void SolutionSet::setDevicePositionsPtr ( float *  ptr) [inline]

Set device positions pointer.

Parameters:
ptrpointer to an array on the device

Definition at line 128 of file SolutionSet.h.

void SolutionSet::setParams ( unsigned int  sn,
unsigned int  pn,
unsigned int  dn 
) [inline]

Set number of sets, number of solutions, and problem dimension SolutionSet will use.

Parameters:
snnumber of sets
pnpopulation size of each set
dnproblem dimension

Definition at line 115 of file SolutionSet.h.

References setProblemDimension(), setSetNumber(), and setSolutionNumber().

Here is the call graph for this function:

void SolutionSet::setParams ( const SolutionSet src) [inline]

Set number of sets, number of solutions, and problem dimension SolutionSet will use.

Parameters:
srcanother SolutionSet instance to get the parameters from

Definition at line 119 of file SolutionSet.h.

References getProblemDimension(), getSetNumber(), getSolutionNumber(), and setParams().

Referenced by setParams().

Here is the call graph for this function:

Here is the caller graph for this function:

void SolutionSet::setProblemDimension ( unsigned int  dn) [inline]

Set problem dimension of the SolutionSet.

Parameters:
dnproblem dimension

Definition at line 110 of file SolutionSet.h.

References iAlignUp().

Referenced by setParams().

Here is the call graph for this function:

Here is the caller graph for this function:

void SolutionSet::setSetNumber ( unsigned int  sn) [inline]

Set number of sets SolutionSet will use.

Parameters:
snnumber of sets

Definition at line 104 of file SolutionSet.h.

Referenced by setParams().

Here is the caller graph for this function:

void SolutionSet::setSolutionNumber ( unsigned int  pn) [inline]

Set number of solutions SolutionSet will use in each set.

Parameters:
pnpopulation size of each set

Definition at line 107 of file SolutionSet.h.

Referenced by setParams().

Here is the caller graph for this function:


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations Enumerator Defines