-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMatrixOptInterface.jl
More file actions
73 lines (63 loc) · 1.7 KB
/
MatrixOptInterface.jl
File metadata and controls
73 lines (63 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Copyright (c) 2019: Joaquim Dias Garcia, and contributors
#
# Use of this source code is governed by an MIT-style license that can be found
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
module MatrixOptInterface
using LinearAlgebra, SparseArrays
using MathOptInterface
const MOI = MathOptInterface
const MOIU = MathOptInterface.Utilities
const CI = MOI.ConstraintIndex
const VI = MOI.VariableIndex
@enum ConstraintSense EQUAL_TO GREATER_THAN LESS_THAN INTERVAL
_sense(::Type{<:MOI.EqualTo}) = EQUAL_TO
_sense(::Type{<:MOI.LessThan}) = LESS_THAN
_sense(::Type{<:MOI.GreaterThan}) = GREATER_THAN
_sense(::Type{<:MOI.Interval}) = INTERVAL
_no_upper(bound) = bound != typemax(bound)
_no_lower(bound) = bound != typemin(bound)
function _bound_sense(lb::T, ub::T) where {T}
if _no_upper(ub)
if _no_lower(lb)
if lb == ub
return EQUAL_TO
else
return INTERVAL
end
else
return LESS_THAN
end
else
if _no_lower(lb)
return GREATER_THAN
else
return
end
end
end
function _bound_set(lb::T, ub::T) where {T}
if _no_upper(ub)
if _no_lower(lb)
if ub == lb
return MOI.EqualTo(lb)
else
return MOI.Interval(lb, ub)
end
else
return MOI.LessThan(ub)
end
else
if _no_lower(lb)
return MOI.GreaterThan(lb)
else
return
end
end
end
@enum VariableType CONTINUOUS INTEGER BINARY
include("sparse_matrix.jl")
include("conic_form.jl")
include("matrix_input.jl")
include("change_form.jl")
include("moi_to_lp.jl")
end