本文整理汇总了C++中Monitor::getCost方法的典型用法代码示例。如果您正苦于以下问题:C++ Monitor::getCost方法的具体用法?C++ Monitor::getCost怎么用?C++ Monitor::getCost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monitor
的用法示例。
在下文中一共展示了Monitor::getCost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_best_solution
void check_best_solution(vector<Ant*> *vec) {
cout << "check_best_solution" << endl;
if (vec->size() > 0) {
if (best_cost == INVALID and best_coverage == INVALID) {
best_cost = monitor.getCost(vec->at(0)->getCost());
best_coverage = monitor.getCoverage(vec->at(0)->getCoverage());
worse_cost = monitor.getCost(
vec->at(POPULATION_SIZE - 1)->getCost());
worse_coverage = monitor.getCoverage(
vec->at(POPULATION_SIZE - 1)->getCoverage());
}
for (int i = 0; i < POPULATION_SIZE; i++) {
vec->at(i)->setCost(monitor.getCost(vec->at(i)->getCost()));
vec->at(i)->setCoverage(
monitor.getCoverage(vec->at(i)->getCoverage()));
if (vec->at(i)->getCost() > best_cost) {
best_cost = vec->at(i)->getCost();
} else if (vec->at(i)->getCost() < worse_cost) {
worse_cost = vec->at(i)->getCost();
}
if (vec->at(i)->getCoverage() > best_coverage) {
best_coverage = vec->at(i)->getCoverage();
} else if (vec->at(i)->getCoverage() < worse_coverage) {
worse_coverage = vec->at(i)->getCoverage();
}
}
for (int i = 0; i < POPULATION_SIZE; i++) {
double quality = monitor.getQuality(vec->at(i)->getCost());
if (quality > best_solution) {
best_solution = quality;
best_route = vec->at(i)->getRoute();
} else if (quality < worse_solution) {
worse_solution = quality;
worse_route = vec->at(i)->getRoute();
}
vec->at(i)->setQuality(quality);
}
}
}