map<string, GRBLinExpr > mSubToursLength2;
for (int i = 1; i < G.N0; i++)
for (int j = i + 1; j < G.N0; j++)
if (G.tau[i][j] + G.tau[j][i] < 1e6)
{
ostringstream subTour;
subTour << "SubTour_" << i << "." << j;
mSubToursLength2[subTour.str()] = model.getRow(model.getConstrByName(subTour.str())); //extract a subtour
model.remove(model.getConstrByName(subTour.str())); //remove from model
}
model.update();
//cout << "Size" << newArcs.size()<< endl;
for (set<VarIndex>::iterator it = newArcs.begin(); it != newArcs.end(); it++)
{
//assert(x_a.find(*it) != x_a.end());
int i = min(it->i, it->j);
int j = max(it->i, it->j);
if (i == j) continue;
ostringstream subTour;
subTour << "SubTour_" << i << "." << j;
mSubToursLength2[subTour.str()] += x_a[*it]; //update subtours - add related variables
}
for (map<string, GRBLinExpr>::iterator it = mSubToursLength2.begin(); it != mSubToursLength2.end(); it++)
model.addConstr(it->second <= 1, it->first); //re insert to the model
model.update();
Error code = 20001 in updateSubTourLength2Constraints
Not in the model
But this is the only place that I do the modification and I removed constraints when i extract them with getConstraintsByName?
--
---
You received this message because you are subscribed to a topic in the Google Groups "Gurobi Optimization" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gurobi/e_yiUIO8TuU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gurobi+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I have created variables and then I store them in a map by using map[var_name] = newvar; then I used variables stored in map. Is this the reason?
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+un...@googlegroups.com.
I guess no. The map only contains constraints that i extracted from the model. Remove. Do the modification. Reinsert.
To unsubscribe from this group and all its topics, send an email to gurobi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+unsubscribe@googlegroups.com.
--
---
You received this message because you are subscribed to a topic in the Google Groups "Gurobi Optimization" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gurobi/e_yiUIO8TuU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gurobi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+unsubscribe@googlegroups.com.
--
---
You received this message because you are subscribed to a topic in the Google Groups "Gurobi Optimization" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gurobi/e_yiUIO8TuU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gurobi+unsubscribe@googlegroups.com.