OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Sampler Class Reference

Implementing sampling. More...

#include <Sampler.h>

Inheritance diagram for Sampler:
Inheritance graph
[legend]
Collaboration diagram for Sampler:
Collaboration graph
[legend]

Public Types

typedef std::vector
< SampleIndividual
SolutionState_t
 type used in solution state exchange with other optimizers More...
 
- Public Types inherited from Optimizer
typedef std::vector< std::pair
< double, double > > 
bounds_t
 type of bounds for design variables More...
 

Public Member Functions

 Sampler (Expressions::Named_t objectives, Expressions::Named_t constraints, DVarContainer_t dvars, size_t dim, Comm::Bundle_t comms, CmdArguments_t args, std::vector< double > hypervolRef, int nrWorkerGroups)
 
 Sampler (const std::map< std::string, std::shared_ptr< SamplingMethod > > &sampleMethods, Expressions::Named_t objectives, DVarContainer_t dvars, Comm::Bundle_t comms, CmdArguments_t args)
 
virtual void initialize ()
 Initialization and start algorithm. More...
 
- Public Member Functions inherited from Optimizer
 Optimizer (MPI_Comm comm)
 
virtual ~Optimizer ()
 

Protected Member Functions

bool onMessage (MPI_Status status, size_t length)
 
void postPoll ()
 executed after handling (if any) new request More...
 
void setupPoll ()
 executed before starting polling loop More...
 
void prePoll ()
 executed before checking for new request More...
 
void onStop ()
 enable implementation to react to STOP tag More...
 
void dispatch_forward_solves ()
 
- Protected Member Functions inherited from Poller
virtual void run ()
 
 Poller (MPI_Comm comm, double delay=0.1)
 
virtual ~Poller ()
 

Private Types

enum  State { SUBMIT, STOP, TERMINATE }
 
typedef SampleIndividual Individual_t
 

Private Member Functions

void writeJsonHeader ()
 
void dumpIndividualsToJSON ()
 
void addIndividualToJSON (const boost::shared_ptr< Individual_t > &ind)
 
void runStateMachine ()
 
void createNewIndividual ()
 

Private Attributes

std::map< std::string,
std::shared_ptr
< SamplingMethod > > 
sampleMethods_m
 
int gid
 
int my_local_pid_
 
Comm::Bundle_t comms_
 communicator bundle for the optimizer More...
 
std::map< size_t,
boost::shared_ptr
< Individual_t > > 
jobmapping_m
 mapping from unique job ID to individual More...
 
std::queue< boost::shared_ptr
< Individual_t > > 
individuals_m
 
bounds_t dVarBounds_m
 bounds on each specified gene More...
 
DVarContainer_t dvars_m
 design variables More...
 
Expressions::Named_t objectives_m
 objectives More...
 
int nSamples_m
 
CmdArguments_t args_
 command line arguments specified by the user More...
 
int act_sample_m
 current generation More...
 
int done_sample_m
 
State curState_m
 
std::size_t jsonDumpFreq_m
 Dumps id, design variables and bound. More...
 
std::string jsonFname_m
 
std::list< Individual_tindividualsToDump_m
 

Additional Inherited Members

- Protected Attributes inherited from Poller
MPI_Comm comm_m
 communicator the poller listens to requests More...
 
bool is_running_
 
double last_polled_
 time of last MPI_Test More...
 
double poll_delay_
 delay in seconds between polls More...
 

Detailed Description

Implementing sampling.

Definition at line 41 of file Sampler.h.

Member Typedef Documentation

Definition at line 107 of file Sampler.h.

type used in solution state exchange with other optimizers

Definition at line 81 of file Sampler.h.

Member Enumeration Documentation

enum Sampler::State
private
Enumerator
SUBMIT 
STOP 
TERMINATE 

Definition at line 137 of file Sampler.h.

Constructor & Destructor Documentation

Sampler::Sampler ( Expressions::Named_t  objectives,
Expressions::Named_t  constraints,
DVarContainer_t  dvars,
size_t  dim,
Comm::Bundle_t  comms,
CmdArguments_t  args,
std::vector< double >  hypervolRef,
int  nrWorkerGroups 
)

This constructor should never be called. It's provided due to the inheritance of SamplePilot from Pilot

Definition at line 17 of file Sampler.cpp.

Sampler::Sampler ( const std::map< std::string, std::shared_ptr< SamplingMethod > > &  sampleMethods,
Expressions::Named_t  objectives,
DVarContainer_t  dvars,
Comm::Bundle_t  comms,
CmdArguments_t  args 
)

Retrieves all (for the sampler) relevant arguments specified on the command line, initializes the variator and sets up statistics and debug traces.

Parameters
[in]sampleMethodsper design variable (dvar)
[in]dvarsof sampling
[in]commsavailable to the sampler
[in]argsthe user passed on the command line

Definition at line 31 of file Sampler.cpp.

References comms_, dVarBounds_m, dvars_m, Comm::Bundle_t::island_id, jsonDumpFreq_m, jsonFname_m, my_local_pid_, Comm::Bundle_t::opt, and writeJsonHeader().

Here is the call graph for this function:

Member Function Documentation

void Sampler::addIndividualToJSON ( const boost::shared_ptr< Individual_t > &  ind)
private

Definition at line 273 of file Sampler.cpp.

References dumpIndividualsToJSON(), individualsToDump_m, and jsonDumpFreq_m.

Referenced by onMessage().

Here is the call graph for this function:

void Sampler::createNewIndividual ( )
private

Definition at line 171 of file Sampler.cpp.

References dvars_m, gid, individuals_m, and sampleMethods_m.

Referenced by postPoll().

void Sampler::dispatch_forward_solves ( )
protected

Definition at line 318 of file Sampler.cpp.

References act_sample_m, comms_, dvars_m, individuals_m, jobmapping_m, Comm::Bundle_t::master_local_pid, MPI_Send_params(), Comm::Bundle_t::opt, and OPT_NEW_JOB_TAG.

Referenced by runStateMachine().

Here is the call graph for this function:

void Sampler::dumpIndividualsToJSON ( )
private
void Sampler::initialize ( )
virtual

Initialization and start algorithm.

Implements Optimizer.

Definition at line 73 of file Sampler.cpp.

References act_sample_m, args_, comms_, curState_m, done_sample_m, gid, Comm::Bundle_t::island_id, nSamples_m, Poller::run(), and SUBMIT.

Here is the call graph for this function:

bool Sampler::onMessage ( MPI_Status  status,
size_t  recv_value 
)
protectedvirtual

User specific behavior on receiving a message.

Returns
boolean indicating if Irecv has to be re-posted

Implements Optimizer.

Definition at line 110 of file Sampler.cpp.

References addIndividualToJSON(), comms_, done_sample_m, endl(), jobmapping_m, MPI_Recv_reqvars(), Comm::Bundle_t::opt, and REQUEST_FINISHED.

Here is the call graph for this function:

void Sampler::onStop ( )
inlineprotectedvirtual

enable implementation to react to STOP tag

Implements Optimizer.

Definition at line 91 of file Sampler.h.

void Sampler::postPoll ( )
protectedvirtual

executed after handling (if any) new request

Implements Optimizer.

Definition at line 161 of file Sampler.cpp.

References act_sample_m, createNewIndividual(), nSamples_m, and runStateMachine().

Here is the call graph for this function:

void Sampler::prePoll ( )
inlineprotectedvirtual

executed before checking for new request

Implements Optimizer.

Definition at line 90 of file Sampler.h.

void Sampler::runStateMachine ( )
private
void Sampler::setupPoll ( )
inlineprotectedvirtual

executed before starting polling loop

Implements Optimizer.

Definition at line 89 of file Sampler.h.

void Sampler::writeJsonHeader ( )
private

Definition at line 196 of file Sampler.cpp.

References bounds(), dVarBounds_m, dvars_m, Util::getGitRevision(), jsonFname_m, OPAL_PROJECT_NAME, and OPAL_PROJECT_VERSION.

Referenced by Sampler().

Here is the call graph for this function:

Member Data Documentation

int Sampler::act_sample_m
private

current generation

Definition at line 133 of file Sampler.h.

Referenced by dispatch_forward_solves(), initialize(), postPoll(), and runStateMachine().

CmdArguments_t Sampler::args_
private

command line arguments specified by the user

Definition at line 130 of file Sampler.h.

Referenced by initialize().

Comm::Bundle_t Sampler::comms_
private

communicator bundle for the optimizer

Definition at line 110 of file Sampler.h.

Referenced by dispatch_forward_solves(), initialize(), onMessage(), runStateMachine(), and Sampler().

State Sampler::curState_m
private

Definition at line 143 of file Sampler.h.

Referenced by initialize(), and runStateMachine().

int Sampler::done_sample_m
private

Definition at line 135 of file Sampler.h.

Referenced by initialize(), onMessage(), and runStateMachine().

bounds_t Sampler::dVarBounds_m
private

bounds on each specified gene

Definition at line 118 of file Sampler.h.

Referenced by Sampler(), and writeJsonHeader().

DVarContainer_t Sampler::dvars_m
private

design variables

Definition at line 121 of file Sampler.h.

Referenced by createNewIndividual(), dispatch_forward_solves(), dumpIndividualsToJSON(), Sampler(), and writeJsonHeader().

int Sampler::gid
private

Definition at line 103 of file Sampler.h.

Referenced by createNewIndividual(), and initialize().

std::queue<boost::shared_ptr<Individual_t> > Sampler::individuals_m
private

Definition at line 115 of file Sampler.h.

Referenced by createNewIndividual(), and dispatch_forward_solves().

std::list<Individual_t> Sampler::individualsToDump_m
private

Definition at line 149 of file Sampler.h.

Referenced by addIndividualToJSON(), and dumpIndividualsToJSON().

std::map<size_t, boost::shared_ptr<Individual_t> > Sampler::jobmapping_m
private

mapping from unique job ID to individual

Definition at line 113 of file Sampler.h.

Referenced by dispatch_forward_solves(), and onMessage().

std::size_t Sampler::jsonDumpFreq_m
private

Dumps id, design variables and bound.

Definition at line 146 of file Sampler.h.

Referenced by addIndividualToJSON(), and Sampler().

std::string Sampler::jsonFname_m
private

Definition at line 147 of file Sampler.h.

Referenced by dumpIndividualsToJSON(), Sampler(), and writeJsonHeader().

int Sampler::my_local_pid_
private

Definition at line 105 of file Sampler.h.

Referenced by Sampler().

int Sampler::nSamples_m
private

Definition at line 126 of file Sampler.h.

Referenced by initialize(), postPoll(), and runStateMachine().

Expressions::Named_t Sampler::objectives_m
private

objectives

Definition at line 124 of file Sampler.h.

Referenced by dumpIndividualsToJSON().

std::map<std::string, std::shared_ptr<SamplingMethod> > Sampler::sampleMethods_m
private

Definition at line 100 of file Sampler.h.

Referenced by createNewIndividual().


The documentation for this class was generated from the following files: