{
  "$defs": {
    "RawCorrelationGroup": {
      "additionalProperties": false,
      "description": "A named group of correlated entities with an associated correlation matrix.\n\nAll entities in a group must share the same `type` (same-type constraint).\nMixing entity types (e.g. inflow and load in the same group) produces a\nruntime validation error.\n\nThe `matrix` must be square, symmetric, have 1.0 on every diagonal, and\nhave all off-diagonal entries in [-1.0, 1.0]. The number of rows (and\ncolumns) must equal the number of `entities`.",
      "properties": {
        "entities": {
          "description": "Ordered list of entity references. The matrix row/column order matches\nthis list. All entities must have the same `type` value; mixing entity\ntypes in one group produces a runtime validation error.",
          "items": {
            "$ref": "#/$defs/RawEntity"
          },
          "type": "array"
        },
        "matrix": {
          "description": "Symmetric correlation matrix in row-major order.\n- Must be square.\n- Diagonal entries must be exactly 1.0.\n- Off-diagonal entries must be in [-1.0, 1.0].\n- Must be symmetric: |m[i][j] - m[j][i]| <= 1e-10.",
          "items": {
            "items": {
              "format": "double",
              "type": "number"
            },
            "type": "array"
          },
          "type": "array"
        },
        "name": {
          "description": "Human-readable group label.",
          "type": "string"
        }
      },
      "required": [
        "name",
        "entities",
        "matrix"
      ],
      "type": "object"
    },
    "RawEntity": {
      "additionalProperties": false,
      "description": "Reference to a single entity within a correlation group.",
      "properties": {
        "id": {
          "description": "Entity identifier matching the corresponding entity's `id` field.",
          "format": "int32",
          "type": "integer"
        },
        "type": {
          "description": "Entity type tag. Valid values: `\"inflow\"` (hydro inflow series),\n`\"load\"` (bus load), `\"ncs\"` (non-controllable source availability).",
          "type": "string"
        }
      },
      "required": [
        "type",
        "id"
      ],
      "type": "object"
    },
    "RawProfile": {
      "additionalProperties": false,
      "description": "A named correlation profile containing one or more correlation groups.",
      "properties": {
        "correlation_groups": {
          "description": "Groups of correlated entities, each with a correlation matrix.",
          "items": {
            "$ref": "#/$defs/RawCorrelationGroup"
          },
          "type": "array"
        }
      },
      "required": [
        "correlation_groups"
      ],
      "type": "object"
    },
    "RawScheduleEntry": {
      "additionalProperties": false,
      "description": "Maps a stage to the named correlation profile active for that stage.",
      "properties": {
        "profile_name": {
          "description": "Name of the correlation profile for this stage. Must match a key in\n`profiles`.",
          "type": "string"
        },
        "stage_id": {
          "description": "Stage index (0-based) this entry applies to.",
          "format": "int32",
          "type": "integer"
        }
      },
      "required": [
        "stage_id",
        "profile_name"
      ],
      "type": "object"
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Spatial correlation model loaded from `scenarios/correlation.json`.\n\nDefines named correlation profiles and an optional stage-to-profile schedule\nfor stochastic scenario generation. Each profile contains one or more\ncorrelation groups, each grouping a set of entity inflow series with a\nsymmetric correlation matrix decomposed via the method specified in the\n`method` field (default: `\"spectral\"`).\n\nProfiles are stored in deterministic order regardless of JSON declaration\norder. Schedule entries reference profile names that must exist in the\n`profiles` map.",
  "properties": {
    "$schema": {
      "description": "JSON schema URI — informational, not validated.",
      "type": [
        "string",
        "null"
      ]
    },
    "method": {
      "description": "Decomposition method for the correlation matrix. Must not be empty.\nDefaults to `\"spectral\"`. `\"cholesky\"` is also accepted for backward\ncompatibility with existing case files. Unrecognized values produce a\nwarning but are not rejected.",
      "type": "string"
    },
    "profiles": {
      "additionalProperties": {
        "$ref": "#/$defs/RawProfile"
      },
      "description": "Named correlation profiles. Must not be empty. Keys are profile names\n(e.g. `\"default\"`, `\"wet_season\"`).",
      "type": "object"
    },
    "schedule": {
      "description": "Optional stage-to-profile schedule. Absent or null = empty schedule\n(single profile applies everywhere). Each entry's `profile_name` must\nmatch a key in `profiles`.",
      "items": {
        "$ref": "#/$defs/RawScheduleEntry"
      },
      "type": [
        "array",
        "null"
      ]
    }
  },
  "required": [
    "method",
    "profiles"
  ],
  "title": "RawCorrelationFile",
  "type": "object"
}