Warning for adding constraints: zero or small (< 1e-13) coefficients, ignored

1,202 views
Skip to first unread message

Jennifer Gossels

unread,
Nov 22, 2016, 2:18:29 AM11/22/16
to Gurobi Optimization
Hello,

I'm trying to solve an LP, and with certain inputs I get the message, "Warning for adding constraints: zero or small (< 1e-13) coefficients, ignored."  Here's the code where I'm adding the problematic constraints.  This is a snippet from inside a larger function.  self.m is the model, var is a Gurobi variable, and then I'm printing weight and on_virt_link.

logger.info(DASHES*3)
self.m.addConstr(var == weight * on_virt_link, name=cname)
self.m.update()
logger
.info("just added constraint %s with weight %s and on_virt_link = %s"
                                   
% (cname, weight, on_virt_link))
logger
.info("max coefficient:  %s" % self.m.maxcoeff)
logger
.info("min coefficient:  %s" % self.m.mincoeff)
logger
.info("max bound:  %s" % self.m.maxbound)
logger
.info("min bound:  %s" % self.m.minbound)
logger
.info(DASHES*3)

Here's the log file for the first constraint that produces a warning:

---------------------------------------------------------------------
Warning for adding constraints: zero or small (< 1e-13) coefficients, ignored
just added constraint 818_path_weight_521(5,16,1,3,21) with weight 1.0 and
    on_virt_link = gurobi.LinExpr: Z_818521(5,16,1,3,21) + Z_818521(5,16,10,3,21) + Z_818521(5,16,1,7,21) + Z_818521(5,16,10,17,7,21)
max coefficient: 5000.0
min coefficient: 0.0262601362977
max bound: 0.0
min bound: 0.0
---------------------------------------------------------------------

I don't see how this constraint has zero or small coefficients?  The only coefficient is weight, and its value is 1.0.  I'd greatly appreciate any help.

Jennifer Gossels

Kostja Siefen

unread,
Nov 22, 2016, 3:18:22 AM11/22/16
to Gurobi Optimization
Hi Jennifer,

You could try to debug this by printing the constraint itself, e.g.

logger.info("just added constraint %s" % (var == weight * on_virt_link))

Kostja

Jennifer Gossels

unread,
Nov 22, 2016, 1:58:23 PM11/22/16
to Gurobi Optimization
Hi Kostja,

Thanks for the suggestion.  But, here's what I get:

-------------------------------------------------------------------------------------------

Warning for adding constraints: zero or small (< 1e-13) coefficients, ignored 
just added constraint gurobi.TempConstr: gurobi.LinExpr: Z_818521(5,16,1,3,21) == gurobi.LinExpr: 1.0 Z_818521(5,16,1,3,21) + 1.0 Z_818521(5,16,10,3,21) + 1.0 Z_818521(5,16,1,7,21) + 1.0 Z_818521(5,16,10,17,7,21)
-------------------------------------------------------------------------------------------

This is consistent with what I was seeing before -- the only coefficients I see are 1.0.  Do you have any idea what's happening?

Thanks,
Jennifer

Michael Winkler

unread,
Nov 22, 2016, 2:16:44 PM11/22/16
to Gurobi Optimization
Hi Jennifer,

internally constraints are changed such that sum ai*xi <=/= constant. Also, if a variable appears multiple times, all coefficients are summed up. In your example you have Z_818521(5,16,1,3,21) twice in your constraint, and if you transform it into the standard form both coefficients cancel each other resulting in a zero coefficient. This leads to the warning you are seeing.

Cheers,
Michael

Jennifer Gossels

unread,
Nov 22, 2016, 4:05:03 PM11/22/16
to Gurobi Optimization
Ah, thank you!
Reply all
Reply to author
Forward
0 new messages