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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
*.jl.mem
docs/build/
docs/site/
Manifest.toml
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ os:
- linux
# - osx
julia:
- 0.6
- 0.7
- 1.0
- 1.1
Expand All @@ -23,15 +22,14 @@ notifications:
on_start: never # options: [always|never|change] default: always

after_success:
- julia -e 'if VERSION < v"0.7-"; cd(Pkg.dir("MathOptInterface")); else; import Pkg; end; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
- julia -e 'import Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'

jobs:
include:
- stage: "Documentation"
julia: 1.0
os: linux
script:
- julia --project=docs/ -e 'using Pkg; Pkg.instantiate();
Pkg.develop(PackageSpec(path=pwd()))'
- julia --project=docs/ -e 'import Pkg; Pkg.instantiate(); Pkg.develop(Pkg.PackageSpec(path=pwd()))'
- julia --project=docs/ docs/make.jl
after_success: skip
16 changes: 16 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name = "MathOptInterface"
uuid = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
authors = ["JuliaOpt"]
version = "0.9.0"

[deps]
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
3 changes: 1 addition & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
julia 0.6
Compat 0.68
julia 0.7
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
environment:
matrix:
# - julia_version: 0.6 # Disabled to speed up CI, Julia v0.6 and v0.7 are still
# - julia_version: 0.7 # tested on Linux with Travis
- julia_version: 1.0

Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"

[compat]
Documenter = "~0.21"
2 changes: 0 additions & 2 deletions src/Bridges/Bridges.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module Bridges

using Compat

using MathOptInterface
const MOI = MathOptInterface
const MOIU = MOI.Utilities
Expand Down
6 changes: 3 additions & 3 deletions src/Bridges/intervalbridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ function MOI.get(model::MOI.ModelLike, ::MOI.ConstraintBasisStatus, c::SplitInte
lower_stat = MOI.get(model, MOI.ConstraintBasisStatus(), c.lower)
upper_stat = MOI.get(model, MOI.ConstraintBasisStatus(), c.upper)
if lower_stat == MOI.NONBASIC_AT_LOWER
Compat.@warn("GreaterThan constraints should not have basis status:" *
@warn("GreaterThan constraints should not have basis status:" *
" NONBASIC_AT_LOWER, instead use NONBASIC.")
end
if upper_stat == MOI.NONBASIC_AT_UPPER
Compat.@warn("LessThan constraints should not have basis status:" *
@warn("LessThan constraints should not have basis status:" *
" NONBASIC_AT_UPPER, instead use NONBASIC.")
end
if lower_stat == MOI.NONBASIC
Expand All @@ -66,7 +66,7 @@ function MOI.get(model::MOI.ModelLike, ::MOI.ConstraintBasisStatus, c::SplitInte
return MOI.NONBASIC_AT_UPPER
end
if lower_stat != upper_stat
Compat.@warn("Basis status of lower (`$lower_stat`) and upper (`$upper_stat`) constraint are inconsistent," *
@warn("Basis status of lower (`$lower_stat`) and upper (`$upper_stat`) constraint are inconsistent," *
" both should be basic or super basic.")
end
return lower_stat
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/lazybridgeoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function update_dist!(b::LazyBridgeOptimizer, constraints)
for (F, S) in constraints
if MOI.supports_constraint(BT, F, S) && all(C -> supports_constraint_no_update(b, C[1], C[2]), added_constraint_types(BT, F, S))
# Number of bridges needed using BT
dist = 1 + Compat.mapreduce(
dist = 1 + mapreduce(
C -> _dist(b, C[1], C[2]), +,
added_constraint_types(BT, F, S), init = 0)
# Is it better that what can currently be done ?
Expand Down
13 changes: 4 additions & 9 deletions src/Bridges/quadtosocbridge.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Compat.LinearAlgebra, Compat.SparseArrays
using LinearAlgebra, SparseArrays

"""
QuadtoSOCBridge{T}
Expand Down Expand Up @@ -70,17 +70,12 @@ function QuadtoSOCBridge{T}(model, func::MOI.ScalarQuadraticFunction{T},
end
Q, index_to_variable_map = matrix_from_quadratic_terms(func.quadratic_terms)
if !less_than
Compat.rmul!(Q, -1)
rmul!(Q, -1)
end
# We have L × L' ≈ Q[p, p]
L, p = try
@static if VERSION >= v"0.7-"
F = cholesky(Symmetric(Q))
sparse(F.L), F.p
else
F = cholfact(Symmetric(Q))
sparse(F[:L]), F[:p]
end
F = cholesky(Symmetric(Q))
sparse(F.L), F.p
catch err
if err isa PosDefException
error("The optimizer supports second-order cone constraints and",
Expand Down
2 changes: 1 addition & 1 deletion src/Bridges/squarepsdbridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function SquarePSDBridge{T, F, G}(model::MOI.ModelLike, f::F,
# functions at entries (i, j) and (j, i) are almost identical
if !MOIU.isapprox_zero(diff, 1e-10)
if MOIU.isapprox_zero(diff, 1e-8)
Compat.@warn "The entries ($i, $j) and ($j, $i) of the" *
@warn "The entries ($i, $j) and ($j, $i) of the" *
" positive semidefinite constraint are almost" *
" identical but a constraint is added to ensure their" *
" equality because the largest difference between the" *
Expand Down
11 changes: 5 additions & 6 deletions src/MathOptInterface.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
VERSION < v"0.7.0-beta2.199" && __precompile__()
module MathOptInterface

"""
Expand All @@ -8,11 +7,11 @@ Abstract supertype for objects that implement the "Model" interface for defining
an optimization problem.
"""
abstract type ModelLike end
@static if VERSION >= v"0.7-"
# This allows to use `ModelLike`s in broadcast calls without the need to
# embed it in a `Ref`
Base.broadcastable(model::ModelLike) = Ref(model)
end

# This allows to use `ModelLike`s in broadcast calls without the need to
# embed it in a `Ref`
Base.broadcastable(model::ModelLike) = Ref(model)


"""
AbstractOptimizer
Expand Down
3 changes: 1 addition & 2 deletions src/Test/Test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ using MathOptInterface
const MOI = MathOptInterface
const MOIU = MOI.Utilities

using Compat
using Compat.Test
using Test

include("config.jl")

Expand Down
2 changes: 1 addition & 1 deletion src/Test/contconic.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Continuous conic problems
using Compat.LinearAlgebra # for dot
using LinearAlgebra # for dot

function _lin1test(model::MOI.ModelLike, config::TestConfig, vecofvars::Bool)
atol = config.atol
Expand Down
32 changes: 8 additions & 24 deletions src/Test/modellike.jl
Original file line number Diff line number Diff line change
Expand Up @@ -391,33 +391,17 @@ function scalar_function_constant_not_zero(model::MOI.ModelLike)
@testset "Constraint with nonzero function constant" begin
err = MOI.ScalarFunctionConstantNotZero{Float64,
MOI.ScalarAffineFunction{Float64}, MOI.EqualTo{Float64}}(1.0)
if VERSION < v"0.7-"
@test_throws typeof(err) begin
MOI.add_constraint(model,
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{Float64}[], 1.0),
MOI.EqualTo(2.0))
end
else
@test_throws err begin
MOI.add_constraint(model,
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{Float64}[], 1.0),
MOI.EqualTo(2.0))
end
@test_throws err begin
MOI.add_constraint(model,
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{Float64}[], 1.0),
MOI.EqualTo(2.0))
end
err = MOI.ScalarFunctionConstantNotZero{Float64,
MOI.ScalarAffineFunction{Float64}, MOI.GreaterThan{Float64}}(2.0)
if VERSION < v"0.7-"
@test_throws typeof(err) begin
MOI.add_constraint(model,
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{Float64}[], 2.0),
MOI.GreaterThan(1.0))
end
else
@test_throws err begin
MOI.add_constraint(model,
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{Float64}[], 2.0),
MOI.GreaterThan(1.0))
end
@test_throws err begin
MOI.add_constraint(model,
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm{Float64}[], 2.0),
MOI.GreaterThan(1.0))
end
end
end
3 changes: 1 addition & 2 deletions src/Utilities/Utilities.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Utilities

using Compat # For firstindex, lastindex, Nothing and `@warn`
using Compat.LinearAlgebra # For dot
using LinearAlgebra # For dot

using MathOptInterface
const MOI = MathOptInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function _pass_attributes(dest::MOI.ModelLike, src::MOI.ModelLike,
# As starting values are simply *hints* for the optimization, not
# supporting them gives a warning, not an error
if !MOI.supports(dest, attr, supports_args...)
Compat.@warn("$attr is not supported by $(typeof(dest)). This ",
@warn("$attr is not supported by $(typeof(dest)). This ",
"information will be discarded.")
continue
end
Expand Down
38 changes: 12 additions & 26 deletions src/Utilities/functions.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Compat
using Compat.Test
using Test

"""
evalvariables(varval::Function, f::AbstractFunction)
Expand All @@ -10,11 +9,7 @@ function evalvariables end
evalvariables(varval::Function, f::SVF) = varval(f.variable)
evalvariables(varval::Function, f::VVF) = varval.(f.variables)
function evalvariables(varval::Function, f::SAF)
@static if VERSION >= v"0.7-"
return mapreduce(t->evalterm(varval, t), +, f.terms, init=f.constant)
else
return mapreduce(t->evalterm(varval, t), +, f.constant, f.terms)
end
return mapreduce(t->evalterm(varval, t), +, f.terms, init=f.constant)
end
function evalvariables(varval::Function, f::VAF)
out = copy(f.constants)
Expand All @@ -25,13 +20,8 @@ function evalvariables(varval::Function, f::VAF)
end
function evalvariables(varval::Function, f::SQF)
init = zero(f.constant)
@static if VERSION >= v"0.7-"
lin = mapreduce(t->evalterm(varval, t), +, f.affine_terms, init=init)
quad = mapreduce(t->evalterm(varval, t), +, f.quadratic_terms, init=init)
else
lin = mapreduce(t->evalterm(varval, t), +, init, f.affine_terms)
quad = mapreduce(t->evalterm(varval, t), +, init, f.quadratic_terms)
end
lin = mapreduce(t->evalterm(varval, t), +, f.affine_terms, init=init)
quad = mapreduce(t->evalterm(varval, t), +, f.quadratic_terms, init=init)
return lin + quad + f.constant
end
function evalvariables(varval::Function, f::VQF)
Expand Down Expand Up @@ -113,26 +103,22 @@ struct ScalarFunctionIterator{F<:MOI.AbstractVectorFunction}
f::F
end
eachscalar(f::MOI.AbstractVectorFunction) = ScalarFunctionIterator(f)
@static if VERSION >= v"0.7-"
function Base.iterate(it::ScalarFunctionIterator, state = 1)
if state > length(it)
return nothing
else
return (it[state], state + 1)
end

function Base.iterate(it::ScalarFunctionIterator, state = 1)
if state > length(it)
return nothing
else
return (it[state], state + 1)
end
else
Base.start(it::ScalarFunctionIterator) = 1
Base.done(it::ScalarFunctionIterator, state) = state > length(it)
Base.next(it::ScalarFunctionIterator, state) = (it[state], state+1)
end

function Base.length(it::ScalarFunctionIterator{<:MOI.AbstractVectorFunction})
return MOI.output_dimension(it.f)
end
Base.eltype(it::ScalarFunctionIterator{VVF}) = SVF
Base.eltype(it::ScalarFunctionIterator{VAF{T}}) where T = SAF{T}
Base.eltype(it::ScalarFunctionIterator{VQF{T}}) where T = SQF{T}
Compat.lastindex(it::ScalarFunctionIterator) = length(it)
Base.lastindex(it::ScalarFunctionIterator) = length(it)

# Define getindex for Vector functions

Expand Down
5 changes: 2 additions & 3 deletions src/Utilities/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,8 @@ function _typedfun(s::SymbolFun)
end

# Base.lowercase is moved to Unicode.lowercase in Julia v0.7
if VERSION >= v"0.7.0-DEV.2813"
using Unicode
end
using Unicode

_field(s::SymbolFS) = Symbol(replace(lowercase(string(s.s)), "." => "_"))

_getC(s::SymbolSet) = :(ConstraintEntry{F, $(_typedset(s))})
Expand Down
Loading