Skip to content

Commit

Permalink
MathOptFormat v0.5 (#14)
Browse files Browse the repository at this point in the history
* Rename head->type

* Add latest sets from MathOptInterface.jl
  • Loading branch information
odow authored Aug 23, 2020
1 parent 58d9a35 commit 81c3550
Show file tree
Hide file tree
Showing 9 changed files with 973 additions and 106 deletions.
148 changes: 75 additions & 73 deletions README.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions examples/biobjective.mof.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "The problem: [min{2x - y + 1, -y}]",
"version": {
"major": 0,
"minor": 4
"minor": 5
},
"variables": [{
"name": "x"
Expand All @@ -12,7 +12,7 @@
"objective": {
"sense": "min",
"function": {
"head": "VectorAffineFunction",
"type": "VectorAffineFunction",
"terms": [{
"output_index": 1,
"scalar_term": {
Expand Down
16 changes: 8 additions & 8 deletions examples/milp.mof.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "The problem: min{x | x + y >= 1, x ∈ [0, 1], y ∈ {0, 1}}",
"version": {
"major": 0,
"minor": 4
"minor": 5
},
"variables": [{
"name": "x",
Expand All @@ -14,14 +14,14 @@
"objective": {
"sense": "min",
"function": {
"head": "SingleVariable",
"type": "SingleVariable",
"variable": "x"
}
},
"constraints": [{
"name": "x + y >= 1",
"function": {
"head": "ScalarAffineFunction",
"type": "ScalarAffineFunction",
"terms": [{
"coefficient": 1,
"variable": "x"
Expand All @@ -34,28 +34,28 @@
"constant": 0
},
"set": {
"head": "GreaterThan",
"type": "GreaterThan",
"lower": 1
}
}, {
"name": "x ∈ [0, 1]",
"function": {
"head": "SingleVariable",
"type": "SingleVariable",
"variable": "x"
},
"set": {
"head": "Interval",
"type": "Interval",
"lower": 0,
"upper": 1
}
}, {
"name": "y ∈ {0, 1}",
"function": {
"head": "SingleVariable",
"type": "SingleVariable",
"variable": "y"
},
"set": {
"head": "ZeroOne"
"type": "ZeroOne"
}
}]
}
30 changes: 15 additions & 15 deletions examples/nlp.mof.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "The problem: min{2x + sin(x)^2 + y}.",
"version": {
"major": 0,
"minor": 4
"minor": 5
},
"variables": [{
"name": "x"
Expand All @@ -12,45 +12,45 @@
"objective": {
"sense": "min",
"function": {
"head": "ScalarNonlinearFunction",
"type": "ScalarNonlinearFunction",
"root": {
"head": "node",
"type": "node",
"index": 4
},
"node_list": [{
"head": "*",
"type": "*",
"args": [{
"head": "real",
"type": "real",
"value": 2
}, {
"head": "variable",
"type": "variable",
"name": "x"
}]
}, {
"head": "sin",
"type": "sin",
"args": [{
"head": "variable",
"type": "variable",
"name": "x"
}]
}, {
"head": "^",
"type": "^",
"args": [{
"head": "node",
"type": "node",
"index": 2
}, {
"head": "real",
"type": "real",
"value": 2
}]
}, {
"head": "+",
"type": "+",
"args": [{
"head": "node",
"type": "node",
"index": 1
}, {
"head": "node",
"type": "node",
"index": 3
}, {
"head": "variable",
"type": "variable",
"name": "y"
}]
}]
Expand Down
4 changes: 2 additions & 2 deletions examples/quadratic.mof.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "The problem: min{x^2 + x * y + y^2}",
"version": {
"major": 0,
"minor": 4
"minor": 5
},
"variables": [{
"name": "x"
Expand All @@ -13,7 +13,7 @@
"sense": "min",
"function": {
"description": "Note that the format is `a'x + 0.5 x' Q x + c`.",
"head": "ScalarQuadraticFunction",
"type": "ScalarQuadraticFunction",
"affine_terms": [],
"quadratic_terms": [{
"coefficient": 2,
Expand Down
6 changes: 3 additions & 3 deletions examples/vector.mof.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"description": "The problem: min{0 | [1 2; 3 4][x, y] + [5, 6] ∈ R+.",
"version": {
"major": 0,
"minor": 4
"minor": 5
},
"variables": [{
"name": "x"
Expand All @@ -14,7 +14,7 @@
},
"constraints": [{
"function": {
"head": "VectorAffineFunction",
"type": "VectorAffineFunction",
"terms": [{
"output_index": 1,
"scalar_term": {
Expand Down Expand Up @@ -43,7 +43,7 @@
"constants": [5, 6]
},
"set": {
"head": "Nonnegatives",
"type": "Nonnegatives",
"dimension": 2
}
}]
Expand Down
4 changes: 2 additions & 2 deletions python/mof.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import jsonschema
import os

SCHEMA_FILENAME = '../mof.0.4.schema.json'
SCHEMA_FILENAME = '../schemas/mof.0.5.schema.json'

def validate(filename):
with open(filename, 'r') as io:
Expand All @@ -27,7 +27,7 @@ def summarize_schema():
return summary

def oneOf_to_object(item):
head = item["properties"]["head"]
head = item["properties"]["type"]
ret = []
if "const" in head:
description = item.get("description", "").replace("|", "\\|")
Expand Down
2 changes: 1 addition & 1 deletion mof.0.4.schema.json → schemas/mof.0.4.schema.json
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/mof.0.4.schema.json",
"$id": "https://jump.dev/MathOptFormat/schemas/mof.0.4.schema.json",
"title": "The schema for MathOptFormat",
"type": "object",
"required": ["version", "variables", "objective", "constraints"],
Expand Down
Loading

0 comments on commit 81c3550

Please sign in to comment.