コード例 #1
0
void UBTeacherGuidePageZeroWidget::fillComboBoxes()
{
    QFile parametersFile(":xml/indexingParameters.xml");
    if(!parametersFile.exists()){
        qCritical() << "Teacher Guide: cannot find the configuration file.";
        return;
    }

    if(parametersFile.open(QFile::ReadOnly)){
        QDomDocument doc;
        doc.setContent(parametersFile.readAll());
        QDomElement rootElement = doc.elementsByTagName("teacherGuide").at(0).toElement();

        QDomNodeList subjects = rootElement.elementsByTagName("subjects");
        for (int baseLevelCounter = 0; baseLevelCounter < subjects.count(); baseLevelCounter += 1) {
            QDomNode subjectsForBaseLevel = subjects.at(baseLevelCounter);
            QDomNodeList subjectsList = subjectsForBaseLevel.childNodes();
            QStringList subjectsRelatedToBaseLevel;
            for (int j = 0; j < subjectsList.count(); j += 1) {
                subjectsRelatedToBaseLevel.append(subjectsList.at(j).toElement().attribute("label"));
            }
            mSubjects.insert( subjectsForBaseLevel.toElement().attribute("baseLevel"), subjectsRelatedToBaseLevel);
        }

        QDomNodeList gradeLevels = rootElement.elementsByTagName("gradeLevels").at(0).childNodes();
        for (int i = 0; i < gradeLevels.count(); i += 1) {
            mGradeLevelsMap.insert(gradeLevels.at(i).toElement().attribute("label"), gradeLevels.at(i).toElement().attribute("baseLevel"));
            mpSchoolLevelBox->addItem( gradeLevels.at(i).toElement().attribute("label"));
        }

        QDomNodeList types = rootElement.elementsByTagName("types").at(0).childNodes();
        for (int i = 0; i < types.count(); i += 1)
            mpSchoolTypeBox->addItem(types.at(i).toElement().attribute("label"));

        parametersFile.close();

        QStringList licences;
        licences << tr("Attribution-ShareAlike CC BY-SA")
                 << tr("Attribution CC BY")
                 << tr("Attribution-NoDerivs CC BY-ND")
                 << tr("Attribution-NonCommercial CC BY-NC")
                 << tr("Attribution-NonCommercial-NoDerivs CC BY-NC-ND")
                 << tr("Attribution-NonCommercial-ShareAlike CC BY-NC-SA")
                 << tr("Public domain")
                 << tr("Copyright");
        mpLicenceBox->addItems(licences);
        QStringList licenceIconList;
        licenceIconList << ":images/licenses/ccbysa.png"
                        << ":images/licenses/ccby.png"
                        << ":images/licenses/ccbynd.png"
                        << ":images/licenses/ccbync.png"
                        << ":images/licenses/ccbyncnd.png"
                        << ":images/licenses/ccbyncsa.png";
        for (int i = 0; i < licenceIconList.count(); i += 1)
            mpLicenceBox->setItemData(i, licenceIconList.at(i));
    }else{
        qCritical() << "Teacher Guide: cannot open the configuration file.";
    }
}
コード例 #2
0
void Parameters::saveParameters()
{
	QFile parametersFile("Parameters.xml");
	if(!parametersFile.open(QFile::WriteOnly))
	{
		qDebug()<<QObject::tr("打开参数文件写入失败");
		return;
	}

	QDomDocument domDocument;

	QDomElement rootElement = domDocument.createElement("Parameters");
	domDocument.appendChild(rootElement);

	rootElement.setAttribute("DayStartTime", dayStartTime.toString("hh:mm"));
	rootElement.setAttribute("DayEndTime", dayEndTime.toString("hh:mm"));
	rootElement.setAttribute("DayVolume", dayVolume);

	rootElement.setAttribute("NightStartTime", nightStartTime.toString("hh:mm"));
	rootElement.setAttribute("NightEndTime", nightEndTime.toString("hh:mm"));
	rootElement.setAttribute("NightVolume", nightVolume);

	rootElement.setAttribute("CheckClientOnlineSecond", (uint)checkClientOnlineSecond);

	rootElement.setAttribute("TransferExistsFileHandleCode", transferExistsFileHandleCode);

	rootElement.setAttribute("PlayListFileTransferMode", playListFileTransferMode);

	rootElement.setAttribute("ComPort", comPort);
	rootElement.setAttribute("isCheckSMSModem",isCheckSMSModem);
	//rootElement.setAttribute("PhoneNo", phoneNo);


	QTextStream stream(&parametersFile);
	domDocument.save(stream, 4);

}
コード例 #3
0
ファイル: lmclus_test.cpp プロジェクト: EvanMisshula/lmclus
int main ( int argc, char *argv[] )
{
    cmdline::parser cmdOpt;
    specifyCommandLineParameters(cmdOpt);
    if (!cmdOpt.parse(argc, argv)) {
        std::cout << cmdOpt.error()<< std::endl << cmdOpt.usage() << std::endl;
        return EXIT_FAILURE;
    }

    // reading command line
    std::string parametersFile(cmdOpt.get<std::string>(CFG));
    std::string inputDataFile(cmdOpt.get<std::string>(IN));

    // Setup logger
    cpplog::OstreamLogger *log;
    if (cmdOpt.exist(LOGF))
    {
        log = new cpplog::FileLogger(cmdOpt.get<std::string>(LOGF)+".log", true);
    }
    else
    {
        log = new cpplog::StdErrLogger();
    }

    // load lmclus parameters from parameters file
    CSimpleIniA ini(false, false, false);
    SI_Error rc = ini.LoadFile(parametersFile.c_str());
    if (rc < 0) {
        LOG_ERROR(log) << "Problem reading parameters file: " << parametersFile;
        return EXIT_FAILURE;
    }

    // Set parameters from ini-file
    clustering::lmclus::Parameters params;
    params.MAX_DIM = static_cast<int>(ini.GetLongValue(SECTION, "MAX_DIM", 2));
    params.NUM_OF_CLUS = static_cast<int>(ini.GetLongValue(SECTION, "NUM_OF_CLUS", 2));
    params.LABEL_COL = static_cast<int>(ini.GetLongValue(SECTION, "LABEL_COL", 0));
    params.CONST_SIZE_HIS = static_cast<int>(ini.GetLongValue(SECTION, "CONST_SIZE_HIS", 0));
    params.NOISE_SIZE = static_cast<unsigned int>(ini.GetLongValue(SECTION, "NOISE_SIZE", 2));
    params.BEST_BOUND = ini.GetDoubleValue(SECTION, "BEST_BOUND", 1.0);
    params.ERROR_BOUND = ini.GetDoubleValue(SECTION, "ERROR_BOUND", 0.0001);
    params.MAX_BIN_PORTION = ini.GetDoubleValue(SECTION, "MAX_BIN_PORTION", 0.1);

    params.RANDOM_SEED = static_cast<unsigned int>(ini.GetLongValue(SECTION, "RANDOM_SEED", 0));
    params.SAMPLING_HEURISTIC = static_cast<int>(ini.GetLongValue(SECTION, "SAMPLING_HEURISTIC", 3));
    params.SAMPLING_FACTOR = ini.GetDoubleValue(SECTION, "SAMPLING_FACTOR", 0.003);
    params.HIS_SAMPLING = ini.GetBoolValue(SECTION, "HIS_SAMPLING", false);
    params.SAVE_RESULT = ini.GetBoolValue(SECTION, "SAVE_RESULT", false);

    // Load dataset
    arma::mat data;
    arma::vec original_labels;
    data.load(inputDataFile, arma::csv_ascii);
    //data = arma::randu<arma::mat>(100,11);
    if (params.LABEL_COL > 0 && params.LABEL_COL <= data.n_cols) {
        LOG_INFO(log) << "Labels in column " << params.LABEL_COL << " will be removed";
        original_labels = data.col(params.LABEL_COL-1);
        data.shed_col(params.LABEL_COL-1);
    }

    LOG_INFO(log) << "Parameters file: " << parametersFile;
    LOG_INFO(log) << "Parameters: \n" << params;
    LOG_INFO(log) << "Input: " << inputDataFile;
    LOG_INFO(log) << "Input rows: " << data.n_rows;
    LOG_INFO(log) << "Input cols: " << data.n_cols;
    //LOG_INFO(log) << "Data: \n" << data;

    //TEST(log, data.n_cols == 11, "Invalid column number")
    //TEST(log, data.n_rows == 3000, "Invalid row number")
    //TEST(log, data.n_cols == 10, "Invalid column number")

    TEST(log, params.MAX_DIM < static_cast<int>(data.n_cols),
         "Linear manifold dimension must be less than the dimension of the data !!!")

    // Process data
    clustering::lmclus::LMCLUS lmclus(log);
    std::vector<arma::uvec> labels;
    std::vector<double> thresholds;
    std::vector<arma::mat> basises;
    std::vector<int> clusterDims;
    lmclus.cluster(data, params, labels, thresholds, basises, clusterDims, progress);

    // Process results
    size_t clusterNum = labels.size();
    TEST(log, clusterDims.size() == clusterNum, "Invalid number of clusters")
    for(size_t i=0; i < clusterNum; ++i)
    {
        LOG_INFO(log) << "Cluster " << i << " dimension: " << clusterDims[i] << ", size: " << labels[i].n_elem <<"\n";
        //LOG_INFO(log) << "Labels: " << labels[i].t();
        LOG_INFO(log) << "Basis: \n"<< basises[i];
    }

    LOG_INFO(log) << "labels found: " << labels.size();
    LOG_INFO(log) << "thresholds found: " << thresholds.size();
    LOG_INFO(log) << "basises found: " << basises.size();
    LOG_INFO(log) << "clusterDims found: " << clusterDims.size();

    // Clear log
    delete log;

    return EXIT_SUCCESS;
}