{
  "format": "refined.math.adapter",
  "schemaVersion": 1,
  "adapterId": "math-model",
  "version": "0.6.0",
  "name": {
    "en": "Field equipment selection",
    "sk": "Výber terénnej výbavy"
  },
  "description": {
    "en": "Select equipment that meets cost and mass limits, group requirements and compatibility rules.",
    "sk": "Vyberte výbavu, ktorá spĺňa cenový a hmotnostný limit, požiadavky na zastúpenie skupín a pravidlá kompatibility."
  },
  "help": {
    "en": "Define the model in defaultTask.payload.model. Put item costs, masses, benefits and resource limits in its data field.",
    "sk": "Matematický model zapíšte do poľa defaultTask.payload.model. Ceny, hmotnosti, prínosy a kapacitné limity vložte do jeho poľa data."
  },
  "runtime": {
    "binding": "math-model",
    "coreRevision": "d2c02f944772b7f7a586c4f3357fc90e480349ad",
    "inputKey": "model"
  },
  "inputSchema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Refined Math ModelSpec v1",
    "description": "Importable mathematical model. Native validation additionally checks names, shapes, finite domains, numeric policy and checked arithmetic. Use strings for exact decimal, fraction or large integer data.",
    "type": "object",
    "additionalProperties": false,
    "required": [
      "schemaVersion",
      "title",
      "variables",
      "data",
      "constraints",
      "goal"
    ],
    "properties": {
      "schemaVersion": {
        "const": 1
      },
      "title": {
        "type": "string",
        "maxLength": 120
      },
      "numericPolicy": {
        "enum": [
          "auto",
          "exact",
          "real"
        ],
        "default": "auto"
      },
      "tolerance": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "absolute": {
            "type": "number",
            "minimum": 0,
            "maximum": 0.1,
            "default": 1e-8
          },
          "relative": {
            "type": "number",
            "minimum": 0,
            "maximum": 0.1,
            "default": 1e-8
          }
        }
      },
      "variables": {
        "type": "array",
        "minItems": 1,
        "maxItems": 16,
        "items": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "name",
            "kind",
            "shape",
            "lower",
            "upper"
          ],
          "properties": {
            "name": {
              "$ref": "#/$defs/name"
            },
            "kind": {
              "enum": [
                "integer",
                "binary",
                "permutation",
                "real"
              ]
            },
            "shape": {
              "type": "array",
              "minItems": 1,
              "maxItems": 2,
              "items": {
                "type": "integer",
                "minimum": 1,
                "maximum": 512
              }
            },
            "lower": {
              "$ref": "#/$defs/bound"
            },
            "upper": {
              "$ref": "#/$defs/bound"
            }
          }
        }
      },
      "data": {
        "type": "array",
        "maxItems": 32,
        "items": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "name",
            "values"
          ],
          "properties": {
            "name": {
              "$ref": "#/$defs/name"
            },
            "values": {
              "type": "array",
              "minItems": 1,
              "maxItems": 512,
              "items": {
                "$ref": "#/$defs/number"
              }
            }
          }
        }
      },
      "constraints": {
        "type": "array",
        "maxItems": 64,
        "items": {
          "$ref": "#/$defs/expression"
        }
      },
      "goal": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "mode"
        ],
        "properties": {
          "mode": {
            "enum": [
              "find",
              "minimize",
              "maximize",
              "count"
            ]
          },
          "expression": {
            "type": "string",
            "maxLength": 4096
          }
        },
        "allOf": [
          {
            "if": {
              "properties": {
                "mode": {
                  "enum": [
                    "minimize",
                    "maximize"
                  ]
                }
              }
            },
            "then": {
              "required": [
                "expression"
              ],
              "properties": {
                "expression": {
                  "$ref": "#/$defs/expression"
                }
              }
            }
          }
        ]
      }
    },
    "$defs": {
      "name": {
        "type": "string",
        "pattern": "^[A-Za-z_][A-Za-z0-9_]{0,31}$"
      },
      "expression": {
        "type": "string",
        "minLength": 1,
        "maxLength": 4096
      },
      "bound": {
        "description": "Discrete bounds must be integers within +/-1e9; real bounds within +/-1e12. Binary domains are 0..1.",
        "oneOf": [
          {
            "type": "number",
            "minimum": -1000000000000,
            "maximum": 1000000000000
          },
          {
            "$ref": "#/$defs/numberString"
          }
        ]
      },
      "numberString": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100,
        "pattern": "^[-+]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][-+]?[0-9]+)?(?:/[-+]?(?:[0-9]+(?:\\.[0-9]*)?|\\.[0-9]+)(?:[eE][-+]?[0-9]+)?)?$"
      },
      "number": {
        "oneOf": [
          {
            "$ref": "#/$defs/numberString"
          },
          {
            "type": "number",
            "description": "Exact mode accepts safe integer JSON numbers only. Prefer strings for portable exact data."
          }
        ]
      }
    }
  },
  "contract": {
    "state": {
      "en": "Eight binary values in the same item order as the parameter vectors.",
      "sk": "Osem binárnych hodnôt, ktorých poradie zodpovedá poradiu položiek v dátových vektoroch."
    },
    "score": {
      "en": "Six hard conditions; maximize total benefit among feasible candidates.",
      "sk": "Šesť povinných podmienok a maximalizácia celkového prínosu prípustných kandidátov."
    },
    "operators": {
      "en": [
        "Supported proposals for binary changes and exchanges, selected by the model compiler."
      ],
      "sk": [
        "Návrhy podporovaných binárnych zmien a výmen, ktoré vyberá prekladač modelu."
      ]
    },
    "output": {
      "en": "The pick vector, objective value, condition checks, numeric policy and available calculation statistics.",
      "sk": "Vektor pick, hodnota cieľovej funkcie, kontroly podmienok, numerická politika a dostupné štatistiky výpočtu."
    }
  },
  "defaultTask": {
    "format": "refined.math.task",
    "schemaVersion": 1,
    "adapterId": "math-model",
    "title": "Field equipment kit — budget 30",
    "payload": {
      "model": {
        "schemaVersion": 1,
        "title": "Field equipment kit — budget 30",
        "numericPolicy": "exact",
        "variables": [
          {
            "name": "pick",
            "kind": "binary",
            "shape": [
              8
            ],
            "lower": 0,
            "upper": 1
          }
        ],
        "data": [
          {
            "name": "cost",
            "values": [
              "9",
              "7",
              "8",
              "6",
              "5",
              "4",
              "10",
              "3"
            ]
          },
          {
            "name": "mass",
            "values": [
              "3",
              "4",
              "5",
              "2",
              "4",
              "1",
              "6",
              "2"
            ]
          },
          {
            "name": "benefit",
            "values": [
              "18",
              "16",
              "20",
              "13",
              "14",
              "9",
              "24",
              "8"
            ]
          },
          {
            "name": "budget",
            "values": [
              "30"
            ]
          },
          {
            "name": "massLimit",
            "values": [
              "16"
            ]
          }
        ],
        "constraints": [
          "sum(pick) == 4",
          "dot(pick, cost) <= budget",
          "dot(pick, mass) <= massLimit",
          "pick[1]+pick[2] >= 1",
          "pick[3]+pick[4] >= 1",
          "pick[2]+pick[7] <= 1"
        ],
        "goal": {
          "mode": "maximize",
          "expression": "dot(pick, benefit)"
        }
      }
    },
    "options": {
      "seed": 42,
      "timeLimitMs": 3000,
      "maxEvaluations": 200000,
      "maxWorkUnits": 50000000
    }
  },
  "samples": [
    {
      "id": "field-kit-budget30",
      "name": {
        "en": "Budget 30",
        "sk": "Rozpočet 30"
      },
      "expected": {
        "en": "Independent reference: items 1, 3, 7, 8; cost 30; mass 16; benefit 70.",
        "sk": "Nezávislá referencia: položky 1, 3, 7, 8; cena 30; hmotnosť 16; prínos 70."
      },
      "task": {
        "format": "refined.math.task",
        "schemaVersion": 1,
        "adapterId": "math-model",
        "title": "Field equipment kit — budget 30",
        "payload": {
          "model": {
            "schemaVersion": 1,
            "title": "Field equipment kit — budget 30",
            "numericPolicy": "exact",
            "variables": [
              {
                "name": "pick",
                "kind": "binary",
                "shape": [
                  8
                ],
                "lower": 0,
                "upper": 1
              }
            ],
            "data": [
              {
                "name": "cost",
                "values": [
                  "9",
                  "7",
                  "8",
                  "6",
                  "5",
                  "4",
                  "10",
                  "3"
                ]
              },
              {
                "name": "mass",
                "values": [
                  "3",
                  "4",
                  "5",
                  "2",
                  "4",
                  "1",
                  "6",
                  "2"
                ]
              },
              {
                "name": "benefit",
                "values": [
                  "18",
                  "16",
                  "20",
                  "13",
                  "14",
                  "9",
                  "24",
                  "8"
                ]
              },
              {
                "name": "budget",
                "values": [
                  "30"
                ]
              },
              {
                "name": "massLimit",
                "values": [
                  "16"
                ]
              }
            ],
            "constraints": [
              "sum(pick) == 4",
              "dot(pick, cost) <= budget",
              "dot(pick, mass) <= massLimit",
              "pick[1]+pick[2] >= 1",
              "pick[3]+pick[4] >= 1",
              "pick[2]+pick[7] <= 1"
            ],
            "goal": {
              "mode": "maximize",
              "expression": "dot(pick, benefit)"
            }
          }
        },
        "options": {
          "seed": 42,
          "timeLimitMs": 3000,
          "maxEvaluations": 200000,
          "maxWorkUnits": 50000000
        }
      }
    },
    {
      "id": "field-kit-budget27",
      "name": {
        "en": "Budget 27",
        "sk": "Rozpočet 27"
      },
      "expected": {
        "en": "Independent reference: items 2, 3, 4, 5; cost 26; mass 15; benefit 63.",
        "sk": "Nezávislá referencia: položky 2, 3, 4, 5; cena 26; hmotnosť 15; prínos 63."
      },
      "task": {
        "format": "refined.math.task",
        "schemaVersion": 1,
        "adapterId": "math-model",
        "title": "Field equipment kit — budget 27",
        "payload": {
          "model": {
            "schemaVersion": 1,
            "title": "Field equipment kit — budget 27",
            "numericPolicy": "exact",
            "variables": [
              {
                "name": "pick",
                "kind": "binary",
                "shape": [
                  8
                ],
                "lower": 0,
                "upper": 1
              }
            ],
            "data": [
              {
                "name": "cost",
                "values": [
                  "9",
                  "7",
                  "8",
                  "6",
                  "5",
                  "4",
                  "10",
                  "3"
                ]
              },
              {
                "name": "mass",
                "values": [
                  "3",
                  "4",
                  "5",
                  "2",
                  "4",
                  "1",
                  "6",
                  "2"
                ]
              },
              {
                "name": "benefit",
                "values": [
                  "18",
                  "16",
                  "20",
                  "13",
                  "14",
                  "9",
                  "24",
                  "8"
                ]
              },
              {
                "name": "budget",
                "values": [
                  "27"
                ]
              },
              {
                "name": "massLimit",
                "values": [
                  "16"
                ]
              }
            ],
            "constraints": [
              "sum(pick) == 4",
              "dot(pick, cost) <= budget",
              "dot(pick, mass) <= massLimit",
              "pick[1]+pick[2] >= 1",
              "pick[3]+pick[4] >= 1",
              "pick[2]+pick[7] <= 1"
            ],
            "goal": {
              "mode": "maximize",
              "expression": "dot(pick, benefit)"
            }
          }
        },
        "options": {
          "seed": 42,
          "timeLimitMs": 3000,
          "maxEvaluations": 200000,
          "maxWorkUnits": 50000000
        }
      }
    }
  ]
}
