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,["# MPCallback\n\nC++ Reference: class MPCallback\n===============================\n\n\nNote: This documentation is automatically generated.\nExtend this class with model specific logic, and register through MPSolver::SetCallback, passing a pointer to this object. \n\nSee go/mpsolver-callbacks for additional documentation.\n\n| Method ||\n|----------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`might_add_cuts`](https://github.com/google/or-tools/blob/v9.4/ortools/linear_solver/linear_solver_callback.h#L157) | Return type: `bool ` \u003cbr /\u003e |\n| [`might_add_lazy_constraints`](https://github.com/google/or-tools/blob/v9.4/ortools/linear_solver/linear_solver_callback.h#L158) | Return type: `bool ` \u003cbr /\u003e |\n| [`MPCallback`](https://github.com/google/or-tools/blob/v9.4/ortools/linear_solver/linear_solver_callback.h#L147) | \u003cbr /\u003e Arguments: `bool might_add_cuts, bool might_add_lazy_constraints` 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. |\n| [`~MPCallback`](https://github.com/google/or-tools/blob/v9.4/ortools/linear_solver/linear_solver_callback.h#L150) | Return type: `virtual ` \u003cbr /\u003e |\n| [`RunCallback`](https://github.com/google/or-tools/blob/v9.4/ortools/linear_solver/linear_solver_callback.h#L155) | Return type: `virtual void ` Arguments: `MPCallbackContext* callback_context` 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. |"]]