void Menu::selectMenu() { int menu_sel; while (true) { cout << endl; cout << "(프로그램을 종료하시려면 -1을 입력해주세요.) \n무슨 함수를 실행해보시겠습니까? "; try { cin >> menu_sel; } catch (...) { cout << "이상한거 입력하지마라.. " << endl; } if (menu_sel < MENU_LIST || menu_sel > GCD) { if (menu_sel == -1) { cout << "프로그램을 종료합니다." << endl; break; } cout << "잘못 입력하셨습니다." << endl; } else { setMenu((MENU_CL)menu_sel); cout << "\n함수를 실행합니다." << endl; executeAlgorithm((MENU_CL)menu_sel); } } }
int main() { int i; int numberOfElements = 0; char *inputFileName = "MSS_Problems.txt"; int numberOfLines = numberOfLinesInFile(inputFileName); for (i = 0; i < numberOfLines; i++) { //Read data from file and store in array numberOfElements = getNumberOfElementsInLine(inputFileName, i); int *inputArray = malloc(numberOfElements * sizeof(int)); //Store file data to inputArray fillIntArray(inputFileName, i, inputArray, numberOfElements); //Find max sum subarray struct timeval start, stop; gettimeofday(&start, NULL); executeAlgorithm(inputArray, 0, numberOfElements); gettimeofday(&stop, NULL); int time_in_micro = stop.tv_usec - start.tv_usec; // printf("Time used in microseconds = %lu\n", time_in_micro); //Free heap free(inputArray); } return 0; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->setFixedSize(832, 717); // Validadores para los parametros del algoritmo QValidator * validatorCognitiveParameter = new QIntValidator(0, 9, this); ui->lineEditCognitiveParameter->setValidator(validatorCognitiveParameter); ui->lineEditCognitiveParameter->setToolTip("[0..9]"); QValidator * validatorSocialParameter = new QIntValidator(0, 9, this); ui->lineEditSocialParameter->setValidator(validatorSocialParameter); ui->lineEditSocialParameter->setToolTip("[0..9]"); QDoubleValidator * validatorInertia = new QDoubleValidator(0.0, 1.0, 2, this); validatorInertia->setNotation(QDoubleValidator::StandardNotation); ui->lineEditInertiaParameter->setValidator(validatorInertia); ui->lineEditInertiaParameter->setToolTip("[0..1]"); QValidator * validatorSpeedParameter = new QIntValidator(1, 9, this); ui->lineEditMaxSpeedParameter->setValidator(validatorSpeedParameter); ui->lineEditMaxSpeedParameter->setToolTip("[1..9]"); QValidator * validatorParticlesParameter = new QIntValidator(1, 400, this); ui->lineEditParticlesParameter->setValidator(validatorParticlesParameter); ui->lineEditParticlesParameter->setToolTip("[1..400]"); QValidator * validatorIterationsParameter = new QIntValidator(1, 1000, this); ui->lineEditIterationsParameter->setValidator(validatorIterationsParameter); ui->lineEditIterationsParameter->setToolTip("[1..1000]"); QValidator * validatorSubintervalsParameter = new QIntValidator(2, 10, this); ui->lineEditSubintervals->setValidator(validatorSubintervalsParameter); ui->lineEditSubintervals->setToolTip("[2..10]"); connect(ui->pushButtonExecute, SIGNAL(clicked()), this, SLOT(executeAlgorithm())); connect(ui->pushButtonCompareAlgorithms, SIGNAL(clicked()), this, SLOT(compareAlgorithms())); connect(ui->checkBoxGrid, SIGNAL(stateChanged(int)), this, SLOT(activateGridSelection(int))); ui->label_9->setEnabled(false); ui->lineEditSubintervals->setEnabled(false); connect(ui->checkBoxComparation, SIGNAL(stateChanged(int)), this, SLOT(activateComparationButton(int))); ui->pushButtonCompareAlgorithms->setEnabled(false); ui->label_PSO_generico->setVisible(false); ui->psoGenericNumber->setVisible(false); ui->label_PSO_modificado->setVisible(false); ui->psoModifiedNumber->setVisible(false); ui->psoGenericTime->setVisible(false); ui->psoModifiedTime->setVisible(false); ui->label_tiempo_generico->setVisible(false); ui->label_tiempo_modificado->setVisible(false); }
void MainWindow::compareAlgorithms() { //ui->labelExternalFile->setVisible(false); //ui->labelNonDominatedNUmber->setVisible(false); //ui->listViewBestNonDominatedParticles->setVisible(false); ui->checkBoxGrid->setChecked(false); QTime timer; timer.start(); executeAlgorithm(); int runtimeGeneric = timer.elapsed(); //gets the runtime in ms ui->psoGenericTime->setText(QString::number(runtimeGeneric)+" ms"); QMessageBox msg; msg.setText("Termino el algoritmo generico"); //msg.exec(); ui->checkBoxGrid->setChecked(true); timer.start(); executeAlgorithm(); int runtimeModified = timer.elapsed(); //gets the runtime in ms ui->psoModifiedTime->setText(QString::number(runtimeModified)+" ms"); ui->checkBoxGrid->setChecked(false); msg.setText("Termino el algoritmo modificado"); //msg.exec(); setupCustomPlot2(ui->customPlot); ui->psoGenericNumber->setText(QString::number(genericAlgorithmSolutions.count())); ui->psoModifiedNumber->setText(QString::number(modificatedAlgorithmSolutions.count())); }
void Main::run() { helper->parseOptions(argc, argv); algorithm = helper->buildAlgorithm(algorithmBuilder); executeAlgorithm(algorithm); long newStartNodeId; long newDestinationNodeId; while(helper->hasNextStartNode()) { newStartNodeId = helper->getNextStartNodeId(); newDestinationNodeId = helper->getNextDestinationNodeId(); algorithm->resetState(newStartNodeId, newDestinationNodeId); executeAlgorithm(algorithm); } double avgTime = totalTime / executions; helper->writeOutputFile(avgTime); }
void _CLASS_GEN(Algorithm)::run(CContextDataStore *dataStore, std::function<void (CContextDataStore *)> callback){ if(!IsBusy() && mSettings != nullptr && mLogger != nullptr && ValidateParameters(mSettings)){ executeAlgorithm(dataStore); callback(dataStore); } }