Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
|
#include <gscip_constraint_handler.h>
Public Member Functions | |
GScipConstraintHandler (const GScipConstraintHandlerProperties &properties) | |
virtual | ~GScipConstraintHandler ()=default |
const GScipConstraintHandlerProperties & | properties () const |
absl::Status | Register (GScip *gscip) |
Template implementations. | |
absl::StatusOr< SCIP_CONS * > | AddCallbackConstraint (GScip *gscip, const std::string &constraint_name, const ConstraintData *constraint_data, const GScipConstraintOptions &options=DefaultGScipConstraintOptions()) |
virtual absl::StatusOr< GScipCallbackResult > | EnforceLp (GScipConstraintHandlerContext context, const ConstraintData &constraint_data, bool solution_infeasible) |
Default callback implementations. | |
virtual absl::StatusOr< GScipCallbackResult > | EnforcePseudoSolution (GScipConstraintHandlerContext context, const ConstraintData &constraint_data, bool solution_infeasible, bool objective_infeasible) |
virtual absl::StatusOr< bool > | CheckIsFeasible (GScipConstraintHandlerContext context, const ConstraintData &constraint_data, bool check_integrality, bool check_lp_rows, bool print_reason, bool check_completely) |
virtual std::vector< std::pair< SCIP_VAR *, RoundingLockDirection > > | RoundingLock (GScip *gscip, const ConstraintData &constraint_data, bool lock_type_is_model) |
virtual absl::StatusOr< GScipCallbackResult > | SeparateLp (GScipConstraintHandlerContext context, const ConstraintData &constraint_data) |
virtual absl::StatusOr< GScipCallbackResult > | SeparateSolution (GScipConstraintHandlerContext context, const ConstraintData &constraint_data) |
GScipCallbackResult | CallEnforceLp (GScipConstraintHandlerContext context, const ConstraintData &constraint_data, bool solution_infeasible) |
The functions below wrap each callback function to manage status. | |
GScipCallbackResult | CallEnforcePseudoSolution (GScipConstraintHandlerContext context, const ConstraintData &constraint_data, bool solution_infeasible, bool objective_infeasible) |
GScipCallbackResult | CallCheckIsFeasible (GScipConstraintHandlerContext context, const ConstraintData &constraint_data, bool check_integrality, bool check_lp_rows, bool print_reason, bool check_completely) |
GScipCallbackResult | CallSeparateLp (GScipConstraintHandlerContext context, const ConstraintData &constraint_data) |
GScipCallbackResult | CallSeparateSolution (GScipConstraintHandlerContext context, const ConstraintData &constraint_data) |
Constraint handler class. To implement a constraint handler, the user can inherit this class and implement the desired callback functions. The templated ConstraintData is the equivalent of SCIP's SCIP_CONSHDLRDATA, and can hold the data needed for the constraint. To then use it, the function Register must be called once, and AddCallbackConstraint must be called for each constraint to be added in this constraint handler.
There is a one-to-one mapping between relevant SCIP callback functions and the functions in this class; see SCIP documentation for which types of callbacks to use. Make sure to follow SCIP's rules (e.g. if implementing enforcement, all enforcement and check callbacks must be implemented).
For examples of usage, see gscip_constraint_handler_test.cc.
Implementation details:
Supported SCIP callback functions:
Used, but not customizable:
Definition at line 286 of file gscip_constraint_handler.h.
|
inlineexplicit |
Constructs a constraint handler that will be registered using the given properties. It is recommended to set priorities and frequencies manually in properties.
Definition at line 291 of file gscip_constraint_handler.h.
|
virtualdefault |
absl::StatusOr< SCIP_CONS * > operations_research::GScipConstraintHandler< ConstraintData >::AddCallbackConstraint | ( | GScip * | gscip, |
const std::string & | constraint_name, | ||
const ConstraintData * | constraint_data, | ||
const GScipConstraintOptions & | options = DefaultGScipConstraintOptions() ) |
Adds a callback constraint to the model. That is, it attaches to the constraint handler a constraint for the given constraint data.
Definition at line 586 of file gscip_constraint_handler.h.
GScipCallbackResult operations_research::GScipConstraintHandler< ConstraintData >::CallCheckIsFeasible | ( | GScipConstraintHandlerContext | context, |
const ConstraintData & | constraint_data, | ||
bool | check_integrality, | ||
bool | check_lp_rows, | ||
bool | print_reason, | ||
bool | check_completely ) |
Definition at line 688 of file gscip_constraint_handler.h.
GScipCallbackResult operations_research::GScipConstraintHandler< ConstraintData >::CallEnforceLp | ( | GScipConstraintHandlerContext | context, |
const ConstraintData & | constraint_data, | ||
bool | solution_infeasible ) |
The functions below wrap each callback function to manage status.
Definition at line 667 of file gscip_constraint_handler.h.
GScipCallbackResult operations_research::GScipConstraintHandler< ConstraintData >::CallEnforcePseudoSolution | ( | GScipConstraintHandlerContext | context, |
const ConstraintData & | constraint_data, | ||
bool | solution_infeasible, | ||
bool | objective_infeasible ) |
Definition at line 677 of file gscip_constraint_handler.h.
GScipCallbackResult operations_research::GScipConstraintHandler< ConstraintData >::CallSeparateLp | ( | GScipConstraintHandlerContext | context, |
const ConstraintData & | constraint_data ) |
Definition at line 706 of file gscip_constraint_handler.h.
GScipCallbackResult operations_research::GScipConstraintHandler< ConstraintData >::CallSeparateSolution | ( | GScipConstraintHandlerContext | context, |
const ConstraintData & | constraint_data ) |
Definition at line 715 of file gscip_constraint_handler.h.
|
virtual |
Callback function called at SCIP's CONSCHECK. Must return true if the current solution stored in the context satisfies all constraints of the constraint handler, or false otherwise. If properties_.feasibility_check_priority < 0, then this only acts on integer solutions.
SCIP CONSCHECK callback arguments:
Reimplemented in operations_research::internal::UntypedGScipConstraintHandlerImpl< ConstraintData >.
Definition at line 616 of file gscip_constraint_handler.h.
|
virtual |
Default callback implementations.
Callback function called at SCIP's CONSENFOLP. Must check if an LP solution at a node is feasible, and if not, resolve the infeasibility if possible by branching, reducing variable domains, or separating the solution with a cutting plane. If properties_.enforcement_priority < 0, then this only acts on integer solutions.
SCIP CONSENFOLP callback arguments:
It is the user's responsibility to return a valid result for CONSENFOLP; see SCIP's documentation (e.g. type_cons.h).
Reimplemented in operations_research::internal::UntypedGScipConstraintHandlerImpl< ConstraintData >.
Definition at line 600 of file gscip_constraint_handler.h.
|
virtual |
Callback function called at SCIP's CONSENFOPS. Must check if a pseudosolution is feasible, and if not, resolve the infeasibility if possible by branching, reducing variable domains, or adding an additional constraint. Separating with a cutting plane is not possible since there is no corresponding LP (i.e. kSeparated cannot be returned). If properties_.enforcement_priority < 0, then this only acts on integer solutions.
SCIP CONSENFOPS callback arguments:
It is the user's responsibility to return a valid result for CONSENFOPS; see SCIP's documentation (e.g. type_cons.h).
Reimplemented in operations_research::internal::UntypedGScipConstraintHandlerImpl< ConstraintData >.
Definition at line 608 of file gscip_constraint_handler.h.
|
inline |
Definition at line 297 of file gscip_constraint_handler.h.
absl::Status operations_research::GScipConstraintHandler< ConstraintData >::Register | ( | GScip * | gscip | ) |
Template implementations.
Registers this constraint handler with GScip. If the handler has already been registered, returns an error.
Definition at line 577 of file gscip_constraint_handler.h.
|
virtual |
Callback function called at SCIP's CONSLOCK. Must return, for each variable, whether the constraint may be violated by decreasing and/or increasing the variable value. It is always safe to claim that both directions can violate the constraint, which is the default implementation, but it may affect SCIP's capabilities.
SCIP CONSLOCK callback arguments:
It is the user's responsibility to return a valid result for CONSLOCK; see SCIP's documentation (e.g. type_cons.h).
Reimplemented in operations_research::internal::UntypedGScipConstraintHandlerImpl< ConstraintData >.
Definition at line 625 of file gscip_constraint_handler.h.
|
virtual |
Callback function called at SCIP's CONSSEPALP. Separates all constraints of the constraint handler for LP solutions.
It is the user's responsibility to return a valid result for CONSSEPALP; see SCIP's documentation (e.g. type_cons.h).
Reimplemented in operations_research::internal::UntypedGScipConstraintHandlerImpl< ConstraintData >.
Definition at line 637 of file gscip_constraint_handler.h.
|
virtual |
Callback function called at SCIP's CONSSEPASOL. Separates all constraints of the constraint handler for solutions that do not come from LP (e.g. relaxators and primal heuristics).
It is the user's responsibility to return a valid result for CONSSEPASOL; see SCIP's documentation (e.g. type_cons.h).
Reimplemented in operations_research::internal::UntypedGScipConstraintHandlerImpl< ConstraintData >.
Definition at line 645 of file gscip_constraint_handler.h.