#define SOLSTOPRINT 5;
SCIP* scip;
SCIP_SOL** sols;
int nsols, i;
// ...
// put here your code to create a SCIP instance, read in a problem and call the
// the solving method of SCIP
// ...
sols = SCIPgetSols(scip);
nsols = SCIPgetNSols(scip);
for( i = 0; i < MIN(nsols, SOLSTOPRINT); ++i )
{
SCIP_CALL( SCIPprintSol(scip, sols[i], NULL, FALSE) );
}
1 回答
您可以使用scip.h提供的解决方法来执行此操作:
SCIP自动从最佳到最差存储解决方案,因此只需迭代
sols
-array的前5个解决方案即可 . 请注意,SCIP默认最多可存储最佳的100个解决方案 . 您可以通过参数limits/maxsol
更改此行为,例如,通过添加行在解决问题之前到上面的代码 .