| |
| """ |
| Validator for problem 051: Kissing Number in Dimension 11 |
| |
| The kissing number τ₁₁ is the maximum number of non-overlapping unit spheres |
| that can touch a central unit sphere in 11 dimensions. |
| |
| Known bounds: 593 ≤ τ₁₁ ≤ 868 |
| |
| This validator checks that: |
| 1. All points are on the unit sphere S¹⁰ (|x| = 1) |
| 2. All pairwise dot products are ≤ 1/2 (equivalently, distances ≥ 1) |
| 3. Counts the number of valid points |
| |
| Expected input format: |
| {"points": [[x₁, ...], [x₁, ...], ...]} each point in ℝ¹¹ |
| or [[x₁, ...], [x₁, ...], ...] |
| """ |
|
|
| import argparse |
| from typing import Any |
|
|
| import numpy as np |
|
|
| from . import ValidationResult, load_solution, output_result, success, failure |
|
|
|
|
| DIMENSION = 11 |
| MIN_CONTACT_DISTANCE = 1.0 |
| TOLERANCE = 1e-9 |
|
|
|
|
| def validate(solution: Any) -> ValidationResult: |
| """ |
| Validate a kissing configuration in dimension 11. |
| |
| Args: |
| solution: Dict with 'points' key or list of points |
| |
| Returns: |
| ValidationResult with point count and minimum distance |
| """ |
| try: |
| if isinstance(solution, dict) and 'points' in solution: |
| points_data = solution['points'] |
| elif isinstance(solution, list): |
| points_data = solution |
| else: |
| return failure("Invalid format: expected dict with 'points' or list of points") |
|
|
| points = np.array(points_data, dtype=np.float64) |
| except (ValueError, TypeError) as e: |
| return failure(f"Failed to parse points: {e}") |
|
|
| if points.ndim != 2: |
| return failure(f"Points must be 2D array, got {points.ndim}D") |
|
|
| n, d = points.shape |
| if d != DIMENSION: |
| return failure(f"Points must be in ℝ¹¹, got dimension {d}") |
|
|
| if n == 0: |
| return failure("No points provided") |
|
|
| |
| norms = np.linalg.norm(points, axis=1) |
| off_sphere = np.abs(norms - 1.0) > TOLERANCE |
| if np.any(off_sphere): |
| worst_idx = np.argmax(np.abs(norms - 1.0)) |
| return failure( |
| f"Point {worst_idx} not on unit sphere: |x| = {norms[worst_idx]:.10f}", |
| off_sphere_count=int(np.sum(off_sphere)) |
| ) |
|
|
| |
| |
| gram = points @ points.T |
| min_dist = float('inf') |
| min_pair = (0, 0) |
| max_dot = -float('inf') |
| max_dot_pair = (0, 0) |
|
|
| for i in range(n): |
| for j in range(i + 1, n): |
| dot_ij = gram[i, j] |
| if dot_ij > max_dot: |
| max_dot = dot_ij |
| max_dot_pair = (i, j) |
| dist_ij = np.sqrt(max(2.0 - 2.0 * dot_ij, 0.0)) |
| if dist_ij < min_dist: |
| min_dist = dist_ij |
| min_pair = (i, j) |
|
|
| if max_dot > 0.5 + TOLERANCE: |
| return failure( |
| f"Points {max_dot_pair[0]} and {max_dot_pair[1]} violate non-overlap: " |
| f"dot product = {max_dot:.12f} > 0.5 " |
| f"(distance = {min_dist:.12f} < 1)", |
| min_distance=min_dist, |
| max_dot_product=max_dot, |
| violating_pair=list(max_dot_pair) |
| ) |
|
|
| return success( |
| f"Valid kissing configuration in ℝ¹¹: {n} points, " |
| f"min distance = {min_dist:.10f}, max dot product = {max_dot:.10f}", |
| dimension=DIMENSION, |
| num_points=n, |
| min_distance=min_dist, |
| max_dot_product=max_dot |
| ) |
|
|
|
|
| def main(): |
| parser = argparse.ArgumentParser(description='Validate kissing configuration in dimension 11') |
| parser.add_argument('solution', help='Solution as JSON string or path to JSON file') |
| parser.add_argument('--verbose', '-v', action='store_true', help='Verbose output') |
| args = parser.parse_args() |
|
|
| solution = load_solution(args.solution) |
| result = validate(solution) |
| output_result(result) |
|
|
|
|
| if __name__ == '__main__': |
| main() |
|
|