{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://witsenhausen.org/schemas/witsenhausen-controller-v1.schema.json",
  "title": "Witsenhausen Controller Submission (v1)",
  "description": "Declarative specification of a first-stage controller x1 = f(x0) for the Witsenhausen counterexample leaderboard. No executable code is submitted; the reference evaluator always computes the optimal second controller g*(y) = E[x1 | y].",
  "type": "object",
  "required": ["schema", "name", "authors", "date", "setting", "controller"],
  "properties": {
    "schema": {
      "const": "witsenhausen-controller/v1",
      "description": "Schema version identifier."
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "description": "Short descriptive title of the controller (inline LaTeX between $...$ is supported)."
    },
    "short_name": {
      "type": "string",
      "minLength": 1,
      "description": "Optional shorter label used in compact tables and charts."
    },
    "authors": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "minLength": 1
      },
      "description": "List of author names."
    },
    "date": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "Date the controller first appeared (YYYY-MM-DD). Use today's date for new submissions, or the paper date when porting a published controller."
    },
    "ported_by": {
      "type": "string",
      "minLength": 1,
      "description": "Optional: person who encoded a published controller into this format."
    },
    "verified_on": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "Optional: date (YYYY-MM-DD, not earlier than date) when a ported paper controller was first scored here."
    },
    "setting": {
      "type": "object",
      "required": ["k", "sigma"],
      "additionalProperties": false,
      "properties": {
        "k": {
          "type": "number",
          "minimum": 0,
          "description": "First-stage cost weight k."
        },
        "sigma": {
          "type": "number",
          "exclusiveMinimum": 0,
          "description": "Standard deviation sigma of the Gaussian initial state x0."
        }
      }
    },
    "method": {
      "type": "string",
      "description": "One-sentence description of how the controller was found."
    },
    "ai_assistance": {
      "type": "string",
      "minLength": 1,
      "description": "Optional: if an AI model helped, one sentence naming the model and what it did."
    },
    "source": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": ["paper", "code", "preprint", "other"]
        },
        "url": {
          "type": "string"
        }
      }
    },
    "claimed_cost": {
      "type": "number",
      "description": "Optional: cost computed by the submitter. CI rejects submissions whose claimed_cost differs from the reference evaluator by more than 1e-6."
    },
    "notes": {
      "type": "string",
      "description": "Optional additional notes (inline LaTeX between $...$ is supported)."
    },
    "controller": {
      "oneOf": [
        {
          "title": "Linear controller",
          "type": "object",
          "required": ["type", "gain"],
          "additionalProperties": false,
          "properties": {
            "type": { "const": "linear" },
            "gain": { "type": "number" }
          }
        },
        {
          "title": "Piecewise-affine controller",
          "type": "object",
          "required": ["type", "breakpoints", "intercepts", "slopes"],
          "additionalProperties": false,
          "properties": {
            "type": { "const": "piecewise_affine" },
            "breakpoints": {
              "type": "array",
              "items": { "type": "number" },
              "description": "Strictly increasing finite breakpoints t_1 < ... < t_{n-1}."
            },
            "intercepts": {
              "type": "array",
              "minItems": 1,
              "items": { "type": "number" },
              "description": "Intercepts a_0, ..., a_{n-1} (length = len(breakpoints) + 1)."
            },
            "slopes": {
              "type": "array",
              "minItems": 1,
              "items": { "type": "number" },
              "description": "Slopes b_0, ..., b_{n-1} (length = len(breakpoints) + 1)."
            }
          }
        },
        {
          "title": "Odd piecewise-affine controller",
          "type": "object",
          "required": ["type", "breakpoints", "intercepts", "slopes"],
          "additionalProperties": false,
          "properties": {
            "type": { "const": "odd_piecewise_affine" },
            "breakpoints": {
              "type": "array",
              "items": { "type": "number", "exclusiveMinimum": 0 },
              "description": "Strictly increasing positive breakpoints 0 < p_1 < ... < p_m for x >= 0; extended by f(-x) = -f(x)."
            },
            "intercepts": {
              "type": "array",
              "minItems": 1,
              "items": { "type": "number" },
              "description": "Intercepts on [0, p_1), ..., [p_m, inf) (length = len(breakpoints) + 1)."
            },
            "slopes": {
              "type": "array",
              "minItems": 1,
              "items": { "type": "number" },
              "description": "Slopes on [0, p_1), ..., [p_m, inf) (length = len(breakpoints) + 1)."
            }
          }
        },
        {
          "title": "Sampled table of points",
          "type": "object",
          "required": ["type", "x", "y"],
          "additionalProperties": false,
          "properties": {
            "type": { "const": "points" },
            "x": {
              "type": "array",
              "minItems": 2,
              "items": { "type": "number" },
              "description": "Strictly increasing x-coordinates (must start at 0 if odd is true)."
            },
            "y": {
              "type": "array",
              "minItems": 2,
              "items": { "type": "number" },
              "description": "Corresponding y = f(x) values (same length as x; must start at 0 if odd is true)."
            },
            "odd": {
              "type": "boolean",
              "default": false
            },
            "extrapolation": {
              "type": "string",
              "enum": ["linear", "constant"],
              "default": "linear"
            }
          }
        }
      ]
    }
  }
}
