I am trying to solve a very simple TSP problem but the TSP example of SCIP is a bit intimidating.
I just want to add simple Lazy constraints like how GuRoBi does.
I might need some help in understanding what is happening at some places.
I assume I do not have to implement SCIP_DECL_CONSSEPALP
SCIP_DECL_CONSENFOLP
and SCIP_DECL_CONSENFOPS
. I only have to implement a simple cycle detection function and add that as a cut.
If I understand correctly, I can write the function do the cycle detection in SCIP_DECL_CONSCHECK
but I am unsure how it is actually working.
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;
If I only have a single constraint handler, should I still use nconss
?
What exactly happens after I find a subtour? Which function is called after we set *result
to SCIP_INFEASIBLE
?
And how can I pass the subtour (the vertices that are in the tour) I found in SCIP_DECL_CONSCHECK
to that function so that I do not have to find the cycle again and add the actual cut?