Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/submodules/FileFormats/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ julia> print(read("file.mof.json", String))
"name": "MathOptFormat Model",
"version": {
"major": 0,
"minor": 5
"minor": 6
},
"variables": [
{
Expand Down
2 changes: 1 addition & 1 deletion src/FileFormats/MOF/MOF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import JSONSchema
import MathOptInterface

const MOI = MathOptInterface
const SCHEMA_PATH = joinpath(@__DIR__, "mof.0.5.schema.json")
const SCHEMA_PATH = joinpath(@__DIR__, "mof.0.6.schema.json")
const VERSION = let data = JSON.parsefile(SCHEMA_PATH, use_mmap = false)
VersionNumber(
data["properties"]["version"]["properties"]["major"]["const"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/schema#",
"$id": "https://jump.dev/MathOptFormat/schemas/mof.0.5.schema.json",
"$id": "https://jump.dev/MathOptFormat/schemas/mof.0.6.schema.json",
"title": "The schema for MathOptFormat",
"type": "object",
"required": ["version", "variables", "objective", "constraints"],
Expand All @@ -11,7 +11,7 @@
"required": ["minor", "major"],
"properties": {
"minor": {
"const": 5
"const": 6
},
"major": {
"const": 0
Expand Down Expand Up @@ -859,6 +859,19 @@
"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` (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"
},
"dimension": {
"type": "integer",
"minimum": 2
}
}
}]
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/FileFormats/MOF/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ end
SOS1,
SOS2,
IndicatorSet,
Complements,
)

"""
Expand Down Expand Up @@ -450,6 +451,10 @@ function set_to_moi(::Val{:DualExponentialCone}, ::Object)
return MOI.DualExponentialCone()
end

function set_to_moi(::Val{:Complements}, object::Object)
return MOI.Complements(div(object["dimension"], 2))
end

# ========== Typed vector sets ==========

function set_to_moi(::Val{:PowerCone}, object::Object)
Expand Down
7 changes: 7 additions & 0 deletions src/FileFormats/MOF/write.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,10 @@ function moi_to_object(
"activate_on" => (I == MOI.ACTIVATE_ON_ONE) ? "one" : "zero",
)
end

function moi_to_object(set::MOI.Complements, ::Dict{MOI.VariableIndex,String})
return OrderedObject(
"type" => "Complements",
"dimension" => MOI.dimension(set),
)
end
7 changes: 7 additions & 0 deletions test/FileFormats/MOF/MOF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,13 @@ end
["c1"],
)
end
@testset "Complements" begin
test_model_equality(
"variables: x, y\nc1: [x, y] in Complements(1)",
["x", "y"],
["c1"],
)
end
@testset "vectoraffine-in-zeros" begin
test_model_equality(
"""
Expand Down
2 changes: 1 addition & 1 deletion test/FileFormats/MOF/empty_model.mof.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "MathOptFormat Model",
"version": {
"major": 0,
"minor": 5
"minor": 6
},
"variables": [],
"objective": {"sense": "feasibility"},
Expand Down
Binary file removed test/FileFormats/MOF/empty_model.mof.json.gz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "MathOptFormat Model",
"version": {
"major": 0,
"minor": 5
"minor": 6
},
"variables": [{"name": ""}],
"objective": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "MathOptFormat Model",
"version": {
"major": 0,
"minor": 5
"minor": 6
},
"variables": [{}],
"objective": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "MathOptFormat Model",
"version": {
"major": 0,
"minor": 5
"minor": 6
},
"variables": [{"name": "x"}],
"objective": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "MathOptFormat Model",
"version": {
"major": 0,
"minor": 5
"minor": 6
},
"variables": [{"name": "x"}],
"objective": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "MathOptFormat Model",
"version": {
"major": 0,
"minor": 5
"minor": 6
},
"variables": [{"name": "x"}],
"objective": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "MathOptFormat Model",
"version": {
"major": 0,
"minor": 5
"minor": 6
},
"variables": [{"name": "x"}],
"objective": {
Expand Down
2 changes: 1 addition & 1 deletion test/FileFormats/MOF/nlp.mof.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "MathOptFormat Model",
"version": {
"major": 0,
"minor": 5
"minor": 6
},
"variables": [
{
Expand Down