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" 62 MoochoTrackerXMLSummary::MoochoTrackerXMLSummary(
63 const Teuchos::RCP<std::ostream> &journal_out
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)
80 using Teuchos::dyn_cast;
82 const NLPAlgo &_algo = rsqp_algo(algo);
84 const NLPObjGrad &nlp = dyn_cast<
const NLPObjGrad>(_algo.nlp());
90 Teuchos::RCP<std::ofstream> xml_out = Teuchos::rcp(
new std::ofstream(xml_filename_.c_str(), std::ios::out));
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 111 using Teuchos::dyn_cast;
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);
121 Teuchos::RCP<std::ofstream> xml_out = Teuchos::rcp(
new std::ofstream(xml_filename_.c_str(), std::ios::out));
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);
255 Teuchos::RCP<std::ofstream> xml_out = Teuchos::rcp(
new std::ofstream(xml_filename_.c_str(), std::ios::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";
269 TEUCHOS_TEST_FOR_EXCEPTION(
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();
314 TEUCHOS_TEST_FOR_EXCEPTION(
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.
rSQP Algorithm control class.
void output_final(const Algorithm &algo, EAlgoReturn algo_return) const
void output_iteration(const Algorithm &algo) const
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.