Skip to content

Commit

Permalink
Merge pull request #9 from odow/od/v3
Browse files Browse the repository at this point in the history
Add SemVer versions
  • Loading branch information
odow authored Oct 11, 2019
2 parents d138167 + ddf58c1 commit 4f32cec
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 15 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ Encoded in our standard form, we have
Encoded into the MathOptFormat file format, this example becomes:
```json
{
"version": 1,
"version": {
"major": 0,
"minor": 3
},
"variables": [{"name": "x"}],
"objectives": [{
"sense": "min",
Expand Down Expand Up @@ -73,8 +76,10 @@ required keys at the top level:

- `"version"`

An integer describing the minimum version of MathOptFormat needed to parse
the file. This is included to safeguard against later revisions.
An object describing the minimum version of MathOptFormat needed to parse
the file. This is included to safeguard against later revisions. It contains
two fields: `"major"` and `"minor"`. These fields should be interpreted
using [SemVer](https://semver.org).

- `"variables"`

Expand Down
7 changes: 5 additions & 2 deletions examples/biobjective.mof.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"description": "The problem: [min{2x - y + 1}, max{y}]",
"version": 0,
"version": {
"major": 0,
"minor": 3
},
"variables": [{
"name": "x"
}, {
Expand Down Expand Up @@ -29,4 +32,4 @@
}
}],
"constraints": []
}
}
7 changes: 5 additions & 2 deletions examples/milp.mof.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"description": "The problem: min{x | x + y >= 1, x ∈ [0, 1], y ∈ {0, 1}}",
"version": 0,
"version": {
"major": 0,
"minor": 3
},
"variables": [{
"name": "x",
"primal_start": 0.0
Expand Down Expand Up @@ -55,4 +58,4 @@
"head": "ZeroOne"
}
}]
}
}
7 changes: 5 additions & 2 deletions examples/nlp.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"description": "The problem: min{2x + sin(x)^2 + y}.",
"version": 0,
"version": {
"major": 0,
"minor": 3
},
"variables": [{
"name": "x"
}, {
Expand Down Expand Up @@ -54,4 +57,4 @@
}
}],
"constraints": []
}
}
7 changes: 5 additions & 2 deletions examples/quadratic.mof.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"description": "The problem: min{x^2 + x * y + y^2}",
"version": 0,
"version": {
"major": 0,
"minor": 3
},
"variables": [{
"name": "x"
}, {
Expand Down Expand Up @@ -32,4 +35,4 @@
}
}],
"constraints": []
}
}
7 changes: 5 additions & 2 deletions examples/vector.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"description": "The problem: min{0 | [1 2; 3 4][x, y] + [5, 6] ∈ R+.",
"version": 0,
"version": {
"major": 0,
"minor": 3
},
"variables": [{
"name": "x"
}, {
Expand Down Expand Up @@ -42,4 +45,4 @@
"dimension": 2
}
}]
}
}
11 changes: 10 additions & 1 deletion mof.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@
"properties": {
"version": {
"description": "The version of MathOptFormat that this schema validates against.",
"const": 0
"type": "object",
"required": ["minor", "major"],
"properties": {
"minor": {
"const": 3
},
"major": {
"const": 0
}
}
},
"name": {
"description": "The name of the model.",
Expand Down
1 change: 1 addition & 0 deletions mof/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.md
*.bat
*staticSchema.go
mof
3 changes: 2 additions & 1 deletion mof/mof.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (

func main() {
if len(os.Args) < 2 {
fmt.Println("Invalid arguments to `mof`. Here is the help:\n")
fmt.Println("Invalid arguments to `mof`. Here is the help:")
fmt.Println()
PrintHelp()
} else {
switch os.Args[1] {
Expand Down

0 comments on commit 4f32cec

Please sign in to comment.