当前位置: 首页>>代码示例>>C++>>正文


C++ DataFrame::getSim方法代码示例

本文整理汇总了C++中DataFrame::getSim方法的典型用法代码示例。如果您正苦于以下问题:C++ DataFrame::getSim方法的具体用法?C++ DataFrame::getSim怎么用?C++ DataFrame::getSim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataFrame的用法示例。


在下文中一共展示了DataFrame::getSim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
}
开发者ID:danielgribel,项目名称:clustering,代码行数:89,代码来源:Main2.cpp


注:本文中的DataFrame::getSim方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。