LibCudaOptimize
1.0
|
Set(s) of solutions. More...
#include <SolutionSet.h>
Public Member Functions | |
SolutionSet (unsigned int dn, unsigned int sn, unsigned int pn) | |
Instantiate a SolutionSet. | |
FitnessSet * | getFitnessSet () |
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. |
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.
SolutionSet::SolutionSet | ( | unsigned int | dn, |
unsigned int | sn, | ||
unsigned int | pn | ||
) |
Instantiate a SolutionSet.
dn | problem dimension: number of elements in a solution |
sn | number of sets |
pn | number of solutions in a set |
void SolutionSet::findBests | ( | bool | maximize = false | ) |
Updates global best fitnesses, indexes in device memory.
maximize | true 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))
Definition at line 152 of file SolutionSet.h.
float* SolutionSet::getDeviceBestFitnesses | ( | ) | [inline] |
Get device pointer to best fitnesses of all sets of the SolutionSet.
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.
sid | index of the set |
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.
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.
sid | index of the set |
Definition at line 194 of file SolutionSet.h.
float* SolutionSet::getDeviceFitnesses | ( | ) | [inline] |
Get device pointer to all fitnesses of the SolutionSet.
Definition at line 160 of file SolutionSet.h.
References FitnessSet::get().
float* SolutionSet::getDeviceFitnesses | ( | unsigned int | sid | ) | [inline] |
Get device pointer to all fitnesses of a set.
sid | index of the set |
Definition at line 182 of file SolutionSet.h.
References FitnessSet::get().
float* SolutionSet::getDeviceFitnesses | ( | unsigned int | sid, |
unsigned int | pid | ||
) | [inline] |
Get device pointer to a fitness of a solution pid in the set sid.
sid | index of the set |
pid | index of the solution |
Definition at line 208 of file SolutionSet.h.
References FitnessSet::get().
float* SolutionSet::getDevicePositions | ( | ) | [inline] |
Get device pointer to all solutions of the SolutionSet.
Definition at line 155 of file SolutionSet.h.
float* SolutionSet::getDevicePositions | ( | unsigned int | sid | ) | [inline] |
Get device pointer to all solutions of a set.
sid | index of the set |
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.
sid | index of the set |
pid | index of the solution |
Definition at line 201 of file SolutionSet.h.
FitnessSet* SolutionSet::getFitnessSet | ( | ) | [inline] |
get the fitnesses of SolutionSet. It must be used during the fitness evaluation
Definition at line 89 of file SolutionSet.h.
float* SolutionSet::getHostBestFitnesses | ( | ) |
Get host pointer to best fitnesses of all sets of the SolutionSet.
float SolutionSet::getHostBestFitnesses | ( | unsigned int | sid | ) |
Get value of the best fitness of a set.
sid | number of the set |
float* SolutionSet::getHostBestPositions | ( | ) |
Get host pointer to best elements of all sets of the SolutionSet.
float* SolutionSet::getHostBestPositions | ( | unsigned int | sid | ) |
Get host pointer to the position of the best solution found in a set.
sid | number of the set |
float* SolutionSet::getHostFitnesses | ( | ) |
Get host pointer to all fitnesses of the SolutionSet.
float* SolutionSet::getHostFitnesses | ( | unsigned int | sid | ) |
Get host pointer to fitnesses of a set.
sid | number of the set |
float SolutionSet::getHostFitnesses | ( | unsigned int | sid, |
unsigned int | pid | ||
) |
Get host pointer to actual fitnesses of the SolutionSet.
sid | index of the swarm (default is ALL_SETS) |
pid | index of the solution (default is ALL_SOLUTIONS) |
const float* SolutionSet::getHostPositions | ( | unsigned int | sid = ALL_SETS , |
unsigned int | pid = ALL_SOLUTIONS |
||
) |
Get updated host pointer to solutions of the SolutionSet.
sid | index of the swarm (default is ALL_SETS) |
pid | index of the solution (default is ALL_SOLUTIONS) |
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.
sid | index of the swarm (default is ALL_SETS) |
pid | index of the solution (default is ALL_SOLUTIONS) |
unsigned int SolutionSet::getProblemDimension | ( | ) | const [inline] |
Get problem dimension (number of dimension) SolutionSet is using.
Definition at line 149 of file SolutionSet.h.
Referenced by setParams().
unsigned int SolutionSet::getSetNumber | ( | ) | const [inline] |
Get number of sets SolutionSet is using.
Definition at line 143 of file SolutionSet.h.
Referenced by setParams().
unsigned int SolutionSet::getSolutionNumber | ( | ) | const [inline] |
Get number of solutions SolutionSet is using for each set.
Definition at line 146 of file SolutionSet.h.
Referenced by setParams().
void SolutionSet::init | ( | LOG_LEVEL | verbosity, |
std::string | loggerFile | ||
) |
Initialize the SolutionSet.
verbosity | verbosity level (see OptimizerLog.h) |
loggerFile | file 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.
ptr | device pointer to an array |
location | whether ptr resides in device or host memory |
sid | number of set whose fitness should be changed (default ALL_SETS) |
void SolutionSet::setDeviceFitnesses | ( | FitnessSet | fitn | ) |
Set all device fitnesses using a FitnessSet.
fitn | the FitnessSet used to update the fitnesses |
void SolutionSet::setDeviceFitnessesPtr | ( | float * | ptr | ) | [inline] |
Set device fitnesses pointer.
ptr | pointer to an array on the device |
Definition at line 136 of file SolutionSet.h.
References FitnessSet::setPtr().
void SolutionSet::setDevicePositions | ( | float * | ptr, |
POINTER_LOCATION | location = HOST_POINTER , |
||
unsigned int | sid = ALL_SETS |
||
) |
Set all device positions of the SolutionSet.
ptr | pointer to an array |
location | whether ptr resides in device or host memory |
sid | number of set whose fitness should be changed (default ALL_SETS) |
void SolutionSet::setDevicePositionsPtr | ( | float * | ptr | ) | [inline] |
Set device positions pointer.
ptr | pointer 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.
sn | number of sets |
pn | population size of each set |
dn | problem dimension |
Definition at line 115 of file SolutionSet.h.
References setProblemDimension(), setSetNumber(), and setSolutionNumber().
void SolutionSet::setParams | ( | const SolutionSet & | src | ) | [inline] |
Set number of sets, number of solutions, and problem dimension SolutionSet will use.
src | another SolutionSet instance to get the parameters from |
Definition at line 119 of file SolutionSet.h.
References getProblemDimension(), getSetNumber(), getSolutionNumber(), and setParams().
Referenced by setParams().
void SolutionSet::setProblemDimension | ( | unsigned int | dn | ) | [inline] |
Set problem dimension of the SolutionSet.
dn | problem dimension |
Definition at line 110 of file SolutionSet.h.
References iAlignUp().
Referenced by setParams().
void SolutionSet::setSetNumber | ( | unsigned int | sn | ) | [inline] |
Set number of sets SolutionSet will use.
sn | number of sets |
Definition at line 104 of file SolutionSet.h.
Referenced by setParams().
void SolutionSet::setSolutionNumber | ( | unsigned int | pn | ) | [inline] |
Set number of solutions SolutionSet will use in each set.
pn | population size of each set |
Definition at line 107 of file SolutionSet.h.
Referenced by setParams().