From ae717a446df949c1837e5a590d7297d27c61a2ba Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 13 Aug 2026 16:35:20 +1200 Subject: [PATCH] [FileFormats.MOF] add support for MOF@1.8 --- src/FileFormats/MOF/mof.schema.json | 1036 ++++++++------------------- src/FileFormats/MOF/read.jl | 5 + src/FileFormats/MOF/write.jl | 1 + test/FileFormats/MOF/test_MOF.jl | 554 +++++++------- 4 files changed, 571 insertions(+), 1025 deletions(-) diff --git a/src/FileFormats/MOF/mof.schema.json b/src/FileFormats/MOF/mof.schema.json index 44e9b52f7f..8bb513feb7 100644 --- a/src/FileFormats/MOF/mof.schema.json +++ b/src/FileFormats/MOF/mof.schema.json @@ -1,6 +1,6 @@ { "$schema": "https://json-schema.org/schema#", - "$id": "https://jump.dev/MathOptFormat/schemas/mof.1.7.schema.json", + "$id": "https://jump.dev/MathOptFormat/schemas/mof.1.8.schema.json", "title": "The schema for MathOptFormat", "type": "object", "required": ["version", "variables", "objective", "constraints"], @@ -8,14 +8,10 @@ "version": { "description": "The version of MathOptFormat that this schema validates against.", "type": "object", - "required": ["minor", "major"], + "required": ["major", "minor"], "properties": { - "minor": { - "enum": [0, 1, 2, 3, 4, 5, 6, 7] - }, - "major": { - "const": 1 - } + "major": {"const": 1}, + "minor": {"enum": [0, 1, 2, 3, 4, 5, 6, 7, 8]} } }, "name": { @@ -31,13 +27,14 @@ "type": "string" }, "variables": { - "description": "An array of variables in the model. Each must have a unique name.", + "description": "An array of variables in the model.", "type": "array", "items": { "type": "object", "required": ["name"], "properties": { "name": { + "description": "A unique name for the variable", "type": "string" }, "primal_start": { @@ -54,9 +51,7 @@ "required": ["sense"], "oneOf": [{ "properties": { - "sense": { - "enum": ["min", "max"] - }, + "sense": {"enum": ["min", "max"]}, "function": { "oneOf": [{ "$ref": "#/definitions/scalar_functions" @@ -66,33 +61,21 @@ } } }, { - "properties": { - "sense": { - "const": "feasibility" - } - } + "properties": {"sense": {"const": "feasibility"}} }] }, "constraints": { - "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.", + "description": "An array of constraints in the model.", "type": "array", "items": { "type": "object", "required": ["function", "set"], - "properties": { - "name": { - "type": "string" - } - }, + "properties": {"name": {"type": "string"}}, "oneOf": [{ "description": "A scalar-valued constraint.", "properties": { - "function": { - "$ref": "#/definitions/scalar_functions" - }, - "set": { - "$ref": "#/definitions/scalar_sets" - }, + "function": {"$ref": "#/definitions/scalar_functions"}, + "set": {"$ref": "#/definitions/scalar_sets"}, "primal_start": { "description": "An initial scalar value for the constraint's primal solution that the optimizer may use to warm-start the solution process.", "type": "number" @@ -105,25 +88,17 @@ }, { "description": "A vector-valued constraint.", "properties": { - "function": { - "$ref": "#/definitions/vector_functions" - }, - "set": { - "$ref": "#/definitions/vector_sets" - }, + "function": {"$ref": "#/definitions/vector_functions"}, + "set": {"$ref": "#/definitions/vector_sets"}, "primal_start": { "description": "An initial vector for the constraint's primal solution that the optimizer may use to warm-start the solution process.", "type": "array", - "items": { - "type": "number" - } + "items": {"type": "number"} }, "dual_start": { "description": "An initial vector for the constraint's dual solution that the optimizer may use to warm-start the solution process.", "type": "array", - "items": { - "type": "number" - } + "items": {"type": "number"} } } }] @@ -137,12 +112,8 @@ "type": "object", "required": ["coefficient", "variable"], "properties": { - "coefficient": { - "type": "number" - }, - "variable": { - "type": "string" - } + "coefficient": {"type": "number"}, + "variable": {"type": "string"} } }, "ScalarQuadraticTerm": { @@ -150,15 +121,9 @@ "type": "object", "required": ["coefficient", "variable_1", "variable_2"], "properties": { - "coefficient": { - "type": "number" - }, - "variable_1": { - "type": "string" - }, - "variable_2": { - "type": "string" - } + "coefficient": {"type": "number"}, + "variable_1": {"type": "string"}, + "variable_2": {"type": "string"} } }, "VectorAffineTerm": { @@ -166,13 +131,8 @@ "type": "object", "required": ["output_index", "scalar_term"], "properties": { - "output_index": { - "type": "integer", - "minimum": 1 - }, - "scalar_term": { - "$ref": "#/definitions/ScalarAffineTerm" - } + "output_index": {"type": "integer", "minimum": 1}, + "scalar_term": {"$ref": "#/definitions/ScalarAffineTerm"} } }, "VectorQuadraticTerm": { @@ -180,13 +140,8 @@ "type": "object", "required": ["output_index", "scalar_term"], "properties": { - "output_index": { - "type": "integer", - "minimum": 1 - }, - "scalar_term": { - "$ref": "#/definitions/ScalarQuadraticTerm" - } + "output_index": {"type": "integer", "minimum": 1}, + "scalar_term": {"$ref": "#/definitions/ScalarQuadraticTerm"} } }, "NonlinearTerm": { @@ -198,85 +153,24 @@ "properties": { "type": { "enum": [ - "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" + "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" ] }, "args": { "type": "array", - "items": { - "$ref": "#/definitions/NonlinearTerm" - }, + "items": {"$ref": "#/definitions/NonlinearTerm"}, "minItems": 1, "maxItems": 1 } @@ -287,24 +181,11 @@ "required": ["type", "args"], "properties": { "type": { - "enum": [ - "/", - "^", - "atan", - "&&", - "||", - "<=", - "<", - ">=", - ">", - "==" - ] + "enum": ["/", "^", "atan", "&&", "||", "<=", "<", ">=", ">", "=="] }, "args": { "type": "array", - "items": { - "$ref": "#/definitions/NonlinearTerm" - }, + "items": {"$ref": "#/definitions/NonlinearTerm"}, "minItems": 2, "maxItems": 2 } @@ -319,9 +200,7 @@ }, "args": { "type": "array", - "items": { - "$ref": "#/definitions/NonlinearTerm" - }, + "items": {"$ref": "#/definitions/NonlinearTerm"}, "minItems": 1 } } @@ -331,12 +210,8 @@ "type": "object", "required": ["type", "value"], "properties": { - "type": { - "const": "real" - }, - "value": { - "type": "number" - } + "type": {"const": "real"}, + "value": {"type": "number"} } }, { "description": "A complex-valued numeric constant", @@ -344,15 +219,9 @@ "type": "object", "required": ["type", "real", "imag"], "properties": { - "type": { - "const": "complex" - }, - "real": { - "type": "number" - }, - "imag": { - "type": "number" - } + "type": {"const": "complex"}, + "real": {"type": "number"}, + "imag": {"type": "number"} } }, { "description": "A reference to an optimization variable", @@ -360,12 +229,8 @@ "type": "object", "required": ["type", "name"], "properties": { - "type": { - "const": "variable" - }, - "name": { - "type": "string" - } + "type": {"const": "variable"}, + "name": {"type": "string"} } }, { "description": "A pointer to a (1-indexed) element in the `node_list` field in a nonlinear function", @@ -373,13 +238,8 @@ "type": "object", "required": ["type", "index"], "properties": { - "type": { - "const": "node" - }, - "index": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "node"}, + "index": {"type": "integer", "minimum": 1} } }, { "description": "A reference to an optimization variable", @@ -392,7 +252,7 @@ }] }, "scalar_functions": { - "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.", + "description": "A schema for the scalar-valued functions defined by MathOptFormat.", "type": "object", "required": ["type"], "oneOf": [{ @@ -400,76 +260,52 @@ "examples": ["{\"type\": \"Variable\", \"name\": \"x\"}"], "required": ["name"], "properties": { - "type": { - "const": "Variable" - }, - "name": { - "type": "string" - } + "type": {"const": "Variable"}, + "name": {"type": "string"} } }, { "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.", "examples": ["{\"type\": \"ScalarAffineFunction\", \"constant\": 1.0, \"terms\": [{\"coefficient\": 2.5, \"variable\": \"x\"}]}"], "required": ["constant", "terms"], "properties": { - "type": { - "const": "ScalarAffineFunction" - }, - "constant": { - "type": "number" - }, + "type": {"const": "ScalarAffineFunction"}, + "constant": {"type": "number"}, "terms": { "type": "array", - "items": { - "$ref": "#/definitions/ScalarAffineTerm" - } + "items": {"$ref": "#/definitions/ScalarAffineTerm"} } } }, { - "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` (that is, `(i,j)` and `(j, i)`) are considered duplicates; only one need to be specified.", + "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.", "examples": ["{\"type\": \"ScalarQuadraticFunction\", \"constant\": 1.0, \"affine_terms\": [{\"coefficient\": 2.5, \"variable\": \"x\"}], \"quadratic_terms\": [{\"coefficient\": 2.0, \"variable_1\": \"x\", \"variable_2\": \"y\"}]}"], "required": ["constant", "affine_terms", "quadratic_terms"], "properties": { - "type": { - "const": "ScalarQuadraticFunction" - }, - "constant": { - "type": "number" - }, + "type": {"const": "ScalarQuadraticFunction"}, + "constant": {"type": "number"}, "affine_terms": { "type": "array", - "items": { - "$ref": "#/definitions/ScalarAffineTerm" - } + "items": {"$ref": "#/definitions/ScalarAffineTerm"} }, "quadratic_terms": { "type": "array", - "items": { - "$ref": "#/definitions/ScalarQuadraticTerm" - } + "items": {"$ref": "#/definitions/ScalarQuadraticTerm"} } } }, { "description": "An expression graph representing a scalar nonlinear function.", "required": ["root", "node_list"], "properties": { - "type": { - "const": "ScalarNonlinearFunction" - }, - "root": { - "$ref": "#/definitions/NonlinearTerm" - }, + "type": {"const": "ScalarNonlinearFunction"}, + "root": {"$ref": "#/definitions/NonlinearTerm"}, "node_list": { "type": "array", - "items": { - "$ref": "#/definitions/NonlinearTerm" - } + "items": {"$ref": "#/definitions/NonlinearTerm"} } } }] }, "vector_functions": { - "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.", + "description": "A schema for the vector-valued functions defined by MathOptFormat.", "type": "object", "required": ["type"], "oneOf": [{ @@ -477,87 +313,54 @@ "examples": ["{\"type\": \"VectorOfVariables\", \"variables\": [\"x\", \"y\"]}"], "required": ["variables"], "properties": { - "type": { - "const": "VectorOfVariables" - }, - "variables": { - "type": "array", - "items": { - "type": "string" - } - } + "type": {"const": "VectorOfVariables"}, + "variables": {"type": "array", "items": {"type": "string"}} } }, { "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`.", "examples": ["{\"type\": \"VectorAffineFunction\", \"constants\": [1.0], \"terms\": [{\"output_index\": 1, \"scalar_term\": {\"coefficient\": 2.5, \"variable\": \"x\"}}]}"], "required": ["constants", "terms"], "properties": { - "type": { - "const": "VectorAffineFunction" - }, - "constants": { - "type": "array", - "items": { - "type": "number" - } - }, + "type": {"const": "VectorAffineFunction"}, + "constants": {"type": "array", "items": {"type": "number"}}, "terms": { "type": "array", - "items": { - "$ref": "#/definitions/VectorAffineTerm" - } + "items": {"$ref": "#/definitions/VectorAffineTerm"} } } }, { "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`.", "required": ["constants", "affine_terms", "quadratic_terms"], "properties": { - "type": { - "const": "VectorQuadraticFunction" - }, - "constants": { - "type": "array", - "items": { - "type": "number" - } - }, + "type": {"const": "VectorQuadraticFunction"}, + "constants": {"type": "array", "items": {"type": "number"}}, "affine_terms": { "type": "array", - "items": { - "$ref": "#/definitions/VectorAffineTerm" - } + "items": {"$ref": "#/definitions/VectorAffineTerm"} }, "quadratc_terms": { "type": "array", - "items": { - "$ref": "#/definitions/VectorQuadraticTerm" - } + "items": {"$ref": "#/definitions/VectorQuadraticTerm"} } } }, { "description": "The vector-valued nonlinear function `f(x)`, comprised of a vector of `ScalarNonlinearFunction`.", "required": ["rows", "node_list"], "properties": { - "type": { - "const": "VectorNonlinearFunction" - }, + "type": {"const": "VectorNonlinearFunction"}, "rows": { "type": "array", - "items": { - "$ref": "#/definitions/NonlinearTerm" - } + "items": {"$ref": "#/definitions/NonlinearTerm"} }, "node_list": { "type": "array", - "items": { - "$ref": "#/definitions/NonlinearTerm" - } + "items": {"$ref": "#/definitions/NonlinearTerm"} } } }] }, "scalar_sets": { - "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.", + "description": "A schema for the scalar-valued sets defined by MathOptFormat.", "type": "object", "required": ["type"], "oneOf": [{ @@ -565,636 +368,426 @@ "examples": ["{\"type\": \"LessThan\", \"upper\": 2.1}"], "required": ["upper"], "properties": { - "type": { - "const": "LessThan" - }, - "upper": { - "type": "number" - } + "type": {"const": "LessThan"}, + "upper": {"type": "number"} } }, { "description": "[lower, ∞)", "examples": ["{\"type\": \"GreaterThan\", \"lower\": 2.1}"], "required": ["lower"], "properties": { - "type": { - "const": "GreaterThan" - }, - "lower": { - "type": "number" - } + "type": {"const": "GreaterThan"}, + "lower": {"type": "number"} } }, { "description": "{value}", "examples": ["{\"type\": \"EqualTo\", \"value\": 2.1}"], "required": ["value"], "properties": { - "type": { - "const": "EqualTo" - }, - "value": { - "type": "number" - } + "type": {"const": "EqualTo"}, + "value": {"type": "number"} } }, { "description": "[lower, upper]", "examples": ["{\"type\": \"Interval\", \"lower\": 2.1, \"upper\": 3.4}"], "required": ["lower", "upper"], "properties": { - "type": { - "const": "Interval" - }, - "lower": { - "type": "number" - }, - "upper": { - "type": "number" - } + "type": {"const": "Interval"}, + "lower": {"type": "number"}, + "upper": {"type": "number"} } }, { "description": "{0} ∪ {lower, lower + 1, ..., upper}", "examples": ["{\"type\": \"Semiinteger\", \"lower\": 2, \"upper\": 4}"], "required": ["lower", "upper"], "properties": { - "type": { - "const": "Semiinteger" - }, - "lower": { - "type": "number" - }, - "upper": { - "type": "number" - } + "type": {"const": "Semiinteger"}, + "lower": {"type": "number"}, + "upper": {"type": "number"} } }, { "description": "{0} ∪ [lower, upper]", "examples": ["{\"type\": \"Semicontinuous\", \"lower\": 2.1, \"upper\": 3.4}"], "required": ["lower", "upper"], "properties": { - "type": { - "const": "Semicontinuous" - }, - "lower": { - "type": "number" - }, - "upper": { - "type": "number" - } + "type": {"const": "Semicontinuous"}, + "lower": {"type": "number"}, + "upper": {"type": "number"} } }, { "description": "{0, 1}", "examples": ["{\"type\": \"ZeroOne\"}"], "properties": { - "type": { - "const": "ZeroOne" - } + "type": {"const": "ZeroOne"} } }, { "description": "ℤ", "examples": ["{\"type\": \"Integer\"}"], "properties": { - "type": { - "const": "Integer" - } + "type": {"const": "Integer"} } }, { "description": "{value}", "examples": ["{\"type\": \"Parameter\", \"value\": 2.1}"], "required": ["value"], "properties": { - "type": { - "const": "Parameter" - }, - "value": { - "type": "number" - } + "type": {"const": "Parameter"}, + "value": {"type": "number"} } }] }, "vector_sets": { - "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.", + "description": "A schema for the vector-valued sets defined by MathOptFormat.", "type": "object", "required": ["type"], "oneOf": [{ - "description": "[x, y, z] ∈ {R³: y * exp(x / y) ≤ z, y ≥ 0}", - "examples": ["{\"type\": \"ExponentialCone\"}"], + "description": "R^{dimension}", + "examples": ["{\"type\": \"Reals\", \"dimension\": 3}"], + "required": ["dimension"], "properties": { - "type": { - "const": "ExponentialCone" - } + "type": {"const": "Reals"}, + "dimension": {"type": "integer", "minimum": 1} } }, { - "description": "[u, v, w] ∈ {R³: -u * exp(v / u) ≤ exp(1) * w, u < 0}", - "examples": ["{\"type\": \"DualExponentialCone\"}"], + "description": "{0}^{dimension}", + "examples": ["{\"type\": \"Zeros\", \"dimension\": 3}"], + "required": ["dimension"], "properties": { - "type": { - "const": "DualExponentialCone" - } + "type": {"const": "Zeros"}, + "dimension": {"type": "integer", "minimum": 1} } }, { - "description": "A special ordered set of type I.", - "examples": ["{\"type\": \"SOS1\", \"weights\": [1, 3, 2]}"], - "required": ["weights"], + "description": "R₋^{dimension}", + "examples": ["{\"type\": \"Nonpositives\", \"dimension\": 3}"], + "required": ["dimension"], "properties": { - "type": { - "const": "SOS1" - }, - "weights": { - "type": "array", - "items": { - "type": "number" - } - } + "type": {"const": "Nonpositives"}, + "dimension": {"type": "integer", "minimum": 1} } }, { - "description": "A special ordered set of type II.", - "examples": ["{\"type\": \"SOS2\", \"weights\": [1, 3, 2]}"], - "required": ["weights"], + "description": "R₊^{dimension}", + "examples": ["{\"type\": \"Nonnegatives\", \"dimension\": 3}"], + "required": ["dimension"], "properties": { - "type": { - "const": "SOS2" - }, - "weights": { - "type": "array", - "items": { - "type": "number" - } - } + "type": {"const": "Nonnegatives"}, + "dimension": {"type": "integer", "minimum": 1} } }, { - "description": "[t, x] ∈ {R^{dimension}: t ≤ (Πxᵢ)^{1 / (dimension-1)}}", - "examples": ["{\"type\": \"GeometricMeanCone\", \"dimension\": 3}"], - "required": ["dimension"], + "description": "x ∈ {R^d: x_i ∈ [lower_i, upper_i]}", + "examples": ["{\"type\": \"HyperRectangle\", \"lower\": [0, 0], \"upper\": [1, 1]}"], + "required": ["lower", "upper"], "properties": { - "type": { - "const": "GeometricMeanCone" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "HyperRectangle"}, + "lower": {"type": "array", "items": {"type": "number"}}, + "upper": {"type": "array", "items": {"type": "number"}} } }, { - "description": "[t, x] ∈ {R^{dimension} : t ≥ ||x||₂", + "description": "[t, x] ∈ {R^{dimension} : t ≥ ||x||₂}", "examples": ["{\"type\": \"SecondOrderCone\", \"dimension\": 3}"], "required": ["dimension"], "properties": { - "type": { - "const": "SecondOrderCone" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "SecondOrderCone"}, + "dimension": {"type": "integer", "minimum": 1} } }, { "description": "[t, u, x] ∈ {R^{dimension} : 2tu ≥ (||x||₂)²; t, u ≥ 0}", "examples": ["{\"type\": \"RotatedSecondOrderCone\", \"dimension\": 3}"], "required": ["dimension"], "properties": { - "type": { - "const": "RotatedSecondOrderCone" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "RotatedSecondOrderCone"}, + "dimension": {"type": "integer", "minimum": 1} } }, { - "description": "{0}^{dimension}", - "examples": ["{\"type\": \"Zeros\", \"dimension\": 3}"], - "required": ["dimension"], + "description": "[x, y, z] ∈ {R³: y * exp(x / y) ≤ z, y ≥ 0}", + "examples": ["{\"type\": \"ExponentialCone\"}"], "properties": { - "type": { - "const": "Zeros" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "ExponentialCone"} } }, { - "description": "R^{dimension}", - "examples": ["{\"type\": \"Reals\", \"dimension\": 3}"], - "required": ["dimension"], + "description": "[u, v, w] ∈ {R³: -u * exp(v / u) ≤ exp(1) * w, u < 0}", + "examples": ["{\"type\": \"DualExponentialCone\"}"], "properties": { - "type": { - "const": "Reals" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "DualExponentialCone"} } }, { - "description": "R₋^{dimension}", - "examples": ["{\"type\": \"Nonpositives\", \"dimension\": 3}"], - "required": ["dimension"], + "description": "[x, y, z] ∈ {R³: x^{exponent} y^{1-exponent} ≥ |z|; x, y ≥ 0}", + "examples": ["{\"type\": \"PowerCone\", \"exponent\": 2.0}"], + "required": ["exponent"], "properties": { - "type": { - "const": "Nonpositives" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "PowerCone"}, + "exponent": {"type": "number"} } }, { - "description": "R₊^{dimension}", - "examples": ["{\"type\": \"Nonnegatives\", \"dimension\": 3}"], - "required": ["dimension"], + "description": "[u, v, w] ∈ {R³: (u / exponent)^{exponent} (v / (1-exponent))^{1-exponent} ≥ |w|; u, v ≥ 0}", + "examples": ["{\"type\": \"DualPowerCone\", \"exponent\": 2.0}"], + "required": ["exponent"], "properties": { - "type": { - "const": "Nonnegatives" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "DualPowerCone"}, + "exponent": {"type": "number"} } }, { - "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`, that is, its number of rows or columns.", - "examples": ["{\"type\": \"RootDetConeTriangle\", \"side_dimension\": 2}"], + "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).", + "examples": ["{\"type\": \"PositiveSemidefiniteConeTriangle\", \"side_dimension\": 2}"], "required": ["side_dimension"], "properties": { - "type": { - "const": "RootDetConeTriangle" - }, - "side_dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "PositiveSemidefiniteConeTriangle"}, + "side_dimension": {"type": "integer", "minimum": 1} } }, { - "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`, that is, its number of rows or columns.", - "examples": ["{\"type\": \"RootDetConeSquare\", \"side_dimension\": 2}"], + "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.", + "examples": ["{\"type\": \"PositiveSemidefiniteConeSquare\", \"side_dimension\": 2}"], "required": ["side_dimension"], "properties": { - "type": { - "const": "RootDetConeSquare" - }, - "side_dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "PositiveSemidefiniteConeSquare"}, + "side_dimension": {"type": "integer", "minimum": 1} } }, { - "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`, that is, its number of rows or columns.", - "examples": ["{\"type\": \"LogDetConeTriangle\", \"side_dimension\": 2}"], - "required": ["side_dimension"], + "description": "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.", + "examples": ["{\"type\": \"Scaled\", \"set\": {\"type\": \"PositiveSemidefiniteConeTriangle\", \"side_dimension\": 2}}"], + "required": ["set"], "properties": { - "type": { - "const": "LogDetConeTriangle" - }, - "side_dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "Scaled"}, + "set": {"$ref": "#/definitions/vector_sets"} } }, { - "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`, that is, its number of rows or columns.", - "examples": ["{\"type\": \"LogDetConeSquare\", \"side_dimension\": 2}"], + "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.", + "examples": ["{\"type\": \"RootDetConeTriangle\", \"side_dimension\": 2}"], "required": ["side_dimension"], "properties": { - "type": { - "const": "LogDetConeSquare" - }, - "side_dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "RootDetConeTriangle"}, + "side_dimension": {"type": "integer", "minimum": 1} } }, { - "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).", - "examples": ["{\"type\": \"PositiveSemidefiniteConeTriangle\", \"side_dimension\": 2}"], + "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.", + "examples": ["{\"type\": \"RootDetConeSquare\", \"side_dimension\": 2}"], "required": ["side_dimension"], "properties": { - "type": { - "const": "PositiveSemidefiniteConeTriangle" - }, - "side_dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "RootDetConeSquare"}, + "side_dimension": {"type": "integer", "minimum": 1} } }, { - "description": "DEPRECATED: use the Scaled set combinned with PositiveSemidefiniteConeTriangle instead.", + "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.", + "examples": ["{\"type\": \"LogDetConeTriangle\", \"side_dimension\": 2}"], "required": ["side_dimension"], "properties": { - "type": { - "const": "ScaledPositiveSemidefiniteConeTriangle" - }, - "side_dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "LogDetConeTriangle"}, + "side_dimension": {"type": "integer", "minimum": 1} } }, { - "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.", - "examples": ["{\"type\": \"PositiveSemidefiniteConeSquare\", \"side_dimension\": 2}"], + "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.", + "examples": ["{\"type\": \"LogDetConeSquare\", \"side_dimension\": 2}"], "required": ["side_dimension"], "properties": { - "type": { - "const": "PositiveSemidefiniteConeSquare" - }, - "side_dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "LogDetConeSquare"}, + "side_dimension": {"type": "integer", "minimum": 1} } }, { - "description": "[x, y, z] ∈ {R³: x^{exponent} y^{1-exponent} ≥ |z|; x, y ≥ 0}", - "examples": ["{\"type\": \"PowerCone\", \"exponent\": 2.0}"], - "required": ["exponent"], + "description": "DEPRECATED: use the Scaled set combinned with PositiveSemidefiniteConeTriangle instead.", + "required": ["side_dimension"], "properties": { - "type": { - "const": "PowerCone" - }, - "exponent": { - "type": "number" - } + "type": {"const": "ScaledPositiveSemidefiniteConeTriangle"}, + "side_dimension": {"type": "integer", "minimum": 1} } }, { - "description": "[u, v, w] ∈ {R³: (u / exponent)^{exponent} (v / (1-exponent))^{1-exponent} ≥ |w|; u, v ≥ 0}", - "examples": ["{\"type\": \"DualPowerCone\", \"exponent\": 2.0}"], - "required": ["exponent"], + "description": "The (vectorized) cone of Hermitian positive semidefinite matrices, with non-negative side_dimension rows and columns.", + "examples": ["{\"type\": \"HermitianPositiveSemidefiniteConeTriangle\", \"side_dimension\": 3}"], + "required": ["side_dimension"], "properties": { - "type": { - "const": "DualPowerCone" - }, - "exponent": { - "type": "number" - } + "type": {"const": "HermitianPositiveSemidefiniteConeTriangle"}, + "side_dimension": {"type": "integer", "minimum": 1} } }, { - "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.", - "examples": ["{\"type\": \"Indicator\", \"set\": {\"type\": \"LessThan\", \"upper\": 2.0}, \"activate_on\": \"one\"}"], - "required": ["set", "activate_on"], + "description": "The p-norm cone (t, x) ∈ {R^d : t ≥ (Σᵢ|xᵢ|^p)^(1/p)}.", + "examples": ["{\"type\": \"NormCone\", \"dimension\": 3, \"p\": 1.5}"], + "required": ["dimension", "p"], "properties": { - "type": { - "const": "Indicator" - }, - "set": { - "oneOf": [{ - "$ref": "#/definitions/scalar_sets" - }, { - "$ref": "#/definitions/vector_sets" - }] - }, - "activate_on": { - "enum": ["one", "zero"] - } + "type": {"const": "NormCone"}, + "dimension": {"type": "integer", "minimum": 1}, + "p": {"type": "number"} } }, { "description": "(t, x) ∈ {R^{dimension}: t ≥ Σᵢ|xᵢ|}", "examples": ["{\"type\": \"NormOneCone\", \"dimension\": 2}"], "required": ["dimension"], "properties": { - "type": { - "const": "NormOneCone" - }, - "dimension": { - "type": "integer", - "minimum": 2 - } + "type": {"const": "NormOneCone"}, + "dimension": {"type": "integer", "minimum": 2} } }, { "description": "(t, x) ∈ {R^{dimension}: t ≥ maxᵢ|xᵢ|}", "examples": ["{\"type\": \"NormInfinityCone\", \"dimension\": 2}"], "required": ["dimension"], "properties": { - "type": { - "const": "NormInfinityCone" - }, - "dimension": { - "type": "integer", - "minimum": 2 - } + "type": {"const": "NormInfinityCone"}, + "dimension": {"type": "integer", "minimum": 2} + } + }, { + "description": "[t, x] ∈ {R^{dimension}: x ≥ 0, t ≤ (Πxᵢ)^{1 / (dimension-1)}}", + "examples": ["{\"type\": \"GeometricMeanCone\", \"dimension\": 3}"], + "required": ["dimension"], + "properties": { + "type": {"const": "GeometricMeanCone"}, + "dimension": {"type": "integer", "minimum": 1} + } + }, { + "description": "[u, v] ∈ {R^{dimension}: v ≥ 0, 0 ≥ u ≥ -n * (Πvᵢ)^{1 / (dimension-1)}}", + "examples": ["{\"type\": \"DualGeometricMeanCone\", \"dimension\": 3}"], + "required": ["dimension"], + "properties": { + "type": {"const": "DualGeometricMeanCone"}, + "dimension": {"type": "integer", "minimum": 1} } }, { "description": "(u, v, w) ∈ {R^{dimension}: u ≥ Σᵢ wᵢlog(wᵢ/vᵢ), vᵢ ≥ 0, wᵢ ≥ 0}", "examples": ["{\"type\": \"RelativeEntropyCone\", \"dimension\": 3}"], "required": ["dimension"], "properties": { - "type": { - "const": "RelativeEntropyCone" - }, - "dimension": { - "type": "integer", - "minimum": 3 - } + "type": {"const": "RelativeEntropyCone"}, + "dimension": {"type": "integer", "minimum": 3} } }, { "description": "(t, X) ∈ {R^{1+row_dim×column_dim}: t ≥ σ₁(X)}", "examples": ["{\"type\": \"NormSpectralCone\", \"row_dim\": 1, \"column_dim\": 2}"], "required": ["row_dim", "column_dim"], "properties": { - "type": { - "const": "NormSpectralCone" - }, - "row_dim": { - "type": "integer", - "minimum": 1 - }, - "column_dim": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "NormSpectralCone"}, + "row_dim": {"type": "integer", "minimum": 1}, + "column_dim": {"type": "integer", "minimum": 1} } }, { "description": "(t, X) ∈ {R^{1+row_dim×column_dim}: t ≥ Σᵢ σᵢ(X)}", "examples": ["{\"type\": \"NormNuclearCone\", \"row_dim\": 1, \"column_dim\": 2}"], "required": ["row_dim", "column_dim"], "properties": { - "type": { - "const": "NormNuclearCone" - }, - "row_dim": { - "type": "integer", - "minimum": 1 - }, - "column_dim": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "NormNuclearCone"}, + "row_dim": {"type": "integer", "minimum": 1}, + "column_dim": {"type": "integer", "minimum": 1} } }, { - "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` (for example, `1.0 * x + 0.0`). The mixed complementarity problem consists of finding `x_i` in the interval `[lb, ub]` (that is, 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`.", + "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`.", "examples": ["{\"type\": \"Complements\", \"dimension\": 2}"], "required": ["dimension"], "properties": { - "type": { - "const": "Complements" + "type": {"const": "Complements"}, + "dimension": {"type": "integer", "minimum": 2} + } + }, { + "description": "A special ordered set of type I.", + "examples": ["{\"type\": \"SOS1\", \"weights\": [1, 3, 2]}"], + "required": ["weights"], + "properties": { + "type": {"const": "SOS1"}, + "weights": {"type": "array", "items": {"type": "number"}} + } + }, { + "description": "A special ordered set of type II.", + "examples": ["{\"type\": \"SOS2\", \"weights\": [1, 3, 2]}"], + "required": ["weights"], + "properties": { + "type": {"const": "SOS2"}, + "weights": {"type": "array", "items": {"type": "number"}} + } + }, { + "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.", + "examples": ["{\"type\": \"Indicator\", \"set\": {\"type\": \"LessThan\", \"upper\": 2.0}, \"activate_on\": \"one\"}"], + "required": ["set", "activate_on"], + "properties": { + "type": {"const": "Indicator"}, + "set": { + "oneOf": [{ + "$ref": "#/definitions/scalar_sets" + }, { + "$ref": "#/definitions/vector_sets" + }] }, - "dimension": { - "type": "integer", - "minimum": 2 - } + "activate_on": {"enum": ["one", "zero"]} } }, { "description": "The set {x in Z^d} such that no two elements in x take the same value and dimension=d.", "examples": ["{\"type\": \"AllDifferent\", \"dimension\": 2}"], "required": ["dimension"], "properties": { - "type": { - "const": "AllDifferent" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "AllDifferent"}, + "dimension": {"type": "integer", "minimum": 1} } }, { "description": "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`.", "examples": ["{\"type\": \"BinPacking\", \"capacity\": 3.0, \"weights\": [1.0, 2.0, 3.0]}"], "required": ["capacity", "weights"], "properties": { - "type": { - "const": "BinPacking" - }, - "capacity": { - "type": "number" - }, - "weights": { - "type": "array", - "items": { - "type": "number" - } - } + "type": {"const": "BinPacking"}, + "capacity": {"type": "number"}, + "weights": {"type": "array", "items": {"type": "number"}} } }, { "description": "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`.", "examples": ["{\"type\": \"Circuit\", \"dimension\": 3}"], "required": ["dimension"], "properties": { - "type": { - "const": "Circuit" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "Circuit"}, + "dimension": {"type": "integer", "minimum": 1} } }, { "description": "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`.", "examples": ["{\"type\": \"CountAtLeast\", \"n\": 1, \"partitions\": [2, 2], \"set\": [3]}"], "required": ["n", "partitions", "set"], "properties": { - "type": { - "const": "CountAtLeast" - }, - "n": { - "type": "integer", - "minimum": 0 - }, - "partitions": { - "type": "array", - "items": { - "type": "integer" - } - }, - "set": { - "type": "array", - "items": { - "type": "integer" - } - } + "type": {"const": "CountAtLeast"}, + "n": {"type": "integer", "minimum": 0}, + "partitions": {"type": "array", "items": {"type": "integer"}}, + "set": {"type": "array", "items": {"type": "integer"}} } }, { "description": "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`.", "examples": ["{\"type\": \"CountBelongs\", \"dimension\": 3, \"set\": [3, 4, 5]}"], "required": ["dimension", "set"], "properties": { - "type": { - "const": "CountBelongs" - }, - "dimension": { - "type": "integer", - "minimum": 1 - }, - "set": { - "type": "array", - "items": { - "type": "integer" - } - } + "type": {"const": "CountBelongs"}, + "dimension": {"type": "integer", "minimum": 1}, + "set": {"type": "array", "items": {"type": "integer"}} } }, { "description": "The set `{(n, x) in Z^{1+d}}`, such that the number of distinct values in `x` is `n` and `dimension = 1 + d`.", "examples": ["{\"type\": \"CountDistinct\", \"dimension\": 3}"], "required": ["dimension"], "properties": { - "type": { - "const": "CountDistinct" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "CountDistinct"}, + "dimension": {"type": "integer", "minimum": 1} } }, { - "description": "The set `{(c, y, x) in Z^{1+1+d}}`, such that `c` is strictly greater than the number of occurences of `y` in `x` and `dimension = 1 + 1 + d`.", + "description": "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`.", "examples": ["{\"type\": \"CountGreaterThan\", \"dimension\": 3}"], "required": ["dimension"], "properties": { - "type": { - "const": "CountGreaterThan" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "CountGreaterThan"}, + "dimension": {"type": "integer", "minimum": 1} } }, { "description": "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.", "examples": ["{\"type\": \"Cumulative\", \"dimension\": 10}"], "required": ["dimension"], "properties": { - "type": { - "const": "Cumulative" - }, - "dimension": { - "type": "integer", - "minimum": 1 - } + "type": {"const": "Cumulative"}, + "dimension": {"type": "integer", "minimum": 1} } }, { "description": "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`.", "examples": ["{\"type\": \"Path\", \"from\": [1, 1, 2, 2, 3], \"to\": [2, 3, 3, 4, 4]}"], "required": ["from", "to"], "properties": { - "type": { - "const": "Path" - }, - "from": { - "type": "array", - "items": { - "type": "integer" - } - }, - "to": { - "type": "array", - "items": { - "type": "integer" - } - } + "type": {"const": "Path"}, + "from": {"type": "array", "items": {"type": "integer"}}, + "to": {"type": "array", "items": {"type": "integer"}} } }, { "description": "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)`.", "examples": ["{\"type\": \"Table\", \"table\": [[1, 1, 0], [0, 1, 1]]}"], "required": ["table"], "properties": { - "type": { - "const": "Table" - }, + "type": {"const": "Table"}, "table": { "type": "array", - "items": { - "type": "array", - "items": { - "type": "number" - } - } + "items": {"type": "array", "items": {"type": "number"}} } } }, { @@ -1202,77 +795,12 @@ "examples": ["{\"type\": \"Reified\", \"set\": {\"type\": \"GreaterThan\", \"lower\": 0}}"], "required": ["set"], "properties": { - "type": { - "const": "Reified" - }, + "type": {"const": "Reified"}, "set": { - "oneOf": [{ - "$ref": "#/definitions/scalar_sets" - }, { - "$ref": "#/definitions/vector_sets" - }] - } - } - }, { - "description": "x ∈ {R^d: x_i ∈ [lower_i, upper_i]}", - "examples": ["{\"type\": \"HyperRectangle\", \"lower\": [0, 0], \"upper\": [1, 1]}"], - "required": ["lower", "upper"], - "properties": { - "type": { - "const": "HyperRectangle" - }, - "lower": { - "type": "array", - "items": { - "type": "number" - } - }, - "upper": { - "type": "array", - "items": { - "type": "number" - } - } - } - }, { - "description": "The (vectorized) cone of Hermitian positive semidefinite matrices, with non-negative side_dimension rows and columns.", - "examples": ["{\"type\": \"HermitianPositiveSemidefiniteConeTriangle\", \"side_dimension\": 3}"], - "required": ["side_dimension"], - "properties": { - "type": { - "const": "HermitianPositiveSemidefiniteConeTriangle" - }, - "side_dimension": { - "type": "integer", - "minimum": 1 - } - } - }, { - "description": "The p-norm cone (t, x) ∈ {R^d : t ≥ (Σᵢ|xᵢ|^p)^(1/p)}.", - "examples": ["{\"type\": \"NormCone\", \"dimension\": 3, \"p\": 1.5}"], - "required": ["dimension", "p"], - "properties": { - "type": { - "const": "NormCone" - }, - "dimension": { - "type": "integer", - "minimum": 1 - }, - "p": { - "type": "number" - } - } - }, { - "description": "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.", - "examples": ["{\"type\": \"Scaled\", \"set\": {\"type\": \"PositiveSemidefiniteConeTriangle\", \"side_dimension\": 2}}"], - "required": ["set"], - "properties": { - "type": { - "const": "Scaled" - }, - "set": { - "$ref": "#/definitions/vector_sets" + "oneOf": [ + {"$ref": "#/definitions/scalar_sets"}, + {"$ref": "#/definitions/vector_sets"} + ] } } }] diff --git a/src/FileFormats/MOF/read.jl b/src/FileFormats/MOF/read.jl index 197f569508..d09be11d27 100644 --- a/src/FileFormats/MOF/read.jl +++ b/src/FileFormats/MOF/read.jl @@ -492,6 +492,7 @@ end SecondOrderCone, RotatedSecondOrderCone, GeometricMeanCone, + DualGeometricMeanCone, NormOneCone, NormInfinityCone, NormCone, @@ -611,6 +612,10 @@ function set_to_moi(::Val{:GeometricMeanCone}, object::Dict) return MOI.GeometricMeanCone(object["dimension"]) end +function set_to_moi(::Val{:DualGeometricMeanCone}, object::Dict) + return MOI.DualGeometricMeanCone(object["dimension"]) +end + function set_to_moi(::Val{:NormOneCone}, object::Dict) return MOI.NormOneCone(object["dimension"]) end diff --git a/src/FileFormats/MOF/write.jl b/src/FileFormats/MOF/write.jl index 73a7543bdd..6cd60e469d 100644 --- a/src/FileFormats/MOF/write.jl +++ b/src/FileFormats/MOF/write.jl @@ -472,6 +472,7 @@ head_name(::Type{MOI.Nonpositives}) = "Nonpositives" head_name(::Type{MOI.SecondOrderCone}) = "SecondOrderCone" head_name(::Type{MOI.RotatedSecondOrderCone}) = "RotatedSecondOrderCone" head_name(::Type{MOI.GeometricMeanCone}) = "GeometricMeanCone" +head_name(::Type{MOI.DualGeometricMeanCone}) = "DualGeometricMeanCone" head_name(::Type{MOI.ExponentialCone}) = "ExponentialCone" head_name(::Type{MOI.DualExponentialCone}) = "DualExponentialCone" head_name(::Type{MOI.NormOneCone}) = "NormOneCone" diff --git a/test/FileFormats/MOF/test_MOF.jl b/test/FileFormats/MOF/test_MOF.jl index a347d2e8bc..bc984e51fd 100644 --- a/test/FileFormats/MOF/test_MOF.jl +++ b/test/FileFormats/MOF/test_MOF.jl @@ -440,9 +440,9 @@ end function test_min_objective() return _test_model_equality( """ -variables: x -minobjective: x -""", + variables: x + minobjective: x + """, ["x"], String[], ) @@ -451,9 +451,9 @@ end function test_max_objective() return _test_model_equality( """ -variables: x -maxobjective: x -""", + variables: x + maxobjective: x + """, ["x"], String[], suffix = ".gz", @@ -463,9 +463,9 @@ end function test_min_scalaraffine() return _test_model_equality( """ -variables: x -minobjective: 1.2x + 0.5 -""", + variables: x + minobjective: 1.2x + 0.5 + """, ["x"], String[], ) @@ -474,9 +474,9 @@ end function test_max_scalaraffine() return _test_model_equality( """ -variables: x -maxobjective: 1.2x + 0.5 -""", + variables: x + maxobjective: 1.2x + 0.5 + """, ["x"], String[], suffix = ".gz", @@ -486,9 +486,9 @@ end function test_min_vector_of_variables() return _test_model_equality( """ -variables: x, y -minobjective: [x, y] -""", + variables: x, y + minobjective: [x, y] + """, ["x", "y"], String[], ) @@ -497,9 +497,9 @@ end function test_max_vector_affine() return _test_model_equality( """ -variables: x, y -maxobjective: [1.0 * x, 2.0 * y, 3.0 * x + 4.0 * y + 5.0] -""", + variables: x, y + maxobjective: [1.0 * x, 2.0 * y, 3.0 * x + 4.0 * y + 5.0] + """, ["x", "y"], String[], ) @@ -508,9 +508,9 @@ end function test_max_vector_quadratic() return _test_model_equality( """ -variables: x, y -maxobjective: [1.0 * x * x + 2.0 * x * y] -""", + variables: x, y + maxobjective: [1.0 * x * x + 2.0 * x * y] + """, ["x", "y"], String[], ) @@ -519,10 +519,10 @@ end function test_singlevariable_in_lower() return _test_model_equality( """ -variables: x -minobjective: 1.2x + 0.5 -x >= 1.0 -""", + variables: x + minobjective: 1.2x + 0.5 + x >= 1.0 + """, ["x"], String[], ) @@ -531,10 +531,10 @@ end function test_singlevariable_in_upper() return _test_model_equality( """ -variables: x -maxobjective: 1.2x + 0.5 -x <= 1.0 -""", + variables: x + maxobjective: 1.2x + 0.5 + x <= 1.0 + """, ["x"], String[], suffix = ".gz", @@ -544,10 +544,10 @@ end function test_singlevariable_in_interval() return _test_model_equality( """ -variables: x -minobjective: 1.2x + 0.5 -x in Interval(1.0, 2.0) -""", + variables: x + minobjective: 1.2x + 0.5 + x in Interval(1.0, 2.0) + """, ["x"], String[], ) @@ -556,10 +556,10 @@ end function test_singlevariable_in_equalto() return _test_model_equality( """ -variables: x -minobjective: 1.2x + 0.5 -x == 1.0 -""", + variables: x + minobjective: 1.2x + 0.5 + x == 1.0 + """, ["x"], String[], ) @@ -568,10 +568,10 @@ end function test_singlevariable_in_zeroone() return _test_model_equality( """ -variables: x -minobjective: 1.2x + 0.5 -x in ZeroOne() -""", + variables: x + minobjective: 1.2x + 0.5 + x in ZeroOne() + """, ["x"], String[], ) @@ -580,10 +580,10 @@ end function test_singlevariable_in_integer() return _test_model_equality( """ -variables: x -minobjective: 1.2x + 0.5 -x in Integer() -""", + variables: x + minobjective: 1.2x + 0.5 + x in Integer() + """, ["x"], String[], ) @@ -592,10 +592,10 @@ end function test_singlevariable_in_Semicontinuous() return _test_model_equality( """ -variables: x -minobjective: 1.2x + 0.5 -x in Semicontinuous(1.0, 2.0) -""", + variables: x + minobjective: 1.2x + 0.5 + x in Semicontinuous(1.0, 2.0) + """, ["x"], String[], ) @@ -604,10 +604,10 @@ end function test_singlevariable_in_Semiinteger() return _test_model_equality( """ -variables: x -minobjective: 1.2x + 0.5 -x in Semiinteger(1.0, 2.0) -""", + variables: x + minobjective: 1.2x + 0.5 + x in Semiinteger(1.0, 2.0) + """, ["x"], String[], ) @@ -616,9 +616,9 @@ end function test_scalarquadratic_objective() return _test_model_equality( """ -variables: x -minobjective: 1.0*x*x + -2.0x + 1.0 -""", + variables: x + minobjective: 1.0*x*x + -2.0x + 1.0 + """, ["x"], String[], ) @@ -627,10 +627,10 @@ end function test_SOS1() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in SOS1([1.0, 2.0, 3.0]) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in SOS1([1.0, 2.0, 3.0]) + """, ["x", "y", "z"], ["c1"], ) @@ -639,10 +639,10 @@ end function test_SOS2() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in SOS2([1.0, 2.0, 3.0]) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in SOS2([1.0, 2.0, 3.0]) + """, ["x", "y", "z"], ["c1"], ) @@ -651,10 +651,10 @@ end function test_Reals() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in Reals(3) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in Reals(3) + """, ["x", "y", "z"], ["c1"], ) @@ -663,10 +663,10 @@ end function test_Zeros() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in Zeros(3) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in Zeros(3) + """, ["x", "y", "z"], ["c1"], ) @@ -675,10 +675,10 @@ end function test_Nonnegatives() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in Nonnegatives(3) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in Nonnegatives(3) + """, ["x", "y", "z"], ["c1"], ) @@ -687,10 +687,10 @@ end function test_Nonpositives() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in Nonpositives(3) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in Nonpositives(3) + """, ["x", "y", "z"], ["c1"], ) @@ -699,10 +699,10 @@ end function test_PowerCone() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in PowerCone(2.0) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in PowerCone(2.0) + """, ["x", "y", "z"], ["c1"], ) @@ -711,10 +711,10 @@ end function test_DualPowerCone() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in DualPowerCone(0.5) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in DualPowerCone(0.5) + """, ["x", "y", "z"], ["c1"], ) @@ -723,10 +723,22 @@ end function test_GeometricMeanCone() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in GeometricMeanCone(3) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in GeometricMeanCone(3) + """, + ["x", "y", "z"], + ["c1"], + ) +end + +function test_DualGeometricMeanCone() + return _test_model_equality( + """ + variables: x, y, z + minobjective: x + c1: [x, y, z] in DualGeometricMeanCone(3) + """, ["x", "y", "z"], ["c1"], ) @@ -743,10 +755,10 @@ end function test_vectoraffine_in_zeros() return _test_model_equality( """ -variables: x, y -minobjective: x -c1: [1.0x + -3.0, 2.0y + -4.0] in Zeros(2) -""", + variables: x, y + minobjective: x + c1: [1.0x + -3.0, 2.0y + -4.0] in Zeros(2) + """, ["x", "y"], ["c1"], ) @@ -755,10 +767,10 @@ end function test_vectorquadratic_in_nonnegatives() return _test_model_equality( """ -variables: x, y -minobjective: x -c1: [1.0*x*x + -2.0x + 1.0, 2.0y + -4.0] in Nonnegatives(2) -""", + variables: x, y + minobjective: x + c1: [1.0*x*x + -2.0x + 1.0, 2.0y + -4.0] in Nonnegatives(2) + """, ["x", "y"], ["c1"], ) @@ -767,9 +779,9 @@ end function test_scalarnonlinearfunction_objective() return _test_model_equality( """ -variables: x -minobjective: ScalarNonlinearFunction(exp(x)) -""", + variables: x + minobjective: ScalarNonlinearFunction(exp(x)) + """, ["x"], String[], ) @@ -778,9 +790,9 @@ end function test_scalarnonlinearfunction_constraint() return _test_model_equality( """ -variables: x -c1: ScalarNonlinearFunction(exp(x)^2) <= 1.0 -""", + variables: x + c1: ScalarNonlinearFunction(exp(x)^2) <= 1.0 + """, ["x"], ["c1"], ) @@ -789,9 +801,9 @@ end function test_vectornonlinearfunction_objective() return _test_model_equality( """ -variables: x -minobjective: VectorNonlinearFunction([exp(x), sin(x)^2]) -""", + variables: x + minobjective: VectorNonlinearFunction([exp(x), sin(x)^2]) + """, ["x"], String[], ) @@ -800,9 +812,9 @@ end function test_vectornonlinearfunction_constraint() return _test_model_equality( """ -variables: x -c1: VectorNonlinearFunction([exp(x), x]) in Complements(2) -""", + variables: x + c1: VectorNonlinearFunction([exp(x), x]) in Complements(2) + """, ["x"], ["c1"], ) @@ -811,10 +823,10 @@ end function test_ExponentialCone() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in ExponentialCone() -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in ExponentialCone() + """, ["x", "y", "z"], ["c1"], ) @@ -823,10 +835,10 @@ end function test_DualExponentialCone() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in DualExponentialCone() -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in DualExponentialCone() + """, ["x", "y", "z"], ["c1"], ) @@ -835,10 +847,10 @@ end function test_SecondOrderCone() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in SecondOrderCone(3) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in SecondOrderCone(3) + """, ["x", "y", "z"], ["c1"], ) @@ -847,10 +859,10 @@ end function test_RotatedSecondOrderCone() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in RotatedSecondOrderCone(3) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in RotatedSecondOrderCone(3) + """, ["x", "y", "z"], ["c1"], ) @@ -859,10 +871,10 @@ end function test_PositiveSemidefiniteConeTriangle() return _test_model_equality( """ -variables: x1, x2, x3 -minobjective: x1 -c1: [x1, x2, x3] in PositiveSemidefiniteConeTriangle(2) -""", + variables: x1, x2, x3 + minobjective: x1 + c1: [x1, x2, x3] in PositiveSemidefiniteConeTriangle(2) + """, ["x1", "x2", "x3"], ["c1"], ) @@ -871,10 +883,10 @@ end function test_ScaledPositiveSemidefiniteConeTriangle() return _test_model_equality( """ -variables: x1, x2, x3 -minobjective: x1 -c1: [x1, x2, x3] in ScaledPositiveSemidefiniteConeTriangle(2) -""", + variables: x1, x2, x3 + minobjective: x1 + c1: [x1, x2, x3] in ScaledPositiveSemidefiniteConeTriangle(2) + """, ["x1", "x2", "x3"], ["c1"], ) @@ -883,10 +895,10 @@ end function test_Scaled_PositiveSemidefiniteConeTriangle() return _test_model_equality( """ -variables: x1, x2, x3 -minobjective: x1 -c1: [x1, x2, x3] in Scaled(PositiveSemidefiniteConeTriangle(2)) -""", + variables: x1, x2, x3 + minobjective: x1 + c1: [x1, x2, x3] in Scaled(PositiveSemidefiniteConeTriangle(2)) + """, ["x1", "x2", "x3"], ["c1"], ) @@ -895,10 +907,10 @@ end function test_PositiveSemidefiniteConeSquare() return _test_model_equality( """ -variables: x1, x2, x3, x4 -minobjective: x1 -c1: [x1, x2, x3, x4] in PositiveSemidefiniteConeSquare(2) -""", + variables: x1, x2, x3, x4 + minobjective: x1 + c1: [x1, x2, x3, x4] in PositiveSemidefiniteConeSquare(2) + """, ["x1", "x2", "x3", "x4"], ["c1"], ) @@ -907,9 +919,9 @@ end function test_HermitianPositiveSemidefiniteConeTriangle() return _test_model_equality( """ -variables: x1, x2, x3, x4 -c1: [x1, x2, x3, x4] in HermitianPositiveSemidefiniteConeTriangle(2) -""", + variables: x1, x2, x3, x4 + c1: [x1, x2, x3, x4] in HermitianPositiveSemidefiniteConeTriangle(2) + """, ["x1", "x2", "x3", "x4"], ["c1"], ) @@ -918,10 +930,10 @@ end function test_LogDetConeTriangle() return _test_model_equality( """ -variables: t, u, x1, x2, x3 -minobjective: x1 -c1: [t, u, x1, x2, x3] in LogDetConeTriangle(2) -""", + variables: t, u, x1, x2, x3 + minobjective: x1 + c1: [t, u, x1, x2, x3] in LogDetConeTriangle(2) + """, ["t", "u", "x1", "x2", "x3"], ["c1"], ) @@ -930,10 +942,10 @@ end function test_LogDetConeSquare() return _test_model_equality( """ -variables: t, u, x1, x2, x3, x4 -minobjective: x1 -c1: [t, u, x1, x2, x3, x4] in LogDetConeSquare(2) -""", + variables: t, u, x1, x2, x3, x4 + minobjective: x1 + c1: [t, u, x1, x2, x3, x4] in LogDetConeSquare(2) + """, ["t", "u", "x1", "x2", "x3", "x4"], ["c1"], ) @@ -942,10 +954,10 @@ end function test_RootDetConeTriangle() return _test_model_equality( """ -variables: t, x1, x2, x3 -minobjective: x1 -c1: [t, x1, x2, x3] in RootDetConeTriangle(2) -""", + variables: t, x1, x2, x3 + minobjective: x1 + c1: [t, x1, x2, x3] in RootDetConeTriangle(2) + """, ["t", "x1", "x2", "x3"], ["c1"], ) @@ -954,10 +966,10 @@ end function test_RootDetConeSquare() return _test_model_equality( """ -variables: t, x1, x2, x3, x4 -minobjective: x1 -c1: [t, x1, x2, x3, x4] in RootDetConeSquare(2) -""", + variables: t, x1, x2, x3, x4 + minobjective: x1 + c1: [t, x1, x2, x3, x4] in RootDetConeSquare(2) + """, ["t", "x1", "x2", "x3", "x4"], ["c1"], ) @@ -966,20 +978,20 @@ end function test_Indicator() _test_model_equality( """ -variables: x, y -minobjective: x -c1: [x, y] in Indicator{ACTIVATE_ON_ONE}(GreaterThan(1.0)) -""", + variables: x, y + minobjective: x + c1: [x, y] in Indicator{ACTIVATE_ON_ONE}(GreaterThan(1.0)) + """, ["x", "y"], ["c1"], ) return _test_model_equality( """ -variables: x, y -minobjective: x -c1: [x, y] in Indicator{ACTIVATE_ON_ZERO}(GreaterThan(1.0)) -""", + variables: x, y + minobjective: x + c1: [x, y] in Indicator{ACTIVATE_ON_ZERO}(GreaterThan(1.0)) + """, ["x", "y"], ["c1"], ) @@ -988,10 +1000,10 @@ end function test_NormOneCone() return _test_model_equality( """ -variables: x, y -minobjective: x -c1: [x, y] in NormOneCone(2) -""", + variables: x, y + minobjective: x + c1: [x, y] in NormOneCone(2) + """, ["x", "y"], ["c1"], ) @@ -1000,10 +1012,10 @@ end function test_NormInfinityCone() return _test_model_equality( """ -variables: x, y -minobjective: x -c1: [x, y] in NormInfinityCone(2) -""", + variables: x, y + minobjective: x + c1: [x, y] in NormInfinityCone(2) + """, ["x", "y"], ["c1"], ) @@ -1012,10 +1024,10 @@ end function test_NormCone() return _test_model_equality( """ -variables: x, y -minobjective: x -c1: [x, y] in NormCone(1.5, 2) -""", + variables: x, y + minobjective: x + c1: [x, y] in NormCone(1.5, 2) + """, ["x", "y"], ["c1"], ) @@ -1024,10 +1036,10 @@ end function test_RelativeEntropyCone() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in RelativeEntropyCone(3) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in RelativeEntropyCone(3) + """, ["x", "y", "z"], ["c1"], ) @@ -1036,10 +1048,10 @@ end function test_NormSpectralCone() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in NormSpectralCone(1, 2) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in NormSpectralCone(1, 2) + """, ["x", "y", "z"], ["c1"], ) @@ -1048,10 +1060,10 @@ end function test_NormNuclearCone() return _test_model_equality( """ -variables: x, y, z -minobjective: x -c1: [x, y, z] in NormNuclearCone(1, 2) -""", + variables: x, y, z + minobjective: x + c1: [x, y, z] in NormNuclearCone(1, 2) + """, ["x", "y", "z"], ["c1"], ) @@ -1064,12 +1076,12 @@ function test_v04() MOI.Utilities.loadfromstring!( model_2, """ -variables: x, y -minobjective: x -c: x + y >= 1.0 -x in Interval(0.0, 1.0) -y in ZeroOne() -""", + variables: x, y + minobjective: x + c: x + y >= 1.0 + x in Interval(0.0, 1.0) + y in ZeroOne() + """, ) MOI.Test.util_test_models_equal(model, model_2, ["x", "y"], ["c"]) return @@ -1078,9 +1090,9 @@ end function test_AllDifferent() return _test_model_equality( """ -variables: x, y, z -c1: [x, y, z] in AllDifferent(3) -""", + variables: x, y, z + c1: [x, y, z] in AllDifferent(3) + """, ["x", "y", "z"], ["c1"], ) @@ -1089,9 +1101,9 @@ end function test_BinPacking() return _test_model_equality( """ -variables: x, y, z -c1: [x, y, z] in BinPacking(3.0, [1.0, 2.0, 3.0]) -""", + variables: x, y, z + c1: [x, y, z] in BinPacking(3.0, [1.0, 2.0, 3.0]) + """, ["x", "y", "z"], ["c1"], ) @@ -1100,9 +1112,9 @@ end function test_Circuit() return _test_model_equality( """ -variables: x, y, z -c1: [x, y, z] in Circuit(3) -""", + variables: x, y, z + c1: [x, y, z] in Circuit(3) + """, ["x", "y", "z"], ["c1"], ) @@ -1111,9 +1123,9 @@ end function test_CountAtLeast() return _test_model_equality( """ -variables: x, y, z -c1: [x, y, y, z] in CountAtLeast(1, [2, 2], Set([3])) -""", + variables: x, y, z + c1: [x, y, y, z] in CountAtLeast(1, [2, 2], Set([3])) + """, ["x", "y", "z"], ["c1"], ) @@ -1122,9 +1134,9 @@ end function test_CountBelongs() return _test_model_equality( """ -variables: x, y, z -c1: [x, y, z] in CountBelongs(3, Set([3, 4, 5])) -""", + variables: x, y, z + c1: [x, y, z] in CountBelongs(3, Set([3, 4, 5])) + """, ["x", "y", "z"], ["c1"], ) @@ -1133,9 +1145,9 @@ end function test_CountDistinct() return _test_model_equality( """ -variables: x, y, z -c1: [x, y, z] in CountDistinct(3) -""", + variables: x, y, z + c1: [x, y, z] in CountDistinct(3) + """, ["x", "y", "z"], ["c1"], ) @@ -1144,9 +1156,9 @@ end function test_CountGreaterThan() return _test_model_equality( """ -variables: x, y, z -c1: [x, y, z] in CountGreaterThan(3) -""", + variables: x, y, z + c1: [x, y, z] in CountGreaterThan(3) + """, ["x", "y", "z"], ["c1"], ) @@ -1155,9 +1167,9 @@ end function test_Cumulative() return _test_model_equality( """ -variables: a, b, c, d, e, f, g, h, i, j -c1: [a, b, c, d, e, f, g, h, i, j] in Cumulative(10) -""", + variables: a, b, c, d, e, f, g, h, i, j + c1: [a, b, c, d, e, f, g, h, i, j] in Cumulative(10) + """, ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"], ["c1"], ) @@ -1166,9 +1178,9 @@ end function test_Path() return _test_model_equality( """ -variables: s, t, n1, n2, n3, n4, e1, e2, e3, e4, e5 -c1: [s, t, n1, n2, n3, n4, e1, e2, e3, e4, e5] in Path([1, 1, 2, 2, 3], [2, 3, 3, 4, 4]) -""", + variables: s, t, n1, n2, n3, n4, e1, e2, e3, e4, e5 + c1: [s, t, n1, n2, n3, n4, e1, e2, e3, e4, e5] in Path([1, 1, 2, 2, 3], [2, 3, 3, 4, 4]) + """, ["s", "t", "n1", "n2", "n3", "n4", "e1", "e2", "e3", "e4", "e5"], ["c1"], ) @@ -1177,9 +1189,9 @@ end function test_Table() return _test_model_equality( """ -variables: x, y, z -c1: [x, y, z] in Table([1.0 1.0 0.0; 0.0 0.0 0.0]) -""", + variables: x, y, z + c1: [x, y, z] in Table([1.0 1.0 0.0; 0.0 0.0 0.0]) + """, ["x", "y", "z"], ["c1"], ) @@ -1188,8 +1200,8 @@ end function test_Parameter() return _test_model_equality( """ -constrainedvariable: x in Parameter(2.0) -""", + constrainedvariable: x in Parameter(2.0) + """, ["x"], String[], ) @@ -1198,9 +1210,9 @@ end function test_HyperRectangle() return _test_model_equality( """ -variables: x, y, z -c1: [x, y, z] in HyperRectangle([1.0, 2.0, 3.0], [1.1, 2.2, 3.3]) -""", + variables: x, y, z + c1: [x, y, z] in HyperRectangle([1.0, 2.0, 3.0], [1.1, 2.2, 3.3]) + """, ["x", "y", "z"], ["c1"], ) @@ -1209,10 +1221,10 @@ end function test_Reified() return _test_model_equality( """ -variables: x, y -minobjective: x -c1: [x, y] in Reified(GreaterThan(1.0)) -""", + variables: x, y + minobjective: x + c1: [x, y] in Reified(GreaterThan(1.0)) + """, ["x", "y"], ["c1"], ) @@ -1348,25 +1360,25 @@ function test_parse_constraintname_variable() print( io, """{ - "version": {"major": 1, "minor": 2}, - "variables": [{"name": "x", "primal_start": 0.0}], - "objective": {"sense": "min", "function": {"type": "Variable", "name": "x"}}, - "constraints": [{ - "name": "x >= 1", - "function": { - "type": "ScalarAffineFunction", - "terms": [{"coefficient": 1, "variable": "x"}], - "constant": 0 - }, - "set": {"type": "GreaterThan", "lower": 1}, - "primal_start": 1, - "dual_start": 0 - }, { - "name": "x ∈ [0, 1]", - "function": {"type": "Variable", "name": "x"}, - "set": {"type": "Interval", "lower": 0, "upper": 1} - }] -}""", + "version": {"major": 1, "minor": 2}, + "variables": [{"name": "x", "primal_start": 0.0}], + "objective": {"sense": "min", "function": {"type": "Variable", "name": "x"}}, + "constraints": [{ + "name": "x >= 1", + "function": { + "type": "ScalarAffineFunction", + "terms": [{"coefficient": 1, "variable": "x"}], + "constant": 0 + }, + "set": {"type": "GreaterThan", "lower": 1}, + "primal_start": 1, + "dual_start": 0 + }, { + "name": "x ∈ [0, 1]", + "function": {"type": "Variable", "name": "x"}, + "set": {"type": "Interval", "lower": 0, "upper": 1} + }] + }""", ) seekstart(io) model = MOF.Model() @@ -1392,18 +1404,18 @@ function test_parse_nonlinear_objective_only() print( io, """{ - "version": {"major": 1, "minor": 2}, - "variables": [{"name": "x"}], - "objective": { - "sense": "min", - "function": { - "type": "ScalarNonlinearFunction", - "root": {"type": "node", "index": 1}, - "node_list": [{"type": "sin", "args": [{"type": "variable", "name": "x"}]}] - } - }, - "constraints": [] -}""", + "version": {"major": 1, "minor": 2}, + "variables": [{"name": "x"}], + "objective": { + "sense": "min", + "function": { + "type": "ScalarNonlinearFunction", + "root": {"type": "node", "index": 1}, + "node_list": [{"type": "sin", "args": [{"type": "variable", "name": "x"}]}] + } + }, + "constraints": [] + }""", ) seekstart(io) model = MOF.Model()