Warning: max constraint violation (9.2015e-06) exceeds tolerance
AnsweredGurobi Optimizer version 9.5.0 build v9.5.0rc5 (win64)
Gurobi Compute Server Worker version 9.5.0 build v9.5.0rc5 (win64)
Thread count: 8 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 2590 rows, 61568 columns and 358730 nonzeros
Model fingerprint: 0xfd9a5041
Model has 52 SOS constraints
Model has 284 general constraints
Variable types: 60509 continuous, 1059 integer (1059 binary)
Coefficient statistics:
Matrix range [1e-03, 5e+03]
Objective range [1e+00, 1e+01]
Bounds range [1e-04, 1e+04]
RHS range [1e+00, 5e+03]
GenCon rhs range [3e-01, 4e+03]
GenCon coe range [1e-01, 3e+05]
Presolve removed 259 rows and 1213 columns
Presolve time: 2.76s
Presolved: 2331 rows, 60355 columns, 316144 nonzeros
Presolved model has 17 SOS constraint(s)
Variable types: 59596 continuous, 759 integer (759 binary)
Found heuristic solution: objective 0.0000000
Root relaxation: objective -8.722800e+01, 1888 iterations, 0.18 seconds (0.17 work units)
Nodes | Current Node | Objective Bounds | Work
Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time
0 0 -87.22800 0 74 0.00000 -87.22800 - - 4s
0 0 -77.63462 0 311 0.00000 -77.63462 - - 8s
0 0 -77.10213 0 295 0.00000 -77.10213 - - 9s
0 0 -76.99283 0 292 0.00000 -76.99283 - - 9s
0 0 -76.87641 0 308 0.00000 -76.87641 - - 10s
0 0 -75.97268 0 309 0.00000 -75.97268 - - 11s
0 0 -75.97268 0 315 0.00000 -75.97268 - - 11s
0 0 -75.71492 0 323 0.00000 -75.71492 - - 12s
0 0 -75.60141 0 222 0.00000 -75.60141 - - 13s
0 2 -75.60141 0 210 0.00000 -75.60141 - - 15s
198 149 -33.45070 16 92 0.00000 -75.60141 - 139 20s
H 462 305 -27.2063206 -75.60141 178% 103 24s
H 463 305 -42.9563191 -75.60141 76.0% 103 24s
* 554 360 84 -42.9563195 -75.60141 76.0% 101 25s
1117 679 -62.77741 37 252 -42.95632 -75.60141 76.0% 103 30s
1542 896 -67.28322 23 213 -42.95632 -75.60141 76.0% 107 36s
1544 897 -64.95480 20 167 -42.95632 -75.60141 76.0% 107 46s
1548 900 -66.91967 32 540 -42.95632 -75.60141 76.0% 106 50s
1552 903 -59.58946 33 339 -42.95632 -75.60141 76.0% 106 55s
1555 906 -44.86568 15 257 -42.95632 -75.60141 76.0% 117 61s
1573 910 infeasible 19 -42.95632 -75.60141 76.0% 118 65s
H 1617 866 -56.5050293 -74.42772 31.7% 119 68s
H 1622 821 -56.5051856 -74.42772 31.7% 120 68s
1715 833 infeasible 40 -56.50519 -74.42772 31.7% 118 70s
H 1882 785 -56.5052020 -72.20901 27.8% 116 73s
1997 821 -60.29536 46 392 -56.50520 -68.71788 21.6% 113 75s
2269 891 -59.18354 81 282 -56.50520 -67.59928 19.6% 104 82s
H 2829 777 -59.5089389 -62.97545 5.83% 91.5 87s
3191 742 -59.79225 46 434 -59.50894 -61.46147 3.28% 87.7 90s
H 3223 696 -59.5990584 -61.46147 3.12% 87.4 90s
* 3415 540 127 -59.5990585 -61.43990 3.09% 84.3 90s
H 3465 499 -59.6042257 -61.43990 3.08% 83.5 90s
* 4010 453 104 -59.6043138 -60.39704 1.33% 78.7 94s
4145 442 -59.65942 57 353 -59.60431 -60.30637 1.18% 77.5 99s
4227 459 cutoff 60 -59.60431 -60.19047 0.98% 76.7 103s
4379 467 -59.64208 52 388 -59.60431 -60.04246 0.74% 75.3 105s
4487 500 -59.62236 59 257 -59.60431 -60.04246 0.74% 74.3 110s
H 4924 515 -59.6043171 -60.04246 0.74% 69.6 116s
5156 550 -59.64796 67 294 -59.60432 -60.03098 0.72% 67.2 124s
5171 568 -59.64673 68 290 -59.60432 -59.75267 0.25% 67.0 127s
5396 460 -59.65954 55 301 -59.60432 -59.73841 0.22% 65.1 131s
H 5681 444 -59.6043191 -59.68730 0.14% 62.9 133s
H 5704 444 -59.6043201 -59.68730 0.14% 62.8 133s
5705 334 -59.62309 75 234 -59.60432 -59.67225 0.11% 62.8 135s
Cutting planes:
Gomory: 2
Cover: 3
Implied bound: 63
MIR: 25
Flow cover: 41
GUB cover: 4
Inf proof: 3
Network: 4
RLT: 4
Relax-and-lift: 7
Explored 6224 nodes (381302 simplex iterations) in 135.74 seconds (210.23 work units)
Thread count was 8 (of 8 available processors)
Solution count 10: -59.6043 -59.6043 -59.6043 ... -56.5052
Optimal solution found (tolerance 1.00e-03)
Warning: max constraint violation (9.2015e-06) exceeds tolerance
Best objective -5.960432009866e+01, best bound -5.965331471614e+01, gap 0.0822%
cons = np.array(m.getConstrs())
slacks = m.getAttr("Slack", cons) df = pd.DataFrame({ "violation":-slacks[slacks < 0], "constr":cons[slacks < 0], })
The code written above which gives the slacks data frame doesn't have violation. How can I identify which constraint is being violated then.
0
-
Hi Sudheer,
The following code snippet should help:
def get_constr_from_index(model, index):
constr_boundaries_and_get = (
(model.NumConstrs, model.getConstrs),
(model.NumQConstrs, model.getQConstrs),
(model.NumSOS, model.getSOSs),
(model.NumGenConstrs, model.getGenConstrs),
)
for boundary, get_func in constr_boundaries_and_get:
if index < boundary:
return get_func()[index]
index -= boundary
raise ValueError(f"Constraint with index {index} not found in model")
def get_max_violated_constr(model):
constr = get_constr_from_index(model, model.ConstrVioIndex)
return constr
max_violated_constr = get_max_violated_constr(model)The max_violated_constr will then be the constraint you're looking for.
- Riley
0
Please sign in to leave a comment.
Comments
1 comment