Skip to content

Commit 81c3550

Browse files
authored
MathOptFormat v0.5 (#14)
* Rename head->type * Add latest sets from MathOptInterface.jl
1 parent 58d9a35 commit 81c3550

9 files changed

+973
-106
lines changed

Diff for: README.md

+75-73
Large diffs are not rendered by default.

Diff for: examples/biobjective.mof.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"description": "The problem: [min{2x - y + 1, -y}]",
33
"version": {
44
"major": 0,
5-
"minor": 4
5+
"minor": 5
66
},
77
"variables": [{
88
"name": "x"
@@ -12,7 +12,7 @@
1212
"objective": {
1313
"sense": "min",
1414
"function": {
15-
"head": "VectorAffineFunction",
15+
"type": "VectorAffineFunction",
1616
"terms": [{
1717
"output_index": 1,
1818
"scalar_term": {

Diff for: examples/milp.mof.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"description": "The problem: min{x | x + y >= 1, x ∈ [0, 1], y ∈ {0, 1}}",
33
"version": {
44
"major": 0,
5-
"minor": 4
5+
"minor": 5
66
},
77
"variables": [{
88
"name": "x",
@@ -14,14 +14,14 @@
1414
"objective": {
1515
"sense": "min",
1616
"function": {
17-
"head": "SingleVariable",
17+
"type": "SingleVariable",
1818
"variable": "x"
1919
}
2020
},
2121
"constraints": [{
2222
"name": "x + y >= 1",
2323
"function": {
24-
"head": "ScalarAffineFunction",
24+
"type": "ScalarAffineFunction",
2525
"terms": [{
2626
"coefficient": 1,
2727
"variable": "x"
@@ -34,28 +34,28 @@
3434
"constant": 0
3535
},
3636
"set": {
37-
"head": "GreaterThan",
37+
"type": "GreaterThan",
3838
"lower": 1
3939
}
4040
}, {
4141
"name": "x ∈ [0, 1]",
4242
"function": {
43-
"head": "SingleVariable",
43+
"type": "SingleVariable",
4444
"variable": "x"
4545
},
4646
"set": {
47-
"head": "Interval",
47+
"type": "Interval",
4848
"lower": 0,
4949
"upper": 1
5050
}
5151
}, {
5252
"name": "y ∈ {0, 1}",
5353
"function": {
54-
"head": "SingleVariable",
54+
"type": "SingleVariable",
5555
"variable": "y"
5656
},
5757
"set": {
58-
"head": "ZeroOne"
58+
"type": "ZeroOne"
5959
}
6060
}]
6161
}

Diff for: examples/nlp.mof.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"description": "The problem: min{2x + sin(x)^2 + y}.",
33
"version": {
44
"major": 0,
5-
"minor": 4
5+
"minor": 5
66
},
77
"variables": [{
88
"name": "x"
@@ -12,45 +12,45 @@
1212
"objective": {
1313
"sense": "min",
1414
"function": {
15-
"head": "ScalarNonlinearFunction",
15+
"type": "ScalarNonlinearFunction",
1616
"root": {
17-
"head": "node",
17+
"type": "node",
1818
"index": 4
1919
},
2020
"node_list": [{
21-
"head": "*",
21+
"type": "*",
2222
"args": [{
23-
"head": "real",
23+
"type": "real",
2424
"value": 2
2525
}, {
26-
"head": "variable",
26+
"type": "variable",
2727
"name": "x"
2828
}]
2929
}, {
30-
"head": "sin",
30+
"type": "sin",
3131
"args": [{
32-
"head": "variable",
32+
"type": "variable",
3333
"name": "x"
3434
}]
3535
}, {
36-
"head": "^",
36+
"type": "^",
3737
"args": [{
38-
"head": "node",
38+
"type": "node",
3939
"index": 2
4040
}, {
41-
"head": "real",
41+
"type": "real",
4242
"value": 2
4343
}]
4444
}, {
45-
"head": "+",
45+
"type": "+",
4646
"args": [{
47-
"head": "node",
47+
"type": "node",
4848
"index": 1
4949
}, {
50-
"head": "node",
50+
"type": "node",
5151
"index": 3
5252
}, {
53-
"head": "variable",
53+
"type": "variable",
5454
"name": "y"
5555
}]
5656
}]

Diff for: examples/quadratic.mof.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"description": "The problem: min{x^2 + x * y + y^2}",
33
"version": {
44
"major": 0,
5-
"minor": 4
5+
"minor": 5
66
},
77
"variables": [{
88
"name": "x"
@@ -13,7 +13,7 @@
1313
"sense": "min",
1414
"function": {
1515
"description": "Note that the format is `a'x + 0.5 x' Q x + c`.",
16-
"head": "ScalarQuadraticFunction",
16+
"type": "ScalarQuadraticFunction",
1717
"affine_terms": [],
1818
"quadratic_terms": [{
1919
"coefficient": 2,

Diff for: examples/vector.mof.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"description": "The problem: min{0 | [1 2; 3 4][x, y] + [5, 6] ∈ R+.",
33
"version": {
44
"major": 0,
5-
"minor": 4
5+
"minor": 5
66
},
77
"variables": [{
88
"name": "x"
@@ -14,7 +14,7 @@
1414
},
1515
"constraints": [{
1616
"function": {
17-
"head": "VectorAffineFunction",
17+
"type": "VectorAffineFunction",
1818
"terms": [{
1919
"output_index": 1,
2020
"scalar_term": {
@@ -43,7 +43,7 @@
4343
"constants": [5, 6]
4444
},
4545
"set": {
46-
"head": "Nonnegatives",
46+
"type": "Nonnegatives",
4747
"dimension": 2
4848
}
4949
}]

Diff for: python/mof.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import jsonschema
33
import os
44

5-
SCHEMA_FILENAME = '../mof.0.4.schema.json'
5+
SCHEMA_FILENAME = '../schemas/mof.0.5.schema.json'
66

77
def validate(filename):
88
with open(filename, 'r') as io:
@@ -27,7 +27,7 @@ def summarize_schema():
2727
return summary
2828

2929
def oneOf_to_object(item):
30-
head = item["properties"]["head"]
30+
head = item["properties"]["type"]
3131
ret = []
3232
if "const" in head:
3333
description = item.get("description", "").replace("|", "\\|")

Diff for: mof.0.4.schema.json renamed to schemas/mof.0.4.schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://json-schema.org/schema#",
3-
"$id": "https://jump.dev/MathOptFormat/mof.0.4.schema.json",
3+
"$id": "https://jump.dev/MathOptFormat/schemas/mof.0.4.schema.json",
44
"title": "The schema for MathOptFormat",
55
"type": "object",
66
"required": ["version", "variables", "objective", "constraints"],

0 commit comments

Comments
 (0)