├── .github └── workflows │ └── python.yaml ├── .gitignore ├── LICENSE ├── README.md ├── examples ├── biobjective.mof.json ├── cpsat.mof.json ├── milp.mof.json ├── nlp.mof.json ├── quadratic.mof.json ├── scaled.json └── vector.mof.json ├── python └── mof.py └── schemas ├── mof.0.4.schema.json ├── mof.0.5.schema.json ├── mof.0.6.schema.json ├── mof.1.0.schema.json ├── mof.1.1.schema.json ├── mof.1.2.schema.json ├── mof.1.3.schema.json ├── mof.1.4.schema.json ├── mof.1.5.schema.json ├── mof.1.6.schema.json ├── mof.1.7.schema.json └── mof.1.schema.json /.github/workflows/python.yaml: -------------------------------------------------------------------------------- 1 | name: Test Python 2 | on: [push] 3 | jobs: 4 | build: 5 | runs-on: ubuntu-latest 6 | strategy: 7 | matrix: 8 | python-version: ['3.10'] 9 | steps: 10 | - uses: actions/checkout@v2 11 | - name: Set up Python ${{ matrix.python-version }} 12 | uses: actions/setup-python@v2 13 | with: 14 | python-version: ${{ matrix.python-version }} 15 | - name: Install dependencies 16 | run: | 17 | python -m pip install --upgrade pip 18 | pip install jsonschema 19 | - name: Test 20 | run: | 21 | cd python 22 | python mof.py 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Oscar Dowson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MathOptFormat 2 | 3 | This repository describes a file-format for mathematical optimization problems 4 | called _MathOptFormat_ with the file extension `.mof.json`. 5 | 6 | MathOptFormat is rigidly defined by the [JSON schema](http://json-schema.org/) 7 | available at 8 | [`https://jump.dev/MathOptFormat/schemas/mof.1.schema.json`](https://jump.dev/MathOptFormat/schemas/mof.1.schema.json). 9 | 10 | It is intended for the schema to be self-documenting. Instead of modifying or 11 | adding to this documentation, clarifying edits should be made to the 12 | `description` field of the relevant part of the schema. 13 | 14 | A number of examples of optimization problems encoded using MathOptFormat are 15 | provided in the [`/examples` directory](https://github.com/jump-dev/MathOptFormat/tree/master/examples). 16 | 17 | A paper describing the motivation, design principles, and historical setting of 18 | MathOptFormat is available at: 19 | 20 | Legat, B., Dowson, O., Garcia, J., Lubin, M. (2022). MathOptInterface: a data 21 | structure for mathematical optimization problems. INFORMS Journal on Computing. 22 | 34(2), 671--1304. [[preprint]](http://www.optimization-online.org/DB_HTML/2020/02/7609.html) 23 | 24 | ## Implementations 25 | 26 | - Julia 27 | 28 | - The [MathOptInterface.jl](https://github.com/jump-dev/MathOptInterface.jl) package 29 | supports reading and writing MathOptFormat files. 30 | 31 | ## Standard form 32 | 33 | MathOptFormat is a generic file format for mathematical optimization problems 34 | encoded in the form 35 | 36 | min/max: f₀(x) 37 | subject to: fᵢ(x) ∈ Sᵢ i=1,2,…,I 38 | 39 | where `x ∈ ℝᴺ`, `fᵢ: ℝᴺ → ℝᴹⁱ`, and `Sᵢ ⊆ ℝᴹⁱ`. 40 | 41 | The functions `fᵢ` and sets `Sᵢ` supported by MathOptFormat are defined in the 42 | [MathOptFormat schema](#the-schema). 43 | 44 | The current list of supported functions and sets is not exhaustive. It is 45 | intended that MathOptFormat will be extended in future versions to support 46 | additional functions and sets. 47 | 48 | ## An example 49 | 50 | The standard form described above is very general. To give a concrete example, 51 | consider the following linear program: 52 | 53 | min: 2x + 1 54 | subject to: x ≥ 1 55 | 56 | Encoded in our standard form, we have 57 | 58 | f₀(x) = 2x + 1 59 | f₁(x) = x 60 | S₁ = [1, ∞) 61 | 62 | Encoded into the MathOptFormat file format, this example becomes: 63 | ```json 64 | { 65 | "version": { 66 | "major": 1, 67 | "minor": 4 68 | }, 69 | "variables": [{"name": "x"}], 70 | "objective": { 71 | "sense": "min", 72 | "function": { 73 | "type": "ScalarAffineFunction", 74 | "terms": [ 75 | {"coefficient": 2, "variable": "x"} 76 | ], 77 | "constant": 1 78 | } 79 | }, 80 | "constraints": [{ 81 | "name": "x >= 1", 82 | "function": {"type": "Variable", "name": "x"}, 83 | "set": {"type": "GreaterThan", "lower": 1} 84 | }] 85 | } 86 | ``` 87 | 88 | Let us now describe each part of the file format in turn. First, notice that the 89 | file format is a valid JSON (JavaScript Object Notation) file. This enables the 90 | MathOptFormat to be both _human-readable_, and _machine-readable_. Some readers 91 | may argue that JSON is tricky to edit as a human due to the quantity of brackets 92 | and "boiler-plate" such as `"function"` and `"type"`. We do not disagree. 93 | However, we believe that JSON strikes a fine balance between human and machine 94 | readability. 95 | 96 | Inside the document, the model is stored as a single JSON object. JSON objects 97 | are key-value mappings enclosed by curly braces (`{` and `}`). There are four 98 | required keys at the top level: 99 | 100 | - `"version"` 101 | 102 | An object describing the minimum version of MathOptFormat needed to parse 103 | the file. This is included to safeguard against later revisions. It contains 104 | two fields: `"major"` and `"minor"`. These fields should be interpreted 105 | using [SemVer](https://semver.org). 106 | 107 | - `"variables"` 108 | 109 | A list of JSON objects, with one object for each variable in the model. Each 110 | object has a required key `"name"` which maps to a unique string for that 111 | variable. It is illegal to have two variables with the same name. These names 112 | will be used later in the file to refer to each variable. 113 | 114 | - `"objective"` 115 | 116 | A JSON objects describing the objective of the model. It has one required 117 | keys: 118 | 119 | - `"sense"` 120 | 121 | A string which must be `"min"`, `"max"`, or `"feasibility"`. If the sense 122 | is `min` or `max`, a second key `"function"`, must be defined: 123 | 124 | - `"function"` 125 | 126 | A JSON object that describes the function. There are many different types 127 | of functions that MathOptFormat recognizes (see 128 | [List of supported functions](#list-of-supported-functions)), each of 129 | which has a different structure. However, each function has a required key 130 | called `"type"` which is used to describe the type of the function. In 131 | this case, the function is `"ScalarAffineFunction"`. 132 | 133 | A `"ScalarAffineFunction"` is the function `f(x) = aᵀx + b`, where `a` is 134 | a constant `N×1` vector, and `b` is a scalar constant. In addition to 135 | `"type"`, it has two required keys: 136 | 137 | - `"terms"` 138 | 139 | A list of JSON objects, containing one object for each non-zero element 140 | in `a`. Each object has two required keys: `"coefficient"`, and 141 | `"variable"`. `"coefficient"` maps to a real number that is the 142 | coefficient in `a` corresponding to the variable (identified by its 143 | string name) in `"variable"`. 144 | 145 | - `"constant"` 146 | 147 | The value of `b`. 148 | 149 | - `"constraints"` 150 | 151 | A list of JSON objects, with one element for each constraint in the model. 152 | Each object has three required fields: 153 | 154 | - `"name"` 155 | 156 | A unique string name for the constraint. 157 | 158 | - `"function"` 159 | 160 | A JSON object that describes the function `gⱼ` associated with constraint 161 | `j`. The function field is similar to the function field in 162 | `"objectives"`; however, in this example, our function is a single 163 | variable function of the variable `"x"`. 164 | 165 | - `"set"` 166 | 167 | A JSON object that describes the set `Sⱼ` associated with constraint `j`. 168 | In this example, the set `[1, ∞)` is the MathOptFormat set `GreaterThan` 169 | with a lower bound of `1`. See [List of supported sets](#list-of-supported-sets) 170 | for other sets supported by MathOptFormat. 171 | 172 | ### List of supported functions 173 | 174 | The list of functions supported by MathOptFormat are contained in the 175 | `#/definitions/scalar_functions` and `#/definitions/vector_functions` fields of 176 | the schema. Scalar functions are functions for which `Mi=1`, while vector 177 | functions are functions for which `Mi≥1`. 178 | 179 | Here is a summary of the functions defined by MathOptFormat. 180 | 181 | #### Scalar Functions 182 | 183 | | Name | Description | Example | 184 | | ---- | ----------- | ------- | 185 | | `"Variable"` | The scalar variable `x`. | {"type": "Variable", "name": "x"} | 186 | | `"ScalarAffineFunction"` | The function `a'x + b`, where `a` is a sparse vector specified by a list of `ScalarAffineTerm`s in `terms` and `b` is the scalar in `constant`. Duplicate variables in `terms` are accepted, and the corresponding coefficients are summed together. | {"type": "ScalarAffineFunction", "constant": 1.0, "terms": [{"coefficient": 2.5, "variable": "x"}]} | 187 | | `"ScalarQuadraticFunction"` | The function `0.5x'Qx + a'x + b`, where `a` is a sparse vector of `ScalarAffineTerm`s in `affine_terms`, `b` is the scalar `constant`, and `Q` is a symmetric matrix specified by a list of `ScalarQuadraticTerm`s in `quadratic_terms`. Duplicate indices in `affine_terms` and `quadratic` are accepted, and the corresponding coefficients are summed together. Mirrored indices in `quadratic_terms` (i.e., `(i,j)` and `(j, i)`) are considered duplicates; only one need to be specified. | {"type": "ScalarQuadraticFunction", "constant": 1.0, "affine_terms": [{"coefficient": 2.5, "variable": "x"}], "quadratic_terms": [{"coefficient": 2.0, "variable_1": "x", "variable_2": "y"}]} | 188 | | `"ScalarNonlinearFunction"` | An expression graph representing a scalar nonlinear function. | | 189 | 190 | For more information on `"ScalarNonlinearFunction"` functions, see 191 | [Nonlinear functions](nonlinear-functions). 192 | 193 | #### Vector Functions 194 | 195 | | Name | Description | Example | 196 | | ---- | ----------- | ------- | 197 | | `"VectorOfVariables"` | An ordered list of variables. | {"type": "VectorOfVariables", "variables": ["x", "y"]} | 198 | | `"VectorAffineFunction"` | The function `Ax + b`, where `A` is a sparse matrix specified by a list of `VectorAffineTerm`s in `terms` and `b` is a dense vector specified by `constants`. | {"type": "VectorAffineFunction", "constants": [1.0], "terms": [{"output_index": 1, "scalar_term": {"coefficient": 2.5, "variable": "x"}}]} | 199 | | `"VectorQuadraticFunction"` | The vector-valued quadratic function `q(x) + Ax + b`, where `q(x)` is specified by a list of `VectorQuadraticTerm`s in `quadratic_terms`, `A` is a sparse matrix specified by a list of `VectorAffineTerm`s in `affine_terms` and `b` is a dense vector specified by `constants`. | | 200 | | `"VectorNonlinearFunction"` | The vector-valued nonlinear function `f(x)`, comprised of a vector of `ScalarNonlinearFunction`. | | 201 | 202 | ### List of supported sets 203 | 204 | The list of sets supported by MathOptFormat are contained in the 205 | `#/definitions/scalar_sets` and `#/definitions/vector_sets` fields of the 206 | schema. Scalar sets are sets for which `Mj=1`, while vector sets are sets for 207 | which `Mj≥1`. 208 | 209 | Here is a summary of the sets defined by MathOptFormat. 210 | 211 | #### Scalar Sets 212 | 213 | | Name | Description | Example | 214 | | ---- | ----------- | ------- | 215 | | `"LessThan"` | (-∞, upper] | {"type": "LessThan", "upper": 2.1} | 216 | | `"GreaterThan"` | [lower, ∞) | {"type": "GreaterThan", "lower": 2.1} | 217 | | `"EqualTo"` | {value} | {"type": "EqualTo", "value": 2.1} | 218 | | `"Interval"` | [lower, upper] | {"type": "Interval", "lower": 2.1, "upper": 3.4} | 219 | | `"Semiinteger"` | {0} ∪ {lower, lower + 1, ..., upper} | {"type": "Semiinteger", "lower": 2, "upper": 4} | 220 | | `"Semicontinuous"` | {0} ∪ [lower, upper] | {"type": "Semicontinuous", "lower": 2.1, "upper": 3.4} | 221 | | `"ZeroOne"` | {0, 1} | {"type": "ZeroOne"} | 222 | | `"Integer"` | ℤ | {"type": "Integer"} | 223 | | `"Parameter"` | {value} | {"type": "Parameter", "value": 2.1} | 224 | 225 | #### Vector Sets 226 | 227 | | Name | Description | Example | 228 | | ---- | ----------- | ------- | 229 | | `"ExponentialCone"` | [x, y, z] ∈ {R³: y * exp(x / y) ≤ z, y ≥ 0} | {"type": "ExponentialCone"} | 230 | | `"DualExponentialCone"` | [u, v, w] ∈ {R³: -u * exp(v / u) ≤ exp(1) * w, u < 0} | {"type": "DualExponentialCone"} | 231 | | `"SOS1"` | A special ordered set of type I. | {"type": "SOS1", "weights": [1, 3, 2]} | 232 | | `"SOS2"` | A special ordered set of type II. | {"type": "SOS2", "weights": [1, 3, 2]} | 233 | | `"GeometricMeanCone"` | [t, x] ∈ {R^{dimension}: t ≤ (Πxᵢ)^{1 / (dimension-1)}} | {"type": "GeometricMeanCone", "dimension": 3} | 234 | | `"SecondOrderCone"` | [t, x] ∈ {R^{dimension} : t ≥ \|\|x\|\|₂ | {"type": "SecondOrderCone", "dimension": 3} | 235 | | `"RotatedSecondOrderCone"` | [t, u, x] ∈ {R^{dimension} : 2tu ≥ (\|\|x\|\|₂)²; t, u ≥ 0} | {"type": "RotatedSecondOrderCone", "dimension": 3} | 236 | | `"Zeros"` | {0}^{dimension} | {"type": "Zeros", "dimension": 3} | 237 | | `"Reals"` | R^{dimension} | {"type": "Reals", "dimension": 3} | 238 | | `"Nonpositives"` | R₋^{dimension} | {"type": "Nonpositives", "dimension": 3} | 239 | | `"Nonnegatives"` | R₊^{dimension} | {"type": "Nonnegatives", "dimension": 3} | 240 | | `"RootDetConeTriangle"` | {[t, X] ∈ R^{1 + d(d+1)/2} : t ≤ det(X)^{1/d}}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeTriangle`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns. | {"type": "RootDetConeTriangle", "side_dimension": 2} | 241 | | `"RootDetConeSquare"` | {[t, X] ∈ R^{1 + d^2} : t ≤ det(X)^{1/d}, X symmetric}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeSquare`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns. | {"type": "RootDetConeSquare", "side_dimension": 2} | 242 | | `"LogDetConeTriangle"` | {[t, u, X] ∈ R^{2 + d(d+1)/2} : t ≤ u log(det(X/u)), u > 0}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeTriangle`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns. | {"type": "LogDetConeTriangle", "side_dimension": 2} | 243 | | `"LogDetConeSquare"` | {[t, u, X] ∈ R^{2 + d^2} : t ≤ u log(det(X/u)), X symmetric, u > 0}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeSquare`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns. | {"type": "LogDetConeSquare", "side_dimension": 2} | 244 | | `"PositiveSemidefiniteConeTriangle"` | The (vectorized) cone of symmetric positive semidefinite matrices, with `side_dimension` rows and columns. The entries of the upper-right triangular part of the matrix are given column by column (or equivalently, the entries of the lower-left triangular part are given row by row). | {"type": "PositiveSemidefiniteConeTriangle", "side_dimension": 2} | 245 | | `"ScaledPositiveSemidefiniteConeTriangle"` | The (vectorized) cone of symmetric positive semidefinite matrices, with `side_dimension` rows and columns, such that the off-diagonal entries are scaled by √2. The entries of the upper-right triangular part of the matrix are given column by column (or equivalently, the entries of the lower-left triangular part are given row by row). | {"type": "ScaledPositiveSemidefiniteConeTriangle", "side_dimension": 2} | 246 | | `"PositiveSemidefiniteConeSquare"` | The cone of symmetric positive semidefinite matrices, with side length `side_dimension`. The entries of the matrix are given column by column (or equivalently, row by row). The matrix is both constrained to be symmetric and to be positive semidefinite. That is, if the functions in entries `(i, j)` and `(j, i)` are different, then a constraint will be added to make sure that the entries are equal. | {"type": "PositiveSemidefiniteConeSquare", "side_dimension": 2} | 247 | | `"PowerCone"` | [x, y, z] ∈ {R³: x^{exponent} y^{1-exponent} ≥ \|z\|; x, y ≥ 0} | {"type": "PowerCone", "exponent": 2.0} | 248 | | `"DualPowerCone"` | [u, v, w] ∈ {R³: (u / exponent)^{exponent} (v / (1-exponent))^{1-exponent} ≥ \|w\|; u, v ≥ 0} | {"type": "DualPowerCone", "exponent": 2.0} | 249 | | `"Indicator"` | If `activate_on=one`: (y, x) ∈ {0,1}×Rᴺ: y = 0 ⟹ x ∈ S, otherwise when `activate_on=zero`: (y, x) ∈ {0,1}×Rᴺ: y = 1 ⟹ x ∈ S. | {"type": "Indicator", "set": {"type": "LessThan", "upper": 2.0}, "activate_on": "one"} | 250 | | `"NormOneCone"` | (t, x) ∈ {R^{dimension}: t ≥ Σᵢ\|xᵢ\|} | {"type": "NormOneCone", "dimension": 2} | 251 | | `"NormInfinityCone"` | (t, x) ∈ {R^{dimension}: t ≥ maxᵢ\|xᵢ\|} | {"type": "NormInfinityCone", "dimension": 2} | 252 | | `"RelativeEntropyCone"` | (u, v, w) ∈ {R^{dimension}: u ≥ Σᵢ wᵢlog(wᵢ/vᵢ), vᵢ ≥ 0, wᵢ ≥ 0} | {"type": "RelativeEntropyCone", "dimension": 3} | 253 | | `"NormSpectralCone"` | (t, X) ∈ {R^{1+row_dim×column_dim}: t ≥ σ₁(X)} | {"type": "NormSpectralCone", "row_dim": 1, "column_dim": 2} | 254 | | `"NormNuclearCone"` | (t, X) ∈ {R^{1+row_dim×column_dim}: t ≥ Σᵢ σᵢ(X)} | {"type": "NormNuclearCone", "row_dim": 1, "column_dim": 2} | 255 | | `"Complements"` | The set corresponding to a mixed complementarity constraint. Complementarity constraints should be specified with an AbstractVectorFunction-in-Complements(dimension) constraint. The dimension of the vector-valued function `F` must be `dimension`. This defines a complementarity constraint between the scalar function `F[i]` and the variable in `F[i + dimension/2]`. Thus, `F[i + dimension/2]` must be interpretable as a single variable `x_i` (e.g., `1.0 * x + 0.0`). The mixed complementarity problem consists of finding `x_i` in the interval `[lb, ub]` (i.e., in the set `Interval(lb, ub)`), such that the following holds: 1. `F_i(x) == 0` if `lb_i < x_i < ub_i`; 2. `F_i(x) >= 0` if `lb_i == x_i`; 3. `F_i(x) <= 0` if `x_i == ub_i`. Classically, the bounding set for `x_i` is `Interval(0, Inf)`, which recovers: `0 <= F_i(x) ⟂ x_i >= 0`, where the `⟂` operator implies `F_i(x) * x_i = 0`. | {"type": "Complements", "dimension": 2} | 256 | | `"AllDifferent"` | The set {x in Z^d} such that no two elements in x take the same value and dimension=d. | {"type": "AllDifferent", "dimension": 2} | 257 | | `"BinPacking"` | The set `{x in Z^d}` where `d = length(w)`, such that each item `i` in `1:d` of weight `w[i]` is put into bin `x[i]`, and the total weight of each bin does not exceed `c`. | {"type": "BinPacking", "capacity": 3.0, "weights": [1.0, 2.0, 3.0]} | 258 | | `"Circuit"` | The set `{x in {1..d}^d}` that constraints `x` to be a circuit, such that `x_i = j` means that `j` is the successor of `i`, and `dimension = d`. | {"type": "Circuit", "dimension": 3} | 259 | | `"CountAtLeast"` | The set `{x in Z^{d_1 + d_2 + ldots d_N}}`, where `x` is partitioned into `N` subsets (`{x_1, ldots, x_{d_1}}`, `{x_{d_1 + 1}, ldots, x_{d_1 + d_2}}` and so on), and at least `n` elements of each subset take one of the values in `set`. | {"type": "CountAtLeast", "n": 1, "partitions": [2, 2], "set": [3]} | 260 | | `"CountBelongs"` | The set `{(n, x) in Z^{1+d}}`, such that `n` elements of the vector `x` take on of the values in `set` and `dimension = 1 + d`. | {"type": "CountBelongs", "dimension": 3, "set": [3, 4, 5]} | 261 | | `"CountDistinct"` | The set `{(n, x) in Z^{1+d}}`, such that the number of distinct values in `x` is `n` and `dimension = 1 + d`. | {"type": "CountDistinct", "dimension": 3} | 262 | | `"CountGreaterThan"` | The set `{(c, y, x) in Z^{1+1+d}}`, such that `c` is strictly greater than the number of occurances of `y` in `x` and `dimension = 1 + 1 + d`. | {"type": "CountGreaterThan", "dimension": 3} | 263 | | `"Cumulative"` | The set `{(s, d, r, b) in Z^{3n+1}}`, representing the `cumulative` global constraint, where `n == length(s) == length(r) == length(b)` and `dimension = 3n + 1`. `Cumulative` requires that a set of tasks given by start times `s`, durations `d`, and resource requirements `r`, never requires more than the global resource bound `b` at any one time. | {"type": "Cumulative", "dimension": 10} | 264 | | `"Path"` | Given a graph comprised of a set of nodes `1..N` and a set of arcs `1..E` represented by an edge from node `from[i]` to node `to[i]`, `Path` constrains the set `(s, t, ns, es) in (1..N)times(1..E)times{0,1}^Ntimes{0,1}^E`, to form subgraph that is a path from node `s` to node `t`, where node `n` is in the path if `ns[n]` is `1`, and edge `e` is in the path if `es[e]` is `1`. The path must be acyclic, and it must traverse all nodes `n` for which `ns[n]` is `1`, and all edges `e` for which `es[e]` is `1`. | {"type": "Path", "from": [1, 1, 2, 2, 3], "to": [2, 3, 3, 4, 4]} | 265 | | `"Table"` | The set `{x in R^d}` where `d = size(table, 2)`, such that `x` belongs to one row of `table`. That is, there exists some `j` in `1:size(table, 1)`, such that `x[i] = table[j, i]` for all `i=1:size(table, 2)`. | {"type": "Table", "table": [[1, 1, 0], [0, 1, 1]]} | 266 | | `"Reified"` | (z, f(x)) ∈ {R^{dimension}: z iff f(x) ∈ S} | {"type": "Reified", "set": {"type": "GreaterThan", "lower": 0}} | 267 | | `"HyperRectangle"` | x ∈ {R^d: x_i ∈ [lower_i, upper_i]} | {"type": "HyperRectangle", "lower": [0, 0], "upper": [1, 1]} | 268 | | `"HermitianPositiveSemidefiniteConeTriangle"` | The (vectorized) cone of Hermitian positive semidefinite matrices, with non-negative side_dimension rows and columns. | {"type": "HermitianPositiveSemidefiniteConeTriangle", "side_dimension": 3} | 269 | | `"NormCone"` | The p-norm cone (t, x) ∈ {R^d : t ≥ (Σᵢ\|xᵢ\|^p)^(1/p)}. | {"type": "NormCone", "dimension": 3, "p": 1.5} | 270 | | `"Scaled"` | The set in the `set` field, scaled such that the inner product of two elements in the set is the same as the dot product of the two vector functions. This is most useful for solvers which require PSD matrices in _scaled_ form. | {"type": "Scaled", "set": {"type": "PositiveSemidefiniteConeTriangle", "side_dimension": 2}} | 271 | 272 | ### Nonlinear functions 273 | 274 | Nonlinear functions are encoded in MathOptFormat by an expression graph. Each 275 | expression graphs is stored in Polish prefix notation. For example, the 276 | nonlinear expression `sin²(x)` is expressed as `^(sin(x), 2)`. 277 | 278 | The expression graph is stored as an object with three required fields: 279 | `"type"`, which must be `"ScalarNonlinearFunction"`, as well as `"root"` and 280 | `"node_list"`. 281 | 282 | `"root"` contains an object defining the root node of the expression graph. All 283 | other nodes are stored as a flattened list in the `"node_list"` field. We 284 | elaborate on permissible nodes and how to store them in the following 285 | subsections. 286 | 287 | #### Leaf nodes 288 | 289 | Leaf nodes in the expression graph are data: they can either reference 290 | optimization variables, or be real or complex valued numeric constants. They are 291 | described as follows. 292 | 293 | | Type | Description | Example | 294 | | ---- | ----------- | ------- | 295 | | `number` | A real-valued numeric constant | 1.0 | 296 | | `string` | A reference to an optimization variable | "x" | 297 | | `{"type": "complex"}` | A complex-valued numeric constant | {"type": "complex", "real": 1.0, "imag": 2.0} | 298 | 299 | Nodes in the flattened list `"node_list"` can be referenced by an object with 300 | the `"type"` field `"node"` and a field `"index"` that is the one-based index of 301 | the node in `"node_list"`. 302 | 303 | | Head | Description | Example | 304 | | ---- | ----------- | ------- | 305 | | `"node"` | A pointer to a (1-indexed) element in the `node_list` field in a nonlinear function | {"type": "node", "index": 2} | 306 | 307 | #### Operators 308 | 309 | All nonlinear operators in MathOptFormat are described by a JSON object with two 310 | fields: 311 | 312 | - `"type"`: A string that corresponds to the operator. 313 | - `"args"`: An ordered list of nodes that are passed as arguments to the 314 | operator. 315 | 316 | The number of elements in `"args"` depends on the arity of the operator. 317 | MathOptFormat distinguishes between three arities: 318 | 319 | - Unary operators take one argument 320 | - Binary operators take two arguments 321 | - N-ary operators take at least one argument 322 | 323 | To give some examples, the unary function `log(x)` is encoded as: 324 | ```json 325 | {"type": "log", "args": ["x"]} 326 | ``` 327 | The binary function `x^2` (i.e., `^(x, 2)`) is encoded as: 328 | ```json 329 | {"type": "^", "args": ["x", 2]} 330 | ``` 331 | The n-ary function `x + y + 1` (i.e., `+(x, y, 1)`) is encoded as: 332 | ```json 333 | {"type": "+", "args": ["x", "y", 1.0]} 334 | ``` 335 | 336 | Here is a complete list of the nonlinear operators supported by MathOptFormat 337 | and their corresponding arity. 338 | 339 | | Arity | Operators | 340 | | ----- | --------- | 341 | | Unary | `"abs"`, `"sqrt"`, `"cbrt"`, `"abs2"`, `"inv"`, `"log"`, `"log10"`, `"log2"`, `"log1p"`, `"exp"`, `"exp2"`, `"expm1"`, `"sin"`, `"cos"`, `"tan"`, `"sec"`, `"csc"`, `"cot"`, `"sind"`, `"cosd"`, `"tand"`, `"secd"`, `"cscd"`, `"cotd"`, `"asin"`, `"acos"`, `"atan"`, `"asec"`, `"acsc"`, `"acot"`, `"asind"`, `"acosd"`, `"atand"`, `"asecd"`, `"acscd"`, `"acotd"`, `"sinh"`, `"cosh"`, `"tanh"`, `"sech"`, `"csch"`, `"coth"`, `"asinh"`, `"acosh"`, `"atanh"`, `"asech"`, `"acsch"`, `"acoth"`, `"deg2rad"`, `"rad2deg"`, `"erf"`, `"erfinv"`, `"erfc"`, `"erfcinv"`, `"erfi"`, `"gamma"`, `"lgamma"`, `"digamma"`, `"invdigamma"`, `"trigamma"`, `"airyai"`, `"airybi"`, `"airyaiprime"`, `"airybiprime"`, `"besselj0"`, `"besselj1"`, `"bessely0"`, `"bessely1"`, `"erfcx"`, `"dawson"`, `"floor"`, `"ceil"` | 342 | | Binary | `"/"`, `"^"`, `"atan"`, `"&&"`, `"\|\|"`, `"<="`, `"<"`, `">="`, `">"`, `"=="` | 343 | | N-ary | `"+"`, `"-"`, `"*"`, `"ifelse"`, `"min"`, `"max"` | 344 | 345 | #### Example 346 | 347 | As an example, consider the function `f(x, y) = (1 + 3i) * x + sin^2(x) + y`. 348 | 349 | In Polish notation, the expression graph is: 350 | `f(x, y) = +(*(1 + 3i, x), ^(sin(x), 2), y)`. 351 | 352 | In MathOptFormat, this expression graph can be encoded as follows: 353 | ```json 354 | { 355 | "type": "ScalarNonlinearFunction", 356 | "root": { 357 | "type": "+", 358 | "args": [{"type": "node", "index": 1}, {"type": "node", "index": 3}, "y"] 359 | }, 360 | "node_list": [{ 361 | "type": "*", 362 | "args": [{"type": "complex", "real": 1, "imag": 3}, "x"] 363 | }, { 364 | "type": "sin", "args": ["x"] 365 | }, { 366 | "type": "^", "args": [{"type": "node", "index": 2}, 2] 367 | }] 368 | } 369 | ``` 370 | -------------------------------------------------------------------------------- /examples/biobjective.mof.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "The problem: [min{2x - y + 1, -y}]", 3 | "version": { 4 | "major": 1, 5 | "minor": 1 6 | }, 7 | "variables": [{ 8 | "name": "x" 9 | }, { 10 | "name": "y" 11 | }], 12 | "objective": { 13 | "sense": "min", 14 | "function": { 15 | "type": "VectorAffineFunction", 16 | "terms": [{ 17 | "output_index": 1, 18 | "scalar_term": { 19 | "coefficient": 2, 20 | "variable": "x" 21 | } 22 | }, { 23 | "output_index": 1, 24 | "scalar_term": { 25 | "coefficient": -1, 26 | "variable": "y" 27 | } 28 | }, { 29 | "output_index": 2, 30 | "scalar_term": { 31 | "coefficient": -1, 32 | "variable": "y" 33 | } 34 | }], 35 | "constants": [1, 0] 36 | } 37 | }, 38 | "constraints": [] 39 | } 40 | -------------------------------------------------------------------------------- /examples/cpsat.mof.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "A constraint programming problem", 3 | "version": { 4 | "major": 1, 5 | "minor": 1 6 | }, 7 | "variables": [{ 8 | "name": "x" 9 | }, { 10 | "name": "y" 11 | }, { 12 | "name": "z" 13 | }], 14 | "objective": { 15 | "sense": "feasibility" 16 | }, 17 | "constraints": [{ 18 | "function": { 19 | "type": "VectorOfVariables", 20 | "variables": ["x", "y"] 21 | }, 22 | "set": { 23 | "type": "AllDifferent", 24 | "dimension": 2 25 | } 26 | },{ 27 | "function": { 28 | "type": "VectorOfVariables", 29 | "variables": ["x", "y", "z"] 30 | }, 31 | "set": { 32 | "type": "BinPacking", 33 | "capacity": 3.0, 34 | "weights": [1.0, 2.0, 3.0] 35 | } 36 | },{ 37 | "function": { 38 | "type": "VectorOfVariables", 39 | "variables": ["x", "y"] 40 | }, 41 | "set": { 42 | "type": "Circuit", 43 | "dimension": 2 44 | } 45 | },{ 46 | "function": { 47 | "type": "VectorOfVariables", 48 | "variables": ["x", "y", "y", "z"] 49 | }, 50 | "set": { 51 | "type": "CountAtLeast", 52 | "n": 1, 53 | "partitions": [2, 2], 54 | "set": [3] 55 | } 56 | },{ 57 | "function": { 58 | "type": "VectorOfVariables", 59 | "variables": ["x", "x", "y", "z"] 60 | }, 61 | "set": { 62 | "type": "CountBelongs", 63 | "dimension": 3, 64 | "set": [3, 4, 5] 65 | } 66 | },{ 67 | "function": { 68 | "type": "VectorOfVariables", 69 | "variables": ["x", "y", "z"] 70 | }, 71 | "set": { 72 | "type": "CountDistinct", 73 | "dimension": 3 74 | } 75 | },{ 76 | "function": { 77 | "type": "VectorOfVariables", 78 | "variables": ["x", "y", "z"] 79 | }, 80 | "set": { 81 | "type": "CountGreaterThan", 82 | "dimension": 3 83 | } 84 | },{ 85 | "function": { 86 | "type": "VectorOfVariables", 87 | "variables": ["x", "x", "y", "z"] 88 | }, 89 | "set": { 90 | "type": "Cumulative", 91 | "dimension": 4 92 | } 93 | },{ 94 | "function": { 95 | "type": "VectorOfVariables", 96 | "variables": ["x", "y", "z"] 97 | }, 98 | "set": { 99 | "type": "Path", 100 | "from": [1, 1, 2, 2, 3], 101 | "to": [2, 3, 3, 4, 4] 102 | } 103 | },{ 104 | "function": { 105 | "type": "VectorOfVariables", 106 | "variables": ["x", "y", "z"] 107 | }, 108 | "set": { 109 | "type": "Table", 110 | "table": [[0, 1, 1], [1, 1, 0]] 111 | } 112 | }] 113 | } 114 | -------------------------------------------------------------------------------- /examples/milp.mof.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "The problem: min{x | x + y >= 1, x ∈ [0, 1], y ∈ {0, 1}}", 3 | "version": { 4 | "major": 1, 5 | "minor": 2 6 | }, 7 | "variables": [{ 8 | "name": "x", 9 | "primal_start": 0.0 10 | }, { 11 | "name": "y", 12 | "primal_start": 1.0 13 | }], 14 | "objective": { 15 | "sense": "min", 16 | "function": { 17 | "type": "Variable", 18 | "name": "x" 19 | } 20 | }, 21 | "constraints": [{ 22 | "name": "x + y >= 1", 23 | "function": { 24 | "type": "ScalarAffineFunction", 25 | "terms": [{ 26 | "coefficient": 1, 27 | "variable": "x" 28 | }, 29 | { 30 | "coefficient": 1, 31 | "variable": "y" 32 | } 33 | ], 34 | "constant": 0 35 | }, 36 | "set": { 37 | "type": "GreaterThan", 38 | "lower": 1 39 | }, 40 | "primal_start": 1, 41 | "dual_start": 0 42 | }, { 43 | "name": "x ∈ [0, 1]", 44 | "function": { 45 | "type": "Variable", 46 | "name": "x" 47 | }, 48 | "set": { 49 | "type": "Interval", 50 | "lower": 0, 51 | "upper": 1 52 | } 53 | }, { 54 | "name": "y ∈ {0, 1}", 55 | "function": { 56 | "type": "Variable", 57 | "name": "y" 58 | }, 59 | "set": { 60 | "type": "ZeroOne" 61 | } 62 | }] 63 | } 64 | -------------------------------------------------------------------------------- /examples/nlp.mof.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "The problem: min{2x + sin(x)^2 + y}.", 3 | "version": {"major": 1, "minor": 7}, 4 | "variables": [{"name": "x"}, {"name": "y"}], 5 | "objective": { 6 | "sense": "min", 7 | "function": { 8 | "type": "ScalarNonlinearFunction", 9 | "root": {"type": "node", "index": 4}, 10 | "node_list": [{ 11 | "type": "*", 12 | "args": [ 13 | {"type": "real", "value": 2}, 14 | {"type": "variable", "name": "x"} 15 | ] 16 | }, { 17 | "type": "sin", 18 | "args": ["x"] 19 | }, { 20 | "type": "^", 21 | "args": [{"type": "node", "index": 2}, 2.0] 22 | }, { 23 | "type": "+", 24 | "args": [ 25 | {"type": "node", "index": 1}, 26 | {"type": "node", "index": 3}, 27 | "y" 28 | ] 29 | }] 30 | } 31 | }, 32 | "constraints": [] 33 | } 34 | -------------------------------------------------------------------------------- /examples/quadratic.mof.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "The problem: min{x^2 + x * y + y^2}", 3 | "version": { 4 | "major": 1, 5 | "minor": 1 6 | }, 7 | "variables": [{ 8 | "name": "x" 9 | }, { 10 | "name": "y" 11 | }], 12 | "objective": { 13 | "sense": "min", 14 | "function": { 15 | "description": "Note that the format is `a'x + 0.5 x' Q x + c`.", 16 | "type": "ScalarQuadraticFunction", 17 | "affine_terms": [], 18 | "quadratic_terms": [{ 19 | "coefficient": 2, 20 | "variable_1": "x", 21 | "variable_2": "x" 22 | }, 23 | { 24 | "coefficient": 1, 25 | "variable_1": "x", 26 | "variable_2": "y" 27 | }, 28 | { 29 | "coefficient": 2, 30 | "variable_1": "y", 31 | "variable_2": "y" 32 | } 33 | ], 34 | "constant": 0 35 | } 36 | }, 37 | "constraints": [] 38 | } 39 | -------------------------------------------------------------------------------- /examples/scaled.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": {"major": 1, "minor": 5}, 3 | "variables": [{"name": "x"}, {"name": "y"}, {"name": "z"}], 4 | "objective": {"sense": "feasibility"}, 5 | "constraints": [{ 6 | "function": { 7 | "type": "VectorOfVariables", 8 | "variables": ["x", "y", "z"] 9 | }, 10 | "set": { 11 | "type": "Scaled", 12 | "set": { 13 | "type": "PositiveSemidefiniteConeTriangle", 14 | "side_dimension": 2 15 | } 16 | } 17 | }] 18 | } 19 | -------------------------------------------------------------------------------- /examples/vector.mof.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "The problem: min{0 | [1 2; 3 4][x, y] + [5, 6] ∈ R+.", 3 | "version": { 4 | "major": 1, 5 | "minor": 2 6 | }, 7 | "variables": [{ 8 | "name": "x" 9 | }, { 10 | "name": "y" 11 | }], 12 | "objective": { 13 | "sense": "feasibility" 14 | }, 15 | "constraints": [{ 16 | "function": { 17 | "type": "VectorAffineFunction", 18 | "terms": [{ 19 | "output_index": 1, 20 | "scalar_term": { 21 | "coefficient": 1, 22 | "variable": "x" 23 | } 24 | }, { 25 | "output_index": 1, 26 | "scalar_term": { 27 | "coefficient": 2, 28 | "variable": "y" 29 | } 30 | }, { 31 | "output_index": 2, 32 | "scalar_term": { 33 | "coefficient": 3, 34 | "variable": "x" 35 | } 36 | }, { 37 | "output_index": 2, 38 | "scalar_term": { 39 | "coefficient": 4, 40 | "variable": "y" 41 | } 42 | }], 43 | "constants": [5, 6] 44 | }, 45 | "set": { 46 | "type": "Nonnegatives", 47 | "dimension": 2 48 | }, 49 | "primal_start": [5, 6], 50 | "dual_start": [0, 0] 51 | }] 52 | } 53 | -------------------------------------------------------------------------------- /python/mof.py: -------------------------------------------------------------------------------- 1 | import json 2 | import jsonschema 3 | import os 4 | 5 | 6 | SCHEMA_FILENAME = '../schemas/mof.1.schema.json' 7 | 8 | def validate(filename): 9 | with open(filename, 'r', encoding='utf-8') as io: 10 | instance = json.load(io) 11 | with open(SCHEMA_FILENAME, 'r', encoding='utf-8') as io: 12 | schema = json.load(io) 13 | jsonschema.validate(instance = instance, schema = schema) 14 | 15 | def summarize_schema(): 16 | with open(SCHEMA_FILENAME, 'r', encoding='utf-8') as io: 17 | schema = json.load(io) 18 | summary = "## Sets\n" 19 | summary += "\n### Scalar Sets\n\n" + summarize(schema, "scalar_sets") 20 | summary += "\n### Vector Sets\n\n" + summarize(schema, "vector_sets") 21 | summary += "\n## Functions\n" 22 | summary += "\n### Scalar Functions\n\n" + summarize(schema, "scalar_functions") 23 | summary += "\n### Vector Functions\n\n" + summarize(schema, "vector_functions") 24 | operators, leaves = summarize_nonlinear(schema) 25 | summary += "\n### Nonlinear\n" 26 | summary += "\n#### Leaf nodes\n\n" + leaves 27 | summary += '\n#### Operators\n\n' + operators 28 | return summary 29 | 30 | def oneOf_to_object(item): 31 | if "properties" not in item: 32 | print(item) 33 | return [{ 34 | "name": None, 35 | "description": item["description"], 36 | "example": item["examples"][0], 37 | }] 38 | head = item["properties"]["type"] 39 | ret = [] 40 | if "const" in head: 41 | description = item.get("description", "").replace("|", "\\|") 42 | example = item.get("examples", [""]) 43 | assert(len(example) == 1) 44 | ret.append({ 45 | 'name': head["const"], 46 | 'description': description, 47 | 'example': example[0], 48 | }) 49 | else: 50 | for k in head["enum"]: 51 | ret.append({ 52 | 'name': k, 53 | 'description': "", 54 | 'example': "", 55 | }) 56 | return ret 57 | 58 | def summarize(schema, key): 59 | summary = \ 60 | "| Name | Description | Example |\n" + \ 61 | "| ---- | ----------- | ------- |\n" 62 | for item in schema["definitions"][key]["oneOf"]: 63 | for obj in oneOf_to_object(item): 64 | summary += "| `\"%s\"` | %s | %s |\n" % \ 65 | (obj['name'], obj['description'], obj['example']) 66 | return summary 67 | 68 | def summarize_nonlinear(schema): 69 | operators = "| Name | Arity |\n| ---- | ----- |\n" 70 | leaves = "| Name | Description | Example |\n| ---- | ----------- | ------- |\n" 71 | description_map = { 72 | "Unary operators": 'Unary', 73 | "Binary operators": 'Binary', 74 | "N-ary operators": 'N-ary', 75 | } 76 | for item in schema["definitions"]["NonlinearTerm"]["oneOf"]: 77 | desc = description_map.get(item["description"], None) 78 | if desc == None: 79 | obj = oneOf_to_object(item)[0] 80 | leaves += "| `\"%s\"` | %s | %s |\n" % \ 81 | (obj['name'], obj['description'], obj['example']) 82 | else: 83 | for obj in oneOf_to_object(item): 84 | operators += "| `\"%s\"` | Unary |\n" % obj['name'] 85 | return operators, leaves 86 | 87 | ### 88 | ### Validate all the files in the examples directory. 89 | ### 90 | 91 | for filename in os.listdir('../examples'): 92 | validate(os.path.join('../examples', filename)) 93 | 94 | ### 95 | ### Summarize the schema for the README table. 96 | ### 97 | 98 | print(summarize_schema()) 99 | -------------------------------------------------------------------------------- /schemas/mof.0.4.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/schema#", 3 | "$id": "https://jump.dev/MathOptFormat/schemas/mof.0.4.schema.json", 4 | "title": "The schema for MathOptFormat", 5 | "type": "object", 6 | "required": ["version", "variables", "objective", "constraints"], 7 | "properties": { 8 | "version": { 9 | "description": "The version of MathOptFormat that this schema validates against.", 10 | "type": "object", 11 | "required": ["minor", "major"], 12 | "properties": { 13 | "minor": { 14 | "const": 4 15 | }, 16 | "major": { 17 | "const": 0 18 | } 19 | } 20 | }, 21 | "name": { 22 | "description": "The name of the model.", 23 | "type": "string" 24 | }, 25 | "author": { 26 | "description": "The author of the model for citation purposes.", 27 | "type": "string" 28 | }, 29 | "description": { 30 | "description": "A human-readable description of the model.", 31 | "type": "string" 32 | }, 33 | "variables": { 34 | "description": "An array of variables in the model. Each must have a unique name.", 35 | "type": "array", 36 | "items": { 37 | "type": "object", 38 | "required": ["name"], 39 | "properties": { 40 | "name": { 41 | "type": "string" 42 | }, 43 | "primal_start": { 44 | "description": "An initial value that the optimizer may use to warm-start the solution process.", 45 | "type": "number" 46 | } 47 | } 48 | }, 49 | "uniqueItems": true 50 | }, 51 | "objective": { 52 | "description": "The objective of the model.", 53 | "type": "object", 54 | "required": ["sense"], 55 | "oneOf": [{ 56 | "properties": { 57 | "sense": { 58 | "enum": ["min", "max"] 59 | }, 60 | "function": { 61 | "oneOf": [{ 62 | "$ref": "#/definitions/scalar_functions" 63 | }, { 64 | "$ref": "#/definitions/vector_functions" 65 | }] 66 | } 67 | } 68 | }, { 69 | "properties": { 70 | "sense": { 71 | "const": "feasibility" 72 | } 73 | } 74 | }] 75 | }, 76 | "constraints": { 77 | "description": "An array of constraints in the model. Scalar-valued functions can only be paired with scalar-sets, and the same applies for vector-valued functions and sets.", 78 | "type": "array", 79 | "items": { 80 | "type": "object", 81 | "required": ["function", "set"], 82 | "properties": { 83 | "name": { 84 | "type": "string" 85 | } 86 | }, 87 | "oneOf": [{ 88 | "description": "A scalar-valued constraint.", 89 | "properties": { 90 | "function": { 91 | "$ref": "#/definitions/scalar_functions" 92 | }, 93 | "set": { 94 | "$ref": "#/definitions/scalar_sets" 95 | } 96 | } 97 | }, { 98 | "description": "A vector-valued constraint.", 99 | "properties": { 100 | "function": { 101 | "$ref": "#/definitions/vector_functions" 102 | }, 103 | "set": { 104 | "$ref": "#/definitions/vector_sets" 105 | } 106 | } 107 | }] 108 | }, 109 | "uniqueItems": true 110 | } 111 | }, 112 | "definitions": { 113 | "ScalarAffineTerm": { 114 | "description": "A helper object that represents `coefficent * variable`.", 115 | "type": "object", 116 | "required": ["coefficient", "variable"], 117 | "properties": { 118 | "coefficient": { 119 | "type": "number" 120 | }, 121 | "variable": { 122 | "type": "string" 123 | } 124 | } 125 | }, 126 | "ScalarQuadraticTerm": { 127 | "description": "A helper object that represents `coefficent * variable_1 * variable_2`.", 128 | "type": "object", 129 | "required": ["coefficient", "variable_1", "variable_2"], 130 | "properties": { 131 | "coefficient": { 132 | "type": "number" 133 | }, 134 | "variable_1": { 135 | "type": "string" 136 | }, 137 | "variable_2": { 138 | "type": "string" 139 | } 140 | } 141 | }, 142 | "VectorAffineTerm": { 143 | "description": "A helper object that represents a `ScalarAffineTerm` in row `output_index`.", 144 | "type": "object", 145 | "required": ["output_index", "scalar_term"], 146 | "properties": { 147 | "output_index": { 148 | "type": "integer", 149 | "minimum": 1 150 | }, 151 | "scalar_term": { 152 | "$ref": "#/definitions/ScalarAffineTerm" 153 | } 154 | } 155 | }, 156 | "VectorQuadraticTerm": { 157 | "description": "A helper object that represents a `ScalarQuadraticTerm` in row `output_index`.", 158 | "type": "object", 159 | "required": ["output_index", "scalar_term"], 160 | "properties": { 161 | "output_index": { 162 | "type": "integer", 163 | "minimum": 1 164 | }, 165 | "scalar_term": { 166 | "$ref": "#/definitions/ScalarQuadraticTerm" 167 | } 168 | } 169 | }, 170 | "NonlinearTerm": { 171 | "description": "A node in an expresion graph representing a nonlinear function.", 172 | "type": "object", 173 | "required": ["head"], 174 | "oneOf": [{ 175 | "description": "Unary operators", 176 | "required": ["args"], 177 | "properties": { 178 | "head": { 179 | "enum": [ 180 | "log", "log10", "exp", "sqrt", "floor", "ceil", 181 | "abs", "cos", "sin", "tan", "acos", "asin", "atan", 182 | "cosh", "sinh", "tanh", "acosh", "asinh", "atanh" 183 | ] 184 | }, 185 | "args": { 186 | "type": "array", 187 | "items": { 188 | "$ref": "#/definitions/NonlinearTerm" 189 | }, 190 | "minItems": 1, 191 | "maxItems": 1 192 | } 193 | } 194 | }, { 195 | "description": "Binary operators", 196 | "required": ["args"], 197 | "properties": { 198 | "head": { 199 | "enum": ["/", "^"] 200 | }, 201 | "args": { 202 | "type": "array", 203 | "items": { 204 | "$ref": "#/definitions/NonlinearTerm" 205 | }, 206 | "minItems": 2, 207 | "maxItems": 2 208 | } 209 | } 210 | }, { 211 | "description": "N-ary operators", 212 | "required": ["args"], 213 | "properties": { 214 | "head": { 215 | "enum": ["+", "-", "*", "min", "max"] 216 | }, 217 | "args": { 218 | "type": "array", 219 | "items": { 220 | "$ref": "#/definitions/NonlinearTerm" 221 | }, 222 | "minItems": 1 223 | } 224 | } 225 | }, { 226 | "description": "A real-valued numeric constant", 227 | "examples": ["{\"head\": \"real\", \"value\": 1.0}"], 228 | "required": ["value"], 229 | "properties": { 230 | "head": { 231 | "const": "real" 232 | }, 233 | "value": { 234 | "type": "number" 235 | } 236 | } 237 | }, { 238 | "description": "A complex-valued numeric constant", 239 | "examples": ["{\"head\": \"complex\", \"real\": 1.0, \"imag\": 2.0}"], 240 | "required": ["real", "imag"], 241 | "properties": { 242 | "head": { 243 | "const": "complex" 244 | }, 245 | "real": { 246 | "type": "number" 247 | }, 248 | "imag": { 249 | "type": "number" 250 | } 251 | } 252 | }, { 253 | "description": "A reference to an optimization variable", 254 | "examples": ["{\"head\": \"variable\", \"name\": \"x\"}"], 255 | "required": ["name"], 256 | "properties": { 257 | "head": { 258 | "const": "variable" 259 | }, 260 | "name": { 261 | "type": "string" 262 | } 263 | } 264 | }, { 265 | "description": "A pointer to a (1-indexed) element in the `node_list` field in a nonlinear function", 266 | "examples": ["{\"head\": \"node\", \"index\": 2}"], 267 | "required": ["index"], 268 | "properties": { 269 | "head": { 270 | "const": "node" 271 | }, 272 | "index": { 273 | "type": "integer", 274 | "minimum": 1 275 | } 276 | } 277 | }] 278 | }, 279 | "scalar_functions": { 280 | "description": "A schema for the scalar-valued functions defined by MathOptFormat.See http://www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Functions-and-function-modifications-1 for a list of the functions and their meanings.", 281 | "type": "object", 282 | "required": ["head"], 283 | "oneOf": [{ 284 | "description": "The scalar variable `variable`.", 285 | "examples": ["{\"head\": \"SingleVariable\", \"variable\": \"x\"}"], 286 | "required": ["variable"], 287 | "properties": { 288 | "head": { 289 | "const": "SingleVariable" 290 | }, 291 | "variable": { 292 | "type": "string" 293 | } 294 | } 295 | }, { 296 | "description": "The function `a'x + b`, where `a` is a sparse vector specified by a list of `ScalarAffineTerm`s in `terms` and `b` is the scalar in `constant`. Duplicate variables in `terms` are accepted, and the corresponding coefficients are summed together.", 297 | "examples": ["{\"head\": \"ScalarAffineFunction\", \"constant\": 1.0, \"terms\": [{\"coefficient\": 2.5, \"variable\": \"x\"}]}"], 298 | "required": ["constant", "terms"], 299 | "properties": { 300 | "head": { 301 | "const": "ScalarAffineFunction" 302 | }, 303 | "constant": { 304 | "type": "number" 305 | }, 306 | "terms": { 307 | "type": "array", 308 | "items": { 309 | "$ref": "#/definitions/ScalarAffineTerm" 310 | } 311 | } 312 | } 313 | }, { 314 | "description": "The function `0.5x'Qx + a'x + b`, where `a` is a sparse vector of `ScalarAffineTerm`s in `affine_terms`, `b` is the scalar `constant`, and `Q` is a symmetric matrix specified by a list of `ScalarQuadraticTerm`s in `quadratic_terms`. Duplicate indices in `affine_terms` and `quadratic` are accepted, and the corresponding coefficients are summed together. Mirrored indices in `quadratic_terms` (i.e., `(i,j)` and `(j, i)`) are considered duplicates; only one need to be specified.", 315 | "examples": ["{\"head\": \"ScalarQuadraticFunction\", \"constant\": 1.0, \"affine_terms\": [{\"coefficient\": 2.5, \"variable\": \"x\"}], \"quadratic_terms\": [{\"coefficient\": 2.0, \"variable_1\": \"x\", \"variable_2\": \"y\"}]}"], 316 | "required": ["constant", "affine_terms", "quadratic_terms"], 317 | "properties": { 318 | "head": { 319 | "const": "ScalarQuadraticFunction" 320 | }, 321 | "constant": { 322 | "type": "number" 323 | }, 324 | "affine_terms": { 325 | "type": "array", 326 | "items": { 327 | "$ref": "#/definitions/ScalarAffineTerm" 328 | } 329 | }, 330 | "quadratic_terms": { 331 | "type": "array", 332 | "items": { 333 | "$ref": "#/definitions/ScalarQuadraticTerm" 334 | } 335 | } 336 | } 337 | }, { 338 | "description": "An expression graph representing a scalar nonlinear function.", 339 | "required": ["root", "node_list"], 340 | "properties": { 341 | "head": { 342 | "const": "ScalarNonlinearFunction" 343 | }, 344 | "root": { 345 | "$ref": "#/definitions/NonlinearTerm" 346 | }, 347 | "node_list": { 348 | "type": "array", 349 | "items": { 350 | "$ref": "#/definitions/NonlinearTerm" 351 | } 352 | } 353 | } 354 | }] 355 | }, 356 | "vector_functions": { 357 | "description": "A schema for the vector-valued functions defined by MathOptFormat.See http://www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Functions-and-function-modifications-1 for a list of the functions and their meanings.", 358 | "type": "object", 359 | "required": ["head"], 360 | "oneOf": [{ 361 | "description": "An ordered list of variables.", 362 | "examples": ["{\"head\": \"VectorOfVariables\", \"variables\": [\"x\", \"y\"]}"], 363 | "required": ["variables"], 364 | "properties": { 365 | "head": { 366 | "const": "VectorOfVariables" 367 | }, 368 | "variables": { 369 | "type": "array", 370 | "items": { 371 | "type": "string" 372 | } 373 | } 374 | } 375 | }, { 376 | "description": "The function `Ax + b`, where `A` is a sparse matrix specified by a list of `VectorAffineTerm`s in `terms` and `b` is a dense vector specified by `constants`.", 377 | "examples": ["{\"head\": \"VectorAffineFunction\", \"constants\": [1.0], \"terms\": [{\"output_index\": 1, \"scalar_term\": {\"coefficient\": 2.5, \"variable\": \"x\"}}]}"], 378 | "required": ["constants", "terms"], 379 | "properties": { 380 | "head": { 381 | "const": "VectorAffineFunction" 382 | }, 383 | "constants": { 384 | "type": "array", 385 | "items": { 386 | "type": "number" 387 | } 388 | }, 389 | "terms": { 390 | "type": "array", 391 | "items": { 392 | "$ref": "#/definitions/VectorAffineTerm" 393 | } 394 | } 395 | } 396 | }, { 397 | "description": "The vector-valued quadratic function `q(x) + Ax + b`, where `q(x)` is specified by a list of `VectorQuadraticTerm`s in `quadratic_terms`, `A` is a sparse matrix specified by a list of `VectorAffineTerm`s in `affine_terms` and `b` is a dense vector specified by `constants`.", 398 | "required": ["constants", "affine_terms", "quadratic_terms"], 399 | "properties": { 400 | "head": { 401 | "const": "VectorQuadraticFunction" 402 | }, 403 | "constants": { 404 | "type": "array", 405 | "items": { 406 | "type": "number" 407 | } 408 | }, 409 | "affine_terms": { 410 | "type": "array", 411 | "items": { 412 | "$ref": "#/definitions/VectorAffineTerm" 413 | } 414 | }, 415 | "quadratc_terms": { 416 | "type": "array", 417 | "items": { 418 | "$ref": "#/definitions/VectorQuadraticTerm" 419 | } 420 | } 421 | } 422 | }] 423 | }, 424 | "scalar_sets": { 425 | "description": "A schema for the scalar-valued sets defined by MathOptFormat. See http: //www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Sets-1 for a list of the sets and their meanings.", 426 | "type": "object", 427 | "required": ["head"], 428 | "oneOf": [{ 429 | "description": "(-∞, upper]", 430 | "examples": ["{\"head\": \"LessThan\", \"upper\": 2.1}"], 431 | "required": ["upper"], 432 | "properties": { 433 | "head": { 434 | "const": "LessThan" 435 | }, 436 | "upper": { 437 | "type": "number" 438 | } 439 | } 440 | }, { 441 | "description": "[lower, ∞)", 442 | "examples": ["{\"head\": \"GreaterThan\", \"lower\": 2.1}"], 443 | "required": ["lower"], 444 | "properties": { 445 | "head": { 446 | "const": "GreaterThan" 447 | }, 448 | "lower": { 449 | "type": "number" 450 | } 451 | } 452 | }, { 453 | "description": "{value}", 454 | "examples": ["{\"head\": \"EqualTo\", \"value\": 2.1}"], 455 | "required": ["value"], 456 | "properties": { 457 | "head": { 458 | "const": "EqualTo" 459 | }, 460 | "value": { 461 | "type": "number" 462 | } 463 | } 464 | }, { 465 | "description": "[lower, upper]", 466 | "examples": ["{\"head\": \"Interval\", \"lower\": 2.1, \"upper\": 3.4}"], 467 | "required": ["lower", "upper"], 468 | "properties": { 469 | "head": { 470 | "const": "Interval" 471 | }, 472 | "lower": { 473 | "type": "number" 474 | }, 475 | "upper": { 476 | "type": "number" 477 | } 478 | } 479 | }, { 480 | "description": "{0} ∪ {lower, lower + 1, ..., upper}", 481 | "examples": ["{\"head\": \"Semiinteger\", \"lower\": 2, \"upper\": 4}"], 482 | "required": ["lower", "upper"], 483 | "properties": { 484 | "head": { 485 | "const": "Semiinteger" 486 | }, 487 | "lower": { 488 | "type": "number" 489 | }, 490 | "upper": { 491 | "type": "number" 492 | } 493 | } 494 | }, { 495 | "description": "{0} ∪ [lower, upper]", 496 | "examples": ["{\"head\": \"Semicontinuous\", \"lower\": 2.1, \"upper\": 3.4}"], 497 | "required": ["lower", "upper"], 498 | "properties": { 499 | "head": { 500 | "const": "Semicontinuous" 501 | }, 502 | "lower": { 503 | "type": "number" 504 | }, 505 | "upper": { 506 | "type": "number" 507 | } 508 | } 509 | }, { 510 | "description": "{0, 1}", 511 | "examples": ["{\"head\": \"ZeroOne\"}"], 512 | "properties": { 513 | "head": { 514 | "const": "ZeroOne" 515 | } 516 | } 517 | }, { 518 | "description": "ℤ", 519 | "examples": ["{\"head\": \"Integer\"}"], 520 | "properties": { 521 | "head": { 522 | "const": "Integer" 523 | } 524 | } 525 | }] 526 | }, 527 | "vector_sets": { 528 | "description": "A schema for the vector-valued sets defined by MathOptFormat. See http: //www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Sets-1 for a list of the sets and their meanings.", 529 | "type": "object", 530 | "required": ["head"], 531 | "oneOf": [{ 532 | "description": "[x, y, z] ∈ {R³: y * exp(x / y) ≤ z, y ≥ 0}", 533 | "examples": ["{\"head\": \"ExponentialCone\"}"], 534 | "properties": { 535 | "head": { 536 | "const": "ExponentialCone" 537 | } 538 | } 539 | }, { 540 | "description": "[u, v, w] ∈ {R³: -u * exp(v / u) ≤ exp(1) * w, u < 0}", 541 | "examples": ["{\"head\": \"DualExponentialCone\"}"], 542 | "properties": { 543 | "head": { 544 | "const": "DualExponentialCone" 545 | } 546 | } 547 | }, { 548 | "description": "A special ordered set of type I.", 549 | "examples": ["{\"head\": \"SOS1\", \"weights\": [1, 3, 2]}"], 550 | "required": ["weights"], 551 | "properties": { 552 | "head": { 553 | "const": "SOS1" 554 | }, 555 | "weights": { 556 | "type": "array", 557 | "items": { 558 | "type": "number" 559 | } 560 | } 561 | } 562 | }, { 563 | "description": "A special ordered set of type II.", 564 | "examples": ["{\"head\": \"SOS2\", \"weights\": [1, 3, 2]}"], 565 | "required": ["weights"], 566 | "properties": { 567 | "head": { 568 | "const": "SOS2" 569 | }, 570 | "weights": { 571 | "type": "array", 572 | "items": { 573 | "type": "number" 574 | } 575 | } 576 | } 577 | }, { 578 | "description": "[t, x] ∈ {R^{dimension}: t ≤ (Πxᵢ)^{1 / (dimension-1)}}", 579 | "examples": ["{\"head\": \"GeometricMeanCone\", \"dimension\": 3}"], 580 | "required": ["dimension"], 581 | "properties": { 582 | "head": { 583 | "const": "GeometricMeanCone" 584 | }, 585 | "dimension": { 586 | "type": "integer", 587 | "minimum": 1 588 | } 589 | } 590 | }, { 591 | "description": "[t, x] ∈ {R^{dimension} : t ≥ ||x||₂", 592 | "examples": ["{\"head\": \"SecondOrderCone\", \"dimension\": 3}"], 593 | "required": ["dimension"], 594 | "properties": { 595 | "head": { 596 | "const": "SecondOrderCone" 597 | }, 598 | "dimension": { 599 | "type": "integer", 600 | "minimum": 1 601 | } 602 | } 603 | }, { 604 | "description": "[t, u, x] ∈ {R^{dimension} : 2tu ≥ (||x||₂)²; t, u ≥ 0}", 605 | "examples": ["{\"head\": \"RotatedSecondOrderCone\", \"dimension\": 3}"], 606 | "required": ["dimension"], 607 | "properties": { 608 | "head": { 609 | "const": "RotatedSecondOrderCone" 610 | }, 611 | "dimension": { 612 | "type": "integer", 613 | "minimum": 1 614 | } 615 | } 616 | }, { 617 | "description": "{0}^{dimension}", 618 | "examples": ["{\"head\": \"Zeros\", \"dimension\": 3}"], 619 | "required": ["dimension"], 620 | "properties": { 621 | "head": { 622 | "const": "Zeros" 623 | }, 624 | "dimension": { 625 | "type": "integer", 626 | "minimum": 1 627 | } 628 | } 629 | }, { 630 | "description": "R^{dimension}", 631 | "examples": ["{\"head\": \"Reals\", \"dimension\": 3}"], 632 | "required": ["dimension"], 633 | "properties": { 634 | "head": { 635 | "const": "Reals" 636 | }, 637 | "dimension": { 638 | "type": "integer", 639 | "minimum": 1 640 | } 641 | } 642 | }, { 643 | "description": "R₋^{dimension}", 644 | "examples": ["{\"head\": \"Nonpositives\", \"dimension\": 3}"], 645 | "required": ["dimension"], 646 | "properties": { 647 | "head": { 648 | "const": "Nonpositives" 649 | }, 650 | "dimension": { 651 | "type": "integer", 652 | "minimum": 1 653 | } 654 | } 655 | }, { 656 | "description": "R₊^{dimension}", 657 | "examples": ["{\"head\": \"Nonnegatives\", \"dimension\": 3}"], 658 | "required": ["dimension"], 659 | "properties": { 660 | "head": { 661 | "const": "Nonnegatives" 662 | }, 663 | "dimension": { 664 | "type": "integer", 665 | "minimum": 1 666 | } 667 | } 668 | }, { 669 | "description": "{[t, X] ∈ R^{1 + d(d+1)/2} : t ≤ det(X)^{1/d}}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeTriangle`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 670 | "examples": ["{\"head\": \"RootDetConeTriangle\", \"side_dimension\": 2}"], 671 | "required": ["side_dimension"], 672 | "properties": { 673 | "head": { 674 | "const": "RootDetConeTriangle" 675 | }, 676 | "side_dimension": { 677 | "type": "integer", 678 | "minimum": 1 679 | } 680 | } 681 | }, { 682 | "description": "{[t, X] ∈ R^{1 + d^2} : t ≤ det(X)^{1/d}, X symmetric}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeSquare`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 683 | "examples": ["{\"head\": \"RootDetConeSquare\", \"side_dimension\": 2}"], 684 | "required": ["side_dimension"], 685 | "properties": { 686 | "head": { 687 | "const": "RootDetConeSquare" 688 | }, 689 | "side_dimension": { 690 | "type": "integer", 691 | "minimum": 1 692 | } 693 | } 694 | }, { 695 | "description": "{[t, u, X] ∈ R^{2 + d(d+1)/2} : t ≤ u log(det(X/u)), u > 0}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeTriangle`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 696 | "examples": ["{\"head\": \"LogDetConeTriangle\", \"side_dimension\": 2}"], 697 | "required": ["side_dimension"], 698 | "properties": { 699 | "head": { 700 | "const": "LogDetConeTriangle" 701 | }, 702 | "side_dimension": { 703 | "type": "integer", 704 | "minimum": 1 705 | } 706 | } 707 | }, { 708 | "description": "{[t, u, X] ∈ R^{2 + d^2} : t ≤ u log(det(X/u)), X symmetric, u > 0}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeSquare`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 709 | "examples": ["{\"head\": \"LogDetConeSquare\", \"side_dimension\": 2}"], 710 | "required": ["side_dimension"], 711 | "properties": { 712 | "head": { 713 | "const": "LogDetConeSquare" 714 | }, 715 | "side_dimension": { 716 | "type": "integer", 717 | "minimum": 1 718 | } 719 | } 720 | }, { 721 | "description": "The (vectorized) cone of symmetric positive semidefinite matrices, with `side_dimension` rows and columns. The entries of the upper-right triangular part of the matrix are given column by column (or equivalently, the entries of the lower-left triangular part are given row by row).", 722 | "examples": ["{\"head\": \"PositiveSemidefiniteConeTriangle\", \"side_dimension\": 2}"], 723 | "required": ["side_dimension"], 724 | "properties": { 725 | "head": { 726 | "const": "PositiveSemidefiniteConeTriangle" 727 | }, 728 | "side_dimension": { 729 | "type": "integer", 730 | "minimum": 1 731 | } 732 | } 733 | }, { 734 | "description": "The cone of symmetric positive semidefinite matrices, with side length `side_dimension`. The entries of the matrix are given column by column (or equivalently, row by row). The matrix is both constrained to be symmetric and to be positive semidefinite. That is, if the functions in entries `(i, j)` and `(j, i)` are different, then a constraint will be added to make sure that the entries are equal.", 735 | "examples": ["{\"head\": \"PositiveSemidefiniteConeSquare\", \"side_dimension\": 2}"], 736 | "required": ["side_dimension"], 737 | "properties": { 738 | "head": { 739 | "const": "PositiveSemidefiniteConeSquare" 740 | }, 741 | "side_dimension": { 742 | "type": "integer", 743 | "minimum": 1 744 | } 745 | } 746 | }, { 747 | "description": "[x, y, z] ∈ {R³: x^{exponent} y^{1-exponent} ≥ |z|; x, y ≥ 0}", 748 | "examples": ["{\"head\": \"PowerCone\", \"exponent\": 2.0}"], 749 | "required": ["exponent"], 750 | "properties": { 751 | "head": { 752 | "const": "PowerCone" 753 | }, 754 | "exponent": { 755 | "type": "number" 756 | } 757 | } 758 | }, { 759 | "description": "[u, v, w] ∈ {R³: (u / exponent)^{exponent} (v / (1-exponent))^{1-exponent} ≥ |w|; u, v ≥ 0}", 760 | "examples": ["{\"head\": \"DualPowerCone\", \"exponent\": 2.0}"], 761 | "required": ["exponent"], 762 | "properties": { 763 | "head": { 764 | "const": "DualPowerCone" 765 | }, 766 | "exponent": { 767 | "type": "number" 768 | } 769 | } 770 | }, { 771 | "description": "If `activate_on=one`: (y, x) ∈ {0,1}×Rᴺ: y = 0 ⟹ x ∈ S, otherwise when `activate_on=zero`: (y, x) ∈ {0,1}×Rᴺ: y = 1 ⟹ x ∈ S.", 772 | "examples": ["{\"head\": \"IndicatorSet\", \"set\": {\"head\": \"LessThan\", \"upper\": 2.0}, \"activate_on\": \"one\"}"], 773 | "required": ["set", "activate_on"], 774 | "properties": { 775 | "head": { 776 | "const": "IndicatorSet" 777 | }, 778 | "set": { 779 | "oneOf": [{ 780 | "$ref": "#/definitions/scalar_sets" 781 | }, { 782 | "$ref": "#/definitions/vector_sets" 783 | }] 784 | }, 785 | "activate_on": { 786 | "enum": ["one", "zero"] 787 | } 788 | } 789 | }, { 790 | "description": "(t, x) ∈ {R^{dimension}: t ≥ Σᵢ|xᵢ|}", 791 | "examples": ["{\"head\": \"NormOneCone\", \"dimension\": 2}"], 792 | "required": ["dimension"], 793 | "properties": { 794 | "head": { 795 | "const": "NormOneCone" 796 | }, 797 | "dimension": { 798 | "type": "integer", 799 | "minimum": 2 800 | } 801 | } 802 | }, { 803 | "description": "(t, x) ∈ {R^{dimension}: t ≥ maxᵢ|xᵢ|}", 804 | "examples": ["{\"head\": \"NormInfinityCone\", \"dimension\": 2}"], 805 | "required": ["dimension"], 806 | "properties": { 807 | "head": { 808 | "const": "NormInfinityCone" 809 | }, 810 | "dimension": { 811 | "type": "integer", 812 | "minimum": 2 813 | } 814 | } 815 | }] 816 | } 817 | } 818 | } 819 | -------------------------------------------------------------------------------- /schemas/mof.0.5.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/schema#", 3 | "$id": "https://jump.dev/MathOptFormat/schemas/mof.0.5.schema.json", 4 | "title": "The schema for MathOptFormat", 5 | "type": "object", 6 | "required": ["version", "variables", "objective", "constraints"], 7 | "properties": { 8 | "version": { 9 | "description": "The version of MathOptFormat that this schema validates against.", 10 | "type": "object", 11 | "required": ["minor", "major"], 12 | "properties": { 13 | "minor": { 14 | "const": 5 15 | }, 16 | "major": { 17 | "const": 0 18 | } 19 | } 20 | }, 21 | "name": { 22 | "description": "The name of the model.", 23 | "type": "string" 24 | }, 25 | "author": { 26 | "description": "The author of the model for citation purposes.", 27 | "type": "string" 28 | }, 29 | "description": { 30 | "description": "A human-readable description of the model.", 31 | "type": "string" 32 | }, 33 | "variables": { 34 | "description": "An array of variables in the model. Each must have a unique name.", 35 | "type": "array", 36 | "items": { 37 | "type": "object", 38 | "required": ["name"], 39 | "properties": { 40 | "name": { 41 | "type": "string" 42 | }, 43 | "primal_start": { 44 | "description": "An initial value that the optimizer may use to warm-start the solution process.", 45 | "type": "number" 46 | } 47 | } 48 | }, 49 | "uniqueItems": true 50 | }, 51 | "objective": { 52 | "description": "The objective of the model.", 53 | "type": "object", 54 | "required": ["sense"], 55 | "oneOf": [{ 56 | "properties": { 57 | "sense": { 58 | "enum": ["min", "max"] 59 | }, 60 | "function": { 61 | "oneOf": [{ 62 | "$ref": "#/definitions/scalar_functions" 63 | }, { 64 | "$ref": "#/definitions/vector_functions" 65 | }] 66 | } 67 | } 68 | }, { 69 | "properties": { 70 | "sense": { 71 | "const": "feasibility" 72 | } 73 | } 74 | }] 75 | }, 76 | "constraints": { 77 | "description": "An array of constraints in the model. Scalar-valued functions can only be paired with scalar-sets, and the same applies for vector-valued functions and sets.", 78 | "type": "array", 79 | "items": { 80 | "type": "object", 81 | "required": ["function", "set"], 82 | "properties": { 83 | "name": { 84 | "type": "string" 85 | } 86 | }, 87 | "oneOf": [{ 88 | "description": "A scalar-valued constraint.", 89 | "properties": { 90 | "function": { 91 | "$ref": "#/definitions/scalar_functions" 92 | }, 93 | "set": { 94 | "$ref": "#/definitions/scalar_sets" 95 | } 96 | } 97 | }, { 98 | "description": "A vector-valued constraint.", 99 | "properties": { 100 | "function": { 101 | "$ref": "#/definitions/vector_functions" 102 | }, 103 | "set": { 104 | "$ref": "#/definitions/vector_sets" 105 | } 106 | } 107 | }] 108 | }, 109 | "uniqueItems": true 110 | } 111 | }, 112 | "definitions": { 113 | "ScalarAffineTerm": { 114 | "description": "A helper object that represents `coefficent * variable`.", 115 | "type": "object", 116 | "required": ["coefficient", "variable"], 117 | "properties": { 118 | "coefficient": { 119 | "type": "number" 120 | }, 121 | "variable": { 122 | "type": "string" 123 | } 124 | } 125 | }, 126 | "ScalarQuadraticTerm": { 127 | "description": "A helper object that represents `coefficent * variable_1 * variable_2`.", 128 | "type": "object", 129 | "required": ["coefficient", "variable_1", "variable_2"], 130 | "properties": { 131 | "coefficient": { 132 | "type": "number" 133 | }, 134 | "variable_1": { 135 | "type": "string" 136 | }, 137 | "variable_2": { 138 | "type": "string" 139 | } 140 | } 141 | }, 142 | "VectorAffineTerm": { 143 | "description": "A helper object that represents a `ScalarAffineTerm` in row `output_index`.", 144 | "type": "object", 145 | "required": ["output_index", "scalar_term"], 146 | "properties": { 147 | "output_index": { 148 | "type": "integer", 149 | "minimum": 1 150 | }, 151 | "scalar_term": { 152 | "$ref": "#/definitions/ScalarAffineTerm" 153 | } 154 | } 155 | }, 156 | "VectorQuadraticTerm": { 157 | "description": "A helper object that represents a `ScalarQuadraticTerm` in row `output_index`.", 158 | "type": "object", 159 | "required": ["output_index", "scalar_term"], 160 | "properties": { 161 | "output_index": { 162 | "type": "integer", 163 | "minimum": 1 164 | }, 165 | "scalar_term": { 166 | "$ref": "#/definitions/ScalarQuadraticTerm" 167 | } 168 | } 169 | }, 170 | "NonlinearTerm": { 171 | "description": "A node in an expresion graph representing a nonlinear function.", 172 | "type": "object", 173 | "required": ["type"], 174 | "oneOf": [{ 175 | "description": "Unary operators", 176 | "required": ["args"], 177 | "properties": { 178 | "type": { 179 | "enum": [ 180 | "log", "log10", "exp", "sqrt", "floor", "ceil", 181 | "abs", "cos", "sin", "tan", "acos", "asin", "atan", 182 | "cosh", "sinh", "tanh", "acosh", "asinh", "atanh" 183 | ] 184 | }, 185 | "args": { 186 | "type": "array", 187 | "items": { 188 | "$ref": "#/definitions/NonlinearTerm" 189 | }, 190 | "minItems": 1, 191 | "maxItems": 1 192 | } 193 | } 194 | }, { 195 | "description": "Binary operators", 196 | "required": ["args"], 197 | "properties": { 198 | "type": { 199 | "enum": ["/", "^"] 200 | }, 201 | "args": { 202 | "type": "array", 203 | "items": { 204 | "$ref": "#/definitions/NonlinearTerm" 205 | }, 206 | "minItems": 2, 207 | "maxItems": 2 208 | } 209 | } 210 | }, { 211 | "description": "N-ary operators", 212 | "required": ["args"], 213 | "properties": { 214 | "type": { 215 | "enum": ["+", "-", "*", "min", "max"] 216 | }, 217 | "args": { 218 | "type": "array", 219 | "items": { 220 | "$ref": "#/definitions/NonlinearTerm" 221 | }, 222 | "minItems": 1 223 | } 224 | } 225 | }, { 226 | "description": "A real-valued numeric constant", 227 | "examples": ["{\"type\": \"real\", \"value\": 1.0}"], 228 | "required": ["value"], 229 | "properties": { 230 | "type": { 231 | "const": "real" 232 | }, 233 | "value": { 234 | "type": "number" 235 | } 236 | } 237 | }, { 238 | "description": "A complex-valued numeric constant", 239 | "examples": ["{\"type\": \"complex\", \"real\": 1.0, \"imag\": 2.0}"], 240 | "required": ["real", "imag"], 241 | "properties": { 242 | "type": { 243 | "const": "complex" 244 | }, 245 | "real": { 246 | "type": "number" 247 | }, 248 | "imag": { 249 | "type": "number" 250 | } 251 | } 252 | }, { 253 | "description": "A reference to an optimization variable", 254 | "examples": ["{\"type\": \"variable\", \"name\": \"x\"}"], 255 | "required": ["name"], 256 | "properties": { 257 | "type": { 258 | "const": "variable" 259 | }, 260 | "name": { 261 | "type": "string" 262 | } 263 | } 264 | }, { 265 | "description": "A pointer to a (1-indexed) element in the `node_list` field in a nonlinear function", 266 | "examples": ["{\"type\": \"node\", \"index\": 2}"], 267 | "required": ["index"], 268 | "properties": { 269 | "type": { 270 | "const": "node" 271 | }, 272 | "index": { 273 | "type": "integer", 274 | "minimum": 1 275 | } 276 | } 277 | }] 278 | }, 279 | "scalar_functions": { 280 | "description": "A schema for the scalar-valued functions defined by MathOptFormat.See http://www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Functions-and-function-modifications-1 for a list of the functions and their meanings.", 281 | "type": "object", 282 | "required": ["type"], 283 | "oneOf": [{ 284 | "description": "The scalar variable `variable`.", 285 | "examples": ["{\"type\": \"SingleVariable\", \"variable\": \"x\"}"], 286 | "required": ["variable"], 287 | "properties": { 288 | "type": { 289 | "const": "SingleVariable" 290 | }, 291 | "variable": { 292 | "type": "string" 293 | } 294 | } 295 | }, { 296 | "description": "The function `a'x + b`, where `a` is a sparse vector specified by a list of `ScalarAffineTerm`s in `terms` and `b` is the scalar in `constant`. Duplicate variables in `terms` are accepted, and the corresponding coefficients are summed together.", 297 | "examples": ["{\"type\": \"ScalarAffineFunction\", \"constant\": 1.0, \"terms\": [{\"coefficient\": 2.5, \"variable\": \"x\"}]}"], 298 | "required": ["constant", "terms"], 299 | "properties": { 300 | "type": { 301 | "const": "ScalarAffineFunction" 302 | }, 303 | "constant": { 304 | "type": "number" 305 | }, 306 | "terms": { 307 | "type": "array", 308 | "items": { 309 | "$ref": "#/definitions/ScalarAffineTerm" 310 | } 311 | } 312 | } 313 | }, { 314 | "description": "The function `0.5x'Qx + a'x + b`, where `a` is a sparse vector of `ScalarAffineTerm`s in `affine_terms`, `b` is the scalar `constant`, and `Q` is a symmetric matrix specified by a list of `ScalarQuadraticTerm`s in `quadratic_terms`. Duplicate indices in `affine_terms` and `quadratic` are accepted, and the corresponding coefficients are summed together. Mirrored indices in `quadratic_terms` (i.e., `(i,j)` and `(j, i)`) are considered duplicates; only one need to be specified.", 315 | "examples": ["{\"type\": \"ScalarQuadraticFunction\", \"constant\": 1.0, \"affine_terms\": [{\"coefficient\": 2.5, \"variable\": \"x\"}], \"quadratic_terms\": [{\"coefficient\": 2.0, \"variable_1\": \"x\", \"variable_2\": \"y\"}]}"], 316 | "required": ["constant", "affine_terms", "quadratic_terms"], 317 | "properties": { 318 | "type": { 319 | "const": "ScalarQuadraticFunction" 320 | }, 321 | "constant": { 322 | "type": "number" 323 | }, 324 | "affine_terms": { 325 | "type": "array", 326 | "items": { 327 | "$ref": "#/definitions/ScalarAffineTerm" 328 | } 329 | }, 330 | "quadratic_terms": { 331 | "type": "array", 332 | "items": { 333 | "$ref": "#/definitions/ScalarQuadraticTerm" 334 | } 335 | } 336 | } 337 | }, { 338 | "description": "An expression graph representing a scalar nonlinear function.", 339 | "required": ["root", "node_list"], 340 | "properties": { 341 | "type": { 342 | "const": "ScalarNonlinearFunction" 343 | }, 344 | "root": { 345 | "$ref": "#/definitions/NonlinearTerm" 346 | }, 347 | "node_list": { 348 | "type": "array", 349 | "items": { 350 | "$ref": "#/definitions/NonlinearTerm" 351 | } 352 | } 353 | } 354 | }] 355 | }, 356 | "vector_functions": { 357 | "description": "A schema for the vector-valued functions defined by MathOptFormat.See http://www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Functions-and-function-modifications-1 for a list of the functions and their meanings.", 358 | "type": "object", 359 | "required": ["type"], 360 | "oneOf": [{ 361 | "description": "An ordered list of variables.", 362 | "examples": ["{\"type\": \"VectorOfVariables\", \"variables\": [\"x\", \"y\"]}"], 363 | "required": ["variables"], 364 | "properties": { 365 | "type": { 366 | "const": "VectorOfVariables" 367 | }, 368 | "variables": { 369 | "type": "array", 370 | "items": { 371 | "type": "string" 372 | } 373 | } 374 | } 375 | }, { 376 | "description": "The function `Ax + b`, where `A` is a sparse matrix specified by a list of `VectorAffineTerm`s in `terms` and `b` is a dense vector specified by `constants`.", 377 | "examples": ["{\"type\": \"VectorAffineFunction\", \"constants\": [1.0], \"terms\": [{\"output_index\": 1, \"scalar_term\": {\"coefficient\": 2.5, \"variable\": \"x\"}}]}"], 378 | "required": ["constants", "terms"], 379 | "properties": { 380 | "type": { 381 | "const": "VectorAffineFunction" 382 | }, 383 | "constants": { 384 | "type": "array", 385 | "items": { 386 | "type": "number" 387 | } 388 | }, 389 | "terms": { 390 | "type": "array", 391 | "items": { 392 | "$ref": "#/definitions/VectorAffineTerm" 393 | } 394 | } 395 | } 396 | }, { 397 | "description": "The vector-valued quadratic function `q(x) + Ax + b`, where `q(x)` is specified by a list of `VectorQuadraticTerm`s in `quadratic_terms`, `A` is a sparse matrix specified by a list of `VectorAffineTerm`s in `affine_terms` and `b` is a dense vector specified by `constants`.", 398 | "required": ["constants", "affine_terms", "quadratic_terms"], 399 | "properties": { 400 | "type": { 401 | "const": "VectorQuadraticFunction" 402 | }, 403 | "constants": { 404 | "type": "array", 405 | "items": { 406 | "type": "number" 407 | } 408 | }, 409 | "affine_terms": { 410 | "type": "array", 411 | "items": { 412 | "$ref": "#/definitions/VectorAffineTerm" 413 | } 414 | }, 415 | "quadratc_terms": { 416 | "type": "array", 417 | "items": { 418 | "$ref": "#/definitions/VectorQuadraticTerm" 419 | } 420 | } 421 | } 422 | }] 423 | }, 424 | "scalar_sets": { 425 | "description": "A schema for the scalar-valued sets defined by MathOptFormat. See http: //www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Sets-1 for a list of the sets and their meanings.", 426 | "type": "object", 427 | "required": ["type"], 428 | "oneOf": [{ 429 | "description": "(-∞, upper]", 430 | "examples": ["{\"type\": \"LessThan\", \"upper\": 2.1}"], 431 | "required": ["upper"], 432 | "properties": { 433 | "type": { 434 | "const": "LessThan" 435 | }, 436 | "upper": { 437 | "type": "number" 438 | } 439 | } 440 | }, { 441 | "description": "[lower, ∞)", 442 | "examples": ["{\"type\": \"GreaterThan\", \"lower\": 2.1}"], 443 | "required": ["lower"], 444 | "properties": { 445 | "type": { 446 | "const": "GreaterThan" 447 | }, 448 | "lower": { 449 | "type": "number" 450 | } 451 | } 452 | }, { 453 | "description": "{value}", 454 | "examples": ["{\"type\": \"EqualTo\", \"value\": 2.1}"], 455 | "required": ["value"], 456 | "properties": { 457 | "type": { 458 | "const": "EqualTo" 459 | }, 460 | "value": { 461 | "type": "number" 462 | } 463 | } 464 | }, { 465 | "description": "[lower, upper]", 466 | "examples": ["{\"type\": \"Interval\", \"lower\": 2.1, \"upper\": 3.4}"], 467 | "required": ["lower", "upper"], 468 | "properties": { 469 | "type": { 470 | "const": "Interval" 471 | }, 472 | "lower": { 473 | "type": "number" 474 | }, 475 | "upper": { 476 | "type": "number" 477 | } 478 | } 479 | }, { 480 | "description": "{0} ∪ {lower, lower + 1, ..., upper}", 481 | "examples": ["{\"type\": \"Semiinteger\", \"lower\": 2, \"upper\": 4}"], 482 | "required": ["lower", "upper"], 483 | "properties": { 484 | "type": { 485 | "const": "Semiinteger" 486 | }, 487 | "lower": { 488 | "type": "number" 489 | }, 490 | "upper": { 491 | "type": "number" 492 | } 493 | } 494 | }, { 495 | "description": "{0} ∪ [lower, upper]", 496 | "examples": ["{\"type\": \"Semicontinuous\", \"lower\": 2.1, \"upper\": 3.4}"], 497 | "required": ["lower", "upper"], 498 | "properties": { 499 | "type": { 500 | "const": "Semicontinuous" 501 | }, 502 | "lower": { 503 | "type": "number" 504 | }, 505 | "upper": { 506 | "type": "number" 507 | } 508 | } 509 | }, { 510 | "description": "{0, 1}", 511 | "examples": ["{\"type\": \"ZeroOne\"}"], 512 | "properties": { 513 | "type": { 514 | "const": "ZeroOne" 515 | } 516 | } 517 | }, { 518 | "description": "ℤ", 519 | "examples": ["{\"type\": \"Integer\"}"], 520 | "properties": { 521 | "type": { 522 | "const": "Integer" 523 | } 524 | } 525 | }] 526 | }, 527 | "vector_sets": { 528 | "description": "A schema for the vector-valued sets defined by MathOptFormat. See http: //www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Sets-1 for a list of the sets and their meanings.", 529 | "type": "object", 530 | "required": ["type"], 531 | "oneOf": [{ 532 | "description": "[x, y, z] ∈ {R³: y * exp(x / y) ≤ z, y ≥ 0}", 533 | "examples": ["{\"type\": \"ExponentialCone\"}"], 534 | "properties": { 535 | "type": { 536 | "const": "ExponentialCone" 537 | } 538 | } 539 | }, { 540 | "description": "[u, v, w] ∈ {R³: -u * exp(v / u) ≤ exp(1) * w, u < 0}", 541 | "examples": ["{\"type\": \"DualExponentialCone\"}"], 542 | "properties": { 543 | "type": { 544 | "const": "DualExponentialCone" 545 | } 546 | } 547 | }, { 548 | "description": "A special ordered set of type I.", 549 | "examples": ["{\"type\": \"SOS1\", \"weights\": [1, 3, 2]}"], 550 | "required": ["weights"], 551 | "properties": { 552 | "type": { 553 | "const": "SOS1" 554 | }, 555 | "weights": { 556 | "type": "array", 557 | "items": { 558 | "type": "number" 559 | } 560 | } 561 | } 562 | }, { 563 | "description": "A special ordered set of type II.", 564 | "examples": ["{\"type\": \"SOS2\", \"weights\": [1, 3, 2]}"], 565 | "required": ["weights"], 566 | "properties": { 567 | "type": { 568 | "const": "SOS2" 569 | }, 570 | "weights": { 571 | "type": "array", 572 | "items": { 573 | "type": "number" 574 | } 575 | } 576 | } 577 | }, { 578 | "description": "[t, x] ∈ {R^{dimension}: t ≤ (Πxᵢ)^{1 / (dimension-1)}}", 579 | "examples": ["{\"type\": \"GeometricMeanCone\", \"dimension\": 3}"], 580 | "required": ["dimension"], 581 | "properties": { 582 | "type": { 583 | "const": "GeometricMeanCone" 584 | }, 585 | "dimension": { 586 | "type": "integer", 587 | "minimum": 1 588 | } 589 | } 590 | }, { 591 | "description": "[t, x] ∈ {R^{dimension} : t ≥ ||x||₂", 592 | "examples": ["{\"type\": \"SecondOrderCone\", \"dimension\": 3}"], 593 | "required": ["dimension"], 594 | "properties": { 595 | "type": { 596 | "const": "SecondOrderCone" 597 | }, 598 | "dimension": { 599 | "type": "integer", 600 | "minimum": 1 601 | } 602 | } 603 | }, { 604 | "description": "[t, u, x] ∈ {R^{dimension} : 2tu ≥ (||x||₂)²; t, u ≥ 0}", 605 | "examples": ["{\"type\": \"RotatedSecondOrderCone\", \"dimension\": 3}"], 606 | "required": ["dimension"], 607 | "properties": { 608 | "type": { 609 | "const": "RotatedSecondOrderCone" 610 | }, 611 | "dimension": { 612 | "type": "integer", 613 | "minimum": 1 614 | } 615 | } 616 | }, { 617 | "description": "{0}^{dimension}", 618 | "examples": ["{\"type\": \"Zeros\", \"dimension\": 3}"], 619 | "required": ["dimension"], 620 | "properties": { 621 | "type": { 622 | "const": "Zeros" 623 | }, 624 | "dimension": { 625 | "type": "integer", 626 | "minimum": 1 627 | } 628 | } 629 | }, { 630 | "description": "R^{dimension}", 631 | "examples": ["{\"type\": \"Reals\", \"dimension\": 3}"], 632 | "required": ["dimension"], 633 | "properties": { 634 | "type": { 635 | "const": "Reals" 636 | }, 637 | "dimension": { 638 | "type": "integer", 639 | "minimum": 1 640 | } 641 | } 642 | }, { 643 | "description": "R₋^{dimension}", 644 | "examples": ["{\"type\": \"Nonpositives\", \"dimension\": 3}"], 645 | "required": ["dimension"], 646 | "properties": { 647 | "type": { 648 | "const": "Nonpositives" 649 | }, 650 | "dimension": { 651 | "type": "integer", 652 | "minimum": 1 653 | } 654 | } 655 | }, { 656 | "description": "R₊^{dimension}", 657 | "examples": ["{\"type\": \"Nonnegatives\", \"dimension\": 3}"], 658 | "required": ["dimension"], 659 | "properties": { 660 | "type": { 661 | "const": "Nonnegatives" 662 | }, 663 | "dimension": { 664 | "type": "integer", 665 | "minimum": 1 666 | } 667 | } 668 | }, { 669 | "description": "{[t, X] ∈ R^{1 + d(d+1)/2} : t ≤ det(X)^{1/d}}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeTriangle`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 670 | "examples": ["{\"type\": \"RootDetConeTriangle\", \"side_dimension\": 2}"], 671 | "required": ["side_dimension"], 672 | "properties": { 673 | "type": { 674 | "const": "RootDetConeTriangle" 675 | }, 676 | "side_dimension": { 677 | "type": "integer", 678 | "minimum": 1 679 | } 680 | } 681 | }, { 682 | "description": "{[t, X] ∈ R^{1 + d^2} : t ≤ det(X)^{1/d}, X symmetric}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeSquare`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 683 | "examples": ["{\"type\": \"RootDetConeSquare\", \"side_dimension\": 2}"], 684 | "required": ["side_dimension"], 685 | "properties": { 686 | "type": { 687 | "const": "RootDetConeSquare" 688 | }, 689 | "side_dimension": { 690 | "type": "integer", 691 | "minimum": 1 692 | } 693 | } 694 | }, { 695 | "description": "{[t, u, X] ∈ R^{2 + d(d+1)/2} : t ≤ u log(det(X/u)), u > 0}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeTriangle`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 696 | "examples": ["{\"type\": \"LogDetConeTriangle\", \"side_dimension\": 2}"], 697 | "required": ["side_dimension"], 698 | "properties": { 699 | "type": { 700 | "const": "LogDetConeTriangle" 701 | }, 702 | "side_dimension": { 703 | "type": "integer", 704 | "minimum": 1 705 | } 706 | } 707 | }, { 708 | "description": "{[t, u, X] ∈ R^{2 + d^2} : t ≤ u log(det(X/u)), X symmetric, u > 0}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeSquare`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 709 | "examples": ["{\"type\": \"LogDetConeSquare\", \"side_dimension\": 2}"], 710 | "required": ["side_dimension"], 711 | "properties": { 712 | "type": { 713 | "const": "LogDetConeSquare" 714 | }, 715 | "side_dimension": { 716 | "type": "integer", 717 | "minimum": 1 718 | } 719 | } 720 | }, { 721 | "description": "The (vectorized) cone of symmetric positive semidefinite matrices, with `side_dimension` rows and columns. The entries of the upper-right triangular part of the matrix are given column by column (or equivalently, the entries of the lower-left triangular part are given row by row).", 722 | "examples": ["{\"type\": \"PositiveSemidefiniteConeTriangle\", \"side_dimension\": 2}"], 723 | "required": ["side_dimension"], 724 | "properties": { 725 | "type": { 726 | "const": "PositiveSemidefiniteConeTriangle" 727 | }, 728 | "side_dimension": { 729 | "type": "integer", 730 | "minimum": 1 731 | } 732 | } 733 | }, { 734 | "description": "The cone of symmetric positive semidefinite matrices, with side length `side_dimension`. The entries of the matrix are given column by column (or equivalently, row by row). The matrix is both constrained to be symmetric and to be positive semidefinite. That is, if the functions in entries `(i, j)` and `(j, i)` are different, then a constraint will be added to make sure that the entries are equal.", 735 | "examples": ["{\"type\": \"PositiveSemidefiniteConeSquare\", \"side_dimension\": 2}"], 736 | "required": ["side_dimension"], 737 | "properties": { 738 | "type": { 739 | "const": "PositiveSemidefiniteConeSquare" 740 | }, 741 | "side_dimension": { 742 | "type": "integer", 743 | "minimum": 1 744 | } 745 | } 746 | }, { 747 | "description": "[x, y, z] ∈ {R³: x^{exponent} y^{1-exponent} ≥ |z|; x, y ≥ 0}", 748 | "examples": ["{\"type\": \"PowerCone\", \"exponent\": 2.0}"], 749 | "required": ["exponent"], 750 | "properties": { 751 | "type": { 752 | "const": "PowerCone" 753 | }, 754 | "exponent": { 755 | "type": "number" 756 | } 757 | } 758 | }, { 759 | "description": "[u, v, w] ∈ {R³: (u / exponent)^{exponent} (v / (1-exponent))^{1-exponent} ≥ |w|; u, v ≥ 0}", 760 | "examples": ["{\"type\": \"DualPowerCone\", \"exponent\": 2.0}"], 761 | "required": ["exponent"], 762 | "properties": { 763 | "type": { 764 | "const": "DualPowerCone" 765 | }, 766 | "exponent": { 767 | "type": "number" 768 | } 769 | } 770 | }, { 771 | "description": "If `activate_on=one`: (y, x) ∈ {0,1}×Rᴺ: y = 0 ⟹ x ∈ S, otherwise when `activate_on=zero`: (y, x) ∈ {0,1}×Rᴺ: y = 1 ⟹ x ∈ S.", 772 | "examples": ["{\"type\": \"IndicatorSet\", \"set\": {\"type\": \"LessThan\", \"upper\": 2.0}, \"activate_on\": \"one\"}"], 773 | "required": ["set", "activate_on"], 774 | "properties": { 775 | "type": { 776 | "const": "IndicatorSet" 777 | }, 778 | "set": { 779 | "oneOf": [{ 780 | "$ref": "#/definitions/scalar_sets" 781 | }, { 782 | "$ref": "#/definitions/vector_sets" 783 | }] 784 | }, 785 | "activate_on": { 786 | "enum": ["one", "zero"] 787 | } 788 | } 789 | }, { 790 | "description": "(t, x) ∈ {R^{dimension}: t ≥ Σᵢ|xᵢ|}", 791 | "examples": ["{\"type\": \"NormOneCone\", \"dimension\": 2}"], 792 | "required": ["dimension"], 793 | "properties": { 794 | "type": { 795 | "const": "NormOneCone" 796 | }, 797 | "dimension": { 798 | "type": "integer", 799 | "minimum": 2 800 | } 801 | } 802 | }, { 803 | "description": "(t, x) ∈ {R^{dimension}: t ≥ maxᵢ|xᵢ|}", 804 | "examples": ["{\"type\": \"NormInfinityCone\", \"dimension\": 2}"], 805 | "required": ["dimension"], 806 | "properties": { 807 | "type": { 808 | "const": "NormInfinityCone" 809 | }, 810 | "dimension": { 811 | "type": "integer", 812 | "minimum": 2 813 | } 814 | } 815 | }, { 816 | "description": "(u, v, w) ∈ {R^{dimension}: u ≥ sumᵢ wᵢlog(wᵢ/vᵢ), vᵢ ≥ 0, wᵢ ≥ 0}", 817 | "examples": ["{\"type\": \"RelativeEntropyCone\", \"dimension\": 3}"], 818 | "required": ["dimension"], 819 | "properties": { 820 | "type": { 821 | "const": "RelativeEntropyCone" 822 | }, 823 | "dimension": { 824 | "type": "integer", 825 | "minimum": 3 826 | } 827 | } 828 | }, { 829 | "description": "(t, X) ∈ {R^{1+row_dim×column_dim}: t ≥ σ₁(X)}", 830 | "examples": ["{\"type\": \"NormSpectralCone\", \"row_dim\": 1, \"column_dim\": 2}"], 831 | "required": ["row_dim", "column_dim"], 832 | "properties": { 833 | "type": { 834 | "const": "NormSpectralCone" 835 | }, 836 | "row_dim": { 837 | "type": "integer", 838 | "minimum": 1 839 | }, 840 | "column_dim": { 841 | "type": "integer", 842 | "minimum": 1 843 | } 844 | } 845 | }, { 846 | "description": "(t, X) ∈ {R^{1+row_dim×column_dim}: t ≥ σ₁(X)}", 847 | "examples": ["{\"type\": \"NormNuclearCone\", \"row_dim\": 1, \"column_dim\": 2}"], 848 | "required": ["row_dim", "column_dim"], 849 | "properties": { 850 | "type": { 851 | "const": "NormNuclearCone" 852 | }, 853 | "row_dim": { 854 | "type": "integer", 855 | "minimum": 1 856 | }, 857 | "column_dim": { 858 | "type": "integer", 859 | "minimum": 1 860 | } 861 | } 862 | }] 863 | } 864 | } 865 | } 866 | -------------------------------------------------------------------------------- /schemas/mof.0.6.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/schema#", 3 | "$id": "https://jump.dev/MathOptFormat/schemas/mof.0.6.schema.json", 4 | "title": "The schema for MathOptFormat", 5 | "type": "object", 6 | "required": ["version", "variables", "objective", "constraints"], 7 | "properties": { 8 | "version": { 9 | "description": "The version of MathOptFormat that this schema validates against.", 10 | "type": "object", 11 | "required": ["minor", "major"], 12 | "properties": { 13 | "minor": { 14 | "const": 6 15 | }, 16 | "major": { 17 | "const": 0 18 | } 19 | } 20 | }, 21 | "name": { 22 | "description": "The name of the model.", 23 | "type": "string" 24 | }, 25 | "author": { 26 | "description": "The author of the model for citation purposes.", 27 | "type": "string" 28 | }, 29 | "description": { 30 | "description": "A human-readable description of the model.", 31 | "type": "string" 32 | }, 33 | "variables": { 34 | "description": "An array of variables in the model. Each must have a unique name.", 35 | "type": "array", 36 | "items": { 37 | "type": "object", 38 | "required": ["name"], 39 | "properties": { 40 | "name": { 41 | "type": "string" 42 | }, 43 | "primal_start": { 44 | "description": "An initial value that the optimizer may use to warm-start the solution process.", 45 | "type": "number" 46 | } 47 | } 48 | }, 49 | "uniqueItems": true 50 | }, 51 | "objective": { 52 | "description": "The objective of the model.", 53 | "type": "object", 54 | "required": ["sense"], 55 | "oneOf": [{ 56 | "properties": { 57 | "sense": { 58 | "enum": ["min", "max"] 59 | }, 60 | "function": { 61 | "oneOf": [{ 62 | "$ref": "#/definitions/scalar_functions" 63 | }, { 64 | "$ref": "#/definitions/vector_functions" 65 | }] 66 | } 67 | } 68 | }, { 69 | "properties": { 70 | "sense": { 71 | "const": "feasibility" 72 | } 73 | } 74 | }] 75 | }, 76 | "constraints": { 77 | "description": "An array of constraints in the model. Scalar-valued functions can only be paired with scalar-sets, and the same applies for vector-valued functions and sets.", 78 | "type": "array", 79 | "items": { 80 | "type": "object", 81 | "required": ["function", "set"], 82 | "properties": { 83 | "name": { 84 | "type": "string" 85 | } 86 | }, 87 | "oneOf": [{ 88 | "description": "A scalar-valued constraint.", 89 | "properties": { 90 | "function": { 91 | "$ref": "#/definitions/scalar_functions" 92 | }, 93 | "set": { 94 | "$ref": "#/definitions/scalar_sets" 95 | } 96 | } 97 | }, { 98 | "description": "A vector-valued constraint.", 99 | "properties": { 100 | "function": { 101 | "$ref": "#/definitions/vector_functions" 102 | }, 103 | "set": { 104 | "$ref": "#/definitions/vector_sets" 105 | } 106 | } 107 | }] 108 | }, 109 | "uniqueItems": true 110 | } 111 | }, 112 | "definitions": { 113 | "ScalarAffineTerm": { 114 | "description": "A helper object that represents `coefficent * variable`.", 115 | "type": "object", 116 | "required": ["coefficient", "variable"], 117 | "properties": { 118 | "coefficient": { 119 | "type": "number" 120 | }, 121 | "variable": { 122 | "type": "string" 123 | } 124 | } 125 | }, 126 | "ScalarQuadraticTerm": { 127 | "description": "A helper object that represents `coefficent * variable_1 * variable_2`.", 128 | "type": "object", 129 | "required": ["coefficient", "variable_1", "variable_2"], 130 | "properties": { 131 | "coefficient": { 132 | "type": "number" 133 | }, 134 | "variable_1": { 135 | "type": "string" 136 | }, 137 | "variable_2": { 138 | "type": "string" 139 | } 140 | } 141 | }, 142 | "VectorAffineTerm": { 143 | "description": "A helper object that represents a `ScalarAffineTerm` in row `output_index`.", 144 | "type": "object", 145 | "required": ["output_index", "scalar_term"], 146 | "properties": { 147 | "output_index": { 148 | "type": "integer", 149 | "minimum": 1 150 | }, 151 | "scalar_term": { 152 | "$ref": "#/definitions/ScalarAffineTerm" 153 | } 154 | } 155 | }, 156 | "VectorQuadraticTerm": { 157 | "description": "A helper object that represents a `ScalarQuadraticTerm` in row `output_index`.", 158 | "type": "object", 159 | "required": ["output_index", "scalar_term"], 160 | "properties": { 161 | "output_index": { 162 | "type": "integer", 163 | "minimum": 1 164 | }, 165 | "scalar_term": { 166 | "$ref": "#/definitions/ScalarQuadraticTerm" 167 | } 168 | } 169 | }, 170 | "NonlinearTerm": { 171 | "description": "A node in an expresion graph representing a nonlinear function.", 172 | "type": "object", 173 | "required": ["type"], 174 | "oneOf": [{ 175 | "description": "Unary operators", 176 | "required": ["args"], 177 | "properties": { 178 | "type": { 179 | "enum": [ 180 | "log", "log10", "exp", "sqrt", "floor", "ceil", 181 | "abs", "cos", "sin", "tan", "acos", "asin", "atan", 182 | "cosh", "sinh", "tanh", "acosh", "asinh", "atanh" 183 | ] 184 | }, 185 | "args": { 186 | "type": "array", 187 | "items": { 188 | "$ref": "#/definitions/NonlinearTerm" 189 | }, 190 | "minItems": 1, 191 | "maxItems": 1 192 | } 193 | } 194 | }, { 195 | "description": "Binary operators", 196 | "required": ["args"], 197 | "properties": { 198 | "type": { 199 | "enum": ["/", "^"] 200 | }, 201 | "args": { 202 | "type": "array", 203 | "items": { 204 | "$ref": "#/definitions/NonlinearTerm" 205 | }, 206 | "minItems": 2, 207 | "maxItems": 2 208 | } 209 | } 210 | }, { 211 | "description": "N-ary operators", 212 | "required": ["args"], 213 | "properties": { 214 | "type": { 215 | "enum": ["+", "-", "*", "min", "max"] 216 | }, 217 | "args": { 218 | "type": "array", 219 | "items": { 220 | "$ref": "#/definitions/NonlinearTerm" 221 | }, 222 | "minItems": 1 223 | } 224 | } 225 | }, { 226 | "description": "A real-valued numeric constant", 227 | "examples": ["{\"type\": \"real\", \"value\": 1.0}"], 228 | "required": ["value"], 229 | "properties": { 230 | "type": { 231 | "const": "real" 232 | }, 233 | "value": { 234 | "type": "number" 235 | } 236 | } 237 | }, { 238 | "description": "A complex-valued numeric constant", 239 | "examples": ["{\"type\": \"complex\", \"real\": 1.0, \"imag\": 2.0}"], 240 | "required": ["real", "imag"], 241 | "properties": { 242 | "type": { 243 | "const": "complex" 244 | }, 245 | "real": { 246 | "type": "number" 247 | }, 248 | "imag": { 249 | "type": "number" 250 | } 251 | } 252 | }, { 253 | "description": "A reference to an optimization variable", 254 | "examples": ["{\"type\": \"variable\", \"name\": \"x\"}"], 255 | "required": ["name"], 256 | "properties": { 257 | "type": { 258 | "const": "variable" 259 | }, 260 | "name": { 261 | "type": "string" 262 | } 263 | } 264 | }, { 265 | "description": "A pointer to a (1-indexed) element in the `node_list` field in a nonlinear function", 266 | "examples": ["{\"type\": \"node\", \"index\": 2}"], 267 | "required": ["index"], 268 | "properties": { 269 | "type": { 270 | "const": "node" 271 | }, 272 | "index": { 273 | "type": "integer", 274 | "minimum": 1 275 | } 276 | } 277 | }] 278 | }, 279 | "scalar_functions": { 280 | "description": "A schema for the scalar-valued functions defined by MathOptFormat.See http://www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Functions-and-function-modifications-1 for a list of the functions and their meanings.", 281 | "type": "object", 282 | "required": ["type"], 283 | "oneOf": [{ 284 | "description": "The scalar variable `variable`.", 285 | "examples": ["{\"type\": \"SingleVariable\", \"variable\": \"x\"}"], 286 | "required": ["variable"], 287 | "properties": { 288 | "type": { 289 | "const": "SingleVariable" 290 | }, 291 | "variable": { 292 | "type": "string" 293 | } 294 | } 295 | }, { 296 | "description": "The function `a'x + b`, where `a` is a sparse vector specified by a list of `ScalarAffineTerm`s in `terms` and `b` is the scalar in `constant`. Duplicate variables in `terms` are accepted, and the corresponding coefficients are summed together.", 297 | "examples": ["{\"type\": \"ScalarAffineFunction\", \"constant\": 1.0, \"terms\": [{\"coefficient\": 2.5, \"variable\": \"x\"}]}"], 298 | "required": ["constant", "terms"], 299 | "properties": { 300 | "type": { 301 | "const": "ScalarAffineFunction" 302 | }, 303 | "constant": { 304 | "type": "number" 305 | }, 306 | "terms": { 307 | "type": "array", 308 | "items": { 309 | "$ref": "#/definitions/ScalarAffineTerm" 310 | } 311 | } 312 | } 313 | }, { 314 | "description": "The function `0.5x'Qx + a'x + b`, where `a` is a sparse vector of `ScalarAffineTerm`s in `affine_terms`, `b` is the scalar `constant`, and `Q` is a symmetric matrix specified by a list of `ScalarQuadraticTerm`s in `quadratic_terms`. Duplicate indices in `affine_terms` and `quadratic` are accepted, and the corresponding coefficients are summed together. Mirrored indices in `quadratic_terms` (i.e., `(i,j)` and `(j, i)`) are considered duplicates; only one need to be specified.", 315 | "examples": ["{\"type\": \"ScalarQuadraticFunction\", \"constant\": 1.0, \"affine_terms\": [{\"coefficient\": 2.5, \"variable\": \"x\"}], \"quadratic_terms\": [{\"coefficient\": 2.0, \"variable_1\": \"x\", \"variable_2\": \"y\"}]}"], 316 | "required": ["constant", "affine_terms", "quadratic_terms"], 317 | "properties": { 318 | "type": { 319 | "const": "ScalarQuadraticFunction" 320 | }, 321 | "constant": { 322 | "type": "number" 323 | }, 324 | "affine_terms": { 325 | "type": "array", 326 | "items": { 327 | "$ref": "#/definitions/ScalarAffineTerm" 328 | } 329 | }, 330 | "quadratic_terms": { 331 | "type": "array", 332 | "items": { 333 | "$ref": "#/definitions/ScalarQuadraticTerm" 334 | } 335 | } 336 | } 337 | }, { 338 | "description": "An expression graph representing a scalar nonlinear function.", 339 | "required": ["root", "node_list"], 340 | "properties": { 341 | "type": { 342 | "const": "ScalarNonlinearFunction" 343 | }, 344 | "root": { 345 | "$ref": "#/definitions/NonlinearTerm" 346 | }, 347 | "node_list": { 348 | "type": "array", 349 | "items": { 350 | "$ref": "#/definitions/NonlinearTerm" 351 | } 352 | } 353 | } 354 | }] 355 | }, 356 | "vector_functions": { 357 | "description": "A schema for the vector-valued functions defined by MathOptFormat.See http://www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Functions-and-function-modifications-1 for a list of the functions and their meanings.", 358 | "type": "object", 359 | "required": ["type"], 360 | "oneOf": [{ 361 | "description": "An ordered list of variables.", 362 | "examples": ["{\"type\": \"VectorOfVariables\", \"variables\": [\"x\", \"y\"]}"], 363 | "required": ["variables"], 364 | "properties": { 365 | "type": { 366 | "const": "VectorOfVariables" 367 | }, 368 | "variables": { 369 | "type": "array", 370 | "items": { 371 | "type": "string" 372 | } 373 | } 374 | } 375 | }, { 376 | "description": "The function `Ax + b`, where `A` is a sparse matrix specified by a list of `VectorAffineTerm`s in `terms` and `b` is a dense vector specified by `constants`.", 377 | "examples": ["{\"type\": \"VectorAffineFunction\", \"constants\": [1.0], \"terms\": [{\"output_index\": 1, \"scalar_term\": {\"coefficient\": 2.5, \"variable\": \"x\"}}]}"], 378 | "required": ["constants", "terms"], 379 | "properties": { 380 | "type": { 381 | "const": "VectorAffineFunction" 382 | }, 383 | "constants": { 384 | "type": "array", 385 | "items": { 386 | "type": "number" 387 | } 388 | }, 389 | "terms": { 390 | "type": "array", 391 | "items": { 392 | "$ref": "#/definitions/VectorAffineTerm" 393 | } 394 | } 395 | } 396 | }, { 397 | "description": "The vector-valued quadratic function `q(x) + Ax + b`, where `q(x)` is specified by a list of `VectorQuadraticTerm`s in `quadratic_terms`, `A` is a sparse matrix specified by a list of `VectorAffineTerm`s in `affine_terms` and `b` is a dense vector specified by `constants`.", 398 | "required": ["constants", "affine_terms", "quadratic_terms"], 399 | "properties": { 400 | "type": { 401 | "const": "VectorQuadraticFunction" 402 | }, 403 | "constants": { 404 | "type": "array", 405 | "items": { 406 | "type": "number" 407 | } 408 | }, 409 | "affine_terms": { 410 | "type": "array", 411 | "items": { 412 | "$ref": "#/definitions/VectorAffineTerm" 413 | } 414 | }, 415 | "quadratc_terms": { 416 | "type": "array", 417 | "items": { 418 | "$ref": "#/definitions/VectorQuadraticTerm" 419 | } 420 | } 421 | } 422 | }] 423 | }, 424 | "scalar_sets": { 425 | "description": "A schema for the scalar-valued sets defined by MathOptFormat. See http: //www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Sets-1 for a list of the sets and their meanings.", 426 | "type": "object", 427 | "required": ["type"], 428 | "oneOf": [{ 429 | "description": "(-∞, upper]", 430 | "examples": ["{\"type\": \"LessThan\", \"upper\": 2.1}"], 431 | "required": ["upper"], 432 | "properties": { 433 | "type": { 434 | "const": "LessThan" 435 | }, 436 | "upper": { 437 | "type": "number" 438 | } 439 | } 440 | }, { 441 | "description": "[lower, ∞)", 442 | "examples": ["{\"type\": \"GreaterThan\", \"lower\": 2.1}"], 443 | "required": ["lower"], 444 | "properties": { 445 | "type": { 446 | "const": "GreaterThan" 447 | }, 448 | "lower": { 449 | "type": "number" 450 | } 451 | } 452 | }, { 453 | "description": "{value}", 454 | "examples": ["{\"type\": \"EqualTo\", \"value\": 2.1}"], 455 | "required": ["value"], 456 | "properties": { 457 | "type": { 458 | "const": "EqualTo" 459 | }, 460 | "value": { 461 | "type": "number" 462 | } 463 | } 464 | }, { 465 | "description": "[lower, upper]", 466 | "examples": ["{\"type\": \"Interval\", \"lower\": 2.1, \"upper\": 3.4}"], 467 | "required": ["lower", "upper"], 468 | "properties": { 469 | "type": { 470 | "const": "Interval" 471 | }, 472 | "lower": { 473 | "type": "number" 474 | }, 475 | "upper": { 476 | "type": "number" 477 | } 478 | } 479 | }, { 480 | "description": "{0} ∪ {lower, lower + 1, ..., upper}", 481 | "examples": ["{\"type\": \"Semiinteger\", \"lower\": 2, \"upper\": 4}"], 482 | "required": ["lower", "upper"], 483 | "properties": { 484 | "type": { 485 | "const": "Semiinteger" 486 | }, 487 | "lower": { 488 | "type": "number" 489 | }, 490 | "upper": { 491 | "type": "number" 492 | } 493 | } 494 | }, { 495 | "description": "{0} ∪ [lower, upper]", 496 | "examples": ["{\"type\": \"Semicontinuous\", \"lower\": 2.1, \"upper\": 3.4}"], 497 | "required": ["lower", "upper"], 498 | "properties": { 499 | "type": { 500 | "const": "Semicontinuous" 501 | }, 502 | "lower": { 503 | "type": "number" 504 | }, 505 | "upper": { 506 | "type": "number" 507 | } 508 | } 509 | }, { 510 | "description": "{0, 1}", 511 | "examples": ["{\"type\": \"ZeroOne\"}"], 512 | "properties": { 513 | "type": { 514 | "const": "ZeroOne" 515 | } 516 | } 517 | }, { 518 | "description": "ℤ", 519 | "examples": ["{\"type\": \"Integer\"}"], 520 | "properties": { 521 | "type": { 522 | "const": "Integer" 523 | } 524 | } 525 | }] 526 | }, 527 | "vector_sets": { 528 | "description": "A schema for the vector-valued sets defined by MathOptFormat. See http: //www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Sets-1 for a list of the sets and their meanings.", 529 | "type": "object", 530 | "required": ["type"], 531 | "oneOf": [{ 532 | "description": "[x, y, z] ∈ {R³: y * exp(x / y) ≤ z, y ≥ 0}", 533 | "examples": ["{\"type\": \"ExponentialCone\"}"], 534 | "properties": { 535 | "type": { 536 | "const": "ExponentialCone" 537 | } 538 | } 539 | }, { 540 | "description": "[u, v, w] ∈ {R³: -u * exp(v / u) ≤ exp(1) * w, u < 0}", 541 | "examples": ["{\"type\": \"DualExponentialCone\"}"], 542 | "properties": { 543 | "type": { 544 | "const": "DualExponentialCone" 545 | } 546 | } 547 | }, { 548 | "description": "A special ordered set of type I.", 549 | "examples": ["{\"type\": \"SOS1\", \"weights\": [1, 3, 2]}"], 550 | "required": ["weights"], 551 | "properties": { 552 | "type": { 553 | "const": "SOS1" 554 | }, 555 | "weights": { 556 | "type": "array", 557 | "items": { 558 | "type": "number" 559 | } 560 | } 561 | } 562 | }, { 563 | "description": "A special ordered set of type II.", 564 | "examples": ["{\"type\": \"SOS2\", \"weights\": [1, 3, 2]}"], 565 | "required": ["weights"], 566 | "properties": { 567 | "type": { 568 | "const": "SOS2" 569 | }, 570 | "weights": { 571 | "type": "array", 572 | "items": { 573 | "type": "number" 574 | } 575 | } 576 | } 577 | }, { 578 | "description": "[t, x] ∈ {R^{dimension}: t ≤ (Πxᵢ)^{1 / (dimension-1)}}", 579 | "examples": ["{\"type\": \"GeometricMeanCone\", \"dimension\": 3}"], 580 | "required": ["dimension"], 581 | "properties": { 582 | "type": { 583 | "const": "GeometricMeanCone" 584 | }, 585 | "dimension": { 586 | "type": "integer", 587 | "minimum": 1 588 | } 589 | } 590 | }, { 591 | "description": "[t, x] ∈ {R^{dimension} : t ≥ ||x||₂", 592 | "examples": ["{\"type\": \"SecondOrderCone\", \"dimension\": 3}"], 593 | "required": ["dimension"], 594 | "properties": { 595 | "type": { 596 | "const": "SecondOrderCone" 597 | }, 598 | "dimension": { 599 | "type": "integer", 600 | "minimum": 1 601 | } 602 | } 603 | }, { 604 | "description": "[t, u, x] ∈ {R^{dimension} : 2tu ≥ (||x||₂)²; t, u ≥ 0}", 605 | "examples": ["{\"type\": \"RotatedSecondOrderCone\", \"dimension\": 3}"], 606 | "required": ["dimension"], 607 | "properties": { 608 | "type": { 609 | "const": "RotatedSecondOrderCone" 610 | }, 611 | "dimension": { 612 | "type": "integer", 613 | "minimum": 1 614 | } 615 | } 616 | }, { 617 | "description": "{0}^{dimension}", 618 | "examples": ["{\"type\": \"Zeros\", \"dimension\": 3}"], 619 | "required": ["dimension"], 620 | "properties": { 621 | "type": { 622 | "const": "Zeros" 623 | }, 624 | "dimension": { 625 | "type": "integer", 626 | "minimum": 1 627 | } 628 | } 629 | }, { 630 | "description": "R^{dimension}", 631 | "examples": ["{\"type\": \"Reals\", \"dimension\": 3}"], 632 | "required": ["dimension"], 633 | "properties": { 634 | "type": { 635 | "const": "Reals" 636 | }, 637 | "dimension": { 638 | "type": "integer", 639 | "minimum": 1 640 | } 641 | } 642 | }, { 643 | "description": "R₋^{dimension}", 644 | "examples": ["{\"type\": \"Nonpositives\", \"dimension\": 3}"], 645 | "required": ["dimension"], 646 | "properties": { 647 | "type": { 648 | "const": "Nonpositives" 649 | }, 650 | "dimension": { 651 | "type": "integer", 652 | "minimum": 1 653 | } 654 | } 655 | }, { 656 | "description": "R₊^{dimension}", 657 | "examples": ["{\"type\": \"Nonnegatives\", \"dimension\": 3}"], 658 | "required": ["dimension"], 659 | "properties": { 660 | "type": { 661 | "const": "Nonnegatives" 662 | }, 663 | "dimension": { 664 | "type": "integer", 665 | "minimum": 1 666 | } 667 | } 668 | }, { 669 | "description": "{[t, X] ∈ R^{1 + d(d+1)/2} : t ≤ det(X)^{1/d}}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeTriangle`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 670 | "examples": ["{\"type\": \"RootDetConeTriangle\", \"side_dimension\": 2}"], 671 | "required": ["side_dimension"], 672 | "properties": { 673 | "type": { 674 | "const": "RootDetConeTriangle" 675 | }, 676 | "side_dimension": { 677 | "type": "integer", 678 | "minimum": 1 679 | } 680 | } 681 | }, { 682 | "description": "{[t, X] ∈ R^{1 + d^2} : t ≤ det(X)^{1/d}, X symmetric}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeSquare`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 683 | "examples": ["{\"type\": \"RootDetConeSquare\", \"side_dimension\": 2}"], 684 | "required": ["side_dimension"], 685 | "properties": { 686 | "type": { 687 | "const": "RootDetConeSquare" 688 | }, 689 | "side_dimension": { 690 | "type": "integer", 691 | "minimum": 1 692 | } 693 | } 694 | }, { 695 | "description": "{[t, u, X] ∈ R^{2 + d(d+1)/2} : t ≤ u log(det(X/u)), u > 0}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeTriangle`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 696 | "examples": ["{\"type\": \"LogDetConeTriangle\", \"side_dimension\": 2}"], 697 | "required": ["side_dimension"], 698 | "properties": { 699 | "type": { 700 | "const": "LogDetConeTriangle" 701 | }, 702 | "side_dimension": { 703 | "type": "integer", 704 | "minimum": 1 705 | } 706 | } 707 | }, { 708 | "description": "{[t, u, X] ∈ R^{2 + d^2} : t ≤ u log(det(X/u)), X symmetric, u > 0}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeSquare`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 709 | "examples": ["{\"type\": \"LogDetConeSquare\", \"side_dimension\": 2}"], 710 | "required": ["side_dimension"], 711 | "properties": { 712 | "type": { 713 | "const": "LogDetConeSquare" 714 | }, 715 | "side_dimension": { 716 | "type": "integer", 717 | "minimum": 1 718 | } 719 | } 720 | }, { 721 | "description": "The (vectorized) cone of symmetric positive semidefinite matrices, with `side_dimension` rows and columns. The entries of the upper-right triangular part of the matrix are given column by column (or equivalently, the entries of the lower-left triangular part are given row by row).", 722 | "examples": ["{\"type\": \"PositiveSemidefiniteConeTriangle\", \"side_dimension\": 2}"], 723 | "required": ["side_dimension"], 724 | "properties": { 725 | "type": { 726 | "const": "PositiveSemidefiniteConeTriangle" 727 | }, 728 | "side_dimension": { 729 | "type": "integer", 730 | "minimum": 1 731 | } 732 | } 733 | }, { 734 | "description": "The cone of symmetric positive semidefinite matrices, with side length `side_dimension`. The entries of the matrix are given column by column (or equivalently, row by row). The matrix is both constrained to be symmetric and to be positive semidefinite. That is, if the functions in entries `(i, j)` and `(j, i)` are different, then a constraint will be added to make sure that the entries are equal.", 735 | "examples": ["{\"type\": \"PositiveSemidefiniteConeSquare\", \"side_dimension\": 2}"], 736 | "required": ["side_dimension"], 737 | "properties": { 738 | "type": { 739 | "const": "PositiveSemidefiniteConeSquare" 740 | }, 741 | "side_dimension": { 742 | "type": "integer", 743 | "minimum": 1 744 | } 745 | } 746 | }, { 747 | "description": "[x, y, z] ∈ {R³: x^{exponent} y^{1-exponent} ≥ |z|; x, y ≥ 0}", 748 | "examples": ["{\"type\": \"PowerCone\", \"exponent\": 2.0}"], 749 | "required": ["exponent"], 750 | "properties": { 751 | "type": { 752 | "const": "PowerCone" 753 | }, 754 | "exponent": { 755 | "type": "number" 756 | } 757 | } 758 | }, { 759 | "description": "[u, v, w] ∈ {R³: (u / exponent)^{exponent} (v / (1-exponent))^{1-exponent} ≥ |w|; u, v ≥ 0}", 760 | "examples": ["{\"type\": \"DualPowerCone\", \"exponent\": 2.0}"], 761 | "required": ["exponent"], 762 | "properties": { 763 | "type": { 764 | "const": "DualPowerCone" 765 | }, 766 | "exponent": { 767 | "type": "number" 768 | } 769 | } 770 | }, { 771 | "description": "If `activate_on=one`: (y, x) ∈ {0,1}×Rᴺ: y = 0 ⟹ x ∈ S, otherwise when `activate_on=zero`: (y, x) ∈ {0,1}×Rᴺ: y = 1 ⟹ x ∈ S.", 772 | "examples": ["{\"type\": \"IndicatorSet\", \"set\": {\"type\": \"LessThan\", \"upper\": 2.0}, \"activate_on\": \"one\"}"], 773 | "required": ["set", "activate_on"], 774 | "properties": { 775 | "type": { 776 | "const": "IndicatorSet" 777 | }, 778 | "set": { 779 | "oneOf": [{ 780 | "$ref": "#/definitions/scalar_sets" 781 | }, { 782 | "$ref": "#/definitions/vector_sets" 783 | }] 784 | }, 785 | "activate_on": { 786 | "enum": ["one", "zero"] 787 | } 788 | } 789 | }, { 790 | "description": "(t, x) ∈ {R^{dimension}: t ≥ Σᵢ|xᵢ|}", 791 | "examples": ["{\"type\": \"NormOneCone\", \"dimension\": 2}"], 792 | "required": ["dimension"], 793 | "properties": { 794 | "type": { 795 | "const": "NormOneCone" 796 | }, 797 | "dimension": { 798 | "type": "integer", 799 | "minimum": 2 800 | } 801 | } 802 | }, { 803 | "description": "(t, x) ∈ {R^{dimension}: t ≥ maxᵢ|xᵢ|}", 804 | "examples": ["{\"type\": \"NormInfinityCone\", \"dimension\": 2}"], 805 | "required": ["dimension"], 806 | "properties": { 807 | "type": { 808 | "const": "NormInfinityCone" 809 | }, 810 | "dimension": { 811 | "type": "integer", 812 | "minimum": 2 813 | } 814 | } 815 | }, { 816 | "description": "(u, v, w) ∈ {R^{dimension}: u ≥ Σᵢ wᵢlog(wᵢ/vᵢ), vᵢ ≥ 0, wᵢ ≥ 0}", 817 | "examples": ["{\"type\": \"RelativeEntropyCone\", \"dimension\": 3}"], 818 | "required": ["dimension"], 819 | "properties": { 820 | "type": { 821 | "const": "RelativeEntropyCone" 822 | }, 823 | "dimension": { 824 | "type": "integer", 825 | "minimum": 3 826 | } 827 | } 828 | }, { 829 | "description": "(t, X) ∈ {R^{1+row_dim×column_dim}: t ≥ σ₁(X)}", 830 | "examples": ["{\"type\": \"NormSpectralCone\", \"row_dim\": 1, \"column_dim\": 2}"], 831 | "required": ["row_dim", "column_dim"], 832 | "properties": { 833 | "type": { 834 | "const": "NormSpectralCone" 835 | }, 836 | "row_dim": { 837 | "type": "integer", 838 | "minimum": 1 839 | }, 840 | "column_dim": { 841 | "type": "integer", 842 | "minimum": 1 843 | } 844 | } 845 | }, { 846 | "description": "(t, X) ∈ {R^{1+row_dim×column_dim}: t ≥ Σᵢ σᵢ(X)}", 847 | "examples": ["{\"type\": \"NormNuclearCone\", \"row_dim\": 1, \"column_dim\": 2}"], 848 | "required": ["row_dim", "column_dim"], 849 | "properties": { 850 | "type": { 851 | "const": "NormNuclearCone" 852 | }, 853 | "row_dim": { 854 | "type": "integer", 855 | "minimum": 1 856 | }, 857 | "column_dim": { 858 | "type": "integer", 859 | "minimum": 1 860 | } 861 | } 862 | }, { 863 | "description": "The set corresponding to a mixed complementarity constraint. Complementarity constraints should be specified with an AbstractVectorFunction-in-Complements(dimension) constraint. The dimension of the vector-valued function `F` must be `dimension`. This defines a complementarity constraint between the scalar function `F[i]` and the variable in `F[i + dimension/2]`. Thus, `F[i + dimension/2]` must be interpretable as a single variable `x_i` (e.g., `1.0 * x + 0.0`). The mixed complementarity problem consists of finding `x_i` in the interval `[lb, ub]` (i.e., in the set `Interval(lb, ub)`), such that the following holds: 1. `F_i(x) == 0` if `lb_i < x_i < ub_i`; 2. `F_i(x) >= 0` if `lb_i == x_i`; 3. `F_i(x) <= 0` if `x_i == ub_i`. Classically, the bounding set for `x_i` is `Interval(0, Inf)`, which recovers: `0 <= F_i(x) ⟂ x_i >= 0`, where the `⟂` operator implies `F_i(x) * x_i = 0`.", 864 | "examples": ["{\"type\": \"Complements\", \"dimension\": 2}"], 865 | "required": ["dimension"], 866 | "properties": { 867 | "type": { 868 | "const": "Complements" 869 | }, 870 | "dimension": { 871 | "type": "integer", 872 | "minimum": 2 873 | } 874 | } 875 | }] 876 | } 877 | } 878 | } 879 | -------------------------------------------------------------------------------- /schemas/mof.1.0.schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/schema#", 3 | "$id": "https://jump.dev/MathOptFormat/schemas/mof.1.0.schema.json", 4 | "title": "The schema for MathOptFormat", 5 | "type": "object", 6 | "required": ["version", "variables", "objective", "constraints"], 7 | "properties": { 8 | "version": { 9 | "description": "The version of MathOptFormat that this schema validates against.", 10 | "type": "object", 11 | "required": ["minor", "major"], 12 | "properties": { 13 | "minor": { 14 | "const": 0 15 | }, 16 | "major": { 17 | "const": 1 18 | } 19 | } 20 | }, 21 | "name": { 22 | "description": "The name of the model.", 23 | "type": "string" 24 | }, 25 | "author": { 26 | "description": "The author of the model for citation purposes.", 27 | "type": "string" 28 | }, 29 | "description": { 30 | "description": "A human-readable description of the model.", 31 | "type": "string" 32 | }, 33 | "variables": { 34 | "description": "An array of variables in the model. Each must have a unique name.", 35 | "type": "array", 36 | "items": { 37 | "type": "object", 38 | "required": ["name"], 39 | "properties": { 40 | "name": { 41 | "type": "string" 42 | }, 43 | "primal_start": { 44 | "description": "An initial value that the optimizer may use to warm-start the solution process.", 45 | "type": "number" 46 | } 47 | } 48 | }, 49 | "uniqueItems": true 50 | }, 51 | "objective": { 52 | "description": "The objective of the model.", 53 | "type": "object", 54 | "required": ["sense"], 55 | "oneOf": [{ 56 | "properties": { 57 | "sense": { 58 | "enum": ["min", "max"] 59 | }, 60 | "function": { 61 | "oneOf": [{ 62 | "$ref": "#/definitions/scalar_functions" 63 | }, { 64 | "$ref": "#/definitions/vector_functions" 65 | }] 66 | } 67 | } 68 | }, { 69 | "properties": { 70 | "sense": { 71 | "const": "feasibility" 72 | } 73 | } 74 | }] 75 | }, 76 | "constraints": { 77 | "description": "An array of constraints in the model. Scalar-valued functions can only be paired with scalar-sets, and the same applies for vector-valued functions and sets.", 78 | "type": "array", 79 | "items": { 80 | "type": "object", 81 | "required": ["function", "set"], 82 | "properties": { 83 | "name": { 84 | "type": "string" 85 | } 86 | }, 87 | "oneOf": [{ 88 | "description": "A scalar-valued constraint.", 89 | "properties": { 90 | "function": { 91 | "$ref": "#/definitions/scalar_functions" 92 | }, 93 | "set": { 94 | "$ref": "#/definitions/scalar_sets" 95 | } 96 | } 97 | }, { 98 | "description": "A vector-valued constraint.", 99 | "properties": { 100 | "function": { 101 | "$ref": "#/definitions/vector_functions" 102 | }, 103 | "set": { 104 | "$ref": "#/definitions/vector_sets" 105 | } 106 | } 107 | }] 108 | }, 109 | "uniqueItems": true 110 | } 111 | }, 112 | "definitions": { 113 | "ScalarAffineTerm": { 114 | "description": "A helper object that represents `coefficent * variable`.", 115 | "type": "object", 116 | "required": ["coefficient", "variable"], 117 | "properties": { 118 | "coefficient": { 119 | "type": "number" 120 | }, 121 | "variable": { 122 | "type": "string" 123 | } 124 | } 125 | }, 126 | "ScalarQuadraticTerm": { 127 | "description": "A helper object that represents `coefficent * variable_1 * variable_2`.", 128 | "type": "object", 129 | "required": ["coefficient", "variable_1", "variable_2"], 130 | "properties": { 131 | "coefficient": { 132 | "type": "number" 133 | }, 134 | "variable_1": { 135 | "type": "string" 136 | }, 137 | "variable_2": { 138 | "type": "string" 139 | } 140 | } 141 | }, 142 | "VectorAffineTerm": { 143 | "description": "A helper object that represents a `ScalarAffineTerm` in row `output_index`.", 144 | "type": "object", 145 | "required": ["output_index", "scalar_term"], 146 | "properties": { 147 | "output_index": { 148 | "type": "integer", 149 | "minimum": 1 150 | }, 151 | "scalar_term": { 152 | "$ref": "#/definitions/ScalarAffineTerm" 153 | } 154 | } 155 | }, 156 | "VectorQuadraticTerm": { 157 | "description": "A helper object that represents a `ScalarQuadraticTerm` in row `output_index`.", 158 | "type": "object", 159 | "required": ["output_index", "scalar_term"], 160 | "properties": { 161 | "output_index": { 162 | "type": "integer", 163 | "minimum": 1 164 | }, 165 | "scalar_term": { 166 | "$ref": "#/definitions/ScalarQuadraticTerm" 167 | } 168 | } 169 | }, 170 | "NonlinearTerm": { 171 | "description": "A node in an expresion graph representing a nonlinear function.", 172 | "type": "object", 173 | "required": ["type"], 174 | "oneOf": [{ 175 | "description": "Unary operators", 176 | "required": ["args"], 177 | "properties": { 178 | "type": { 179 | "enum": [ 180 | "log", "log10", "exp", "sqrt", "floor", "ceil", 181 | "abs", "cos", "sin", "tan", "acos", "asin", "atan", 182 | "cosh", "sinh", "tanh", "acosh", "asinh", "atanh" 183 | ] 184 | }, 185 | "args": { 186 | "type": "array", 187 | "items": { 188 | "$ref": "#/definitions/NonlinearTerm" 189 | }, 190 | "minItems": 1, 191 | "maxItems": 1 192 | } 193 | } 194 | }, { 195 | "description": "Binary operators", 196 | "required": ["args"], 197 | "properties": { 198 | "type": { 199 | "enum": ["/", "^"] 200 | }, 201 | "args": { 202 | "type": "array", 203 | "items": { 204 | "$ref": "#/definitions/NonlinearTerm" 205 | }, 206 | "minItems": 2, 207 | "maxItems": 2 208 | } 209 | } 210 | }, { 211 | "description": "N-ary operators", 212 | "required": ["args"], 213 | "properties": { 214 | "type": { 215 | "enum": ["+", "-", "*", "min", "max"] 216 | }, 217 | "args": { 218 | "type": "array", 219 | "items": { 220 | "$ref": "#/definitions/NonlinearTerm" 221 | }, 222 | "minItems": 1 223 | } 224 | } 225 | }, { 226 | "description": "A real-valued numeric constant", 227 | "examples": ["{\"type\": \"real\", \"value\": 1.0}"], 228 | "required": ["value"], 229 | "properties": { 230 | "type": { 231 | "const": "real" 232 | }, 233 | "value": { 234 | "type": "number" 235 | } 236 | } 237 | }, { 238 | "description": "A complex-valued numeric constant", 239 | "examples": ["{\"type\": \"complex\", \"real\": 1.0, \"imag\": 2.0}"], 240 | "required": ["real", "imag"], 241 | "properties": { 242 | "type": { 243 | "const": "complex" 244 | }, 245 | "real": { 246 | "type": "number" 247 | }, 248 | "imag": { 249 | "type": "number" 250 | } 251 | } 252 | }, { 253 | "description": "A reference to an optimization variable", 254 | "examples": ["{\"type\": \"variable\", \"name\": \"x\"}"], 255 | "required": ["name"], 256 | "properties": { 257 | "type": { 258 | "const": "variable" 259 | }, 260 | "name": { 261 | "type": "string" 262 | } 263 | } 264 | }, { 265 | "description": "A pointer to a (1-indexed) element in the `node_list` field in a nonlinear function", 266 | "examples": ["{\"type\": \"node\", \"index\": 2}"], 267 | "required": ["index"], 268 | "properties": { 269 | "type": { 270 | "const": "node" 271 | }, 272 | "index": { 273 | "type": "integer", 274 | "minimum": 1 275 | } 276 | } 277 | }] 278 | }, 279 | "scalar_functions": { 280 | "description": "A schema for the scalar-valued functions defined by MathOptFormat.See http://www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Functions-and-function-modifications-1 for a list of the functions and their meanings.", 281 | "type": "object", 282 | "required": ["type"], 283 | "oneOf": [{ 284 | "description": "The scalar variable `x`.", 285 | "examples": ["{\"type\": \"Variable\", \"name\": \"x\"}"], 286 | "required": ["name"], 287 | "properties": { 288 | "type": { 289 | "const": "Variable" 290 | }, 291 | "name": { 292 | "type": "string" 293 | } 294 | } 295 | }, { 296 | "description": "The function `a'x + b`, where `a` is a sparse vector specified by a list of `ScalarAffineTerm`s in `terms` and `b` is the scalar in `constant`. Duplicate variables in `terms` are accepted, and the corresponding coefficients are summed together.", 297 | "examples": ["{\"type\": \"ScalarAffineFunction\", \"constant\": 1.0, \"terms\": [{\"coefficient\": 2.5, \"variable\": \"x\"}]}"], 298 | "required": ["constant", "terms"], 299 | "properties": { 300 | "type": { 301 | "const": "ScalarAffineFunction" 302 | }, 303 | "constant": { 304 | "type": "number" 305 | }, 306 | "terms": { 307 | "type": "array", 308 | "items": { 309 | "$ref": "#/definitions/ScalarAffineTerm" 310 | } 311 | } 312 | } 313 | }, { 314 | "description": "The function `0.5x'Qx + a'x + b`, where `a` is a sparse vector of `ScalarAffineTerm`s in `affine_terms`, `b` is the scalar `constant`, and `Q` is a symmetric matrix specified by a list of `ScalarQuadraticTerm`s in `quadratic_terms`. Duplicate indices in `affine_terms` and `quadratic` are accepted, and the corresponding coefficients are summed together. Mirrored indices in `quadratic_terms` (i.e., `(i,j)` and `(j, i)`) are considered duplicates; only one need to be specified.", 315 | "examples": ["{\"type\": \"ScalarQuadraticFunction\", \"constant\": 1.0, \"affine_terms\": [{\"coefficient\": 2.5, \"variable\": \"x\"}], \"quadratic_terms\": [{\"coefficient\": 2.0, \"variable_1\": \"x\", \"variable_2\": \"y\"}]}"], 316 | "required": ["constant", "affine_terms", "quadratic_terms"], 317 | "properties": { 318 | "type": { 319 | "const": "ScalarQuadraticFunction" 320 | }, 321 | "constant": { 322 | "type": "number" 323 | }, 324 | "affine_terms": { 325 | "type": "array", 326 | "items": { 327 | "$ref": "#/definitions/ScalarAffineTerm" 328 | } 329 | }, 330 | "quadratic_terms": { 331 | "type": "array", 332 | "items": { 333 | "$ref": "#/definitions/ScalarQuadraticTerm" 334 | } 335 | } 336 | } 337 | }, { 338 | "description": "An expression graph representing a scalar nonlinear function.", 339 | "required": ["root", "node_list"], 340 | "properties": { 341 | "type": { 342 | "const": "ScalarNonlinearFunction" 343 | }, 344 | "root": { 345 | "$ref": "#/definitions/NonlinearTerm" 346 | }, 347 | "node_list": { 348 | "type": "array", 349 | "items": { 350 | "$ref": "#/definitions/NonlinearTerm" 351 | } 352 | } 353 | } 354 | }] 355 | }, 356 | "vector_functions": { 357 | "description": "A schema for the vector-valued functions defined by MathOptFormat.See http://www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Functions-and-function-modifications-1 for a list of the functions and their meanings.", 358 | "type": "object", 359 | "required": ["type"], 360 | "oneOf": [{ 361 | "description": "An ordered list of variables.", 362 | "examples": ["{\"type\": \"VectorOfVariables\", \"variables\": [\"x\", \"y\"]}"], 363 | "required": ["variables"], 364 | "properties": { 365 | "type": { 366 | "const": "VectorOfVariables" 367 | }, 368 | "variables": { 369 | "type": "array", 370 | "items": { 371 | "type": "string" 372 | } 373 | } 374 | } 375 | }, { 376 | "description": "The function `Ax + b`, where `A` is a sparse matrix specified by a list of `VectorAffineTerm`s in `terms` and `b` is a dense vector specified by `constants`.", 377 | "examples": ["{\"type\": \"VectorAffineFunction\", \"constants\": [1.0], \"terms\": [{\"output_index\": 1, \"scalar_term\": {\"coefficient\": 2.5, \"variable\": \"x\"}}]}"], 378 | "required": ["constants", "terms"], 379 | "properties": { 380 | "type": { 381 | "const": "VectorAffineFunction" 382 | }, 383 | "constants": { 384 | "type": "array", 385 | "items": { 386 | "type": "number" 387 | } 388 | }, 389 | "terms": { 390 | "type": "array", 391 | "items": { 392 | "$ref": "#/definitions/VectorAffineTerm" 393 | } 394 | } 395 | } 396 | }, { 397 | "description": "The vector-valued quadratic function `q(x) + Ax + b`, where `q(x)` is specified by a list of `VectorQuadraticTerm`s in `quadratic_terms`, `A` is a sparse matrix specified by a list of `VectorAffineTerm`s in `affine_terms` and `b` is a dense vector specified by `constants`.", 398 | "required": ["constants", "affine_terms", "quadratic_terms"], 399 | "properties": { 400 | "type": { 401 | "const": "VectorQuadraticFunction" 402 | }, 403 | "constants": { 404 | "type": "array", 405 | "items": { 406 | "type": "number" 407 | } 408 | }, 409 | "affine_terms": { 410 | "type": "array", 411 | "items": { 412 | "$ref": "#/definitions/VectorAffineTerm" 413 | } 414 | }, 415 | "quadratc_terms": { 416 | "type": "array", 417 | "items": { 418 | "$ref": "#/definitions/VectorQuadraticTerm" 419 | } 420 | } 421 | } 422 | }] 423 | }, 424 | "scalar_sets": { 425 | "description": "A schema for the scalar-valued sets defined by MathOptFormat. See http: //www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Sets-1 for a list of the sets and their meanings.", 426 | "type": "object", 427 | "required": ["type"], 428 | "oneOf": [{ 429 | "description": "(-∞, upper]", 430 | "examples": ["{\"type\": \"LessThan\", \"upper\": 2.1}"], 431 | "required": ["upper"], 432 | "properties": { 433 | "type": { 434 | "const": "LessThan" 435 | }, 436 | "upper": { 437 | "type": "number" 438 | } 439 | } 440 | }, { 441 | "description": "[lower, ∞)", 442 | "examples": ["{\"type\": \"GreaterThan\", \"lower\": 2.1}"], 443 | "required": ["lower"], 444 | "properties": { 445 | "type": { 446 | "const": "GreaterThan" 447 | }, 448 | "lower": { 449 | "type": "number" 450 | } 451 | } 452 | }, { 453 | "description": "{value}", 454 | "examples": ["{\"type\": \"EqualTo\", \"value\": 2.1}"], 455 | "required": ["value"], 456 | "properties": { 457 | "type": { 458 | "const": "EqualTo" 459 | }, 460 | "value": { 461 | "type": "number" 462 | } 463 | } 464 | }, { 465 | "description": "[lower, upper]", 466 | "examples": ["{\"type\": \"Interval\", \"lower\": 2.1, \"upper\": 3.4}"], 467 | "required": ["lower", "upper"], 468 | "properties": { 469 | "type": { 470 | "const": "Interval" 471 | }, 472 | "lower": { 473 | "type": "number" 474 | }, 475 | "upper": { 476 | "type": "number" 477 | } 478 | } 479 | }, { 480 | "description": "{0} ∪ {lower, lower + 1, ..., upper}", 481 | "examples": ["{\"type\": \"Semiinteger\", \"lower\": 2, \"upper\": 4}"], 482 | "required": ["lower", "upper"], 483 | "properties": { 484 | "type": { 485 | "const": "Semiinteger" 486 | }, 487 | "lower": { 488 | "type": "number" 489 | }, 490 | "upper": { 491 | "type": "number" 492 | } 493 | } 494 | }, { 495 | "description": "{0} ∪ [lower, upper]", 496 | "examples": ["{\"type\": \"Semicontinuous\", \"lower\": 2.1, \"upper\": 3.4}"], 497 | "required": ["lower", "upper"], 498 | "properties": { 499 | "type": { 500 | "const": "Semicontinuous" 501 | }, 502 | "lower": { 503 | "type": "number" 504 | }, 505 | "upper": { 506 | "type": "number" 507 | } 508 | } 509 | }, { 510 | "description": "{0, 1}", 511 | "examples": ["{\"type\": \"ZeroOne\"}"], 512 | "properties": { 513 | "type": { 514 | "const": "ZeroOne" 515 | } 516 | } 517 | }, { 518 | "description": "ℤ", 519 | "examples": ["{\"type\": \"Integer\"}"], 520 | "properties": { 521 | "type": { 522 | "const": "Integer" 523 | } 524 | } 525 | }] 526 | }, 527 | "vector_sets": { 528 | "description": "A schema for the vector-valued sets defined by MathOptFormat. See http: //www.juliaopt.org/MathOptInterface.jl/v0.8/apireference/#Sets-1 for a list of the sets and their meanings.", 529 | "type": "object", 530 | "required": ["type"], 531 | "oneOf": [{ 532 | "description": "[x, y, z] ∈ {R³: y * exp(x / y) ≤ z, y ≥ 0}", 533 | "examples": ["{\"type\": \"ExponentialCone\"}"], 534 | "properties": { 535 | "type": { 536 | "const": "ExponentialCone" 537 | } 538 | } 539 | }, { 540 | "description": "[u, v, w] ∈ {R³: -u * exp(v / u) ≤ exp(1) * w, u < 0}", 541 | "examples": ["{\"type\": \"DualExponentialCone\"}"], 542 | "properties": { 543 | "type": { 544 | "const": "DualExponentialCone" 545 | } 546 | } 547 | }, { 548 | "description": "A special ordered set of type I.", 549 | "examples": ["{\"type\": \"SOS1\", \"weights\": [1, 3, 2]}"], 550 | "required": ["weights"], 551 | "properties": { 552 | "type": { 553 | "const": "SOS1" 554 | }, 555 | "weights": { 556 | "type": "array", 557 | "items": { 558 | "type": "number" 559 | } 560 | } 561 | } 562 | }, { 563 | "description": "A special ordered set of type II.", 564 | "examples": ["{\"type\": \"SOS2\", \"weights\": [1, 3, 2]}"], 565 | "required": ["weights"], 566 | "properties": { 567 | "type": { 568 | "const": "SOS2" 569 | }, 570 | "weights": { 571 | "type": "array", 572 | "items": { 573 | "type": "number" 574 | } 575 | } 576 | } 577 | }, { 578 | "description": "[t, x] ∈ {R^{dimension}: t ≤ (Πxᵢ)^{1 / (dimension-1)}}", 579 | "examples": ["{\"type\": \"GeometricMeanCone\", \"dimension\": 3}"], 580 | "required": ["dimension"], 581 | "properties": { 582 | "type": { 583 | "const": "GeometricMeanCone" 584 | }, 585 | "dimension": { 586 | "type": "integer", 587 | "minimum": 1 588 | } 589 | } 590 | }, { 591 | "description": "[t, x] ∈ {R^{dimension} : t ≥ ||x||₂", 592 | "examples": ["{\"type\": \"SecondOrderCone\", \"dimension\": 3}"], 593 | "required": ["dimension"], 594 | "properties": { 595 | "type": { 596 | "const": "SecondOrderCone" 597 | }, 598 | "dimension": { 599 | "type": "integer", 600 | "minimum": 1 601 | } 602 | } 603 | }, { 604 | "description": "[t, u, x] ∈ {R^{dimension} : 2tu ≥ (||x||₂)²; t, u ≥ 0}", 605 | "examples": ["{\"type\": \"RotatedSecondOrderCone\", \"dimension\": 3}"], 606 | "required": ["dimension"], 607 | "properties": { 608 | "type": { 609 | "const": "RotatedSecondOrderCone" 610 | }, 611 | "dimension": { 612 | "type": "integer", 613 | "minimum": 1 614 | } 615 | } 616 | }, { 617 | "description": "{0}^{dimension}", 618 | "examples": ["{\"type\": \"Zeros\", \"dimension\": 3}"], 619 | "required": ["dimension"], 620 | "properties": { 621 | "type": { 622 | "const": "Zeros" 623 | }, 624 | "dimension": { 625 | "type": "integer", 626 | "minimum": 1 627 | } 628 | } 629 | }, { 630 | "description": "R^{dimension}", 631 | "examples": ["{\"type\": \"Reals\", \"dimension\": 3}"], 632 | "required": ["dimension"], 633 | "properties": { 634 | "type": { 635 | "const": "Reals" 636 | }, 637 | "dimension": { 638 | "type": "integer", 639 | "minimum": 1 640 | } 641 | } 642 | }, { 643 | "description": "R₋^{dimension}", 644 | "examples": ["{\"type\": \"Nonpositives\", \"dimension\": 3}"], 645 | "required": ["dimension"], 646 | "properties": { 647 | "type": { 648 | "const": "Nonpositives" 649 | }, 650 | "dimension": { 651 | "type": "integer", 652 | "minimum": 1 653 | } 654 | } 655 | }, { 656 | "description": "R₊^{dimension}", 657 | "examples": ["{\"type\": \"Nonnegatives\", \"dimension\": 3}"], 658 | "required": ["dimension"], 659 | "properties": { 660 | "type": { 661 | "const": "Nonnegatives" 662 | }, 663 | "dimension": { 664 | "type": "integer", 665 | "minimum": 1 666 | } 667 | } 668 | }, { 669 | "description": "{[t, X] ∈ R^{1 + d(d+1)/2} : t ≤ det(X)^{1/d}}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeTriangle`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 670 | "examples": ["{\"type\": \"RootDetConeTriangle\", \"side_dimension\": 2}"], 671 | "required": ["side_dimension"], 672 | "properties": { 673 | "type": { 674 | "const": "RootDetConeTriangle" 675 | }, 676 | "side_dimension": { 677 | "type": "integer", 678 | "minimum": 1 679 | } 680 | } 681 | }, { 682 | "description": "{[t, X] ∈ R^{1 + d^2} : t ≤ det(X)^{1/d}, X symmetric}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeSquare`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 683 | "examples": ["{\"type\": \"RootDetConeSquare\", \"side_dimension\": 2}"], 684 | "required": ["side_dimension"], 685 | "properties": { 686 | "type": { 687 | "const": "RootDetConeSquare" 688 | }, 689 | "side_dimension": { 690 | "type": "integer", 691 | "minimum": 1 692 | } 693 | } 694 | }, { 695 | "description": "{[t, u, X] ∈ R^{2 + d(d+1)/2} : t ≤ u log(det(X/u)), u > 0}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeTriangle`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 696 | "examples": ["{\"type\": \"LogDetConeTriangle\", \"side_dimension\": 2}"], 697 | "required": ["side_dimension"], 698 | "properties": { 699 | "type": { 700 | "const": "LogDetConeTriangle" 701 | }, 702 | "side_dimension": { 703 | "type": "integer", 704 | "minimum": 1 705 | } 706 | } 707 | }, { 708 | "description": "{[t, u, X] ∈ R^{2 + d^2} : t ≤ u log(det(X/u)), X symmetric, u > 0}, where the matrix `X` is represented in the same symmetric packed format as in the `PositiveSemidefiniteConeSquare`. The argument `side_dimension` is the side dimension of the matrix `X`, i.e., its number of rows or columns.", 709 | "examples": ["{\"type\": \"LogDetConeSquare\", \"side_dimension\": 2}"], 710 | "required": ["side_dimension"], 711 | "properties": { 712 | "type": { 713 | "const": "LogDetConeSquare" 714 | }, 715 | "side_dimension": { 716 | "type": "integer", 717 | "minimum": 1 718 | } 719 | } 720 | }, { 721 | "description": "The (vectorized) cone of symmetric positive semidefinite matrices, with `side_dimension` rows and columns. The entries of the upper-right triangular part of the matrix are given column by column (or equivalently, the entries of the lower-left triangular part are given row by row).", 722 | "examples": ["{\"type\": \"PositiveSemidefiniteConeTriangle\", \"side_dimension\": 2}"], 723 | "required": ["side_dimension"], 724 | "properties": { 725 | "type": { 726 | "const": "PositiveSemidefiniteConeTriangle" 727 | }, 728 | "side_dimension": { 729 | "type": "integer", 730 | "minimum": 1 731 | } 732 | } 733 | }, { 734 | "description": "The cone of symmetric positive semidefinite matrices, with side length `side_dimension`. The entries of the matrix are given column by column (or equivalently, row by row). The matrix is both constrained to be symmetric and to be positive semidefinite. That is, if the functions in entries `(i, j)` and `(j, i)` are different, then a constraint will be added to make sure that the entries are equal.", 735 | "examples": ["{\"type\": \"PositiveSemidefiniteConeSquare\", \"side_dimension\": 2}"], 736 | "required": ["side_dimension"], 737 | "properties": { 738 | "type": { 739 | "const": "PositiveSemidefiniteConeSquare" 740 | }, 741 | "side_dimension": { 742 | "type": "integer", 743 | "minimum": 1 744 | } 745 | } 746 | }, { 747 | "description": "[x, y, z] ∈ {R³: x^{exponent} y^{1-exponent} ≥ |z|; x, y ≥ 0}", 748 | "examples": ["{\"type\": \"PowerCone\", \"exponent\": 2.0}"], 749 | "required": ["exponent"], 750 | "properties": { 751 | "type": { 752 | "const": "PowerCone" 753 | }, 754 | "exponent": { 755 | "type": "number" 756 | } 757 | } 758 | }, { 759 | "description": "[u, v, w] ∈ {R³: (u / exponent)^{exponent} (v / (1-exponent))^{1-exponent} ≥ |w|; u, v ≥ 0}", 760 | "examples": ["{\"type\": \"DualPowerCone\", \"exponent\": 2.0}"], 761 | "required": ["exponent"], 762 | "properties": { 763 | "type": { 764 | "const": "DualPowerCone" 765 | }, 766 | "exponent": { 767 | "type": "number" 768 | } 769 | } 770 | }, { 771 | "description": "If `activate_on=one`: (y, x) ∈ {0,1}×Rᴺ: y = 0 ⟹ x ∈ S, otherwise when `activate_on=zero`: (y, x) ∈ {0,1}×Rᴺ: y = 1 ⟹ x ∈ S.", 772 | "examples": ["{\"type\": \"Indicator\", \"set\": {\"type\": \"LessThan\", \"upper\": 2.0}, \"activate_on\": \"one\"}"], 773 | "required": ["set", "activate_on"], 774 | "properties": { 775 | "type": { 776 | "const": "Indicator" 777 | }, 778 | "set": { 779 | "oneOf": [{ 780 | "$ref": "#/definitions/scalar_sets" 781 | }, { 782 | "$ref": "#/definitions/vector_sets" 783 | }] 784 | }, 785 | "activate_on": { 786 | "enum": ["one", "zero"] 787 | } 788 | } 789 | }, { 790 | "description": "(t, x) ∈ {R^{dimension}: t ≥ Σᵢ|xᵢ|}", 791 | "examples": ["{\"type\": \"NormOneCone\", \"dimension\": 2}"], 792 | "required": ["dimension"], 793 | "properties": { 794 | "type": { 795 | "const": "NormOneCone" 796 | }, 797 | "dimension": { 798 | "type": "integer", 799 | "minimum": 2 800 | } 801 | } 802 | }, { 803 | "description": "(t, x) ∈ {R^{dimension}: t ≥ maxᵢ|xᵢ|}", 804 | "examples": ["{\"type\": \"NormInfinityCone\", \"dimension\": 2}"], 805 | "required": ["dimension"], 806 | "properties": { 807 | "type": { 808 | "const": "NormInfinityCone" 809 | }, 810 | "dimension": { 811 | "type": "integer", 812 | "minimum": 2 813 | } 814 | } 815 | }, { 816 | "description": "(u, v, w) ∈ {R^{dimension}: u ≥ Σᵢ wᵢlog(wᵢ/vᵢ), vᵢ ≥ 0, wᵢ ≥ 0}", 817 | "examples": ["{\"type\": \"RelativeEntropyCone\", \"dimension\": 3}"], 818 | "required": ["dimension"], 819 | "properties": { 820 | "type": { 821 | "const": "RelativeEntropyCone" 822 | }, 823 | "dimension": { 824 | "type": "integer", 825 | "minimum": 3 826 | } 827 | } 828 | }, { 829 | "description": "(t, X) ∈ {R^{1+row_dim×column_dim}: t ≥ σ₁(X)}", 830 | "examples": ["{\"type\": \"NormSpectralCone\", \"row_dim\": 1, \"column_dim\": 2}"], 831 | "required": ["row_dim", "column_dim"], 832 | "properties": { 833 | "type": { 834 | "const": "NormSpectralCone" 835 | }, 836 | "row_dim": { 837 | "type": "integer", 838 | "minimum": 1 839 | }, 840 | "column_dim": { 841 | "type": "integer", 842 | "minimum": 1 843 | } 844 | } 845 | }, { 846 | "description": "(t, X) ∈ {R^{1+row_dim×column_dim}: t ≥ Σᵢ σᵢ(X)}", 847 | "examples": ["{\"type\": \"NormNuclearCone\", \"row_dim\": 1, \"column_dim\": 2}"], 848 | "required": ["row_dim", "column_dim"], 849 | "properties": { 850 | "type": { 851 | "const": "NormNuclearCone" 852 | }, 853 | "row_dim": { 854 | "type": "integer", 855 | "minimum": 1 856 | }, 857 | "column_dim": { 858 | "type": "integer", 859 | "minimum": 1 860 | } 861 | } 862 | }, { 863 | "description": "The set corresponding to a mixed complementarity constraint. Complementarity constraints should be specified with an AbstractVectorFunction-in-Complements(dimension) constraint. The dimension of the vector-valued function `F` must be `dimension`. This defines a complementarity constraint between the scalar function `F[i]` and the variable in `F[i + dimension/2]`. Thus, `F[i + dimension/2]` must be interpretable as a single variable `x_i` (e.g., `1.0 * x + 0.0`). The mixed complementarity problem consists of finding `x_i` in the interval `[lb, ub]` (i.e., in the set `Interval(lb, ub)`), such that the following holds: 1. `F_i(x) == 0` if `lb_i < x_i < ub_i`; 2. `F_i(x) >= 0` if `lb_i == x_i`; 3. `F_i(x) <= 0` if `x_i == ub_i`. Classically, the bounding set for `x_i` is `Interval(0, Inf)`, which recovers: `0 <= F_i(x) ⟂ x_i >= 0`, where the `⟂` operator implies `F_i(x) * x_i = 0`.", 864 | "examples": ["{\"type\": \"Complements\", \"dimension\": 2}"], 865 | "required": ["dimension"], 866 | "properties": { 867 | "type": { 868 | "const": "Complements" 869 | }, 870 | "dimension": { 871 | "type": "integer", 872 | "minimum": 2 873 | } 874 | } 875 | }] 876 | } 877 | } 878 | } 879 | --------------------------------------------------------------------------------