If you intend to call call MPCallbackContext::AddCut(), you must set
might_add_cuts below to be true. Likewise for
MPCallbackContext::AddLazyConstraint() and might_add_lazy_constraints.
Threading behavior may be solver dependent:
* Gurobi: RunCallback always runs on the same thread that you called
MPSolver::Solve() on, even when Gurobi uses multiple threads.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eMPCallback\u003c/code\u003e class is designed to be extended with custom logic for specific optimization models.\u003c/p\u003e\n"],["\u003cp\u003eRegister your custom callback using \u003ccode\u003eMPSolver::SetCallback\u003c/code\u003e, passing a pointer to your \u003ccode\u003eMPCallback\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eYou must indicate during construction whether your callback will add cuts or lazy constraints to the solver.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRunCallback\u003c/code\u003e method is where you implement your core logic and interact with the solver via \u003ccode\u003eMPCallbackContext\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eRefer to go/mpsolver-callbacks for further details and advanced usage.\u003c/p\u003e\n"]]],["The `MPCallback` class in C++ allows users to extend model-specific logic. Users must register instances of extended classes via `MPSolver::SetCallback`. The class includes virtual methods: `RunCallback`, which executes custom logic within a solver's process, and `~MPCallback`, `might_add_cuts` and `might_add_lazy_constraints`. The user has to indicate in the constructor of `MPCallback` if the methods `AddCut` and/or `AddLazyConstraint` are going to be called. Threading behavior is solver-dependent.\n"],null,[]]