Adding all violated cuts at the root node
AnsweredHi,
I am truggeling with adding all violated cuts at the root node.
I want at the root node: Gurobi added violated cuts → reoptimize → add new violated cuts → reoptimize → …→ no violated cuts are found.
However, Gurobi jumped to the other nodes before adding all violated cuts at the root node.
Is there any way to add all cuts that I want to add at the root node?
My C++ code is as follows:
void callback() override {
try {
if (where == GRB_CB_MIPNODE) {
int status = getIntInfo(GRB_CB_MIPNODE_STATUS);
if (status != GRB_OPTIMAL)
return;
double nodecnt = getDoubleInfo(GRB_CB_MIPNODE_NODCNT);
std::vector<double> xvals(num_vars);
std::vector<std::vector<double>> zvals(
num_vars, std::vector<double>(num_vars, 0.0));
for (size_t i = 0; i < num_vars; ++i)
xvals[i] = getNodeRel(x[i]);
for (auto& it : z) {
auto [i, j] = it.first;
double val = getNodeRel(it.second);
zvals[i][j] = val;
zvals[j][i] = val;
}
std::vector<Cut> cuts;
if (nodecnt == 0) {
cuts.clear();
separateCutsfor2Variables(x, z, xvals, zvals, num_vars, tolerance, num_vars, cuts);
for (auto& c : cuts) {
addCut(c.expr <= c.rhs);
}
cuts.clear();
separateViolatedCutsfor3Variables(x, z, xvals, zvals, num_vars, tolerance, 3 * num_vars, cuts);
for (auto& c : cuts) {
addCut(c.expr <= c.rhs);
}
return;
}
Could you please help me to solve the issue?
Thank you very much!
-
Hi Thi,
I don't think you will be able to have the level of control you are wanting, but you can try to postpone the branching as long as possible by increasing the value of the CutPasses parameter.
- Riley
0
Please sign in to leave a comment.
Comments
1 comment