本文整理汇总了C++中Energy::GetSolution方法的典型用法代码示例。如果您正苦于以下问题:C++ Energy::GetSolution方法的具体用法?C++ Energy::GetSolution怎么用?C++ Energy::GetSolution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Energy
的用法示例。
在下文中一共展示了Energy::GetSolution方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
if (!strncmp("TRWS=", &argv[i][1], 5))
{
current->options.TRWS_weighting = atof(&argv[i][1+5]);
continue;
}
if (!strcmp("BLP", &argv[i][1]))
{
BLP_relaxation = true;
continue;
}
if (!strcmp("FULL", &argv[i][1]))
{
FULL_relaxation = true;
continue;
}
if (!strncmp("FULL=", &argv[i][1], 5))
{
FULL_relaxation = true;
FULL_relaxation_flag = atoi(&argv[i][1+5]);
continue;
}
if (!strcmp("FULLDUAL", &argv[i][1]))
{
FULLDUAL_relaxation = true;
continue;
}
if (!strncmp("FULLDUAL=", &argv[i][1], 9))
{
FULLDUAL_relaxation = true;
FULLDUAL_relaxation_flag = atoi(&argv[i][1+9]);
continue;
}
if (!strncmp("sort=", &argv[i][1], 5))
{
current->options.sort_flag = atoi(&argv[i][1+5]);
continue;
}
if (!strncmp("verbose=", &argv[i][1], 8))
{
current->options.verbose = (atoi(&argv[i][1+8])) ? true : false;
continue;
}
if (!strcmp("takelog", &argv[i][1]))
{
TAKE_LOG = true;
continue;
}
if (!strcmp("stats", &argv[i][1]))
{
print_stats = true;
continue;
}
ShowUsage(argv[0]);
}
if (!filename) ShowUsage(argv[0]);
bool start = true;
Energy* g = ReadUAI(filename);
if (BLP_relaxation) g->SetMinimalEdges();
if (FULL_relaxation) g->SetFullEdges(FULL_relaxation_flag);
if (FULLDUAL_relaxation) g->SetFullEdgesDual(FULLDUAL_relaxation_flag);
for (run_ptr=run_list.ScanFirst(); run_ptr; run_ptr=run_list.ScanNext())
{
current = *run_ptr;
if (current->tighten_filename)
{
if (start) g->SetFullEdges();
AddTriplets(g, current->tighten_filename);
}
g->Solve(current->options);
delete current;
start = false;
}
if (print_stats)
{
g->PrintStats();
}
if (save_filename)
{
FILE* fp = fopen(save_filename, "w");
if (!fp) { printf("Can't open %s for writing\n", save_filename); exit(1); }
for (i=0; i<g->GetNodeNum(); i++) fprintf(fp, "%d ", g->GetSolution(i));
fclose(fp);
}
if (save_rep_filename)
{
g->SaveUAI(save_rep_filename, false, true);
}
delete g;
return 0;
}