{
  "$defs": {
    "PenaltyBasis": {
      "description": "What one unit of a generic-constraint violation is charged.\n\nThe row's quantity decides the basis: a rate (MW, m³/s) is integrated over the\nhours its row spans, an amount (`MWh`, hm³) is not.",
      "oneOf": [
        {
          "const": "per_hour",
          "description": "`penalty × hours` per unit of violation, for rate rows.",
          "type": "string"
        },
        {
          "const": "per_unit",
          "description": "`penalty` per unit of violation, for amount rows.",
          "type": "string"
        }
      ]
    },
    "RawConstraint": {
      "additionalProperties": false,
      "description": "A single constraint entry.",
      "properties": {
        "description": {
          "description": "Optional human-readable description.",
          "type": [
            "string",
            "null"
          ]
        },
        "expression": {
          "description": "Linear expression over LP variables, with numbers and `@parameters` combined by `+`, `-`,\n`*`, `/` and parentheses, e.g. `\"2.5 * thermal_generation(5) - @k * hydro_generation(3) <= @cap\"`.\nTo constrain an anticipated thermal's commitment, use `\"anticipated_decision(5)\"` (stage-level scalar, no block index).\nTo constrain one bus of a plant split across several buses, use `\"hydro_turbined(5, bus=2)\"`\nor `\"hydro_generation(5, bus=2)\"` — the only two variables accepting a `bus=` selector.\nFor a stage volume in hm³ use `\"hydro_outflow_volume(5)\"` (turbined plus spilled),\n`\"hydro_diversion_volume(5)\"` or `\"pumping_volume(2)\"`: each block's m³/s flow times its\nduration, summed over the stage, so a coefficient multiplies hm³. A constraint with one\ntakes only stage volumes, `hydro_storage`, and `hydro_storage_*` or\n`hydro_useful_volume_*` without a block argument; price its slack `\"per_unit\"`.\nAn optional inline relational operator (`<=`, `>=`, `==`) moves every variable term to\nthe left and assigns the remainder to the bound it targets.",
          "type": "string"
        },
        "id": {
          "description": "Constraint identifier. Must be unique within the file.",
          "format": "int32",
          "type": "integer"
        },
        "name": {
          "description": "Short name used in reports and log output.",
          "type": "string"
        },
        "slack": {
          "$ref": "#/$defs/RawSlackConfig",
          "description": "Slack variable configuration."
        }
      },
      "required": [
        "id",
        "name",
        "expression",
        "slack"
      ],
      "type": "object"
    },
    "RawNamedExpression": {
      "additionalProperties": false,
      "description": "A named linear-expression declaration.",
      "properties": {
        "description": {
          "description": "Optional human-readable description.",
          "type": [
            "string",
            "null"
          ]
        },
        "expression": {
          "description": "Linear expression over LP variables, under the same arithmetic as a constraint's\n`expression`, without a relational operator.",
          "type": "string"
        },
        "name": {
          "description": "Name bound to the expression; unique in the file and distinct from every scalar-parameter name.",
          "type": "string"
        }
      },
      "required": [
        "name",
        "expression"
      ],
      "type": "object"
    },
    "RawSlackConfig": {
      "additionalProperties": false,
      "description": "The slack configuration.",
      "properties": {
        "enabled": {
          "description": "Whether a slack variable is allowed.",
          "type": "boolean"
        },
        "penalty": {
          "description": "Penalty per unit of violation. Required and > 0.0 when `enabled` is `true`;\nabsent otherwise.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "penalty_basis": {
          "anyOf": [
            {
              "$ref": "#/$defs/PenaltyBasis"
            },
            {
              "type": "null"
            }
          ],
          "description": "How `penalty` is charged: `\"per_hour\"` multiplies it by the hours the row\nspans (rows in MW or m³/s); `\"per_unit\"` does not (rows in `MWh` or hm³).\nRequired when `enabled` is `true`; absent otherwise."
        }
      },
      "required": [
        "enabled"
      ],
      "type": "object"
    }
  },
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Root object of `generic_constraints.json`.",
  "properties": {
    "$schema": {
      "description": "`$schema` field — informational, not validated.",
      "type": [
        "string",
        "null"
      ]
    },
    "constraints": {
      "description": "Array of constraint entries.",
      "items": {
        "$ref": "#/$defs/RawConstraint"
      },
      "type": "array"
    },
    "expressions": {
      "description": "Named linear-expression declarations sharing the `@name` namespace with\nscalar parameters. Absent ⇒ empty ⇒ no named expressions.",
      "items": {
        "$ref": "#/$defs/RawNamedExpression"
      },
      "type": "array"
    }
  },
  "required": [
    "constraints"
  ],
  "title": "RawGenericConstraintsFile",
  "type": "object"
}