I’m trying to optimize my Integer Linear Model by automatic analysing of the input data and generate lots of constraints like

x[3,45,12,7,8,1] == 0

I have several different subalghoritms that may return partially overlapping sets of constraints. I don’t want to overload my model by duplicated (or worse) costraints, as I’m concerned it can slow down solution process. Therefore I’m looking for some easy and elegant way of verifying if given constraint already exists. I think I could do it by dumping current model state to a string and parse it looking for particular substring, but I’m wondering whether there is better way to do it. Or is JuMP / Cbc Solver proofed for redundant constraints and there is nothing to be worry about?

If the constraints look like this it might be the easiest option to use a set structure first. Combine them in the end and apply it to your JuMP model.

Instead of x[3,45,12,7,8,1] == 0 you could update the bounds of the variables or use JuMP.fix. Generally, however, you can assume that solvers like Cbc will efficiently preprocess these constraints away. If the constraints involve more than fixing a variable to a value, this may no longer be the case.

Set function indeed eliminates doubled elements. It works even on vectors like [3,45,12,7,8,1], so that I can first precalculate all vectors (with doubles), then apply Set function (eliminating doubles) and then create constraints or fix.

While trying Jump.fix, I get following warning:

WARNING: Ignoring partial starting solution. Cbc requires a feasible value to be specified for all variables.

Is this something problematic, or can I safely ignore it?