Regulation

How HACKB evaluates your submissions: scoring per mode, submission statuses, judge sandbox details, and ranking rules. Please skim before joining a contest.

Submission interface

This page documents the function signature, interface, and file-level constraints for submission code.

solve(problem, evaluate) contract

The judge calls your solve(problem, evaluate) exactly once. problem is a TypedDict carrying the contest metadata (search space, budget, seed, …); evaluate is a callable that scores one point at a time. The type aliases (Problem / Evaluator) ship in the optional hackb-judge stub package.

from hackb_judge import Problem, Evaluator  # optional, type-only

def solve(problem: Problem, evaluate: Evaluator) -> object:
    ...

Run pip install hackb-judge to get IDE autocomplete. The package is type-stub only — no runtime dependency.

  • problemREQUIRED
    TYPE
    Problem (TypedDict)
    A TypedDict passed as the first argument to solve. It carries the keys below.
    EXAMPLE
    {
        "problem_id": "sphere-5d",
        "search_space": {
            "variables": [
                {"name": "x1", "type": "continuous", "lower": -5.12, "upper": 5.12},
                {"name": "x2", "type": "continuous", "lower": -5.12, "upper": 5.12},
            ],
        },
        "budget": 100,
        "seed": 42,
        "initial_data": [
            {"x": {"x1": 0.0, "x2": 0.0}, "y": 0.0},
        ],
    }
    • problem_idREQUIRED
      TYPE
      str
      Identifier of the problem. Available to your code for identification only.
      EXAMPLE
      "sphere-5d"
    • search_spaceREQUIRED
      TYPE
      SearchSpace
      Search-space definition. Each dimension has a name (key) and an admissible range (continuous: [low, high]; discrete: an enumeration). Every x dict you pass to evaluate must use this set of keys.
      EXAMPLE
      {
          "variables": [
              # 連続値: float, lower <= x <= upper
              {"name": "lr",        "type": "continuous",  "lower": 1e-5, "upper": 1.0},
              # 整数: int (両端含む)
              {"name": "layers",    "type": "integer",     "lower": 1,    "upper": 8},
              # カテゴリカル: choices からひとつ
              {"name": "optimizer", "type": "categorical", "choices": ["sgd", "adam"]},
              # バイナリ: 0 or 1
              {"name": "dropout",   "type": "binary"},
          ],
      }
    • budgetREQUIRED
      TYPE
      int
      Number of objective-function evaluations you may consume. Caps evaluate calls inside solve. Calls past the budget are rejected.
      EXAMPLE
      100
    • seedREQUIRED
      TYPE
      int
      Random seed used by the judge for scoring. If your code uses randomness, reusing this seed lets you reproduce a run.
      EXAMPLE
      1
    • initial_dataOPTIONAL
      TYPE
      list[InitialPoint]
      DEFAULT
      []
      Pre-labelled observations. Each entry is a dict with two keys: x (a dict that respects search_space) and y (the observed float). Some problems ship an empty list.
      EXAMPLE
      [
          {"x": {"x1": 0.5,  "x2": -0.3}, "y": 0.34},
          {"x": {"x1": -1.2, "x2":  0.8}, "y": 2.08},
      ]
  • evaluateREQUIRED
    TYPE
    Callable[[dict[str, Any]], float]

    A callable that evaluates the unknown objective f one point at a time. Decorator-based libraries (e.g. amplify-bbopt) can wrap this callable as their black-box function directly.

    • x must contain every dimension declared in search_space. Each value must respect that dimension's type and range.
    • The return value is a finite scalar (no NaN, no ±inf). Observations may include observation noise.
    • Each call counts as one evaluation. Calls past budget raise ValueError.
    • If x violates the search space, the call raises ValueError. Your code may catch it and retry, but the call still counts toward budget.
    • The objective function f and ground-truth labels are not visible from the submission. They run outside the sandbox boundary inside the judge.
    EXAMPLE
    # 1 点ずつ評価。ジャッジ側で budget をカウントする。
    y = evaluate({"x1": 0.5, "x2": -0.3})
    # y は float (例: 0.34)。NaN / ±inf は返らない。
    
    # search_space 違反は ValueError として上がる (呼び出しは消費される)。
    try:
        evaluate({"x1": 99.0, "x2": 0.0})
    except ValueError:
        ...
    
    # budget 超過時も ValueError。
    for _ in range(budget + 1):
        evaluate(sample_x())  # 最後の 1 回が ValueError

The concrete search_space, budget, and initial_data values for each problem are visible from the problem's detail page once the contest opens. Only the invariant types and meanings are documented here.

Submission constraints

Submissions must satisfy the following constraints. Violations are rejected at upload time or surface as InvalidSubmission.

File / fieldRequiredMax
submission.pyYes1 MiB
requirements.txtYes64 KiB
NoteNo500 chars

Both submission.py and requirements.txt are required. submission.py must define solve(problem, evaluate). An empty requirements.txt is fine, but the file itself must be present.