/
dummy.jl
56 lines (47 loc) · 1.51 KB
/
dummy.jl
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
# Copyright (c) 2017: Miles Lubin and contributors
# Copyright (c) 2017: Google Inc.
#
# 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.
import MathOptInterface as MOI
import MathOptInterface.Utilities as MOIU
abstract type AbstractDummyModel <: MOI.ModelLike end
function MOI.empty!(::AbstractDummyModel) end
function MOI.copy_to(dest::AbstractDummyModel, src::MOI.ModelLike)
return MOIU.default_copy_to(dest, src)
end
MOI.supports_incremental_interface(::AbstractDummyModel) = true
MOI.supports(::AbstractDummyModel, ::MOI.ObjectiveSense) = true
function MOI.supports(
::AbstractDummyModel,
::MOI.ConstraintPrimalStart,
::Type{<:MOI.ConstraintIndex},
)
return true
end
function MOI.supports_constraint(
::AbstractDummyModel,
::Type{MOI.VariableIndex},
::Type{MOI.EqualTo{Float64}},
)
return true
end
function MOI.supports_constraint(
::AbstractDummyModel,
::Type{MOI.VectorOfVariables},
::Type{MOI.Zeros},
)
return true
end
struct DummyModel <: AbstractDummyModel end
# Implements add_variable and add_constraint
struct DummyModelWithAdd <: AbstractDummyModel end
MOI.add_variable(::DummyModelWithAdd) = MOI.VariableIndex(0)
MOI.add_variables(::DummyModelWithAdd, n) = fill(MOI.VariableIndex(0), n)
function MOI.add_constraint(
::DummyModelWithAdd,
::MOI.VariableIndex,
::MOI.EqualTo{Float64},
)
return MOI.ConstraintIndex{MOI.VariableIndex,MOI.EqualTo{Float64}}(0)
end