{
  "$defs": {
    "Criterion": {
      "additionalProperties": false,
      "description": "What makes one option better than another, read off each run's series.",
      "properties": {
        "description": {
          "default": "",
          "title": "Description",
          "type": "string"
        },
        "measure": {
          "description": "rises: how many times the series went from 0.5 or below to above it \u2014 a switch turning on",
          "enum": [
            "max",
            "min",
            "mean",
            "final",
            "rises"
          ],
          "title": "Measure",
          "type": "string"
        },
        "name": {
          "minLength": 1,
          "title": "Name",
          "type": "string"
        },
        "prefer": {
          "enum": [
            "lower",
            "higher"
          ],
          "title": "Prefer",
          "type": "string"
        },
        "series": {
          "minLength": 1,
          "title": "Series",
          "type": "string"
        },
        "weight": {
          "anyOf": [
            {
              "minimum": 0,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Its share in the penalty, when the criteria are weighed; left out, it is reported only",
          "title": "Weight"
        }
      },
      "required": [
        "name",
        "series",
        "measure",
        "prefer"
      ],
      "title": "Criterion",
      "type": "object"
    },
    "DecisionOption": {
      "additionalProperties": false,
      "properties": {
        "current": {
          "default": false,
          "description": "The way things are now: changing nothing",
          "title": "Current",
          "type": "boolean"
        },
        "description": {
          "default": "",
          "title": "Description",
          "type": "string"
        },
        "name": {
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
          "title": "Name",
          "type": "string"
        },
        "scenario": {
          "description": "The system with this option in place, as a scenario",
          "pattern": "^sha256:[0-9a-f]{64}$",
          "title": "Scenario",
          "type": "string"
        }
      },
      "required": [
        "name",
        "scenario"
      ],
      "title": "DecisionOption",
      "type": "object"
    },
    "Uncertain": {
      "additionalProperties": false,
      "description": "A parameter whose value is not known exactly, the law it follows, and\nwhere that law comes from.",
      "properties": {
        "basis": {
          "default": "",
          "description": "Where the law comes from: a datasheet, a measurement, a judgement",
          "title": "Basis",
          "type": "string"
        },
        "factor": {
          "anyOf": [
            {
              "exclusiveMinimum": 1,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "lognormal: the value is within median/factor and median*factor with 95% probability",
          "title": "Factor"
        },
        "high": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "High"
        },
        "law": {
          "enum": [
            "uniform",
            "normal",
            "triangular",
            "lognormal"
          ],
          "title": "Law",
          "type": "string"
        },
        "low": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Low"
        },
        "mean": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Mean"
        },
        "median": {
          "anyOf": [
            {
              "exclusiveMinimum": 0,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "lognormal: the median",
          "title": "Median"
        },
        "mode": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Mode"
        },
        "name": {
          "minLength": 1,
          "title": "Name",
          "type": "string"
        },
        "std": {
          "anyOf": [
            {
              "exclusiveMinimum": 0,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Std"
        }
      },
      "required": [
        "name",
        "law"
      ],
      "title": "Uncertain",
      "type": "object"
    }
  },
  "$id": "mokili.decision/1",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "A choice between options, made on simulations: each option runs on the same\ndraws of what is uncertain, so they are compared draw by draw. An option is\nadmissible when every requirement holds in the share `required` of its runs.\nWithout weights the first criterion ranks the admissible ones and the others\nare reported; with weights, each criterion is put on a 0\u20131 scale across every\nrun (0 the best value seen, 1 the worst) and the weighted mean is the penalty:\nthe option with the least is preferred.",
  "properties": {
    "confidence": {
      "default": 0.95,
      "exclusiveMaximum": 1,
      "exclusiveMinimum": 0,
      "title": "Confidence",
      "type": "number"
    },
    "criteria": {
      "description": "In order of priority: the first decides",
      "items": {
        "$ref": "#/$defs/Criterion"
      },
      "minItems": 1,
      "title": "Criteria",
      "type": "array"
    },
    "name": {
      "minLength": 1,
      "title": "Name",
      "type": "string"
    },
    "options": {
      "items": {
        "$ref": "#/$defs/DecisionOption"
      },
      "minItems": 2,
      "title": "Options",
      "type": "array"
    },
    "question": {
      "description": "What is to be decided",
      "minLength": 1,
      "title": "Question",
      "type": "string"
    },
    "required": {
      "default": 1.0,
      "description": "The share of runs in which each requirement must hold",
      "exclusiveMinimum": 0,
      "maximum": 1,
      "title": "Required",
      "type": "number"
    },
    "requirements": {
      "default": [],
      "items": {
        "pattern": "^sha256:[0-9a-f]{64}$",
        "type": "string"
      },
      "title": "Requirements",
      "type": "array"
    },
    "samples": {
      "default": 32,
      "description": "Draws of the uncertain parameters, shared by the options",
      "maximum": 10000,
      "minimum": 1,
      "title": "Samples",
      "type": "integer"
    },
    "schema": {
      "const": "mokili.decision/1",
      "title": "Schema",
      "type": "string"
    },
    "seed": {
      "default": 0,
      "minimum": 0,
      "title": "Seed",
      "type": "integer"
    },
    "uncertain": {
      "default": [],
      "items": {
        "$ref": "#/$defs/Uncertain"
      },
      "title": "Uncertain",
      "type": "array"
    }
  },
  "required": [
    "schema",
    "name",
    "question",
    "options",
    "criteria"
  ],
  "title": "Decision",
  "type": "object"
}
