本文整理汇总了C++中Response::active_set方法的典型用法代码示例。如果您正苦于以下问题:C++ Response::active_set方法的具体用法?C++ Response::active_set怎么用?C++ Response::active_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response::active_set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_local_evaluations
/// Convenience function for common code between wait and nowait case.
void GridApplicInterface::test_local_evaluations(PRPQueue& prp_queue)
{
//
// Iterate through the set of requests
//
for (ISIter it=idSet.begin(); it!=idSet.end(); it++) {
//
// Test for existence of the results file(s) corresponding to this eval
//
int fn_eval_id = *it;
bool err_msg_caught = false;
const String& file_to_test = fileNameMap[fn_eval_id].second;
if (grid_file_test(file_to_test)) {
//
// File exists; test for complete/valid set of results (an incomplete
// set can result from a race condition in which Dakota is reading a
// file that a simulator has not finished writing). Response::read
// throws a String exception if data is missing/misformatted.
//
ParamResponsePair pr_pair;
bool found = lookup_by_eval_id(prp_queue, fn_eval_id, pr_pair);
if (!found) {
Cerr << "Error: failure in queue lookup within GridApplicInterface::"
<< "test_local_evaluations()." << std::endl;
abort_handler(-1);
}
Response response = pr_pair.prp_response(); // shallow copy
try { read_results_files(response, fn_eval_id); }
catch(String& err_msg) {
//
// If a String exception (incomplete file) is caught, set
// err_msg_caught to true so that processing is not performed below.
// The for loop will then cycle through the other active asynch. evals.
// before coming back to the one with the exception. This should allow
// file writing by a simulator to complete. 100 failures are currently
// allowed for any fn_eval_id before it is assumed that the error is
// real (not race condition related) and aborting.
//
err_msg_caught = true;
IntShMIter map_iter = failCountMap.find(fn_eval_id);
if (map_iter != failCountMap.end()) {
if (++map_iter->second > 100) {
Cerr << "Error: too many failed reads for file " << file_to_test
<< "\n check data format and completeness" << std::endl;
abort_handler(-1);
}
}
else
failCountMap[fn_eval_id] = 1;
#ifdef HAVE_UNISTD_H
//
// Sleep for 1 millisecond
//
usleep(1000);
#endif // HAVE_UNISTD_H
#ifdef ASYNCH_DEBUG
Cerr << "Warning: exception caught in reading response file "
<< file_to_test << "\nException = \"" << err_msg
<< "\"\nException recovery: returning " << file_to_test
<< " to processing queue.\n";
#endif
}
catch(int fail_code) {
//
// If an int exception ("fail" detected in results file) is caught,
// call manage_failure which will either (1) repair the failure and
// populate response, or (2) abort the run.
//
manage_failure(pr_pair.prp_parameters(), response.active_set(),
response, fn_eval_id);
}
//
// Process successful results for this asynchronous eval. Set
// the response within the PRPair, remove entry in failCountMap, and
// add evaluation id to completion set.
//
if (!err_msg_caught) {
//pr_pair.prp_response(response); // not needed
//replace_by_eval_id(prp_queue, fn_eval_id, pr_pair);// not needed
completionSet.insert(fn_eval_id);
failCountMap.erase(fn_eval_id); // if present
}
}
}
#ifdef HAVE_UNISTD_H
// reduce processor load from DAKOTA testing if jobs are not finishing
if (completionSet.empty()) // no jobs completed in pass through entire set
usleep(1000); // 1000 microseconds = 1 millisec
#endif // HAVE_UNISTD_H
// Remove completed jobs from idSet
for (ISIter it = completionSet.begin(); it != completionSet.end(); it++)
idSet.erase(*it);
}