60 namespace IterationPack {
135 {
public:
DoesNotExist(
const std::string& what_arg) : std::logic_error(what_arg) {}};
139 {
public:
AlreadyExists(
const std::string& what_arg) : std::logic_error(what_arg) {}};
318 ,
const std::string& assoc_step_name)
const;
420 ,
const std::string& assoc_step_name,
const step_ptr_t& assoc_step);
486 virtual void do_step_next(
const std::string& step_name);
530 virtual bool do_step(
const std::string& step_name);
670 template<
class T_Step_ptr>
674 ,
const std::string& _name )
712 template<
class T_ele>
748 #ifdef DOXYGEN_COMPILE
882 steps_t::iterator
step_itr(
const std::string& step_name);
885 steps_t::const_iterator
step_itr(
const std::string& step_name)
const;
897 ,
const std::string& assoc_step_name);
901 ,
const std::string& assoc_step_name);
1007 return std::find_if( assoc_list.begin() , assoc_list.end()
1015 return std::find_if( assoc_list.begin() , assoc_list.end()
1021 switch(assoc_step_type) {
1031 #endif // ALGORITHM_H
Base type for all objects that perform steps in an Algorithm.
std::vector< double > step_times_t
void validate_not_in_state(ERunningState running_state) const
Validate that this is not in a specific running state.
virtual EAlgoReturn do_algorithm(poss_type step_poss=1)
Called by clients to begin an algorithm.
step_ptr_and_name< step_ptr_t > assoc_steps_ele_list_ele_t
std::string saved_curr_step_name_
step_ptr_and_name< step_ptr_t > steps_ele_t
void compute_final_time_stats() const
Teuchos::RCP< AlgorithmTracker > track_ptr_t
steps_t::iterator step_itr(const std::string &step_name)
Find a step given its name and throw a DoesNotExist exception if not found.
bool imp_do_step(poss_type step_poss)
bool operator()(const T_ele &ele)
Algorithm()
Constructs an algorithm with no steps and a default of max_iter() == 100.
virtual poss_type get_step_poss(const std::string &step_name) const
Return the possition in the major loop of a named step.
ERunningState running_state() const
Return the current running state of this algorithm object.
virtual void print_steps(std::ostream &out) const
Print out just a listing of the steps, their positions in the algorithm and the subclasses.
state_ptr_t & get_state()
virtual void begin_config_update()
Changes from running_state() == RUNNING to running_state() == RUNNING_BEING_CONFIGURED.
assoc_steps_ele_list_t assoc_steps_lists_[2]
virtual void insert_assoc_step(poss_type step_poss, EAssocStepType type, poss_type assoc_step_poss, const std::string &assoc_step_name, const step_ptr_t &assoc_step)
Insert an pre or post step into for the main step step_poss into the possition assoc_step_poss.
Thrown if name or id does not exist.
static const int TIME_STAT_AV_OFFSET
typedef void(CALL_API *RTOp_reduct_op_func_ptr_t)(void *
Thrown if an invalid control protocal is used.
virtual bool algo_timing() const
void get_step_times_k(int offset, double step_times[]) const
Returns the step_times for iteration offset.
virtual const std::string & what_is_next_step_name() const
Returns the name of the next step this will call the next time it calls a step.
void get_final_step_stats(size_t step, double *total, double *average, double *min, double *max, double *percent) const
Returns the final statistics for a given step Do not call when algorithm is running.
virtual void insert_step(poss_type step_poss, const std::string &step_name, const step_ptr_t &step)
Insert a step object with the name step_name into the possition step_poss.
void imp_inform_steps(inform_func_ptr_t inform_func_ptr)
static const int TIME_STAT_MAX_OFFSET
virtual int num_steps() const
Return the number of main steps.
ETerminateStatus terminate_status_
std::string saved_next_step_name_
void validate_in_state(ERunningState running_state) const
Validate that this is in a specific running state.
virtual void change_step_name(poss_type step_poss, const std::string &new_name)
Change the name of an existing step.
STANDARD_MEMBER_COMPOSITION_MEMBERS(std::string, interrupt_file_name)
Name of an file that will cause the algorithm to terminate.
std::deque< assoc_steps_ele_t > assoc_steps_t
InvalidConfigChange(const std::string &what_arg)
static const int TIME_STAT_MIN_OFFSET
ERunningState running_state_
void validate_not_next_step(const std::string &step_name) const
Validate that the step_name in not the next step.
virtual void print_algorithm(std::ostream &out) const
Print out the entire algorithm by calling print_step(...) on the step objects.
virtual bool do_step(const std::string &step_name)
Calls do_step() on all of the pre step objects the step object and the post step objects in order for...
virtual void terminate(bool success)
Called by step objects to terminate the algorithm.
void set_state(const state_ptr_t &state)
AlreadyExists(const std::string &what_arg)
void imp_print_algorithm(std::ostream &out, bool print_steps) const
const assoc_steps_ele_list_t & operator[](int i) const
virtual void replace_step(poss_type step_poss, const step_ptr_t &step)
Replace the step object of an existing step.
assoc_steps_ele_list_t & operator[](int i)
DoesNotExist(const std::string &what_arg)
steps_t::iterator step_itr_and_assert(const std::string &step_name)
Find a step given its name and throw a DoesNotExist exception if not found.
bool time_stats_computed_
virtual void do_step_next(const std::string &step_name)
Called by step objects to set the step (given its name) that this will envoke the next time this call...
const std::string & name_
virtual poss_type what_is_next_step_poss() const
Returns the possition of the next step this will call the next time it calls a step.
Abstacts a set of iteration quantities for an iterative algorithm.
virtual poss_type get_assoc_step_poss(poss_type step_poss, EAssocStepType type, const std::string &assoc_step_name) const
Return the possition of the pre or post step for the main step_poss.
AlgorithmTracker & track()
virtual int num_assoc_steps(poss_type step_poss, EAssocStepType type) const
Return the number of pre or post steps for the main step step_poss.
const std::string * next_step_name_
Teuchos::RCP< AlgorithmState > state_ptr_t
static const int TIME_STAT_PERCENT_OFFSET
virtual step_ptr_t & get_assoc_step(poss_type step_poss, EAssocStepType type, poss_type assoc_step_poss)
Return the RCP<...> object for the associated step object at step_poss and assoc_step_poss.
virtual step_ptr_t & get_step(poss_type step_poss)
Return the RCP<...> object for the step object at step_poss.
std::list< assoc_steps_ele_list_ele_t > assoc_steps_ele_list_t
poss_type curr_step_poss_
static assoc_steps_ele_list_t::iterator assoc_step_itr(assoc_steps_ele_list_t &assoc_list, const std::string &assoc_step_name)
Find a an associated step given its name and throw a DoesNotExist exception if not found...
void validate_not_curr_step(poss_type step_poss) const
Validate that the step_poss in not the current step.
EDoStepType do_step_type(EAssocStepType assoc_step_type)
EAssocStepType -> EDoStepType.
virtual void end_config_update()
Changes from running_state() == RUNNING_BEING_CONFIGURED to running_state() == RUNNING.
std::deque< steps_ele_t > steps_t
void(AlgorithmStep::* inform_func_ptr_t)(Algorithm &algo, poss_type step_poss, EDoStepType type, poss_type assoc_step_poss)
virtual const std::string & get_step_name(poss_type step_poss) const
Return the name of a step given its possition.
virtual double max_run_time() const
EAlgoReturn finalize_algorithm(EAlgoReturn algo_return)
assoc_steps_t assoc_steps_
bool do_step_next_called_
track_ptr_t & get_track()
InvalidRunningState(const std::string &what_arg)
Thrown if a member function is called while this is in an invalid running state.. ...
Acts as the central hub for an iterative algorithm.
InvalidControlProtocal(const std::string &what_arg)
Thrown if Algorithm was interrupted by the user.
step_ptr_and_name(const T_Step_ptr &_step_ptr, const std::string &_name)
void look_for_interrupt()
virtual void remove_assoc_step(poss_type step_poss, EAssocStepType type, poss_type assoc_step_poss)
Remove an pre or post step for the main step step_poss in the possition assoc_step_poss.
virtual void print_algorithm_times(std::ostream &out) const
Outputs table of times for each step, cummulative times and other statistics.
Used to ouput iteration results and other information.
virtual const std::string & get_assoc_step_name(poss_type step_poss, EAssocStepType type, poss_type assoc_step_poss) const
Return the name of the pre or post step at step_poss and at assoc_step_poss.
Thrown if a member function is called while this is in an invalid running state.. ...
static const int TIME_STAT_TOTALS_OFFSET
virtual void remove_step(poss_type step_poss)
Remove an existing step object and all of its pre and post steps.
bool imp_do_assoc_steps(EAssocStepType type)
Thrown if name already exists.
virtual size_t max_iter() const
poss_type next_step_poss_
Teuchos::RCP< AlgorithmStep > step_ptr_t
virtual void set_algo_timing(bool algo_timing)
Causes algorithm to be timed.
void set_track(const track_ptr_t &track)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
name_comp(const std::string &name)
AlgorithmInterrupted(const std::string &what_arg)
void change_running_state(ERunningState running_state)
Change the running state.
poss_type validate(poss_type step_poss, int past_end=0) const
Validate a step_poss and throw a DoesNotExist exception if it does not.