Fix Amaldi checker numerical overflow and document hardening
Browse filesValidate finite hyperplane coefficients and use high-precision distances to reject finite overflow attacks while preserving scaling equivalence. All six published references and nine targeted regression checks passed. Update Hardened feasibility checkers in RELEASE_NOTES.md.
- RELEASE_NOTES.md +1 -0
- tasks/amaldi2013/feasibility_check.py +53 -28
RELEASE_NOTES.md
CHANGED
|
@@ -37,6 +37,7 @@ The feasibility checkers were systematically audited and strengthened:
|
|
| 37 |
- Checkers no longer trust fixed problem parameters supplied by a candidate solution.
|
| 38 |
- The affected solver-dependent checkers were converted to validate complete witnesses without invoking an optimization solver at evaluation time.
|
| 39 |
- Checker execution limits and error handling were made more robust for large solutions.
|
|
|
|
| 40 |
|
| 41 |
All published Gurobi reference solutions were revalidated using the updated checkers.
|
| 42 |
|
|
|
|
| 37 |
- Checkers no longer trust fixed problem parameters supplied by a candidate solution.
|
| 38 |
- The affected solver-dependent checkers were converted to validate complete witnesses without invoking an optimization solver at evaluation time.
|
| 39 |
- Checker execution limits and error handling were made more robust for large solutions.
|
| 40 |
+
- **Numerically stable hyperplane geometry (`amaldi2013`, 2026-10-10).** The checker now validates finite numeric coefficients and computes distances using high-precision decimal arithmetic, preventing finite but extreme normal vectors from overflowing the floating-point norm and incorrectly accepting infeasible coverage. Exactly zero normals are rejected, while valid large, small, and negative rescalings remain equivalent. All six published Gurobi reference solutions were revalidated, and targeted overflow and scaling regressions passed.
|
| 41 |
|
| 42 |
All published Gurobi reference solutions were revalidated using the updated checkers.
|
| 43 |
|
tasks/amaldi2013/feasibility_check.py
CHANGED
|
@@ -20,6 +20,8 @@ This patched version additionally enforces:
|
|
| 20 |
import argparse
|
| 21 |
import json
|
| 22 |
import math
|
|
|
|
|
|
|
| 23 |
import numpy as np
|
| 24 |
|
| 25 |
# FRONTIEROR_RELEASE_CONTRACT_V2
|
|
@@ -163,6 +165,38 @@ def write_json(path, data):
|
|
| 163 |
json.dump(data, f, indent=2)
|
| 164 |
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
def check_feasibility(instance, solution):
|
| 167 |
tol = 1e-5
|
| 168 |
eps = 1e-5
|
|
@@ -216,31 +250,22 @@ def check_feasibility(instance, solution):
|
|
| 216 |
# ----------------------------------------------------------------
|
| 217 |
constraint_1_violated = False
|
| 218 |
for j, hp in enumerate(hyperplanes):
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
| 224 |
if int(D[:, j].sum()) > 0:
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
violation_magnitudes.append({
|
| 229 |
-
"constraint": 1,
|
| 230 |
-
"lhs": float(w_norm),
|
| 231 |
-
"rhs": float(tol),
|
| 232 |
-
"raw_excess": float(tol - w_norm),
|
| 233 |
-
"normalizer": max(tol, eps),
|
| 234 |
-
"ratio": float((tol - w_norm) / max(tol, eps))
|
| 235 |
-
})
|
| 236 |
-
violations.append(
|
| 237 |
-
f"Constraint 1 violated: hyperplane {j} has zero normal vector "
|
| 238 |
-
f"but has assigned points"
|
| 239 |
-
)
|
| 240 |
continue
|
| 241 |
for i in range(n):
|
| 242 |
if D[i, j] == 1:
|
| 243 |
-
dist =
|
| 244 |
if dist > epsilon + tol:
|
| 245 |
violation_amount = dist - epsilon
|
| 246 |
normalizer = max(abs(epsilon), eps)
|
|
@@ -254,7 +279,7 @@ def check_feasibility(instance, solution):
|
|
| 254 |
"rhs": float(epsilon),
|
| 255 |
"raw_excess": float(violation_amount),
|
| 256 |
"normalizer": float(normalizer),
|
| 257 |
-
"ratio": float(ratio)
|
| 258 |
})
|
| 259 |
|
| 260 |
if constraint_1_violated:
|
|
@@ -291,7 +316,7 @@ def check_feasibility(instance, solution):
|
|
| 291 |
"rhs": float(true_obj),
|
| 292 |
"raw_excess": float(abs_diff),
|
| 293 |
"normalizer": float(normalizer),
|
| 294 |
-
"ratio": float(ratio)
|
| 295 |
})
|
| 296 |
violations.append(
|
| 297 |
f"Constraint 2 (Eq.2, objective consistency) violated: "
|
|
@@ -321,7 +346,7 @@ def check_feasibility(instance, solution):
|
|
| 321 |
"rhs": float(rhs_val),
|
| 322 |
"raw_excess": float(violation_amount),
|
| 323 |
"normalizer": float(normalizer),
|
| 324 |
-
"ratio": float(ratio)
|
| 325 |
})
|
| 326 |
|
| 327 |
if constraint_3_violated:
|
|
@@ -355,7 +380,7 @@ def check_feasibility(instance, solution):
|
|
| 355 |
"rhs": float(rhs_val),
|
| 356 |
"raw_excess": float(violation_amount),
|
| 357 |
"normalizer": float(normalizer),
|
| 358 |
-
"ratio": float(ratio)
|
| 359 |
})
|
| 360 |
|
| 361 |
if constraint_4_violated:
|
|
@@ -386,7 +411,7 @@ def check_feasibility(instance, solution):
|
|
| 386 |
"rhs": float(rhs_val),
|
| 387 |
"raw_excess": float(violation_amount),
|
| 388 |
"normalizer": float(normalizer),
|
| 389 |
-
"ratio": float(ratio)
|
| 390 |
})
|
| 391 |
|
| 392 |
if constraint_5_violated:
|
|
@@ -417,7 +442,7 @@ def check_feasibility(instance, solution):
|
|
| 417 |
"rhs": float(round(val)),
|
| 418 |
"raw_excess": float(violation_amount),
|
| 419 |
"normalizer": float(normalizer),
|
| 420 |
-
"ratio": float(ratio)
|
| 421 |
})
|
| 422 |
|
| 423 |
if constraint_6_violated:
|
|
@@ -466,7 +491,7 @@ def check_feasibility(instance, solution):
|
|
| 466 |
"rhs": float(round(val)),
|
| 467 |
"raw_excess": float(violation_amount),
|
| 468 |
"normalizer": float(normalizer),
|
| 469 |
-
"ratio": float(ratio)
|
| 470 |
})
|
| 471 |
|
| 472 |
if constraint_7_violated:
|
|
|
|
| 20 |
import argparse
|
| 21 |
import json
|
| 22 |
import math
|
| 23 |
+
import sys
|
| 24 |
+
from decimal import Decimal, localcontext
|
| 25 |
import numpy as np
|
| 26 |
|
| 27 |
# FRONTIEROR_RELEASE_CONTRACT_V2
|
|
|
|
| 165 |
json.dump(data, f, indent=2)
|
| 166 |
|
| 167 |
|
| 168 |
+
def _finite_decimal(value):
|
| 169 |
+
# JSON numbers only; do not let strings, booleans or nonfinite values
|
| 170 |
+
# participate in geometry. Decimal avoids float norm/dot overflow.
|
| 171 |
+
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
| 172 |
+
raise ValueError("hyperplane coefficients must be finite JSON numbers")
|
| 173 |
+
if isinstance(value, float) and not math.isfinite(value):
|
| 174 |
+
raise ValueError("hyperplane coefficients must be finite JSON numbers")
|
| 175 |
+
return Decimal(str(value))
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def _geometric_distances(points, w, w0, dimension):
|
| 179 |
+
if not isinstance(w, list) or len(w) != dimension:
|
| 180 |
+
raise ValueError("hyperplane normal dimension does not match instance")
|
| 181 |
+
with localcontext() as ctx:
|
| 182 |
+
# Covers the exponent span of products of finite binary64 values,
|
| 183 |
+
# including subnormals and cancellation, without changing tolerance.
|
| 184 |
+
ctx.prec = 1600
|
| 185 |
+
normal = [_finite_decimal(v) for v in w]
|
| 186 |
+
offset = _finite_decimal(w0)
|
| 187 |
+
norm = sum((v * v for v in normal), Decimal(0)).sqrt()
|
| 188 |
+
if norm == 0:
|
| 189 |
+
return None
|
| 190 |
+
cap = Decimal(str(sys.float_info.max))
|
| 191 |
+
distances = []
|
| 192 |
+
for point in points:
|
| 193 |
+
residual = sum((_finite_decimal(v) * a for v, a in zip(point, normal)), Decimal(0)) - offset
|
| 194 |
+
distance = abs(residual) / norm
|
| 195 |
+
# Finite diagnostic values even for geometrically enormous distances.
|
| 196 |
+
distances.append(float(min(distance, cap)))
|
| 197 |
+
return distances
|
| 198 |
+
|
| 199 |
+
|
| 200 |
def check_feasibility(instance, solution):
|
| 201 |
tol = 1e-5
|
| 202 |
eps = 1e-5
|
|
|
|
| 250 |
# ----------------------------------------------------------------
|
| 251 |
constraint_1_violated = False
|
| 252 |
for j, hp in enumerate(hyperplanes):
|
| 253 |
+
try:
|
| 254 |
+
distances = _geometric_distances(instance["points"], hp["w"], hp["w0"], d)
|
| 255 |
+
except (ValueError, ArithmeticError) as exc:
|
| 256 |
+
return {"feasible": False, "violated_constraints": [5],
|
| 257 |
+
"violations": [f"Invalid hyperplane {j}: {exc}"],
|
| 258 |
+
"violation_magnitudes": []}
|
| 259 |
+
if distances is None:
|
| 260 |
+
# Exactly zero is degenerate; tiny nonzero rescalings are valid.
|
| 261 |
if int(D[:, j].sum()) > 0:
|
| 262 |
+
constraint_1_violated = True
|
| 263 |
+
violated_constraints_set.add(1)
|
| 264 |
+
violations.append(f"Constraint 1 violated: hyperplane {j} has zero normal vector but has assigned points")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 265 |
continue
|
| 266 |
for i in range(n):
|
| 267 |
if D[i, j] == 1:
|
| 268 |
+
dist = distances[i]
|
| 269 |
if dist > epsilon + tol:
|
| 270 |
violation_amount = dist - epsilon
|
| 271 |
normalizer = max(abs(epsilon), eps)
|
|
|
|
| 279 |
"rhs": float(epsilon),
|
| 280 |
"raw_excess": float(violation_amount),
|
| 281 |
"normalizer": float(normalizer),
|
| 282 |
+
"ratio": float(min(ratio, sys.float_info.max))
|
| 283 |
})
|
| 284 |
|
| 285 |
if constraint_1_violated:
|
|
|
|
| 316 |
"rhs": float(true_obj),
|
| 317 |
"raw_excess": float(abs_diff),
|
| 318 |
"normalizer": float(normalizer),
|
| 319 |
+
"ratio": float(min(ratio, sys.float_info.max))
|
| 320 |
})
|
| 321 |
violations.append(
|
| 322 |
f"Constraint 2 (Eq.2, objective consistency) violated: "
|
|
|
|
| 346 |
"rhs": float(rhs_val),
|
| 347 |
"raw_excess": float(violation_amount),
|
| 348 |
"normalizer": float(normalizer),
|
| 349 |
+
"ratio": float(min(ratio, sys.float_info.max))
|
| 350 |
})
|
| 351 |
|
| 352 |
if constraint_3_violated:
|
|
|
|
| 380 |
"rhs": float(rhs_val),
|
| 381 |
"raw_excess": float(violation_amount),
|
| 382 |
"normalizer": float(normalizer),
|
| 383 |
+
"ratio": float(min(ratio, sys.float_info.max))
|
| 384 |
})
|
| 385 |
|
| 386 |
if constraint_4_violated:
|
|
|
|
| 411 |
"rhs": float(rhs_val),
|
| 412 |
"raw_excess": float(violation_amount),
|
| 413 |
"normalizer": float(normalizer),
|
| 414 |
+
"ratio": float(min(ratio, sys.float_info.max))
|
| 415 |
})
|
| 416 |
|
| 417 |
if constraint_5_violated:
|
|
|
|
| 442 |
"rhs": float(round(val)),
|
| 443 |
"raw_excess": float(violation_amount),
|
| 444 |
"normalizer": float(normalizer),
|
| 445 |
+
"ratio": float(min(ratio, sys.float_info.max))
|
| 446 |
})
|
| 447 |
|
| 448 |
if constraint_6_violated:
|
|
|
|
| 491 |
"rhs": float(round(val)),
|
| 492 |
"raw_excess": float(violation_amount),
|
| 493 |
"normalizer": float(normalizer),
|
| 494 |
+
"ratio": float(min(ratio, sys.float_info.max))
|
| 495 |
})
|
| 496 |
|
| 497 |
if constraint_7_violated:
|