/*Compute the performance for unlabeled nodes provided their target values*/ void computeUnlabeledPerf(char* preds,int* unlabeled,int nbUnlabeled,int nbClass, InputParams* inputParams,PerfMeasures* unlabeledPerf,int verbose){ /*Allocate the array containing target values*/ char* targets = char_vec_alloc(nbUnlabeled); /*Read the targets from input file*/ int nbTarClass = readTargets(inputParams->tarFname,unlabeled,targets); /*Initialize performance measures*/ init_PerfMeasures(unlabeledPerf,nbClass+1); /*Check that no new classes are present in the target file*/ if(nbTarClass > nbClass){ textcolor(BRIGHT,RED,BLACK); printf("WARNING: The number of classes in targetFile (%i) is larger than in graphFile (%i)\n",nbTarClass,nbClass); textcolor(RESET,WHITE,BLACK); nbClass = nbTarClass; } /*Allocate the confusion matrix*/ unlabeledPerf->confusion = int_mat_alloc(nbClass+1,nbClass+1); /*Create the confusion matrix*/ createConfusionMatrix(preds,targets,nbUnlabeled,unlabeledPerf->confusion,nbClass); /*Get the performance measure on unlabeled nodes*/ computePerfs(unlabeledPerf,nbClass,inputParams->priors); /*Display the test performance*/ if(inputParams->verbose >= 1){ show_ConfusionMatrix(unlabeledPerf->confusion,nbClass,stdout); printPerfs(unlabeledPerf,NULL); } /*Release memory*/ free(targets); }
/** * Given a set of values, times how long it takes to find if a specified target * value can be made by summing a subset of the given set of values. * * Command line args: * argv[1] - a file of numbers that are in our set of values. The first line of * the file is the number of values in the file. * argv[2] - a file of 30 numbers that are the targets that we try to reach * with a subset of the values in argv[1] * * Compile: gcc proj1.c -fopenmp -o proj1 * Run: ./proj1 set_I_filename targets_filename * * Authors: Gaurav Luthria <*****@*****.**> * Rajan Patel <*****@*****.**> * Michael Bishoff <*****@*****.**> */ int main(int argc, char* argv[]) { // Check if command line args are valid if (argc != 3) { printf("ERROR: Command line arguments are <set_I_filename> "); printf("<targets_filename>\n"); return 1; } // Initializes I, the set of values, and the list of targets that we use // to see if a subset of I sums to the value of a target int* I = readSet(argv[1]); int* targets = readTargets(argv[2]); // Determines the number of columns needed in the Q table numCols = getNumColumns(I); // Allocates space for the Q table int** Q = malloc(sizeof(*Q)*numRows); for (int i = 0; i < numRows; i++) { Q[i] = malloc(sizeof(*(Q[i]))*numCols); } double totalTime = 0; for (int i = 0; i < NUM_TARGETS; i++) { clearQMatrix(Q); double startTime = omp_get_wtime(); //clock_t startTime = clock(); int solutionExists = findSolution(I, Q, targets[i]); double endTime = omp_get_wtime(); //clock_t endTime = clock(); totalTime += (double) (endTime - startTime); // Uncomment this to see the reconstructed solution! /* printf("%d: ", targets[i]); // If there's a solution, print it if (solutionExists) { // Uncomment this to see the Q table! // printPretty(I, Q); reconstructSolution(I, Q, targets[i]); } else { printf("NO SOUTION EXISTS! "); } */ } printf("Average Time: %f\n", (totalTime / NUM_TARGETS)); printf("Total Time: %f\n", totalTime); // Freeeee free(I); for (int i = 0; i < numRows; i++) { free(Q[i]); } free(Q); return 0; }
OptionDlg::OptionDlg(QWidget *parent) : QDialog(parent) { readConfigure("etc/conf.xml"); readTargets("etc/targets.xml"); // 创建控件 tabWidget = new QTabWidget; tabGeneral = new QWidget; tabNetwork = new QWidget; tabTargets = new QWidget; tabWidget->addTab(tabGeneral, tr("General")); tabWidget->addTab(tabNetwork, tr("Network")); tabWidget->addTab(tabTargets, tr("Targets")); // tab general labelRecursiveLayer = new QLabel(tr("&Recursive layer:")); spinBoxRecursiveLayer = new QSpinBox(); spinBoxRecursiveLayer->setValue(recursiveLayer); labelRecursiveLayer->setBuddy(spinBoxRecursiveLayer); labelMinFileSize = new QLabel(tr("&Minimum file size(Kb):")); spinBoxMinFileSize = new QSpinBox(); spinBoxMinFileSize->setValue(minFileSize); labelMinFileSize->setBuddy(spinBoxMinFileSize); checkBoxSaveInSingleDir = new QCheckBox(tr("&Save targets in single directory")); checkBoxSaveInSingleDir->setChecked(saveInSingleDir); labelFileExistsAction = new QLabel(tr("&Do what when file exists:")); comboBoxFileExistsAction = new QComboBox(); comboBoxFileExistsAction->addItem(tr("Overwrite"), feaOverwrite); comboBoxFileExistsAction->addItem(tr("Ignore"), feaIgnore); comboBoxFileExistsAction->setCurrentIndex(fileExistsAction); labelFileExistsAction->setBuddy(comboBoxFileExistsAction); gridLayoutGeneral = new QGridLayout(); gridLayoutGeneral->addWidget(labelRecursiveLayer, 0, 0, 1, 1); gridLayoutGeneral->addWidget(spinBoxRecursiveLayer, 0, 1, 1, 1); gridLayoutGeneral->addWidget(labelMinFileSize, 1, 0, 1, 1); gridLayoutGeneral->addWidget(spinBoxMinFileSize, 1, 1, 1, 1); gridLayoutGeneral->addWidget(checkBoxSaveInSingleDir, 2, 0, 1, 2); gridLayoutGeneral->addWidget(labelFileExistsAction, 3, 0, 1, 1); gridLayoutGeneral->addWidget(comboBoxFileExistsAction, 3, 1, 1, 1); boxLayoutGeneral = new QVBoxLayout; boxLayoutGeneral->addLayout(gridLayoutGeneral); boxLayoutGeneral->addStretch(); tabGeneral->setLayout(boxLayoutGeneral); // tab Network checkBoxUseProxy = new QCheckBox(tr("&Enable proxy")); checkBoxUseProxy->setChecked(useProxy); connect(checkBoxUseProxy, SIGNAL(stateChanged(int)), this, SLOT(useProxyOrNot(int))); labelHost = new QLabel(tr("&Host:")); editHost = new QLineEdit(); editHost->setText(proxyHost); labelHost->setBuddy(editHost); labelPort = new QLabel(tr("&Port:")); spinBoxPort = new QSpinBox(); spinBoxPort->setMaximum(65535); spinBoxPort->setValue(proxyPort); labelPort->setBuddy(spinBoxPort); labelUsername = new QLabel(tr("&Username:"******"Pass&word:")); editPassword = new QLineEdit(); editPassword->setText(proxyPassword); editPassword->setEchoMode(QLineEdit::Password); labelPassword->setBuddy(editPassword); // 启用不启用代理 useProxyOrNot(checkBoxUseProxy->checkState()); gridLayoutNetwork = new QGridLayout(); gridLayoutNetwork->addWidget(checkBoxUseProxy, 0, 0, 1, 2); gridLayoutNetwork->addWidget(labelHost, 1, 0, 1, 1); gridLayoutNetwork->addWidget(editHost, 1, 1, 1, 1); gridLayoutNetwork->addWidget(labelPort, 2, 0, 1, 1); gridLayoutNetwork->addWidget(spinBoxPort, 2, 1, 1, 1); gridLayoutNetwork->addWidget(labelUsername, 3, 0, 1, 1); gridLayoutNetwork->addWidget(editUsername, 3, 1, 1, 1); gridLayoutNetwork->addWidget(labelPassword, 4, 0, 1, 1); gridLayoutNetwork->addWidget(editPassword, 4, 1, 1, 1); boxLayoutNetwork = new QVBoxLayout; boxLayoutNetwork->addLayout(gridLayoutNetwork); boxLayoutNetwork->addStretch(); tabNetwork->setLayout(boxLayoutNetwork); // tab targets boxLayoutTargets = new QVBoxLayout; int i = 1; foreach(Target target, targets) { QCheckBox *checkBoxTarget = new QCheckBox( QString("&%1. %2").arg(i).arg(target.desc)); if(target.selected) checkBoxTarget->setChecked(true); boxLayoutTargets->addWidget(checkBoxTarget); checkBoxTargets.push_back(checkBoxTarget); ++i; }