本文整理汇总了C++中ParameterList::name方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterList::name方法的具体用法?C++ ParameterList::name怎么用?C++ ParameterList::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterList
的用法示例。
在下文中一共展示了ParameterList::name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tab
RCP<OptConvergenceTestBase>
OptConvergenceTestBuilder::createConvTest(const ParameterList& params,
int verb)
{
Tabs tab(0);
PLAYA_MSG1(verb, tab << "OptConvergenceTestBuilder::createConvTest()");
Tabs tab1;
PLAYA_MSG2(verb, tab1 << "params=" << params);
TEUCHOS_TEST_FOR_EXCEPTION(params.name() != "Convergence Test",
std::runtime_error,
"OptConvTestBuilder::createConvTest() expected parameter list named "
"\"Convergence Test\", got name [" << params.name() << "]");
const std::string& ctType = getParameter<string>(params, "Type");
RCP<OptConvergenceTestBase> ct;
if (ctType=="Default")
{
PLAYA_MSG2(verb, tab1 << "found Default convergence test");
ct = rcp(new DefaultOptConvergenceTest(params));
}
TEUCHOS_TEST_FOR_EXCEPTION(ct.get()==0,
std::runtime_error,
"OptConvTestBuilder::createConvTest() could not construct a valid "
"convergence test object from parameter list " << params);
return ct;
}
示例2: convertParameterList
XMLObject XMLParameterListWriter::convertParameterList(
const ParameterList& p,
ParameterEntry::ParameterEntryID& idCounter,
EntryIDsMap& entryIDsMap,
const ValidatortoIDMap& validatorIDsMap) const
{
XMLObject rtn(getParameterListTagName());
for (ParameterList::ConstIterator i=p.begin(); i!=p.end(); ++i){
RCP<const ParameterEntry> entry = p.getEntryRCP(i->first);
if(entry->isList()){
XMLObject newPL = convertParameterList(
getValue<ParameterList>(entry),
idCounter,
entryIDsMap,
validatorIDsMap);
newPL.addAttribute(
getNameAttributeName(), p.name(i));
newPL.addAttribute(
ParameterEntryXMLConverter::getIdAttributeName(), idCounter);
entryIDsMap.insert(EntryIDsMap::value_type(entry, idCounter));
rtn.addChild(newPL);
++idCounter;
}
else{
rtn.addChild(ParameterEntryXMLConverterDB::convertEntry(
entry, p.name(i), idCounter, validatorIDsMap));
entryIDsMap.insert(EntryIDsMap::value_type(entry, idCounter));
++idCounter;
}
}
return rtn;
}
示例3: ParameterControlledObjectWithVerbosity
/** Construct with a parameter list controlling the verbosity settings */
ParameterControlledObjectWithVerbosity(const std::string& objName, const ParameterList& p)
: ObjectWithClassVerbosity<X>(),
verbControlParams_()
{
RCP<ParameterList> defaults = VerbosityTraits<X>::defaultVerbParams();
TEUCHOS_TEST_FOR_EXCEPTION(defaults->name() != objName, std::runtime_error,
"mismatched ParameterList names for verbosity control: expected "
<< defaults->name() << ", got " << objName);
TEUCHOS_TEST_FOR_EXCEPTION(defaults->name() != p.name(), std::runtime_error,
"mismatched ParameterList names for verbosity control: expected "
<< defaults->name() << ", got " << p.name());
verbControlParams_ = rcp(new ParameterList(mergeParams(*defaults, p)));
}
示例4: haveSameValues
bool Teuchos::haveSameValues( const ParameterList& list1, const ParameterList& list2 )
{
// Check that the top-level names of the two parameter lists are the same
//const std::string ¶mListName1 = list1.name();
//const std::string ¶mListName2 = list2.name();
//if ( paramListName1 != paramListName2 ) {
// return false;
//}
ParameterList::ConstIterator itr1, itr2;
for(
itr1 = list1.begin(), itr2 = list2.begin();
itr1 != list1.end() && itr2 != list2.end();
++itr1, ++itr2
)
{
const std::string &entryName1 = list1.name(itr1);
const std::string &entryName2 = list2.name(itr2);
const ParameterEntry &entry1 = list1.entry(itr1);
const ParameterEntry &entry2 = list2.entry(itr2);
if( entryName1 != entryName2 ) {
return false;
}
if( entry1.isList() && entry2.isList() ) {
if (
!haveSameValues(
getValue<ParameterList>(entry1),
getValue<ParameterList>(entry2))
)
{
// Note: Above we cast to a non-const ParameterList even through we
// only need a const ParameterList. We have to do this since a
// non-const ParameterList is always added initially which determines
// the value.
return false;
}
}
else {
if( entry1.getAny() != entry2.getAny() ) {
return false;
}
}
}
// Check that the two parameter lists are the same length:
if ((itr1 != list1.end()) || (itr2 != list2.end())) {
return false;
}
return true;
}
示例5: getParameterLists
void getParameterLists(const string &inputFileName,
queue<ParameterList> &problems,
queue<ParameterList> &comparisons,
const RCP<const Teuchos::Comm<int> > & comm)
{
int rank = comm->getRank();
// return a parameter list of problem definitions
// and a parameter list for solution comparisons
Teuchos::FileInputSource inputSource(inputFileName);
if(rank == 0) cout << "input file source: " << inputFileName << endl;
XMLObject xmlInput;
// Try to get xmlObject from inputfile
try{
xmlInput = inputSource.getObject();
}
catch(exception &e)
{
EXC_ERRMSG("Test Driver error: reading", e); // error reading input
}
// get the parameter lists for each model
for(int i = 0; i < xmlInput.numChildren(); i++)
{
ParameterList plist;
xmlToModelPList(xmlInput.getChild(i), plist);
if(plist.name() == "Comparison") comparisons.emplace(plist);
else problems.emplace(plist);
}
}
示例6: buildInitialValidatorMap
XMLObject
XMLParameterListWriter::toXML(
const ParameterList& p,
RCP<const DependencySheet> depSheet) const
{
EntryIDsMap entryIDsMap;
ValidatortoIDMap validatorIDsMap;
ParameterEntry::ParameterEntryID peIDCounter = 0;
//We build an initial map full of validators that are located in the
//parameter list. That way we can convert the parameter entries.
buildInitialValidatorMap(p, validatorIDsMap);
XMLObject toReturn =
convertParameterList(p, peIDCounter, entryIDsMap, validatorIDsMap);
toReturn.addAttribute(getNameAttributeName(), p.name());
if(!depSheet.is_null()){
XMLObject deps =
convertDependencies(depSheet, entryIDsMap, validatorIDsMap);
toReturn.addChild(deps);
}
//Validators must be done after depencneies because dependencies might add
//entries to the validator map. KLN 09/20/2010
XMLObject validators = convertValidators(p, validatorIDsMap);
toReturn.addChild(validators);
return toReturn;
}
示例7: submitReport
bool deliverEmail::submitReport(QWidget* parent, const QString reportName, const QString fileName, const QString from, const QString to, const QString cc, const QString subject, const QString body, const bool emailHTML, ParameterList &rptParams)
{
if (to.isEmpty())
return false;
q.prepare( "SELECT submitReportToBatch( :reportname, :fromEmail, :emailAddress, :ccAddress, :subject,"
" :emailBody, :fileName, CURRENT_TIMESTAMP, :emailHTML) AS batch_id;" );
q.bindValue(":reportname", reportName);
q.bindValue(":fileName", fileName);
q.bindValue(":fromEmail", from);
q.bindValue(":emailAddress", to);
q.bindValue(":ccAddress", cc);
q.bindValue(":subject", subject);
q.bindValue(":emailBody", body);
q.bindValue(":emailHTML", emailHTML);
q.exec();
if (q.first())
{
int batch_id = q.value("batch_id").toInt();
int counter;
q.prepare( "INSERT INTO batchparam "
"( batchparam_batch_id, batchparam_order,"
" batchparam_name, batchparam_value ) "
"VALUES "
"( :batchparam_batch_id, :batchparam_order,"
" :batchparam_name, :batchparam_value );" );
q.bindValue(":batchparam_batch_id", batch_id);
for (counter = 0; counter < rptParams.count(); counter++)
{
q.bindValue(":batchparam_order", counter+1);
q.bindValue(":batchparam_name", rptParams.name(counter));
q.bindValue(":batchparam_value", rptParams.value(counter));
q.exec();
if (q.lastError().type() != QSqlError::NoError)
{
systemError(parent, q.lastError().databaseText(), __FILE__, __LINE__);
return false;
}
}
q.bindValue(":batchparam_batch_id", batch_id);
q.bindValue(":batchparam_order", counter+2);
q.bindValue(":batchparam_name", "title");
q.bindValue(":batchparam_value", "Emailed Customer Copy");
q.exec();
if (q.lastError().type() != QSqlError::NoError)
{
systemError(parent, q.lastError().databaseText(), __FILE__, __LINE__);
return false;
}
}
return true;
}
示例8: ParameterListtoScriptValue
// ParameterList Conversion functions
QScriptValue ParameterListtoScriptValue(QScriptEngine *engine, const ParameterList ¶ms)
{
QScriptValue obj = engine->newObject();
for(int i = 0; i < params.count(); i++)
{
obj.setProperty(params.name(i), ScriptToolbox::variantToScriptValue(engine, params.value(i)));
}
return obj;
}
示例9: run
void BCManager::run()
{
if (jacT != Teuchos::null) isAdjoint = true;
typedef ParameterList::ConstIterator ParamIter;
for (ParamIter i = bcParams.begin(); i != bcParams.end(); ++i)
{
std::string const& name = bcParams.name(i);
Teuchos::ParameterEntry const& entry = bcParams.entry(i);
assert(entry.isList());
applyBC(Teuchos::getValue<ParameterList>(entry));
}
}
示例10: generateXML
QString ExportHelper::generateXML(QString qtext, QString tableElemName, ParameterList ¶ms, QString &errmsg, int xsltmapid)
{
if (DEBUG)
qDebug("ExportHelper::generateXML(%s..., %s, %d params, errmsg, %d) entered",
qPrintable(qtext.left(80)), qPrintable(tableElemName),
params.size(), xsltmapid);
if (DEBUG)
{
QStringList plist;
for (int i = 0; i < params.size(); i++)
plist.append("\t" + params.name(i) + ":\t" + params.value(i).toString());
qDebug("generateXML parameters:\n%s", qPrintable(plist.join("\n")));
}
QDomDocument xmldoc("xtupleimport");
QDomElement rootelem = xmldoc.createElement("xtupleimport");
xmldoc.appendChild(rootelem);
if (! qtext.isEmpty())
{
MetaSQLQuery mql(qtext);
XSqlQuery qry = mql.toQuery(params);
if (qry.first())
{
do {
QDomElement tableElem = xmldoc.createElement(tableElemName);
if (DEBUG)
qDebug("generateXML starting %s", qPrintable(tableElemName));
for (int i = 0; i < qry.record().count(); i++)
{
QDomElement fieldElem = xmldoc.createElement(qry.record().fieldName(i));
if (qry.record().value(i).isNull())
fieldElem.appendChild(xmldoc.createTextNode("[NULL]"));
else
fieldElem.appendChild(xmldoc.createTextNode(qry.record().value(i).toString()));
tableElem.appendChild(fieldElem);
}
rootelem.appendChild(tableElem);
} while (qry.next());
}
if (qry.lastError().type() != QSqlError::NoError)
errmsg = qry.lastError().text();
}
if (xsltmapid < 0)
return xmldoc.toString();
else
return XSLTConvertString(xmldoc.toString(), xsltmapid, errmsg);
}
示例11: if
bool Teuchos::operator==( const ParameterList& list1, const ParameterList& list2 )
{
// Check that the top-level names of the two parameter lists are the same
//const std::string ¶mListName1 = list1.name();
//const std::string ¶mListName2 = list2.name();
//if ( paramListName1 != paramListName2 ) {
// return false;
//}
ParameterList::ConstIterator itr1, itr2;
for(
itr1 = list1.begin(), itr2 = list2.begin();
itr1 != list1.end() && itr2 != list2.end();
++itr1, ++itr2
)
{
const std::string &entryName1 = list1.name(itr1);
const std::string &entryName2 = list2.name(itr2);
const ParameterEntry &entry1 = list1.entry(itr1);
const ParameterEntry &entry2 = list2.entry(itr2);
if( entryName1 != entryName2 ) {
return false;
}
else if( entry1 != entry2 ) {
return false;
}
// Note that the above statement automatically recursively compare the
// sublists since ParameterList objects are stored in the 'any' variable
// held by the ParameterEntry object and this same comparison operator will
// be used.
}
// Check that the two parameter lists are the same length:
if ((itr1 != list1.end()) || (itr2 != list2.end())) {
return false;
}
return true;
}
示例12: analyzeMetrics
/// \brief Analyze metrics for a problem based on a range of tolerances
///
/// @param metricsPlist parameter list defining tolerances
/// @param problem the problem whose metrics are to be analyzed
/// @param comm an RCP for a communicator
/// @param[out] msg_stream a std::ostringstream stream to return information from the analysis
///
/// @return returns a boolean value indicated pass/failure.
static bool analyzeMetrics( const ParameterList &metricsPlist,
const RCP<const Zoltan2::EvaluatePartition <basic_id_t> > &metricObject,
const RCP<const Comm<int>> &comm,
std::ostringstream &msg_stream) {
auto type = metricsPlist.name();
if (type == "Metrics")
return MetricAnalyzer::analyzePartitionMetrics( metricsPlist,
metricObject,
comm,
msg_stream);
else if (type == "Graph Metrics")
return MetricAnalyzer::analyzeGraphMetrics( metricsPlist,
metricObject,
comm,
msg_stream);
return false;
}
示例13: LoadMetricInfo
static void LoadMetricInfo(std::vector<MetricAnalyzerInfo> & metricInfoSet,
const RCP<const Zoltan2::EvaluatePartition <basic_id_t> > &metricObject,
const ParameterList &metricsParameters) {
// at this point we should be looking at a metricsPlist with the following format - note that weight is optional
// <ParameterList name="metriccheck1">
// <Parameter name="check" type="string" value="imbalance"/>
// <Parameter name="lower" type="double" value="0.99"/>
// <Parameter name="upper" type="double" value="1.4"/>
// </ParameterList>
// <ParameterList name="metriccheck2">
// <Parameter name="check" type="string" value="imbalance"/>
// <Parameter name="weight" type="int" value="0"/>
// <Parameter name="lower" type="double" value="0.99"/>
// <Parameter name="upper" type="double" value="1.4"/>
// </ParameterList>
// first let's get a list of all the headings, so "metriccheck1", "metriccheck2" in this case
// I've currently got this enforcing those names strictly to make sure formatting is correct
// But really the headings could just be any unique names and are arbitrary
int headingIndex = 1;
for (auto iterateArbitraryHeadingNames = metricsParameters.begin(); iterateArbitraryHeadingNames != metricsParameters.end(); ++iterateArbitraryHeadingNames) {
auto headingName = metricsParameters.name(iterateArbitraryHeadingNames);
// we could be flexible on these headers but for now let's enforce it to get any convention inconsistencies cleaned up
std::string expectedHeadingName = "metriccheck" + std::to_string(headingIndex);
if( expectedHeadingName != headingName) {
throw std::logic_error( "The parameter list expected to find a heading with name '" + expectedHeadingName + "' but instead found '" + headingName );
}
// get the parameters specific to the check we want to run
const ParameterList & metricCheckParameters = metricsParameters.sublist(headingName);
MetricAnalyzerInfo metricInfo = getMetricInfo(metricCheckParameters, metricObject);
metricInfoSet.push_back(metricInfo);
++headingIndex;
}
}
示例14: main
int main(int argc, char *argv[])
{
////////////////////////////////////////////////////////////
// (0) Set up MPI environment and timer
////////////////////////////////////////////////////////////
Teuchos::GlobalMPISession session(&argc, &argv);
RCP<const Comm<int> > comm = Teuchos::DefaultComm<int>::getComm();
int rank = comm->getRank(); // get rank
////////////////////////////////////////////////////////////
// (1) Get and read the input file
// the input file defines tests to be run
////////////////////////////////////////////////////////////
string inputFileName("");
if(argc > 1)
inputFileName = argv[1]; // user has provided an input file
else{
if(rank == 0){
std::cout << "\nFAILED to specify xml input file!" << std::endl;
ostringstream msg;
msg << "\nStandard use of test_driver.cpp:\n";
msg << "mpiexec -n <procs> ./Zoltan2_test_driver.exe <input_file.xml>\n";
std::cout << msg.str() << std::endl;
}
return 1;
}
////////////////////////////////////////////////////////////
// (2) Get All Input Parameter Lists
////////////////////////////////////////////////////////////
queue<ParameterList> problems, comparisons;
getParameterLists(inputFileName,problems, comparisons, comm);
////////////////////////////////////////////////////////////
// (3) Get Input Data Parameters
////////////////////////////////////////////////////////////
// assumes that first block will always be
// the input block
const ParameterList inputParameters = problems.front();
if(inputParameters.name() != "InputParameters")
{
if(rank == 0)
cout << "InputParameters not defined. Testing FAILED." << endl;
return 1;
}
// get the user input for all tests
UserInputForTests uinput(inputParameters,comm);
problems.pop();
comm->barrier();
if(uinput.hasInput())
{
////////////////////////////////////////////////////////////
// (4) Perform all tests
////////////////////////////////////////////////////////////
// pamgen debugging
// MyUtils::writeMesh(uinput,comm);
// MyUtils::getConnectivityGraph(uinput, comm);
RCP<ComparisonHelper> comparison_manager
= rcp(new ComparisonHelper);
while (!problems.empty()) {
run(uinput, problems.front(), comparison_manager, comm);
problems.pop();
}
////////////////////////////////////////////////////////////
// (5) Compare solutions
////////////////////////////////////////////////////////////
while (!comparisons.empty()) {
comparison_manager->Compare(comparisons.front(),comm);
comparisons.pop();
}
}else{
if(rank == 0){
cout << "\nFAILED to load input data source.";
cout << "\nSkipping all tests." << endl;
}
}
return 0;
}
示例15: run
void run(const UserInputForTests &uinput,
const ParameterList &problem_parameters,
RCP<ComparisonHelper> & comparison_helper,
const RCP<const Teuchos::Comm<int> > & comm)
{
// Major steps in running a problem in zoltan 2
// 1. get an input adapter
// 2. construct the problem
// 3. solve the problem
// 4. analyze metrics
// 5. clean up
int rank = comm->getRank();
if(!problem_parameters.isParameter("kind"))
{
if(rank == 0) std::cerr << "Problem kind not provided" << std::endl;
return;
}
if(!problem_parameters.isParameter("InputAdapterParameters"))
{
if(rank == 0) std::cerr << "Input adapter parameters not provided" << std::endl;
return;
}
if(!problem_parameters.isParameter("Zoltan2Parameters"))
{
if(rank == 0) std::cerr << "Zoltan2 problem parameters not provided" << std::endl;
return;
}
if(rank == 0)
cout << "\n\nRunning test: " << problem_parameters.name() << endl;
////////////////////////////////////////////////////////////
// 0. add comparison source
////////////////////////////////////////////////////////////
ComparisonSource * comparison_source = new ComparisonSource;
comparison_helper->AddSource(problem_parameters.name(), comparison_source);
comparison_source->addTimer("adapter construction time");
comparison_source->addTimer("problem construction time");
comparison_source->addTimer("solve time");
////////////////////////////////////////////////////////////
// 1. get basic input adapter
////////////////////////////////////////////////////////////
const ParameterList &adapterPlist = problem_parameters.sublist("InputAdapterParameters");
comparison_source->timers["adapter construction time"]->start();
base_adapter_t * ia = AdapterForTests::getAdapterForInput(const_cast<UserInputForTests *>(&uinput), adapterPlist,comm); // a pointer to a basic type
comparison_source->timers["adapter construction time"]->stop();
// if(rank == 0) cout << "Got input adapter... " << endl;
if(ia == nullptr)
{
if(rank == 0)
cout << "Get adapter for input failed" << endl;
return;
}
////////////////////////////////////////////////////////////
// 2. construct a Zoltan2 problem
////////////////////////////////////////////////////////////
string adapter_name = adapterPlist.get<string>("input adapter"); // If we are here we have an input adapter, no need to check for one.
// get Zoltan2 partion parameters
ParameterList zoltan2_parameters = const_cast<ParameterList &>(problem_parameters.sublist("Zoltan2Parameters"));
//if(rank == 0){
// cout << "\nZoltan 2 parameters:" << endl;
// zoltan2_parameters.print(std::cout);
// cout << endl;
//}
comparison_source->timers["problem construction time"]->start();
std::string problem_kind = problem_parameters.get<std::string>("kind");
if (rank == 0) std::cout << "Creating a new " << problem_kind << " problem." << std::endl;
#ifdef HAVE_ZOLTAN2_MPI
base_problem_t * problem =
Zoltan2_TestingFramework::ProblemFactory::newProblem(problem_kind, adapter_name, ia, &zoltan2_parameters, MPI_COMM_WORLD);
#else
base_problem_t * problem =
Zoltan2_TestingFramework::ProblemFactory::newProblem(problem_kind, adapter_name, ia, &zoltan2_parameters);
#endif
if (problem == nullptr) {
if (rank == 0)
std::cerr << "Input adapter type: " + adapter_name + ", is unvailable, or misspelled." << std::endl;
return;
}
////////////////////////////////////////////////////////////
// 3. Solve the problem
////////////////////////////////////////////////////////////
comparison_source->timers["solve time"]->start();
if (problem_kind == "partitioning") {
reinterpret_cast<partitioning_problem_t *>(problem)->solve();
} else if (problem_kind == "ordering") {
reinterpret_cast<ordering_problem_t *>(problem)->solve();
} else if (problem_kind == "coloring") {
reinterpret_cast<coloring_problem_t *>(problem)->solve();
//.........这里部分代码省略.........