ConshdlrSubtour.cpp
Go to the documentation of this file.
21 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
86 * start again with the last visited node as starting node, because this must be member of the subtour;
102 /* we didn't find an outgoing edge in the solution: the degree constraints must be violated; abort! */
166 // create a new cutting plane for every suitable arc (representing a cut with value < 2) of the Gomory Hu Tree
170 SCIP_CALL( SCIPcreateEmptyRowCons(scip, &row, conshdlr, "sepa_con", 2.0, SCIPinfinity(scip), FALSE, FALSE, TRUE) );
220 * WARNING! There may exist unprocessed events. For example, a variable's bound may have been already changed, but
252 SCIPconsIsModifiable(sourcecons), SCIPconsIsDynamic(sourcecons), SCIPconsIsRemovable(sourcecons),
261 * Separates all constraints of the constraint handler. The method is called in the LP solution loop,
264 * The first nusefulconss constraints are the ones, that are identified to likely be violated. The separation
265 * method should process only the useful constraints in most runs, and only occasionally the remaining
268 * possible return values for *result (if more than one applies, the first in the list should be used):
273 * - SCIP_DIDNOTFIND : the separator searched, but did not find domain reductions, cutting planes, or cut constraints
287 * Separates all constraints of the constraint handler. The method is called outside the LP solution loop (e.g., by
291 * The first nusefulconss constraints are the ones, that are identified to likely be violated. The separation
292 * method should process only the useful constraints in most runs, and only occasionally the remaining
295 * possible return values for *result (if more than one applies, the first in the list should be used):
300 * - SCIP_DIDNOTFIND : the separator searched, but did not find domain reductions, cutting planes, or cut constraints
314 * The method is called at the end of the node processing loop for a node where the LP was solved.
315 * The LP solution has to be checked for feasibility. If possible, an infeasibility should be resolved by
316 * branching, reducing a variable's domain to exclude the solution or separating the solution with a valid
319 * The enforcing methods of the active constraint handlers are called in decreasing order of their enforcing
320 * priorities until the first constraint handler returned with the value SCIP_CUTOFF, SCIP_SEPARATED,
322 * The integrality constraint handler has an enforcing priority of zero. A constraint handler which can
323 * (or wants) to enforce its constraints only for integral solutions should have a negative enforcing priority
325 * A constraint handler which wants to incorporate its own branching strategy even on non-integral
326 * solutions must have an enforcing priority greater than zero (e.g. the SOS-constraint incorporates
329 * The first nusefulconss constraints are the ones, that are identified to likely be violated. The enforcing
330 * method should process the useful constraints first. The other nconss - nusefulconss constraints should only
333 * possible return values for *result (if more than one applies, the first in the list should be used):
338 * - SCIP_BRANCHED : no changes were made to the problem, but a branching was applied to resolve an infeasibility
358 // if a subtour was found, we generate a cut constraint saying that there must be at least two outgoing edges
368 * The method is called at the end of the node processing loop for a node where the LP was not solved.
369 * The pseudo solution has to be checked for feasibility. If possible, an infeasibility should be resolved by
370 * branching, reducing a variable's domain to exclude the solution or adding an additional constraint.
371 * Separation is not possible, since the LP is not processed at the current node. All LP informations like
374 * Like in the enforcing method for LP solutions, the enforcing methods of the active constraint handlers are
375 * called in decreasing order of their enforcing priorities until the first constraint handler returned with
378 * The first nusefulconss constraints are the ones, that are identified to likely be violated. The enforcing
379 * method should process the useful constraints first. The other nconss - nusefulconss constraints should only
382 * If the pseudo solution's objective value is lower than the lower bound of the node, it cannot be feasible
383 * and the enforcing method may skip it's check and set *result to SCIP_DIDNOTRUN. However, it can also process
386 * possible return values for *result (if more than one applies, the first in the list should be used):
390 * - SCIP_BRANCHED : no changes were made to the problem, but a branching was applied to resolve an infeasibility
391 * - SCIP_SOLVELP : at least one constraint is infeasible, and this can only be resolved by solving the SCIP_LP
424 * The check methods of the active constraint handlers are called in decreasing order of their check
426 * The integrality constraint handler has a check priority of zero. A constraint handler which can
427 * (or wants) to check its constraints only for integral solutions should have a negative check priority
429 * A constraint handler which wants to check feasibility even on non-integral solutions must have a
430 * check priority greater than zero (e.g. if the check is much faster than testing all variables for
433 * In some cases, integrality conditions or rows of the current LP don't have to be checked, because their
475 * The first nusefulconss constraints are the ones, that are identified to likely be violated. The propagation
476 * method should process only the useful constraints in most runs, and only occasionally the remaining
496 * It should update the rounding locks of all associated variables with calls to SCIPaddVarLocksType(),
499 * SCIPaddVarLocksType(scip, var, SCIP_LOCKTYPE_MODEL, nlockspos, nlocksneg), saying that rounding down is
500 * potentially rendering the (positive) constraint infeasible and rounding up is potentially rendering the
503 * SCIPaddVarLocksType(scip, var, SCIP_LOCKTYPE_MODEL, nlocksneg, nlockspos), saying that rounding up is
504 * potentially rendering the constraint's negation infeasible and rounding up is potentially rendering the
506 * - If the constraint may get violated by changing the variable in any direction, it should call
507 * SCIPaddVarLocksType(scip, var, SCIP_LOCKTYPE_MODEL, nlockspos + nlocksneg, nlockspos + nlocksneg).
509 * Consider the linear constraint "3x -5y +2z <= 7" as an example. The variable rounding lock method of the
510 * linear constraint handler should call SCIPaddVarLocksType(scip, x, SCIP_LOCKTYPE_MODEL, nlocksneg, nlockspos),
513 * that rounding up of x and z and rounding down of y can destroy the feasibility of the constraint, while rounding
514 * down of x and z and rounding up of y can destroy the feasibility of the constraint's negation "3x -5y +2z > 7".
516 * SCIPaddVarLocksType(scip, ..., SCIP_LOCKTYPE_MODEL, nlockspos + nlocksneg, nlockspos + nlocksneg) on all variables,
517 * since rounding in both directions of each variable can destroy both the feasibility of the constraint and it's negation
520 * If the constraint itself contains other constraints as sub constraints (e.g. the "or" constraint concatenation
521 * "c(x) or d(x)"), the rounding lock methods of these constraints should be called in a proper way.
523 * SCIPaddConsLocks(scip, c, nlockspos, nlocksneg), saying that infeasibility of c may lead to infeasibility of
524 * the (positive) constraint, and infeasibility of c's negation (i.e. feasibility of c) may lead to infeasibility
526 * - If the constraint may get violated by the feasibility of the sub constraint c, it should call
527 * SCIPaddConsLocks(scip, c, nlocksneg, nlockspos), saying that infeasibility of c may lead to infeasibility of
528 * the constraint's negation (i.e. feasibility of the constraint), and infeasibility of c's negation (i.e. feasibility
530 * - If the constraint may get violated by any change in the feasibility of the sub constraint c, it should call
533 * Consider the or concatenation "c(x) or d(x)". The variable rounding lock method of the or constraint handler
534 * should call SCIPaddConsLocks(scip, c, nlockspos, nlocksneg) and SCIPaddConsLocks(scip, d, nlockspos, nlocksneg)
537 * As a second example, consider the equivalence constraint "y <-> c(x)" with variable y and constraint c. The
538 * constraint demands, that y == 1 if and only if c(x) is satisfied. The variable lock method of the corresponding
539 * constraint handler should call SCIPaddVarLocksType(scip, y, SCIP_LOCKTYPE_MODEL, nlockspos + nlocksneg, nlockspos + nlocksneg) and
540 * SCIPaddConsLocks(scip, c, nlockspos + nlocksneg, nlockspos + nlocksneg), because any modification to the
541 * value of y or to the feasibility of c can alter the feasibility of the equivalence constraint.
556 SCIP_CALL( SCIPaddVarLocksType(scip, g->edges[i].var, SCIP_LOCKTYPE_MODEL, nlocksneg, nlockspos) );
564 * This method should iterate over all constraints of the constraint handler and delete all variables
581 * The constraint handler should store a representation of the constraint into the given text file.
594 SCIPinfoMessage(scip, file, "subtour of Graph G with %d nodes and %d edges\n", g->nnodes, g->nedges);
608 * The constraint handler can provide a copy method, which copies a constraint from one SCIP data structure into a other
657 SCIP_Bool removable /**< should the constraint be removed from the LP due to aging or cleanup? */
677 SCIP_CALL( SCIPcreateCons(scip, cons, name, conshdlr, consdata, initial, separate, enforce, check, propagate,
Definition: type_result.h:33
Definition: type_result.h:37
SCIP_RETCODE SCIPcacheRowExtensions(SCIP *scip, SCIP_ROW *row)
Definition: scip_lp.c:1547
Definition: struct_scip.h:58
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip_cons.c:954
SCIP_RETCODE SCIPflushRowExtensions(SCIP *scip, SCIP_ROW *row)
Definition: scip_lp.c:1570
SCIP_DECL_CONSSEPALP(ConshdlrSubtour::scip_sepalp)
Definition: ConshdlrSubtour.cpp:277
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
Definition: scip_lp.c:1602
SCIP_DECL_CONSENFOPS(ConshdlrSubtour::scip_enfops)
Definition: ConshdlrSubtour.cpp:396
generator for global cuts in undirected graphs
Definition: type_result.h:40
SCIP_DECL_CONSSEPASOL(ConshdlrSubtour::scip_sepasol)
Definition: ConshdlrSubtour.cpp:304
SCIP_DECL_CONSDELETE(ConshdlrSubtour::scip_delete)
Definition: ConshdlrSubtour.cpp:223
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:279
SCIP_RETCODE SCIPcreateCons(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_CONSHDLR *conshdlr, SCIP_CONSDATA *consdata, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
Definition: scip_cons.c:1011
SCIP_DECL_CONSENFOLP(ConshdlrSubtour::scip_enfolp)
Definition: ConshdlrSubtour.cpp:342
Definition: struct_sol.h:63
SCIP_DECL_CONSCHECK(ConshdlrSubtour::scip_check)
Definition: ConshdlrSubtour.cpp:441
SCIP_RETCODE SCIPaddVarLocksType(SCIP *scip, SCIP_VAR *var, SCIP_LOCKTYPE locktype, int nlocksdown, int nlocksup)
Definition: scip_var.c:4199
Definition: ProbDataTSP.h:33
SCIP_Bool SCIPisCutEfficacious(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
Definition: scip_cut.c:161
SCIP_RETCODE SCIPcreateConsSubtour(SCIP *scip, SCIP_CONS **cons, const char *name, GRAPH *graph, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable)
Definition: ConshdlrSubtour.cpp:644
Definition: type_result.h:35
Definition: struct_cons.h:37
Definition: struct_cons.h:117
Definition: pqueue.h:28
Definition: type_result.h:36
SCIP_DECL_CONSTRANS(ConshdlrSubtour::scip_trans)
Definition: ConshdlrSubtour.cpp:235
C++ wrapper classes for SCIP.
Definition: type_retcode.h:33
SCIP_DECL_CONSDELVARS(ConshdlrSubtour::scip_delvars)
Definition: ConshdlrSubtour.cpp:573
SCIP_RETCODE SCIPaddRow(SCIP *scip, SCIP_ROW *row, SCIP_Bool forcecut, SCIP_Bool *infeasible)
Definition: scip_cut.c:294
SCIP_RETCODE SCIPcreateEmptyRowCons(SCIP *scip, SCIP_ROW **row, SCIP_CONSHDLR *conshdlr, const char *name, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool removable)
Definition: scip_lp.c:1336
C++ constraint handler for TSP subtour elimination constraints.
SCIP_RETCODE SCIPprintCons(SCIP *scip, SCIP_CONS *cons, FILE *file)
Definition: scip_cons.c:2550
Definition: struct_lp.h:192
Constraint handler for linear constraints in their most general form, .
Definition: ConshdlrSubtour.h:34
Definition: GomoryHuTree.h:30
Definition of base class for all clonable classes which define problem data.
Definition: objprobcloneable.h:42
SCIP_DECL_CONSHDLRCLONE(ObjProbCloneable *ConshdlrSubtour::clone)
Definition: ConshdlrSubtour.cpp:600
SCIP_Bool ghc_tree(GRAPH *gr, SCIP_Bool **cuts, int *ncuts, double minviol)
Definition: GomoryHuTree.cpp:538
Definition: GomoryHuTree.h:53
Definition: ConshdlrSubtour.h:30
Definition: type_var.h:84
SCIP_DECL_CONSPRINT(ConshdlrSubtour::scip_print)
Definition: ConshdlrSubtour.cpp:583
Definition: type_retcode.h:45
static SCIP_Bool findSubtour(SCIP *scip, GRAPH *graph, SCIP_SOL *sol)
Definition: ConshdlrSubtour.cpp:44
Definition: objbenders.h:33
static SCIP_RETCODE sepaSubtour(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_CONS **conss, int nconss, int nusefulconss, SCIP_SOL *sol, SCIP_RESULT *result)
Definition: ConshdlrSubtour.cpp:118
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip_sol.c:1410
Definition: type_result.h:39