51 namespace IterationPack {
93 algo.
track().
journal_out() <<
"\n* Do step \"Step_2_p1\" then Jump to \"Step_1\"\n";
116 algo.
track().
journal_out() <<
"\n* Remove step \"Step_1\" then put it back then print steps\n";
126 << algo.
get_step_name(1) <<
" but don't put it back then print steps\n";
147 std::ostream& _out = *
out;
154 _out << std::boolalpha;
156 _out <<
"\n\n*************************\n"
157 <<
"*** Testing Algorithm ***\n"
158 <<
"*************************\n";
187 _out <<
"\n\n*** algo.print_algorithm(_out)\n\n";
192 _out <<
"\n\n*** Test the major loop for two iterations ***\n";
194 _out <<
"\nalgo.set_algo_timing(true); algo.max_iter(2); algo.do_algorithm();\n\n";
201 _out <<
"\n\n*** Test Minor Loop 1 ***\n";
203 _out <<
"\nalgo.remove_assoc_step( 4, PRE_STEP, 2 );\n";
206 _out <<
"\nalgo.insert_assoc_step( 4, PRE_STEP, 2, \"Step_4_m1\", new MinorLoop1Step );\n";
209 _out <<
"\nalgo.state().k(0);\n";
212 _out <<
"\nalgo.max_iter(1);\n";
215 _out <<
"\n\nalgo.print_steps(_out)\n\n";
218 _out <<
"\nalgo.do_algorithm();\n";
223 _out <<
"\n\n*** Test Controlled Loop 1 ***\n";
225 _out <<
"\nalgo.remove_assoc_step( 4, PRE_STEP, 2 );\n";
228 _out <<
"\nalgo.insert_assoc_step( 4, PRE_STEP, 2, \"Step_4_m1\", assoc_step );\n";
231 _out <<
"\nalgo.remove_assoc_step( 4, PRE_STEP, 1 );\n";
234 _out <<
"\nalgo.insert_assoc_step( 4, PRE_STEP, 1 , \"Step_4_m2\", new ControledLoop1Step );\n";
237 _out <<
"\n\nalgo.print_steps(_out)\n\n";
240 _out <<
"\nalgo.state.k(0);\n";
243 _out <<
"\nalgo.do_algorithm();\n";
248 _out <<
"\n\n*** Test runtime configuration change ***\n";
250 _out <<
"\nalgo.remove_assoc_step( 4, PRE_STEP, 1 );\n";
253 _out <<
"\nalgo.insert_assoc_step( 4, PRE_STEP, 1, \"Step_4_m2\", new RuntimeConfigChangeStep );\n";
256 _out <<
"\n\nalgo.print_steps(_out)\n\n";
259 _out <<
"\nalgo.state.k(0);\n";
262 _out <<
"\nalgo.max_iter(5);\n";
266 _out <<
"In the 5th (k= 4) iteration an Algorithm::InvalidConfigChange exception should be thrown.";
267 _out <<
"\nalgo.do_algorithm();\n";
271 <<
"Algorithm threw exception : false\n";
274 _out <<
"\nAs expected! Caught a Algorithm::InvalidConfigChange&: " << excpt.what() << endl
275 <<
"Algorithm threw exception : true\n";
278 _out <<
"\n*** Congradulations, If you read this the tests for Algorithm"
279 " seem to have been successful\n";
284 catch(
const std::exception& excpt) {
285 _out <<
"\nCaught a std::exception: " << excpt.what() << endl;
288 _out <<
"\nCaught an unknown exception\n";
291 _out <<
"\n*** Oops, If you read this some function throw an unexpected exception and the tests have failed!\n";
virtual EAlgoReturn do_algorithm(poss_type step_poss=1)
Called by clients to begin an algorithm.
virtual void max_iter(size_t max_iter)
virtual void print_steps(std::ostream &out) const
Print out just a listing of the steps, their positions in the algorithm and the subclasses.
bool TestAlgorithm(std::ostream *out)
bool do_step(Algorithm &algo, poss_type step_poss, EDoStepType type, poss_type assoc_step_poss)
virtual void begin_config_update()
Changes from running_state() == RUNNING to running_state() == RUNNING_BEING_CONFIGURED.
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.
bool do_step(Algorithm &algo, poss_type step_poss, EDoStepType type, poss_type assoc_step_poss)
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.
RuntimeConfigChangeStep()
virtual void print_algorithm(std::ostream &out) const
Print out the entire algorithm by calling print_step(...) on the step objects.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void terminate(bool success)
Called by step objects to terminate the algorithm.
virtual std::ostream & journal_out() const
Return a reference to a std::ostream to be used to output debug information and the like...
void set_state(const state_ptr_t &state)
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...
Abstacts a set of iteration quantities for an iterative algorithm.
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.
virtual void end_config_update()
Changes from running_state() == RUNNING_BEING_CONFIGURED to running_state() == RUNNING.
virtual const std::string & get_step_name(poss_type step_poss) const
Return the name of a step given its possition.
Acts as the central hub for an iterative algorithm.
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.
Thrown if a member function is called while this is in an invalid running state.. ...
virtual void remove_step(poss_type step_poss)
Remove an existing step object and all of its pre and post steps.
bool do_step(Algorithm &algo, poss_type step_poss, EDoStepType type, poss_type assoc_step_poss)
virtual void set_algo_timing(bool algo_timing)
Causes algorithm to be timed.
void set_track(const track_ptr_t &track)
bool do_step(Algorithm &algo, poss_type step_poss, EDoStepType type, poss_type assoc_step_poss)