本文整理汇总了C++中ParameterMap::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterMap::insert方法的具体用法?C++ ParameterMap::insert怎么用?C++ ParameterMap::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParameterMap
的用法示例。
在下文中一共展示了ParameterMap::insert方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseOptions
ParameterMap parseOptions(int argc, char* argv[]) {
if (argc < 3) {
usage();
}
QStringList args;
for (int i=0; i<argc; i++) args << argv[i];
ParameterMap options;
options.insert("inputFiles", args[1]);
options.insert("dataset", args[2]);
// this is ugly, but works...
for (int i=0; i<args.size(); i++) {
if (args[i].startsWith("--select=")) {
descs_select = args[i].mid(9).split(",");
args.removeAt(i);
i--;
}
if (args[i].startsWith("--exclude=")) {
descs_exclude = args[i].mid(10).split(",");
args.removeAt(i);
i--;
}
if (args[i].startsWith("--reflayout=")) {
layout = new PointLayout();
Point refp; refp.load(args[i].mid(12));
*layout = refp.layout();
args.removeAt(i);
i--;
}
if (args[i].startsWith("--nthreads=")) {
QThreadPool::globalInstance()->setMaxThreadCount(args[i].mid(11).toInt());
args.removeAt(i);
i--;
}
}
int start = 0, end = 10000000;
if (args.size() > 3) start = args[3].toInt();
if (args.size() > 4) end = args[4].toInt();
if (args.size() > 5) usage();
options.insert("start", start);
options.insert("end", end);
return options;
}
示例2: analyze
Transformation Normalize::analyze(const DataSet* dataset, const Region& descs) const {
G_INFO("Doing normalize analysis...");
checkDataSet(dataset);
checkMinPoints(dataset, 2);
Region region = checkFixedLength(descs.select(RealType), dataset->layout());
// get statistics on the input dataset
Point mmin, mmax, mean, var;
if (!_params.contains("outliers") || _params.value("outliers").toDouble() < 0.0) {
getStats(*dataset, region, mmin, mmax, mean, var);
}
else {
getStatsWithOutliers(*dataset, region, mmin, mmax, mean, var);
}
Transformation result(dataset->layout());
result.analyzerName = "normalize";
result.analyzerParams = _params;
result.applierName = "dotproduct";
// insert info values inside Transfo object: mean & var
ParameterMap stats;
foreach (const Segment& seg, region.segments) {
// FIXME: not necessarily correct if some adjacent descriptors have been
// merged into a single segment
QString descriptorName = mmin.layout().descriptorName(RealType, FixedLength, seg.begin);
ParameterMap meanvar;
meanvar.insert("mean", mean.value(descriptorName));
meanvar.insert("var", var.value(descriptorName));
stats.insert(descriptorName, meanvar);
}
result.info = stats;
// insert actual Transformation parameters
ParameterMap& applierParams = result.params;
applierParams.insert("applyClipping", _params.value("applyClipping", false));
ParameterMap coeffMap;
foreach (const Segment& seg, region.segments) {
QString descriptorName = mmin.layout().descriptorName(RealType, FixedLength, seg.begin);
coeffMap.insert(descriptorName, getNormalizationCoeffs(descriptorName, mmin, mmax, mean, var));
}
applierParams.insert("coeffs", coeffMap);
G_DEBUG(GAlgorithms, "normalization success!");
return result;
}
示例3: receiveMessage
ReceiveMessageResponse*
SQSConnection::receiveMessage (const std::string &aQueueUrl,
int aNumberOfMessages,
int aVisibilityTimeout,
bool aDecode) {
ParameterMap lMap;
if (aNumberOfMessages != 0) {
std::stringstream s;
s << aNumberOfMessages;
lMap.insert (ParameterPair ("MaxNumberOfMessages", s.str()));
}
if (aVisibilityTimeout > -1) {
std::stringstream s;
s << aVisibilityTimeout;
lMap.insert (ParameterPair ("VisibilityTimeout", s.str()));
}
return receiveMessage (aQueueUrl, lMap, aDecode);
}
示例4: CreateQueueException
CreateQueueResponse*
SQSConnection::createQueue ( const std::string &aQueueName, int aDefaultVisibilityTimeout)
{
ParameterMap lMap;
lMap.insert ( ParameterPair ( "QueueName", aQueueName ) );
if (aDefaultVisibilityTimeout > -1 ) {
std::stringstream s;
s << aDefaultVisibilityTimeout;
lMap.insert ( ParameterPair ( "DefaultVisibilityTimeout", s.str() ) );
}
CreateQueueHandler lHandler;
makeQueryRequest ( "CreateQueue", &lMap, &lHandler );
if (lHandler.isSuccessful()) {
setCommons(lHandler, lHandler.theCreateQueueResponse);
return lHandler.theCreateQueueResponse;
} else {
throw CreateQueueException( lHandler.getQueryErrorResponse() );
}
}
示例5: parseOptions
ParameterMap parseOptions(int argc, char* argv[]) {
if (argc < 2) {
G_ERROR("not enough arguments...\n\n"
"Usage: " << argv[0] << " [-v] dataset_file");
}
ParameterMap options;
options.insert("verbose", false);
if (argc >= 3) {
if (QString(argv[1]) == "-v") {
options.insert("verbose", true);
options.insert("dataset", argv[2]);
}
else if (QString(argv[2]) == "-v") {
options.insert("verbose", true);
options.insert("dataset", argv[1]);
}
}
else {
options.insert("dataset", argv[1]);
}
return options;
}
示例6: parameters
ParameterMap Driver::parameters() {
if(!isValid()) {
return ParameterMap();
}
ParameterMap parameterMap;
const JSList *parameters = jackctl_driver_get_parameters(_jackDriver);
while(parameters) {
Parameter p = Parameter((jackctl_parameter_t*)parameters->data);
parameterMap.insert(p.name(), p);
parameters = parameters->next;
}
return parameterMap;
}
示例7: DeleteMessageException
DeleteMessageResponse*
SQSConnection::deleteMessage(const std::string &aQueueUrl, const std::string &aReceiptHandle)
{
ParameterMap lMap;
lMap.insert ( ParameterPair ( "ReceiptHandle", aReceiptHandle ) );
DeleteMessageHandler lHandler;
makeQueryRequest ( aQueueUrl, "DeleteMessage", &lMap, &lHandler );
if (lHandler.isSuccessful()) {
setCommons(lHandler, lHandler.theDeleteMessageResponse);
return lHandler.theDeleteMessageResponse;
} else {
throw DeleteMessageException( lHandler.getQueryErrorResponse() );
}
}
示例8: ListQueuesException
ListQueuesResponse*
SQSConnection::listQueues(const std::string &aQueueNamePrefix)
{
ParameterMap lMap;
if (aQueueNamePrefix != "") {
lMap.insert ( ParameterPair ( "QueueNamePrefix", aQueueNamePrefix ) );
}
ListQueuesHandler lHandler;
makeQueryRequest ( "ListQueues", &lMap, &lHandler );
if (lHandler.isSuccessful()) {
setCommons(lHandler, lHandler.theListQueuesResponse);
return lHandler.theListQueuesResponse;
} else {
throw ListQueuesException( lHandler.getQueryErrorResponse() );
}
}
示例9: SendMessageException
SendMessageResponse*
SQSConnection::sendMessage(const std::string &aQueueUrl, const std::string &aMessageBody, bool aEncode)
{
ParameterMap lMap;
long lBody64Len;
std::string enc;
if (aEncode)
enc = AWSConnection::base64Encode(aMessageBody.c_str(), aMessageBody.size(), lBody64Len);
else
enc = aMessageBody;
if (enc.size() > 32768) {
std::stringstream lTmp;
lTmp << "Message larger than 32kB : " << enc.size() / 1024 << " kb";
throw SendMessageException( QueryErrorResponse("1", lTmp.str(), "", "") );
}
lMap.insert ( ParameterPair ( "MessageBody", enc ) );
return sendMessage(aQueueUrl, lMap);
}
示例10: getNormalizationCoeffs
ParameterMap Normalize::getNormalizationCoeffs(const QString& descriptorName,
const Point& mmin, const Point& mmax,
const Point& mean, const Point& var) const {
RealDescriptor a, b;
if (!_params.contains("type") || // default case: type was not defined
_params.value("type") == "range") {
// normalization using minimum and maximum
// y = ax+b, y = (x - min)/(max - min), a=1/(max-min) and b = -min/(max-min)
// normalization as a vector (default)
if (!_params.contains("independent") || // default case
!_params.value("independent").toBool()) {
RealDescriptor maxd = mmax.value(descriptorName);
RealDescriptor mind = mmin.value(descriptorName);
Real maxv = maxd[0], minv = mind[0];
for (int i=1; i<maxd.size(); i++) maxv = std::max(maxv, maxd[i]);
for (int i=1; i<mind.size(); i++) minv = std::min(minv, mind[i]);
a = RealDescriptor(maxd.size(), 1 / (maxv-minv) );
b = RealDescriptor(mind.size(), -minv / (maxv - minv) );
}
// normalization each dimension separately
else {
a = (mmax.value(descriptorName) - mmin.value(descriptorName)).inverse();
b = -mmin.value(descriptorName) * a;
}
}
else if (_params.value("type") == "variance") {
// normalization using 4 * stddev, between 0 and 1 (centered around 0.5)
// y = ax+b, y = (x - mean)/(4*stddev) + 0.5, thus
// a=1/(4*stddev) and b = -mean/(4*stddev)+0.5
// normalization as a vector (default)
if (!_params.contains("independent") || // default case
!_params.value("independent").toBool()) {
throw GaiaException("This type of normalization (type=variance, independent=false)"
" is not implemented at the moment");
}
// normalization each dimension separately
else {
a = Real(1.0) / (Real(4.0) * sqrt(var.value(descriptorName)));
b = -mean.value(descriptorName) * a + 0.5;
}
}
else {
throw GaiaException("Normalize: unknown normalization type: ", _params.value("type").toString());
}
//G_DEBUG(GAlgorithms, "a:" << a << "b:" << b);
// SECURITY CHECK - shouldn't happen, apply cleaner transfo before if it does...
// happens for 2D arrays, where 2 first values are dimensions, hence constant, but
// as a vector doesn't get cleaned
if (a.isinf() || a.isnan()) {
throw GaiaException("ERROR: Division by zero in ", descriptorName);
}
ParameterMap coeffs;
coeffs.insert("a", a);
coeffs.insert("b", b);
return coeffs;
}
示例11: addParameter
void addParameter( SLSF::Parameter parameter ) {
_parameterMap.insert( std::make_pair( static_cast< std::string >( parameter.name() ), parameter ) );
}
示例12: main
int main(int argc, char* argv[]) {
QCoreApplication app(argc, argv);
ParameterMap options = parseOptions(argc, argv);
gaia2::init();
gaia2::verbose = true;
if (options.value("verbose").toBool()) {
setDebugLevel(GTools);
}
DataSet dataset;
int npoints;
int dimension;
try {
G_INFO("Loading dataset: " << options.value("dataset"));
dataset.load(options.value("dataset"));
npoints = dataset.size();
dimension = dataset.layout().correspondingRegion().dimension();
}
catch (GaiaException& e) {
G_ERROR(e.msg());
exit(1);
}
G_INFO("DataSet name: " << dataset.name());
G_INFO("Total number of points: " << npoints);
G_INFO("Dimension: " << dimension);
G_INFO("");
// ---------------------------------------------------------------------------
G_INFO("Copying data into SuperMatrix (naive FrozenDataset)...");
G_INFO("fixed real data dimension = " << dataset[0]->frealData().size());
G_INFO("(note: should be 175 for gaiabench)");
G_INFO("");
float* frozenDataSet = new float[npoints*dimension];
for (int i=0; i<npoints; i++) {
const int offset = i*dimension;
const RealDescriptor& d = dataset[i]->frealData();
for (int j=0; j<dimension; j++) {
frozenDataSet[offset+j] = d[j];
}
}
float* frozenDataSet2 = new float[npoints*25];
for (int i=0; i<npoints; i++) {
const int offset = i*25;
const RealDescriptor& d = dataset[i]->frealData();
for (int j=0; j<25; j++) {
frozenDataSet2[offset+j] = d[150+j];
}
}
G_INFO("Copying data into gaia::FrozenDataSet...");
FrozenDataSet frozenDS;
frozenDS.fromDataSet(dataset);
gaia2::verbose = false;
ParameterMap eucp;
eucp.insert("descriptorNames", "pca");
DataSet* eucds = transform(&dataset, "select", eucp);
FrozenDataSet frozeuc;
frozeuc.fromDataSet(*eucds);
delete eucds;
gaia2::verbose = true;
G_INFO("FrozenDataSets ready");
G_INFO("");
// ---------------------------------------------------------------------------
G_INFO(G_HLINE "\n");
const char* hybridDistanceParams =
"colfilter: \n"
" weight: 0.4 \n"
" distance: cosineangle \n"
" params: \n"
" descriptorNames: colfilter \n"
" defaultValue: 0.0 \n"
" \n"
"context: \n"
" weight: 0.4 \n"
" distance: cosineangle \n"
" params: \n"
" descriptorNames: context \n"
" defaultValue: 0.0 \n"
" \n"
"content: \n"
" weight: 0.2 \n"
" distance: euclidean \n"
" params: \n"
" descriptorNames: pca \n"
" \n";
//.........这里部分代码省略.........