Skip to content

Commit 6498687

Browse files
committed
Merge branch 'master' into addspectralnormcone
2 parents e81356a + 78c15ba commit 6498687

File tree

93 files changed

+7407
-101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+7407
-101
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
*.jl.cov
22
*.jl.*.cov
33
*.jl.mem
4+
.vscode/*
45
docs/build/
56
docs/site/
6-
Manifest.toml
77
test/Benchmarks/*.json
8+
Manifest.toml

LICENSE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ The MathOptInterface.jl package is licensed under the MIT "Expat" License:
22

33
> Copyright (c) 2017: Miles Lubin and contributors
44
> Copyright (c) 2017: Google Inc.
5-
>
5+
>
66
> Permission is hereby granted, free of charge, to any person obtaining a copy
77
> of this software and associated documentation files (the "Software"), to deal
88
> in the Software without restriction, including without limitation the rights
99
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1010
> copies of the Software, and to permit persons to whom the Software is
1111
> furnished to do so, subject to the following conditions:
12-
>
12+
>
1313
> The above copyright notice and this permission notice shall be included in all
1414
> copies or substantial portions of the Software.
15-
>
15+
>
1616
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1818
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1919
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2020
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2222
> SOFTWARE.
23-
>
23+
>

NEWS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
MathOptInterface (MOI) release notes
22
====================================
33

4+
v0.9.9 (December 29, 2019)
5+
---------------------
6+
7+
- Incorporated MathOptFormat.jl as the FileFormats submodule. FileFormats
8+
provides readers and writers for a number of standard file formats and MOF, a
9+
file format specialized for MOI (#969).
10+
- Improved performance of deletion of vector of variables in
11+
`MOI.Utilities.Model` (#983).
12+
- Updated to MutableArithmetics v0.2 (#981).
13+
- Added `MutableArithmetics.promote_operation` allocation tests (#975).
14+
- Fixed inference issue on Julia v1.1 (#982).
15+
416
v0.9.8 (December 19, 2019)
517
---------------------
618

Project.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
name = "MathOptInterface"
22
uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
3-
version = "0.9.8"
3+
version = "0.9.9"
44

55
[deps]
66
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
7+
CodecBzip2 = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd"
8+
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
9+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
10+
JSONSchema = "7d188eb4-7ad8-530c-ae41-71a32a6d4692"
711
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
812
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
913
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
@@ -13,6 +17,10 @@ Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
1317

1418
[compat]
1519
BenchmarkTools = "0.4"
16-
MutableArithmetics = "0.1.1"
20+
CodecBzip2 = "~0.6"
21+
CodecZlib = "~0.6"
22+
JSON = "~0.21"
23+
JSONSchema = "0.2"
24+
MutableArithmetics = "0.2"
1725
OrderedCollections = "1"
1826
julia = "1"

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
44

55
[compat]
6-
Documenter = "~0.22"
6+
Documenter = "0.24"

docs/make.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ using Documenter, MathOptInterface
22

33
makedocs(
44
sitename = "MathOptInterface",
5-
# See https://github.com/JuliaDocs/Documenter.jl/issues/868
6-
format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true"),
5+
format = Documenter.HTML(
6+
# See https://github.com/JuliaDocs/Documenter.jl/issues/868
7+
prettyurls = get(ENV, "CI", nothing) == "true",
8+
mathengine = Documenter.MathJax()
9+
),
710
# See https://github.com/JuliaOpt/JuMP.jl/issues/1576
811
strict = true,
912
pages = [

docs/src/apimanual.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,63 @@ becomes ``A = [3.0, 4.0]^\top`` as follows:
796796
modify(m, c, MultirowChange(x, [3.0, 4.0]))
797797
```
798798

799+
## File formats
800+
801+
The `FileFormats` module provides functionality for reading and writing MOI models using
802+
[`write_to_file`](@ref) and [`read_from_file`](@ref).
803+
804+
To write a model `src` to a MathOptFormat file, use:
805+
```julia
806+
src = # ...
807+
dest = FileFormats.Model(format = FileFormats.FORMAT_MOF)
808+
MOI.copy_to(dest, src)
809+
MOI.write_to_file(dest, "file.mof.json")
810+
```
811+
The list of supported formats is given by the [`FileFormats.FileFormat`](@ref) enum.
812+
813+
Instead of the `format` keyword, you can also use the `filename` keyword argument to
814+
[`FileFormats.Model`](@ref). This will attempt to automatically guess the format from the
815+
file extension. For example:
816+
```julia
817+
src = # ...
818+
filename = "my_model.cbf.gz"
819+
dest = FileFormats.Model(filename = filename)
820+
MOI.copy_to(dest, src)
821+
MOI.write_to_file(dest, filename)
822+
823+
src_2 = FileFormats.Model(filename = filename)
824+
MOI.read_from_file(src_2, filename)
825+
```
826+
Note how the compression format (GZip) is also automatically detected from the filename.
827+
828+
In some cases `src` may contain constraints that are not supported by the file format (e.g.,
829+
the CBF format supports integer variables but not binary). If so, you should copy `src` to a
830+
bridged model using [`Bridges.full_bridge_optimizer`](@ref):
831+
```julia
832+
src = # ... conic model ...
833+
dest = FileFormats.Model(format = FileFormats.FORMAT_CBF)
834+
bridged = MOI.Bridges.full_bridge_optimizer(dest, Float64)
835+
MOI.copy_to(bridged, src)
836+
MOI.write_to_file(dest, "my_model.cbf")
837+
```
838+
You should also note that even after bridging, it may still not be possible to write the
839+
model to file because of unsupported constraints (e.g., PSD variables in the LP file
840+
format).
841+
842+
In addition to [`write_to_file`](@ref) and [`read_from_file`](@ref), you can read and write
843+
directly from `IO` streams using `Base.write` and `Base.read!`:
844+
```julia
845+
src = # ...
846+
io = IOBuffer()
847+
dest = FileFormats.Model(format = FileFormats.FORMAT_MPS)
848+
MOI.copy_to(dest, src)
849+
write(io, dest)
850+
851+
seekstart(io)
852+
src_2 = FileFormats.Model(format = FileFormats.FORMAT_MPS)
853+
read!(io, src_2)
854+
```
855+
799856
## Advanced
800857

801858
### Duals

docs/src/apireference.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ ConstraintIndex
196196
is_valid
197197
throw_if_not_valid
198198
delete(::ModelLike, ::Index)
199+
delete(::ModelLike, ::Vector{<:Index})
199200
```
200201

201202
### Variables
@@ -963,6 +964,7 @@ The following utilities are available for functions:
963964
Utilities.eval_variables
964965
Utilities.map_indices
965966
Utilities.substitute_variables
967+
Utilities.filter_variables
966968
Utilities.remove_variable
967969
Utilities.all_coefficients
968970
Utilities.unsafe_add
@@ -1019,3 +1021,13 @@ Benchmarks.suite
10191021
Benchmarks.create_baseline
10201022
Benchmarks.compare_against_baseline
10211023
```
1024+
1025+
## File Formats
1026+
1027+
Functions to help read and write MOI models to/from various file formats. See
1028+
[File Formats](@ref) for more details.
1029+
1030+
```@docs
1031+
FileFormats.Model
1032+
FileFormats.FileFormat
1033+
```

src/Bridges/Constraint/set_map.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function bridge_constraint(
44
BT::Type{<:SetMapBridge{T, S2, S1, F, G}}, model::MOI.ModelLike,
55
func::G, set::S1) where {T, S2, S1, F, G}
66
mapped_func = map_function(BT, func)
7-
constraint = MOI.add_constraint(model, map_function(BT, func), map_set(BT, set))
7+
constraint = MOI.add_constraint(model, mapped_func, map_set(BT, set))
88
return BT(constraint)
99
end
1010

0 commit comments

Comments
 (0)