pythonmathematical-optimizationscipoperations-researchpyscipopt

Can I set the SCIP constraint handler to work only after a feasible solution is found?


I read the SCIP constraint handler documentation, and reads that CONSHDLR_CHECKPRIORITY= -1 makes that the constraint handler only works when the solution is integral. However, my handler is still adding constraints before finding a feasible solution. So, even if the solution is integral, is not satisfying all the constraints.

I couldn't find another parameter to set the constraint handler to start only after the presolve is over and a feasible solution is found, or to only add constraints when the solution satisfies all the model constraints.

Is there a specific parameter to set this? or some trick to put with restriction?


Solution

  • You simply need to give your constraint handler the lowest Priority out of all the constraint handlers (both for checking and enforcing). That way your constraint handler will only be called when all other constraint handlers have acted.

    You can see all the default priorities by typing disp conshdlrs in the interactive shell. The default values are

     constraint handler   chckprio enfoprio sepaprio sepaf propf eager prestim description
     ------------------   -------- -------- -------- ----- ----- ----- ------- -----------
     benderslp            10000000 10000000        0    -1    -1   100     fme  constraint handler for Benders' Decomposition to separate LP solutions
     integral                    0        0        0    -1    -1    -1     fme  integrality constraint
     cardinality               -10      100       10    10     1   100     f    cardinality constraint handler
     SOS1                      -10      100     1000    10     1   100      m   SOS1 constraint handler
     SOS2                      -10      100       10     0     1   100     f    SOS2 constraint handler
     varbound              -500000  -500000   900000     0     1   100     fm   variable bounds  lhs <= x + c*y <= rhs, x non-binary, y non-continuous
     knapsack              -600000  -600000   600000     0     1   100     fme  knapsack constraint of the form  a^T x <= b, x binary and a >= 0
     setppc                -700000  -700000   700000     0     1   100     fme  set partitioning / packing / covering constraints
     linking               -750000 -2050000   750000     1     1   100      m   linking constraint x = sum_{i=1}^{n} c_i*y_i, y1+...+yn = 1, x real, y's binary
     or                    -850000  -850000   850000     0     1   100      m   constraint handler for or constraints: r = or(x1, ..., xn)
     and                   -850100  -850100   850100     1     1   100     f e  constraint handler for AND-constraints: r = and(x1, ..., xn)
     xor                   -850200  -850200   850200     0     1   100     fme  constraint handler for xor constraints: r = xor(x1, ..., xn)
     conjunction           -900000   900000        0    -1    -1   100     f    conjunction of constraints
     disjunction           -900000  -950000        0    -1    -1   100     f    disjunction of constraints (or(cons1, cons2, ..., consn))
     exactsol              -999999 -9999999        0    -1    -1   100     fme  constraint to ensure that primal solutions report back exact solutions
     linear               -1000000 -1000000   100000     0     1   100     f e  linear constraints of the form  lhs <= a^T x <= rhs
     orbisack             -1005200 -1005200    40100     5     5    -1       e  symmetry breaking constraint handler for orbisacks
     orbitope             -1005200 -1005200    40100    -1     1    -1      m   symmetry breaking constraint handler relying on (partitioning/packing) orbitopes
     symresack            -1005200 -1005200    40100     5     5    -1       e  symmetry breaking constraint handler relying on symresacks
     logicor              -2000000 -2000000    10000     0     1   100     fme  logic or constraints
     bounddisjunction     -3000000 -3000000        0    -1     1   100     f    bound disjunction constraints
     cumulative           -3030000 -2040000  2100000     1     1   100     fme  cumulative constraint handler
     nonlinear            -4000010      -60       10     1     1   100     fme  handler for nonlinear constraints specified by algebraic expressions
     benders              -5000000     -100        0    -1    -1   100     f    constraint handler to execute Benders' Decomposition
     pseudoboolean        -5000000 -1000000        0    -1    -1   100      m   constraint handler dealing with pseudo Boolean constraints
     superindicator       -5000000 -5000000        0    -1     1   100      m   constraint handler for indicator constraints over arbitrary constraint types
     indicator            -6000000     -100       10    10     1   100     f    indicator constraint handler
     countsols            -9999999 -9999999        0    -1    -1   100     fme  constraint to count feasible solutions
     components           -9999999        0        0    -1     1    -1          independent components constraint handler