49 #include "MoochoPack_MoochoTrackerXMLSummary.hpp"
50 #include "MoochoPack_NLPAlgoState.hpp"
51 #include "MoochoPack_moocho_algo_conversion.hpp"
52 #include "NLPInterfacePack_NLPFirstOrder.hpp"
55 #include "Teuchos_dyn_cast.hpp"
60 namespace MoochoPack {
62 MoochoTrackerXMLSummary::MoochoTrackerXMLSummary(
64 ,
const std::string xml_filename
65 ,
const std::string problem_name
66 ,
const std::string algorithm_description
68 :AlgorithmTracker(journal_out)
71 ,xml_filename_(xml_filename)
72 ,problem_name_(problem_name)
73 ,algorithm_description_(algorithm_description)
82 const NLPAlgo &_algo = rsqp_algo(algo);
84 const NLPObjGrad &nlp =
dyn_cast<
const NLPObjGrad>(_algo.nlp());
91 std::ofstream &out = *xml_out.
get();
98 out << ind <<
"<Solution status=\"UNKNOWN_FAILURE\" objective_value=\"?\" constraint_norm=\"?\"/>\n";
100 out << ind <<
"<Iterations overall=\"?\"/>\n";
102 close_problem_element(out);
109 , EAlgoReturn algo_return)
const
113 const NLPAlgo &_algo = rsqp_algo(algo);
115 const NLPObjGrad &nlp =
dyn_cast<
const NLPObjGrad>(_algo.nlp());
116 const NLPFirstOrder *nlp_foi =
dynamic_cast<const NLPFirstOrder*
>(&nlp);
122 std::ofstream &out = *xml_out.
get();
129 char soln_status[256];
132 case IterationPack::TERMINATE_TRUE:
133 std::strcpy(soln_status,
"SOLVED");
135 case IterationPack::TERMINATE_FALSE:
136 std::strcpy(soln_status,
"FAILED");
138 case IterationPack::MAX_ITER_EXCEEDED:
139 std::strcpy(soln_status,
"MAX_ITER");
141 case IterationPack::MAX_RUN_TIME_EXCEEDED:
142 std::strcpy(soln_status,
"MAX_RUN_TIME");
144 case IterationPack::INTERRUPTED_TERMINATE_TRUE:
145 std::strcpy(soln_status,
"INTERRUPTED_SOLVED");
147 case IterationPack::INTERRUPTED_TERMINATE_FALSE:
148 std::strcpy(soln_status,
"INTERRUPTED_FAILED");
151 std::strcpy(soln_status,
"UNKNOWN_STATUS");
156 out << ind <<
"<Solution status=\"" << soln_status;
158 if (s.f().updated_k(0)) {
159 out <<
"\" objective_value=\"" << s.f().get_k(0) <<
"\"";
162 out <<
"\" objective_value=\"?\"";
165 if (m && s.c().updated_k(0)) {
166 out <<
" constraint_norm=\"" << s.c().get_k(0).norm_inf() <<
"\"";
169 out <<
" constraint_norm=\"?\"";
175 out << ind <<
"<Iterations overall=\"" << s.
k() <<
"\"/>\n";
178 out << ind <<
"<Evaluations>\n"
179 << ind << ind <<
"<Objective evaluations=\"" << nlp.num_f_evals() <<
"\"/>\n"
180 << ind << ind <<
"<Constraint evaluations=\"" << ( m ? nlp.num_c_evals() : 0 ) <<
"\"/>\n"
181 << ind << ind <<
"<Objective_Gradient evaluations=\"" << nlp.num_Gf_evals() <<
"\"/>\n"
182 << ind << ind <<
"<Constraint_Gradient evaluations=\"";
186 out << nlp_foi->num_Gc_evals();
197 << ind <<
"</Evaluations>\n";
247 close_problem_element(out);
256 std::ofstream &out = *xml_out.
get();
261 time_t current_time = time(NULL);
263 std::strcpy(time_str, ctime(¤t_time));
265 out <<
"<Problem name=\"" << problem_name_ <<
"\" time=\"" << time_str <<
"\">\n";
267 out << ind <<
"<Dimension n=\"?\" m=\"?\"/>\n";
270 true, std::logic_error
271 ,
"Error!, this function stopped compiling so RAB commented "
272 "it out on 2/4/2005. Sorry!"
308 const NLPAlgo &_algo = rsqp_algo(algo);
309 const NLP &nlp = _algo.nlp();
315 true, std::logic_error
316 ,
"Error!, this function stopped compiling so RAB commented "
317 "it out on 2/4/2005. Sorry!"
357 void MoochoTrackerXMLSummary::close_problem_element( std::ostream& out)
const
360 out <<
"</Problem>\n";
void open_problem_element(std::ostream &out, const Algorithm &algo) const
Print the header to the output.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
T_To & dyn_cast(T_From &from)
rSQP Algorithm control class.
void output_final(const Algorithm &algo, EAlgoReturn algo_return) const
void output_iteration(const Algorithm &algo) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Reduced space SQP state encapsulation interface.
NLPAlgoState & rsqp_state()
<<std aggr>="">> members for algo_cntr
void output_pre_file() const
Set the output stream for summary outputting.