本文整理汇总了C++中DataFrame::getLabel方法的典型用法代码示例。如果您正苦于以下问题:C++ DataFrame::getLabel方法的具体用法?C++ DataFrame::getLabel怎么用?C++ DataFrame::getLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataFrame
的用法示例。
在下文中一共展示了DataFrame::getLabel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: demo
void demo(int seed, clock_t begin) {
const Instance instance = getDatasets()[0];
const int n = instance.N;
const int m = instance.M;
const int d = instance.D;
const int NUM_ANNOTATED = PORC_ANNOTATED * n;
srand(seed);
int* annotated;
vector<int> conflictGraph[n];
DataFrame dataFrame = load(instance);
annotated = randAnnotated(n, NUM_ANNOTATED);
imposeConflicts(annotated, dataFrame.getLabel(), conflictGraph, NUM_ANNOTATED);
const int sizePopulation = 40;
const int maxPopulation = 200;
const int itNoImprovement = 500;
const int itDiv = 0.4*itNoImprovement;
int it = 0;
int lastImprovement = 0;
int lastDiv = 0;
double bestCost = MAX_FLOAT;
double delta = 0.000000000;
vector<int*> population;
vector<pdi> costHeap;
double costS;
int* bestSolution;
vector<KCenterSolver*> solvers;
//make_heap(costHeap.begin(), costHeap.end(), smallerOp());
/*vector<pii> G = loadGraph(dataFrame.getSim(), n);
for(int i = 0; i < sizePopulation; i++) {
int* s0 = graspConstructive(dataFrame, G);
KCenterSolver* ind = createSolver(dataFrame, s0);
ind->localSearch(conflictGraph);
population.push_back(ind->getSolution());
costS = ind->getCost();
solvers.push_back(ind);
if(costS < bestCost) {
bestCost = costS;
bestSolution = ind->getSolution();
}
//delete ind;
printf("g(%d) = %.15f\n", i, costS);
}*/
population = getPopulation(instance, sizePopulation);
for(int i = 0; i < sizePopulation; i++) {
KCenterSolver* ind = createSolver(dataFrame, population[i]);
ind->localSearch(conflictGraph);
population[i] = ind->getSolution();
costS = ind->getCost();
solvers.push_back(ind);
if(costS < bestCost) {
bestCost = costS;
bestSolution = ind->getSolution();
}
//delete ind;
printf("g(%d) = %.15f\n", i, costS);
double elapsedSecs = double(clock() - begin) / CLOCKS_PER_SEC;
cout << elapsedSecs << endl;
}
while((it-lastImprovement) < itNoImprovement) {
int* offspring1 = new int[n];
//int* offspring2 = new int[n];
//costHeap = fill(solvers, sizePopulation, m, d);
int* p1 = tournamentSelection2(population, 2, population.size(), dataFrame);
int* p2 = tournamentSelection2(population, 2, population.size(), dataFrame);
crossoverX(p1, p2, offspring1, n, m);
//crossoverUniform(p1, p2, offspring1, offspring2, 0.3, n);
KCenterSolver* off1 = createSolver(dataFrame, offspring1);
off1->localSearch(conflictGraph);
double off1Cost = off1->getCost();
solvers.push_back(off1);
if(off1Cost < bestCost) {
bestCost = off1Cost;
bestSolution = off1->getSolution();
lastImprovement = it;
}
population.push_back(off1->getSolution());
if(population.size() >= maxPopulation) {
//cout << "-- selectSurvivors()" << endl;
//.........这里部分代码省略.........
示例2: demo
void demo(Instance instance, int seed) {
const int n = instance.N;
const int m = instance.M;
const int d = instance.D;
const int NUM_ANNOTATED = PORC_ANNOTATED * n;
srand(seed);
int* annotated;
vector<int> conflictGraph[n];
DataFrame dataFrame = load(instance);
annotated = randAnnotated(n, NUM_ANNOTATED);
imposeConflicts(annotated, dataFrame.getLabel(), conflictGraph, NUM_ANNOTATED);
int* s0;
double costS;
double bestCost = MAX_FLOAT;
int* bestSolution = new int[n];
int numRestarts = 100;
int p = 1;
int numPert = 1000;
int numExchanges = 0.3*instance.N;
double costS_;
vector<pii> G = loadGraph(dataFrame.getSim(), n);
// grasp phase
for(int i = 0; i < numRestarts; i++) {
s0 = graspConstructive(dataFrame, G);
KCenterSolver* solver = createSolver(dataFrame, s0);
solver->localSearch(conflictGraph);
costS = solver->getCost();
if(costS < bestCost) {
bestCost = costS;
bestSolution = solver->getSolution();
}
while(p <= numPert) {
int* s = perturbation(solver->getSolution(), numExchanges, n, m);
KCenterSolver* solver2 = createSolver(dataFrame, s);
solver2->localSearch(conflictGraph);
costS = solver2->getCost();
if(costS < bestCost) {
bestCost = costS;
bestSolution = solver2->getSolution();
}
delete solver2;
//printf("f(%d) = %.15f\n", p, bestCost);
p++;
}
p = 1;
printf("g(%d) = %.15g\n", i, bestCost);
delete solver;
}
/*printf("bestCost = %.15f\n", bestCost);
int p = 1;
int numPert = 1000;
int numExchanges = 0.3*instance.N;
double costS_;
// perturbation phase
while(p <= numPert) {
int* s = perturbation(bestSolution, numExchanges, n, m);
KCenterSolver* solver = createSolver(dataFrame, s);
solver->localSearch(dataFrame, conflictGraph);
costS_ = solver->getCost();
if(costS_ < bestCost) {
bestCost = costS_;
lastImp = p;
bestSolution = s;
}
delete solver;
printf("f(%d) = %.15f\n", p, bestCost);
p++;
}*/
evalSolution(bestSolution, dataFrame.getLabel(), instance, "perturbation");
printSolution(bestSolution, instance.N);
}