{
  "$defs": {
    "CapacityDecision": {
      "additionalProperties": false,
      "description": "One capacity the design study sizes, shared by every horizon.\n\nAttributes:\n    name: The decision's name, e.g. ``\"battery_energy\"``.\n    variable: The scalar variable's path, e.g.\n        ``\"battery.energy_capacity\"``.\n    capital_cost: The overnight cost per unit of the variable.\n    lifetime_years: The asset life used to annualize it.\n    lower: The lower bound, in the variable's units.\n    upper: The upper bound, in the variable's units.",
      "properties": {
        "capital_cost": {
          "title": "Capital Cost",
          "type": "number"
        },
        "lifetime_years": {
          "title": "Lifetime Years",
          "type": "number"
        },
        "lower": {
          "default": 0.0,
          "title": "Lower",
          "type": "number"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "upper": {
          "title": "Upper",
          "type": "number"
        },
        "variable": {
          "title": "Variable",
          "type": "string"
        }
      },
      "required": [
        "name",
        "variable",
        "capital_cost",
        "lifetime_years",
        "upper"
      ],
      "title": "CapacityDecision",
      "type": "object"
    },
    "Case": {
      "additionalProperties": false,
      "description": "One hand-picked combination in a :class:`CasesSweep`.\n\nAttributes:\n    name: The case's name, which ``output_name`` renders as ``{case}``.\n    spec: A model spec to build from instead of ``base_model_spec``.\n    surrogates: ``{unit: surrogate tag}``.\n    configuration_options: ``{option path: value}``, as a\n        :class:`ConfigurationSweep` sets them.\n    variables: ``{variable path: value}``, as a :class:`VariableSweep`\n        fixes them.\n    model_inputs: Entries that set variables from stored data, as a\n        :class:`ModelInputsSweep` value does.",
      "properties": {
        "configuration_options": {
          "additionalProperties": true,
          "title": "Configuration Options",
          "type": "object"
        },
        "model_inputs": {
          "items": {
            "$ref": "#/$defs/ModelInput"
          },
          "title": "Model Inputs",
          "type": "array"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "spec": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Spec"
        },
        "surrogates": {
          "additionalProperties": {
            "type": "string"
          },
          "title": "Surrogates",
          "type": "object"
        },
        "variables": {
          "additionalProperties": true,
          "title": "Variables",
          "type": "object"
        }
      },
      "required": [
        "name"
      ],
      "title": "Case",
      "type": "object"
    },
    "CasesSweep": {
      "additionalProperties": false,
      "description": "Each task runs one of ``cases``: chosen combinations, not every one.\n\nA cases sweep is one sweep like any other, so it can be combined with the\nrest (a ``product`` with a price sweep runs every case at every price).\n\nAttributes:\n    name: The field ``output_name`` renders the case's name as; ``case``\n        by default.\n    cases: The cases; their names must differ.",
      "properties": {
        "cases": {
          "items": {
            "$ref": "#/$defs/Case"
          },
          "minItems": 1,
          "title": "Cases",
          "type": "array"
        },
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Name"
        },
        "type": {
          "const": "cases",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "type",
        "cases"
      ],
      "title": "CasesSweep",
      "type": "object"
    },
    "ConfigurationSweep": {
      "additionalProperties": false,
      "description": "Each task sets the configuration option at ``path`` to one of ``values``.\n\nThe option is set in a copy of the base spec (the ``configure`` hook), which\nis stored under the task's tag with the base as parent. For flex-pse,\n``path`` is any element's name followed by the option: a unit's\nconstruction option (``\"plant.feed.max_withdrawal\"``) or another\nelement's field (``\"costing.energy_prices.electrical\"``). A dict-valued\noption is set whole by a dict value, or one key at a time by a longer\npath (``\"plant.feed.max_withdrawal.value\"``).\n\nAttributes:\n    name: The field ``output_name`` renders the value as; ``path`` by\n        default.\n    path: The option's path.\n    values: The values; any JSON value, dicts included.",
      "properties": {
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Name"
        },
        "path": {
          "title": "Path",
          "type": "string"
        },
        "type": {
          "const": "configuration_option",
          "title": "Type",
          "type": "string"
        },
        "values": {
          "items": {},
          "minItems": 1,
          "title": "Values",
          "type": "array"
        }
      },
      "required": [
        "type",
        "path",
        "values"
      ],
      "title": "ConfigurationSweep",
      "type": "object"
    },
    "DesignStudy": {
      "additionalProperties": false,
      "description": "Run each task's model spec as a flex-pse design study.\n\nThis mirrors flex-pse's ``DesignSpec``; flex-pse checks the rules (weights\nsum to 12, years are consecutive) before any task runs.\n\nAttributes:\n    schema_version: The version of this study.\n    years: The modeled years, ascending.\n    months: The representative months.\n    changes: Changes to base elements, applied in order.\n    capacities: What to size.",
      "properties": {
        "capacities": {
          "items": {
            "$ref": "#/$defs/CapacityDecision"
          },
          "minItems": 1,
          "title": "Capacities",
          "type": "array"
        },
        "changes": {
          "items": {
            "$ref": "#/$defs/ParameterChange"
          },
          "title": "Changes",
          "type": "array"
        },
        "months": {
          "items": {
            "$ref": "#/$defs/RepresentativeMonth"
          },
          "minItems": 1,
          "title": "Months",
          "type": "array"
        },
        "schema_version": {
          "default": "0.1.0",
          "title": "Schema Version",
          "type": "string"
        },
        "years": {
          "items": {
            "$ref": "#/$defs/PlanningYear"
          },
          "minItems": 1,
          "title": "Years",
          "type": "array"
        }
      },
      "required": [
        "years",
        "months",
        "capacities"
      ],
      "title": "DesignStudy",
      "type": "object"
    },
    "Execution": {
      "additionalProperties": false,
      "description": "How tasks run.\n\n``max_workers: 1`` (the default) runs the tasks one after another in this\nprocess. More than 1 runs them on Ray: a local Ray started for this\nprocess (``namespace=\"flexorch\"``), the one already connected, or the\ncluster at ``ray_address``. Either way the main process stores every\nresult, so workers never hold database credentials.\n\nAttributes:\n    max_workers: Tasks run at once.\n    ray_address: A Ray cluster, e.g. ``\"ray://tenant-ray-head:10001\"``;\n        local Ray if ``None``. Its workers need flex-orchestrator and the\n        hooks' modules installed.\n    resources: What each task reserves on Ray.\n    max_calls: Restart a Ray worker process after this many tasks, to\n        keep memory bounded; ``None`` never restarts.\n    task_timeout_s: A task's time limit on Ray, counted from when it's\n        submitted, so it includes starting a worker (a few seconds the\n        first time). A task that runs over is killed and stored as a failed\n        result (``termination: timeout``); it isn't retried. Two hours by\n        default; ``None`` means no limit. In-process it is not enforced.\n    retries: How many times a task is built and solved again when building\n        or exporting raises, the solve hook raises, or its Ray worker dies.\n        A task whose spec or result can't be stored isn't retried.\n    on_error: Go on with the other tasks after one fails (``continue``) or\n        stop (``stop``); on Ray, ``stop`` cancels the tasks still running.",
      "properties": {
        "max_calls": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Max Calls"
        },
        "max_workers": {
          "default": 1,
          "minimum": 1,
          "title": "Max Workers",
          "type": "integer"
        },
        "on_error": {
          "default": "continue",
          "enum": [
            "continue",
            "stop"
          ],
          "title": "On Error",
          "type": "string"
        },
        "ray_address": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Ray Address"
        },
        "resources": {
          "$ref": "#/$defs/Resources"
        },
        "retries": {
          "default": 0,
          "minimum": 0,
          "title": "Retries",
          "type": "integer"
        },
        "task_timeout_s": {
          "anyOf": [
            {
              "exclusiveMinimum": 0,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": 7200.0,
          "title": "Task Timeout S"
        }
      },
      "title": "Execution",
      "type": "object"
    },
    "ExportConfig": {
      "additionalProperties": false,
      "description": "What each task's result stores; nothing set means the default selection.\n\nAttributes:\n    keys: Exact paths to export.\n    include: Glob patterns to export.\n    exclude: Glob patterns to leave out.\n    streams: Values to also store natively.\n    strict_units: Raise on a unit with no QUDT key.",
      "properties": {
        "exclude": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Exclude"
        },
        "include": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Include"
        },
        "keys": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Keys"
        },
        "streams": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Streams"
        },
        "strict_units": {
          "default": false,
          "title": "Strict Units",
          "type": "boolean"
        }
      },
      "title": "ExportConfig",
      "type": "object"
    },
    "FitParams": {
      "additionalProperties": false,
      "description": "The parameters of ``fit_surrogate``.\n\nAttributes:\n    tag: The surrogate spec's tag; a template with ``{name}`` when there\n        are variants (``\"biogas_{name}\"``).\n    regressor: A flex-pse ``SurrogateType`` (``\"multilinear\"``,\n        ``\"constant_intensity\"``) or an import string of a class that\n        follows flex-pse's ``Regressor`` protocol.\n    params: The regressor's constructor arguments.\n    spec_options: Passed to its ``to_surrogate_spec``.\n    X: The inputs: one selector or a list, merged column-wise.\n    y: The output: one selector (or a list) giving one column.\n    window: Only data in this window.\n    prep: How the data is prepared (see :class:`Prep`).\n    validation: Hold-out metrics (see :class:`Validation`).\n    variants: Several fits in one call, each overriding these fields.\n    on_existing: What to do when a tag is stored: ``error``, ``skip`` it,\n        or ``replace`` it.\n    store_series: Also store ``actual`` / ``fitted`` / ``residual``\n        timeseries with the fit, for plotting.\n    max_workers: Variants fitted at once; more than 1 fits them on Ray.\n        In a study, the study's ``execution`` decides instead.\n    ray_address: The Ray cluster for ``max_workers > 1``; local Ray if\n        ``None``.",
      "properties": {
        "X": {
          "anyOf": [
            {
              "$ref": "#/$defs/Selector"
            },
            {
              "items": {
                "$ref": "#/$defs/Selector"
              },
              "type": "array"
            }
          ],
          "title": "X"
        },
        "max_workers": {
          "default": 1,
          "minimum": 1,
          "title": "Max Workers",
          "type": "integer"
        },
        "on_existing": {
          "default": "error",
          "enum": [
            "error",
            "skip",
            "replace"
          ],
          "title": "On Existing",
          "type": "string"
        },
        "params": {
          "additionalProperties": true,
          "title": "Params",
          "type": "object"
        },
        "prep": {
          "$ref": "#/$defs/Prep"
        },
        "ray_address": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Ray Address"
        },
        "regressor": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Regressor"
        },
        "spec_options": {
          "additionalProperties": true,
          "title": "Spec Options",
          "type": "object"
        },
        "store_series": {
          "default": false,
          "title": "Store Series",
          "type": "boolean"
        },
        "tag": {
          "title": "Tag",
          "type": "string"
        },
        "validation": {
          "anyOf": [
            {
              "$ref": "#/$defs/Validation"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "variants": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Variant"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Variants"
        },
        "window": {
          "anyOf": [
            {
              "$ref": "#/$defs/Window"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "y": {
          "anyOf": [
            {
              "$ref": "#/$defs/Selector"
            },
            {
              "items": {
                "$ref": "#/$defs/Selector"
              },
              "type": "array"
            }
          ],
          "title": "Y"
        }
      },
      "required": [
        "tag",
        "X",
        "y"
      ],
      "title": "FitParams",
      "type": "object"
    },
    "HooksConfig": {
      "additionalProperties": false,
      "description": "Hooks for the study's tasks: import strings or registered names.\n\nUnset slots use the orchestrator's hooks; hooks passed to\n``execute_study`` win over these.\n\nAttributes:\n    build: The build hook.\n    solve: The solve hook.\n    apply_surrogate: Applies a surrogate sweep's surrogates to the spec.\n    swap_surrogate: Swaps a surrogate on a live model.\n    time_sets: Names a built model's time Sets for the exporter.\n    configure: Sets a configuration sweep's options in the spec.\n    time_grid: Gives a spec's time axis, for ``model_inputs``.",
      "properties": {
        "apply_surrogate": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Apply Surrogate"
        },
        "build": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Build"
        },
        "configure": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Configure"
        },
        "solve": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Solve"
        },
        "swap_surrogate": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Swap Surrogate"
        },
        "time_grid": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Time Grid"
        },
        "time_sets": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Time Sets"
        }
      },
      "title": "HooksConfig",
      "type": "object"
    },
    "InputResample": {
      "additionalProperties": false,
      "description": "How samples become one value per time step.\n\nAttributes:\n    agg: How the samples in one step combine.",
      "properties": {
        "agg": {
          "default": "mean",
          "enum": [
            "mean",
            "sum",
            "min",
            "max",
            "median",
            "first",
            "last"
          ],
          "title": "Agg",
          "type": "string"
        }
      },
      "title": "InputResample",
      "type": "object"
    },
    "InputSet": {
      "additionalProperties": false,
      "description": "One value of a ``model_inputs`` sweep: a labelled set of entries.\n\nAttributes:\n    label: What ``output_name`` renders the set as.\n    inputs: The entries a task with this value uses.",
      "properties": {
        "inputs": {
          "items": {
            "$ref": "#/$defs/ModelInput"
          },
          "minItems": 1,
          "title": "Inputs",
          "type": "array"
        },
        "label": {
          "title": "Label",
          "type": "string"
        }
      },
      "required": [
        "label",
        "inputs"
      ],
      "title": "InputSet",
      "type": "object"
    },
    "ModelInput": {
      "additionalProperties": false,
      "description": "One ``model_inputs`` entry: a selector, then its alignment.\n\nAttributes:\n    timezone: The facility's time zone (an IANA name such as\n        ``\"America/Los_Angeles\"``). The model runs on that site's wall\n        clock, so stored UTC timestamps are converted to it before they're\n        lined up with the model's (naive) time steps. ``UTC`` by default:\n        data stored in UTC means a model in UTC.\n    resample: How the samples in one time step combine; ``mean`` by\n        default.\n    gaps: A time step with no value is filled by ``interpolate`` (in\n        time, the default), ``ffill`` (the last value carried forward) or\n        ``zero``; ``error`` refuses any gap.\n    limit: The longest run of missing steps ``interpolate`` or ``ffill``\n        fills; a longer one fails.\n    reduce: Set the variable to one number instead of a series: this\n        statistic of the data over the model's horizon.\n    offset: Read the data this far from the model's horizon, as a pandas\n        offset (``\"-365D\"``: last year's data for this horizon).",
      "properties": {
        "columns": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Columns"
        },
        "dataset": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Dataset"
        },
        "end": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "End"
        },
        "gaps": {
          "default": "interpolate",
          "enum": [
            "interpolate",
            "ffill",
            "zero",
            "error"
          ],
          "title": "Gaps",
          "type": "string"
        },
        "keys": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Keys"
        },
        "limit": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Limit"
        },
        "offset": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Offset"
        },
        "reduce": {
          "anyOf": [
            {
              "enum": [
                "mean",
                "last",
                "first",
                "min",
                "max",
                "median"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Reduce"
        },
        "ref_uris": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Ref Uris"
        },
        "rename": {
          "additionalProperties": {
            "type": "string"
          },
          "title": "Rename",
          "type": "object"
        },
        "resample": {
          "anyOf": [
            {
              "$ref": "#/$defs/InputResample"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "resolve": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Resolve"
        },
        "result": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Result"
        },
        "sparql": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Sparql"
        },
        "start": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Start"
        },
        "streams": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/StreamName"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Streams"
        },
        "study": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Study"
        },
        "timezone": {
          "default": "UTC",
          "title": "Timezone",
          "type": "string"
        },
        "units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "additionalProperties": {
                "type": "string"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Units"
        }
      },
      "title": "ModelInput",
      "type": "object"
    },
    "ModelInputsSweep": {
      "additionalProperties": false,
      "description": "Each task sets model variables from one of ``values``' sets of data.\n\nAn entry in a set replaces the config's ``model_inputs`` entry for the same\npath, so a sweep can vary only the streams it names.\n\nAttributes:\n    name: The field ``output_name`` renders a set's label as;\n        ``model_inputs`` by default.\n    values: The sets; their labels must differ.",
      "properties": {
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Name"
        },
        "type": {
          "const": "model_inputs",
          "title": "Type",
          "type": "string"
        },
        "values": {
          "items": {
            "$ref": "#/$defs/InputSet"
          },
          "minItems": 1,
          "title": "Values",
          "type": "array"
        }
      },
      "required": [
        "type",
        "values"
      ],
      "title": "ModelInputsSweep",
      "type": "object"
    },
    "ParameterChange": {
      "additionalProperties": false,
      "description": "A change to one base element for some years and months.\n\nAttributes:\n    element: The name of the base element.\n    values: The fields to deep-merge into it. Files named here are stored\n        with the spec.\n    years: The years it applies to; all if omitted.\n    months: The months it applies to; all if omitted.",
      "properties": {
        "element": {
          "title": "Element",
          "type": "string"
        },
        "months": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Months"
        },
        "values": {
          "additionalProperties": true,
          "title": "Values",
          "type": "object"
        },
        "years": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Years"
        }
      },
      "required": [
        "element",
        "values"
      ],
      "title": "ParameterChange",
      "type": "object"
    },
    "PlanningYear": {
      "additionalProperties": false,
      "description": "One modeled year of a design study.\n\nAttributes:\n    year: The calendar year.\n    represents: The calendar years it stands in for.",
      "properties": {
        "represents": {
          "default": 1,
          "title": "Represents",
          "type": "integer"
        },
        "year": {
          "title": "Year",
          "type": "integer"
        }
      },
      "required": [
        "year"
      ],
      "title": "PlanningYear",
      "type": "object"
    },
    "Prep": {
      "additionalProperties": false,
      "description": "How the selected data is prepared before fitting.\n\nAttributes:\n    align: ``inner`` keeps the timestamps every column has; ``outer`` keeps\n        any column's, leaving gaps.\n    resample: Resample to a regular index first.\n    gaps: What to do with missing values: ``error`` (the default),\n        ``drop`` the rows, ``interpolate`` (in time, up to ``limit``\n        missing values in a row), or keep the ``longest_segment`` with\n        none.\n    limit: The longest run of missing values ``interpolate`` fills.\n    max_rows: Refuse more rows than this (a guard against running out of\n        memory).",
      "properties": {
        "align": {
          "default": "inner",
          "enum": [
            "inner",
            "outer"
          ],
          "title": "Align",
          "type": "string"
        },
        "gaps": {
          "default": "error",
          "enum": [
            "error",
            "drop",
            "interpolate",
            "longest_segment"
          ],
          "title": "Gaps",
          "type": "string"
        },
        "limit": {
          "anyOf": [
            {
              "minimum": 1,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Limit"
        },
        "max_rows": {
          "default": 1000000,
          "minimum": 1,
          "title": "Max Rows",
          "type": "integer"
        },
        "resample": {
          "anyOf": [
            {
              "$ref": "#/$defs/Resample"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "title": "Prep",
      "type": "object"
    },
    "RepresentativeMonth": {
      "additionalProperties": false,
      "description": "One calendar month modeled in every planning year.\n\nAttributes:\n    month: The calendar month, 1 to 12.\n    weight: The months of the year it stands in for; weights sum to 12.\n    days: Model only the first N days and scale the bill up to the full\n        month; the whole month if omitted.",
      "properties": {
        "days": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Days"
        },
        "month": {
          "title": "Month",
          "type": "integer"
        },
        "weight": {
          "title": "Weight",
          "type": "number"
        }
      },
      "required": [
        "month",
        "weight"
      ],
      "title": "RepresentativeMonth",
      "type": "object"
    },
    "Resample": {
      "additionalProperties": false,
      "description": "Resample to a regular index.\n\nAttributes:\n    freq: A pandas offset alias, e.g. ``\"1h\"``.\n    agg: How values in one bin combine.",
      "properties": {
        "agg": {
          "default": "mean",
          "enum": [
            "mean",
            "sum",
            "min",
            "max",
            "median",
            "first",
            "last"
          ],
          "title": "Agg",
          "type": "string"
        },
        "freq": {
          "title": "Freq",
          "type": "string"
        }
      },
      "required": [
        "freq"
      ],
      "title": "Resample",
      "type": "object"
    },
    "Resources": {
      "additionalProperties": false,
      "description": "What each Ray task reserves.\n\nAttributes:\n    num_cpus: CPUs per task; Ray runs as many at once as the cluster\n        fits, up to ``max_workers``.\n    memory: Bytes of memory per task, or ``None`` to reserve none.",
      "properties": {
        "memory": {
          "anyOf": [
            {
              "exclusiveMinimum": 0,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Memory"
        },
        "num_cpus": {
          "default": 1.0,
          "exclusiveMinimum": 0,
          "title": "Num Cpus",
          "type": "number"
        }
      },
      "title": "Resources",
      "type": "object"
    },
    "Selector": {
      "additionalProperties": false,
      "description": "Where one or more columns of fit data come from.\n\nExactly one source key is set:\n\n- ``dataset`` (with optional ``study`` and ``columns``): a dataset of this\n  study, or of another study in the same store;\n- ``result`` (with ``keys``): exported values of a stored result;\n- ``ref_uris``: streams of the general store, by reference URI;\n- ``streams``: streams of the general store, by ``source_id`` and\n  ``ref_name``;\n- ``resolve``: the one general-store stream whose label matches this text;\n- ``sparql``: a read-only SPARQL ``SELECT`` whose first column is stream\n  references.\n\nAttributes:\n    start: Only rows at or after this time.\n    end: Only rows at or before this time.\n    units: Units to convert to: one for every column, or ``{column: unit}``\n        (after ``rename``). A Pyomo unit (``\"m^3/hr\"``) or a QUDT key\n        (``\"M3-PER-HR\"``).\n    rename: ``{column: new name}``, or ``{\"*\": name}`` for a selector with\n        one column. The surrogate's variable names are the column names,\n        so they must be the unit's variable names.",
      "properties": {
        "columns": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Columns"
        },
        "dataset": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Dataset"
        },
        "end": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "End"
        },
        "keys": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Keys"
        },
        "ref_uris": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Ref Uris"
        },
        "rename": {
          "additionalProperties": {
            "type": "string"
          },
          "title": "Rename",
          "type": "object"
        },
        "resolve": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Resolve"
        },
        "result": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Result"
        },
        "sparql": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Sparql"
        },
        "start": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Start"
        },
        "streams": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/StreamName"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Streams"
        },
        "study": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Study"
        },
        "units": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "additionalProperties": {
                "type": "string"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Units"
        }
      },
      "title": "Selector",
      "type": "object"
    },
    "SpecListSweep": {
      "additionalProperties": false,
      "description": "Each task builds from one of ``specs`` instead of ``base_model_spec``.\n\nAttributes:\n    name: The field ``output_name`` renders the tag as; ``spec`` by\n        default.\n    specs: Model spec tags.",
      "properties": {
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Name"
        },
        "specs": {
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "title": "Specs",
          "type": "array"
        },
        "type": {
          "const": "spec_list",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "type",
        "specs"
      ],
      "title": "SpecListSweep",
      "type": "object"
    },
    "StreamName": {
      "additionalProperties": false,
      "description": "A general-store stream by the names its driver registered it with.\n\nAttributes:\n    source_id: The datasource, e.g. ``\"historian\"``.\n    ref_name: The stream's name in that source, e.g. ``\"FT_101\"``.",
      "properties": {
        "ref_name": {
          "title": "Ref Name",
          "type": "string"
        },
        "source_id": {
          "title": "Source Id",
          "type": "string"
        }
      },
      "required": [
        "source_id",
        "ref_name"
      ],
      "title": "StreamName",
      "type": "object"
    },
    "SurrogateSweep": {
      "additionalProperties": false,
      "description": "Each task uses one of ``surrogates`` for ``unit``.\n\nAttributes:\n    name: The field ``output_name`` renders the surrogate's tag as;\n        ``surrogate`` by default.\n    unit: The unit's path, e.g. ``\"plant.ro\"``.\n    relation: The relation the surrogate replaces; the hook's default if\n        omitted.\n    surrogates: Surrogate spec tags, stored or fitted by ``fits``.",
      "properties": {
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Name"
        },
        "relation": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Relation"
        },
        "surrogates": {
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "title": "Surrogates",
          "type": "array"
        },
        "type": {
          "const": "surrogate",
          "title": "Type",
          "type": "string"
        },
        "unit": {
          "title": "Unit",
          "type": "string"
        }
      },
      "required": [
        "type",
        "unit",
        "surrogates"
      ],
      "title": "SurrogateSweep",
      "type": "object"
    },
    "Validation": {
      "additionalProperties": false,
      "description": "Hold out the end of the data to check the fit on.\n\nAttributes:\n    holdout: How much to hold out from the end, as a pandas offset (``\"7D\"``);\n        the fit uses the rows before it.",
      "properties": {
        "holdout": {
          "title": "Holdout",
          "type": "string"
        }
      },
      "required": [
        "holdout"
      ],
      "title": "Validation",
      "type": "object"
    },
    "VariableSweep": {
      "additionalProperties": false,
      "description": "Each task fixes the model variable at ``path`` to one of ``values``.\n\nThe values are passed to the build hook as overrides; for flex-pse each\nbecomes a ``fix`` element. Use it for variables (``\"plant.ro.recovery\"``);\nan option the unit is built with is a :class:`ConfigurationSweep`.\n\nAttributes:\n    name: The field ``output_name`` renders the value as; ``path`` by\n        default.\n    path: The variable's path from the model root, e.g.\n        ``\"plant.ro.recovery\"`` or ``\"plant.tank.level[*]\"``.\n    values: The values: numbers in the variable's units,\n        ``{\"value\", \"units\"}``, or one number per time point.",
      "properties": {
        "name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Name"
        },
        "path": {
          "title": "Path",
          "type": "string"
        },
        "type": {
          "const": "variable",
          "title": "Type",
          "type": "string"
        },
        "values": {
          "items": {},
          "minItems": 1,
          "title": "Values",
          "type": "array"
        }
      },
      "required": [
        "type",
        "path",
        "values"
      ],
      "title": "VariableSweep",
      "type": "object"
    },
    "Variant": {
      "additionalProperties": false,
      "description": "One fit of a :class:`FitParams` with ``variants``; set fields override the base.\n\nAttributes:\n    name: Rendered into the tag template as ``{name}``.\n\nThe other fields are those of :class:`FitParams`; ``None`` keeps the base's.",
      "properties": {
        "X": {
          "anyOf": [
            {
              "$ref": "#/$defs/Selector"
            },
            {
              "items": {
                "$ref": "#/$defs/Selector"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "X"
        },
        "name": {
          "title": "Name",
          "type": "string"
        },
        "params": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Params"
        },
        "prep": {
          "anyOf": [
            {
              "$ref": "#/$defs/Prep"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "regressor": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Regressor"
        },
        "spec_options": {
          "anyOf": [
            {
              "additionalProperties": true,
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Spec Options"
        },
        "validation": {
          "anyOf": [
            {
              "$ref": "#/$defs/Validation"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "window": {
          "anyOf": [
            {
              "$ref": "#/$defs/Window"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        },
        "y": {
          "anyOf": [
            {
              "$ref": "#/$defs/Selector"
            },
            {
              "items": {
                "$ref": "#/$defs/Selector"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Y"
        }
      },
      "required": [
        "name"
      ],
      "title": "Variant",
      "type": "object"
    },
    "Window": {
      "additionalProperties": false,
      "description": "A time window; either end may be open.\n\nAttributes:\n    start: Rows at or after this time (naive means UTC).\n    end: Rows at or before this time.",
      "properties": {
        "end": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "End"
        },
        "start": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Start"
        }
      },
      "title": "Window",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "description": "A study as data; see :mod:`flexorchestrator.study.config`.\n\nAttributes:\n    study: The study to run in, created if needed; the selected one if\n        omitted.\n    base_model_spec: The model spec every task builds from, unless a\n        ``spec_list`` sweep names others.\n    design: Run every task as a design study\n        (:class:`~flexorchestrator.study.config.DesignStudy`). Can't be combined\n        with ``model_inputs``.\n    fits: ``fit_surrogate`` parameters, run before the sweeps.\n    model_inputs: Model variables every task sets from stored data:\n        fit selectors, each column (after ``rename``) named by the path it\n        sets, lined up with the model's time steps.\n    hooks: See :class:`HooksConfig`.\n    sweeps: See :class:`SurrogateSweep`, :class:`VariableSweep`,\n        :class:`ConfigurationSweep`, :class:`SpecListSweep`,\n        :class:`ModelInputsSweep` and :class:`CasesSweep`.\n    combine: ``product`` (every combination) or ``zip`` (the sweeps in\n        step; they must be the same length).\n    solve_options: Passed to the solve hook. For flex-pse: ``prefer``,\n        ``tee``, ``warmstart``, ``mip_gap``, ``time_limit`` and ``options``.\n    export: See :class:`ExportConfig`.\n    output_name: Each task's tag, e.g.\n        ``\"ro_{surrogate}_{plant.ro.recovery}\"``: fields are the sweeps'\n        names, plus ``base`` and ``index``. By default the base tag and\n        each sweep's value, joined by ``_``. A value is written exactly\n        (``str``; ``0.1 + 0.2`` gives ``0.30000000000000004``) unless the\n        field has a format spec, as in Python: ``{recovery:.3g}``,\n        ``{price:.2f}``. The tag is only a name: the values themselves are\n        stored in full with the result. Values that format alike make\n        tags that repeat, which is refused before anything runs.\n    on_existing: When a task's tag is stored: ``error`` (checked before\n        anything runs), ``skip`` it (resume), or ``replace`` it.\n    execution: See :class:`Execution`.",
  "properties": {
    "base_model_spec": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Base Model Spec"
    },
    "combine": {
      "default": "product",
      "enum": [
        "product",
        "zip"
      ],
      "title": "Combine",
      "type": "string"
    },
    "design": {
      "anyOf": [
        {
          "$ref": "#/$defs/DesignStudy"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "execution": {
      "$ref": "#/$defs/Execution"
    },
    "export": {
      "$ref": "#/$defs/ExportConfig"
    },
    "fits": {
      "items": {
        "$ref": "#/$defs/FitParams"
      },
      "title": "Fits",
      "type": "array"
    },
    "hooks": {
      "$ref": "#/$defs/HooksConfig"
    },
    "model_inputs": {
      "items": {
        "$ref": "#/$defs/ModelInput"
      },
      "title": "Model Inputs",
      "type": "array"
    },
    "on_existing": {
      "default": "error",
      "enum": [
        "error",
        "skip",
        "replace"
      ],
      "title": "On Existing",
      "type": "string"
    },
    "output_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Output Name"
    },
    "solve_options": {
      "additionalProperties": true,
      "title": "Solve Options",
      "type": "object"
    },
    "study": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Study"
    },
    "sweeps": {
      "items": {
        "discriminator": {
          "mapping": {
            "cases": "#/$defs/CasesSweep",
            "configuration_option": "#/$defs/ConfigurationSweep",
            "model_inputs": "#/$defs/ModelInputsSweep",
            "spec_list": "#/$defs/SpecListSweep",
            "surrogate": "#/$defs/SurrogateSweep",
            "variable": "#/$defs/VariableSweep"
          },
          "propertyName": "type"
        },
        "oneOf": [
          {
            "$ref": "#/$defs/SurrogateSweep"
          },
          {
            "$ref": "#/$defs/VariableSweep"
          },
          {
            "$ref": "#/$defs/ConfigurationSweep"
          },
          {
            "$ref": "#/$defs/SpecListSweep"
          },
          {
            "$ref": "#/$defs/ModelInputsSweep"
          },
          {
            "$ref": "#/$defs/CasesSweep"
          }
        ]
      },
      "title": "Sweeps",
      "type": "array"
    }
  },
  "title": "StudyConfig",
  "type": "object"
}
