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

#include <Sampler.h>

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

Public Types

typedef std::vector< SampleIndividualSolutionState_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 ()
 
virtual void initialize ()=0
 entry point for optimizer More...
 

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 ()
 
virtual void setupPoll ()=0
 executed before starting polling loop More...
 
virtual void prePoll ()=0
 executed before checking for new request More...
 
virtual void postPoll ()=0
 executed after handling (if any) new request More...
 
virtual void onStop ()=0
 enable implementation to react to STOP tag More...
 
virtual bool onMessage (MPI_Status status, size_t length)=0
 
- Protected Member Functions inherited from Poller
virtual bool onMessage (MPI_Status status, size_t recv_value)=0
 
virtual void onStop ()=0
 enable implementation to react to STOP tag More...
 
virtual void setupPoll ()=0
 executed before starting polling loop More...
 
virtual void prePoll ()=0
 executed before checking for new request More...
 
virtual void postPoll ()=0
 executed after handling (if any) new request More...
 
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

Definition at line 50 of file Sampler.h.

Member Typedef Documentation

◆ Individual_t

Definition at line 116 of file Sampler.h.

◆ SolutionState_t

type used in solution state exchange with other optimizers

Definition at line 90 of file Sampler.h.

Member Enumeration Documentation

◆ State

enum Sampler::State
private
Enumerator
SUBMIT 
STOP 
TERMINATE 

Definition at line 146 of file Sampler.h.

Constructor & Destructor Documentation

◆ Sampler() [1/2]

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 39 of file Sampler.cpp.

◆ Sampler() [2/2]

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 53 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

◆ addIndividualToJSON()

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

Definition at line 295 of file Sampler.cpp.

References dumpIndividualsToJSON(), individualsToDump_m, and jsonDumpFreq_m.

Referenced by onMessage().

Here is the call graph for this function:

◆ createNewIndividual()

void Sampler::createNewIndividual ( )
private

Definition at line 193 of file Sampler.cpp.

References dvars_m, gid, individuals_m, and sampleMethods_m.

Referenced by postPoll().

◆ dispatch_forward_solves()

void Sampler::dispatch_forward_solves ( )
protected

Definition at line 340 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:

◆ dumpIndividualsToJSON()

void Sampler::dumpIndividualsToJSON ( )
private

Definition at line 242 of file Sampler.cpp.

References individualsToDump_m.

Referenced by addIndividualToJSON(), and runStateMachine().

◆ initialize()

void Sampler::initialize ( )
virtual

Initialization and start algorithm.

Implements Optimizer.

Definition at line 95 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:

◆ onMessage()

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 132 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:

◆ onStop()

void Sampler::onStop ( )
inlineprotectedvirtual

enable implementation to react to STOP tag

Implements Optimizer.

Definition at line 100 of file Sampler.h.

◆ postPoll()

void Sampler::postPoll ( )
protectedvirtual

executed after handling (if any) new request

Implements Optimizer.

Definition at line 183 of file Sampler.cpp.

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

Here is the call graph for this function:

◆ prePoll()

void Sampler::prePoll ( )
inlineprotectedvirtual

executed before checking for new request

Implements Optimizer.

Definition at line 99 of file Sampler.h.

◆ runStateMachine()

void Sampler::runStateMachine ( )
private

◆ setupPoll()

void Sampler::setupPoll ( )
inlineprotectedvirtual

executed before starting polling loop

Implements Optimizer.

Definition at line 98 of file Sampler.h.

◆ writeJsonHeader()

void Sampler::writeJsonHeader ( )
private

Definition at line 218 of file Sampler.cpp.

Referenced by Sampler().

Member Data Documentation

◆ act_sample_m

int Sampler::act_sample_m
private

current generation

Definition at line 142 of file Sampler.h.

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

◆ args_

CmdArguments_t Sampler::args_
private

command line arguments specified by the user

Definition at line 139 of file Sampler.h.

Referenced by initialize().

◆ comms_

Comm::Bundle_t Sampler::comms_
private

communicator bundle for the optimizer

Definition at line 119 of file Sampler.h.

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

◆ curState_m

State Sampler::curState_m
private

Definition at line 152 of file Sampler.h.

Referenced by initialize(), and runStateMachine().

◆ done_sample_m

int Sampler::done_sample_m
private

Definition at line 144 of file Sampler.h.

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

◆ dVarBounds_m

bounds_t Sampler::dVarBounds_m
private

bounds on each specified gene

Definition at line 127 of file Sampler.h.

Referenced by Sampler().

◆ dvars_m

DVarContainer_t Sampler::dvars_m
private

design variables

Definition at line 130 of file Sampler.h.

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

◆ gid

int Sampler::gid
private

Definition at line 112 of file Sampler.h.

Referenced by createNewIndividual(), and initialize().

◆ individuals_m

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

Definition at line 124 of file Sampler.h.

Referenced by createNewIndividual(), and dispatch_forward_solves().

◆ individualsToDump_m

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

Definition at line 158 of file Sampler.h.

Referenced by addIndividualToJSON(), and dumpIndividualsToJSON().

◆ jobmapping_m

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

mapping from unique job ID to individual

Definition at line 122 of file Sampler.h.

Referenced by dispatch_forward_solves(), and onMessage().

◆ jsonDumpFreq_m

std::size_t Sampler::jsonDumpFreq_m
private

Dumps id, design variables and bound.

Definition at line 155 of file Sampler.h.

Referenced by addIndividualToJSON(), and Sampler().

◆ jsonFname_m

std::string Sampler::jsonFname_m
private

Definition at line 156 of file Sampler.h.

Referenced by Sampler().

◆ my_local_pid_

int Sampler::my_local_pid_
private

Definition at line 114 of file Sampler.h.

Referenced by Sampler().

◆ nSamples_m

int Sampler::nSamples_m
private

Definition at line 135 of file Sampler.h.

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

◆ objectives_m

Expressions::Named_t Sampler::objectives_m
private

objectives

Definition at line 133 of file Sampler.h.

◆ sampleMethods_m

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

Definition at line 109 of file Sampler.h.

Referenced by createNewIndividual().


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