Strategy Class Reference

Base class for the strategy class hierarchy. More...

Inheritance diagram for Strategy:

ConcurrentStrategy HybridStrategy SingleMethodStrategy CollaborativeHybridStrategy EmbeddedHybridStrategy SequentialHybridStrategy List of all members.

Public Member Functions

 Strategy ()
 default constructor
 Strategy (ProblemDescDB &problem_db)
 envelope constructor
 Strategy (const Strategy &strat)
 copy constructor
virtual ~Strategy ()
 destructor
Strategy operator= (const Strategy &strat)
 assignment operator
virtual void run_strategy ()
 the model(s). Called from main.C.
virtual const Variablesvariables_results () const
 return the final strategy solution (variables)
virtual const Responseresponse_results () const
 return the final strategy solution (response)
ProblemDescDBproblem_description_db () const
 returns the problem description database (probDescDB)

Protected Member Functions

 Strategy (BaseConstructor, ProblemDescDB &problem_db)
 derived class constructors - Coplien, p. 139)
virtual void initialize_iterator (int index)
 scheduling function (serve_iterators() or static_schedule_iterators())
virtual void pack_parameters_buffer (MPIPackBuffer &send_buffer, int job_index)
 pack a send_buffer for assigning an iterator job to a server
virtual void unpack_parameters_buffer (MPIUnpackBuffer &recv_buffer)
 unpack a recv_buffer for accepting an iterator job from the scheduler
virtual void pack_results_buffer (MPIPackBuffer &send_buffer, int job_index)
 pack a send_buffer for returning iterator results from a server
virtual void unpack_results_buffer (MPIUnpackBuffer &recv_buffer, int job_index)
 unpack a recv_buffer for accepting iterator results from a server
virtual void update_local_results (int job_index)
 update local prpResults with current iteration results
void init_iterator_parallelism ()
 parallel configuration attributes, and managing outputs and restart.
void init_iterator (Iterator &the_iterator, Model &the_model)
 convenience function for allocating comms prior to running an iterator
void run_iterator (Iterator &the_iterator, Model &the_model)
 due to use by MINLPNode.
void free_iterator (Iterator &the_iterator, Model &the_model)
 convenience function for deallocating comms after running an iterator
void schedule_iterators (Iterator &the_iterator, Model &the_model)
 static_schedule_iterators()
void self_schedule_iterators (Model &the_model)
 among slave iterator servers (called by derived run_strategy())
void serve_iterators (Iterator &the_iterator, Model &the_model)
 assigned by the strategy master (called by derived run_strategy())
void static_schedule_iterators (Iterator &the_iterator, Model &the_model)
 (called by derived run_strategy())

Protected Attributes

ProblemDescDBprobDescDB
 class member reference to the problem description database
ParallelLibraryparallelLib
 class member reference to the parallel library
String strategyName
 type of strategy: single_method, hybrid, multi_start, or pareto_set.
bool stratIterMessagePass
 flag for message passing at si level
bool stratIterDedMaster
 flag for dedicated master part. at si level
int worldRank
 processor rank in MPI_COMM_WORLD
int worldSize
 size of MPI_COMM_WORLD
int iteratorCommRank
 processor rank in iteratorComm
int iteratorCommSize
 number of processors in iteratorComm
int numIteratorServers
 number of concurrent iterator partitions
int iteratorServerId
 identifier for an iterator server
bool graph2DFlag
 flag for using 2D graphics plots
bool tabularDataFlag
 flag for file tabulation of graphics data
String tabularDataFile
 filename for tabulation of graphics data
int maxConcurrency
 maximum iterator concurrency possible in Strategy
int numIteratorJobs
 number of iterator executions to schedule
PRPArray prpResults
 array of results corresponding to numIteratorJobs
int paramsMsgLen
 length of MPI buffer for parameterSets instance(s)
int resultsMsgLen
 length of MPI buffer for prpResults instance(s)

Private Member Functions

Strategyget_strategy ()
 Used by the envelope to instantiate the correct letter class.

Private Attributes

StrategystrategyRep
 pointer to the letter (initialized only for the envelope)
int referenceCount
 number of objects sharing strategyRep

Detailed Description

Base class for the strategy class hierarchy.

The Strategy class is the base class for the class hierarchy providing the top level control in DAKOTA. The strategy is responsible for creating and managing iterators and models. For memory efficiency and enhanced polymorphism, the strategy hierarchy employs the "letter/envelope idiom" (see Coplien "Advanced C++", p. 133), for which the base class (Strategy) serves as the envelope and one of the derived classes (selected in Strategy::get_strategy()) serves as the letter.


Constructor & Destructor Documentation

Strategy (  ) 

default constructor

Default constructor. strategyRep is NULL in this case (a populated problem_db is needed to build a meaningful Strategy object). This makes it necessary to check for NULL in the copy constructor, assignment operator, and destructor.

Strategy ( ProblemDescDB problem_db  ) 

envelope constructor

Used in main.C instantiation to build the envelope. This constructor only needs to extract enough data to properly execute get_strategy, since Strategy::Strategy(BaseConstructor, problem_db) builds the actual base class data inherited by the derived strategies.

Strategy ( const Strategy strat  ) 

copy constructor

Copy constructor manages sharing of strategyRep and incrementing of referenceCount.

~Strategy (  )  [virtual]

destructor

Destructor decrements referenceCount and only deletes strategyRep when referenceCount reaches zero.

Strategy ( BaseConstructor  ,
ProblemDescDB problem_db 
) [protected]

derived class constructors - Coplien, p. 139)

This constructor is the one which must build the base class data for all inherited strategies. get_strategy() instantiates a derived class letter and the derived constructor selects this base class constructor in its initialization list (to avoid the recursion of the base class constructor calling get_strategy() again). Since the letter IS the representation, its representation pointer is set to NULL (an uninitialized pointer causes problems in ~Strategy).


Member Function Documentation

Strategy operator= ( const Strategy strat  ) 

assignment operator

Assignment operator decrements referenceCount for old strategyRep, assigns new strategyRep, and increments referenceCount for new strategyRep.

void pack_parameters_buffer ( MPIPackBuffer send_buffer,
int  job_index 
) [protected, virtual]

pack a send_buffer for assigning an iterator job to a server

This virtual function redefinition is executed on the dedicated master processor for self scheduling. It is not used for peer partitions.

Reimplemented in ConcurrentStrategy, and SequentialHybridStrategy.

void unpack_parameters_buffer ( MPIUnpackBuffer recv_buffer  )  [protected, virtual]

unpack a recv_buffer for accepting an iterator job from the scheduler

This virtual function redefinition is executed on an iterator server for dedicated master self scheduling. It is not used for peer partitions.

Reimplemented in ConcurrentStrategy, and SequentialHybridStrategy.

void pack_results_buffer ( MPIPackBuffer send_buffer,
int  job_index 
) [protected, virtual]

pack a send_buffer for returning iterator results from a server

This virtual function redefinition is executed either on an iterator server for dedicated master self scheduling or on peers 2 through n for static scheduling.

Reimplemented in ConcurrentStrategy, and SequentialHybridStrategy.

void unpack_results_buffer ( MPIUnpackBuffer recv_buffer,
int  job_index 
) [protected, virtual]

unpack a recv_buffer for accepting iterator results from a server

This virtual function redefinition is executed on an strategy master (either the dedicated master processor for self scheduling or peer 1 for static scheduling).

Reimplemented in ConcurrentStrategy, and SequentialHybridStrategy.

void init_iterator_parallelism (  )  [protected]

parallel configuration attributes, and managing outputs and restart.

This function is called from derived class constructors once maxConcurrency is defined but prior to instantiating Iterators and Models.

void init_iterator ( Iterator the_iterator,
Model the_model 
) [protected]

convenience function for allocating comms prior to running an iterator

This is a convenience function for encapsulating the allocation of communicators prior to running an iterator. It does not require a strategyRep forward since it is only used by letter objects.

void run_iterator ( Iterator the_iterator,
Model the_model 
) [protected]

due to use by MINLPNode.

This is a convenience function for encapsulating the parallel features (run/serve) of running an iterator. This function omits allocation/deallocation of communicators to provide greater efficiency in those strategies which involve multiple iterator executions but only require communicator allocation/deallocation to be performed once.

It does not require a strategyRep forward since it is only used by letter objects. While it is currently a public function due to its use in MINLPNode, this usage still involves a strategy letter object.

void free_iterator ( Iterator the_iterator,
Model the_model 
) [protected]

convenience function for deallocating comms after running an iterator

This is a convenience function for encapsulating the deallocation of communicators after running an iterator. It does not require a strategyRep forward since it is only used by letter objects.

void schedule_iterators ( Iterator the_iterator,
Model the_model 
) [protected]

static_schedule_iterators()

This implementation supports the scheduling of multiple jobs using a single iterator/model pair. Additional future (overloaded) implementations could involve independent iterator instances.

void self_schedule_iterators ( Model the_model  )  [protected]

among slave iterator servers (called by derived run_strategy())

This function is adapted from ApplicationInterface::self_schedule_evaluations().

void serve_iterators ( Iterator the_iterator,
Model the_model 
) [protected]

assigned by the strategy master (called by derived run_strategy())

This function is similar in structure to ApplicationInterface::serve_evaluations_synch().

Strategy * get_strategy (  )  [private]

Used by the envelope to instantiate the correct letter class.

Used only by the envelope constructor to initialize strategyRep to the appropriate derived type, as given by the strategyName attribute.


The documentation for this class was generated from the following files:
Generated on Wed Nov 5 19:54:06 2008 for DAKOTA by  doxygen 1.5.1