【发布时间】:2021-01-13 10:39:31
【问题描述】:
我正在尝试解决一个非常简单的 TSP 问题,但是 SCIP 的 TSP 示例有点吓人。
我只想像 GuRoBi 那样添加简单的 Lazy 约束。
我可能需要一些帮助来了解某些地方正在发生的事情。
我假设我不必实现 SCIP_DECL_CONSSEPALP SCIP_DECL_CONSENFOLP 和 SCIP_DECL_CONSENFOPS。我只需要实现一个简单的循环检测功能并将其添加为剪切。
如果我理解正确,我可以在SCIP_DECL_CONSCHECK 中编写循环检测函数,但我不确定它实际上是如何工作的。
assert(result != NULL);
*result = SCIP_FEASIBLE;
for( int i = 0; i < nconss; ++i )
{
SCIP_CONSDATA* consdata;
GRAPH* graph;
SCIP_Bool found;
assert(conss != NULL);
assert(conss[i] != NULL);
consdata = SCIPconsGetData(conss[i]);
assert(consdata != NULL);
graph = consdata->graph;
assert(graph != NULL);
// if a subtour is found, the solution must be infeasible
found = findSubtour(scip, graph, sol);
if( found )
{
*result = SCIP_INFEASIBLE;
if( printreason )
{
SCIP_CALL( SCIPprintCons(scip, conss[i], NULL) );
SCIPinfoMessage(scip, NULL, "violation: graph has a subtour\n");
}
}
}
return SCIP_OKAY;
如果我只有一个约束处理程序,我还应该使用nconss吗?
在我找到 subtour 后究竟会发生什么?将*result设置为SCIP_INFEASIBLE后调用了哪个函数?
我怎样才能将我在SCIP_DECL_CONSCHECK 中找到的子图(图中的顶点)传递给该函数,这样我就不必再次找到循环并添加实际剪切?
【问题讨论】:
标签: linear-programming scip mixed-integer-programming