Skip to content

Commit f8c5071

Browse files
authored
Fix MOI.supports for MOI.ObjectiveFunction (#63)
1 parent cf1f92e commit f8c5071

File tree

9 files changed

+30
-18
lines changed

9 files changed

+30
-18
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ MathOptInterface = "b8f27783-ece8-5eb3-8dc8-9495eed66fee"
1111
Combinatorics = "1"
1212
HiGHS = "1"
1313
Ipopt = "1"
14-
MathOptInterface = "1.13"
14+
MathOptInterface = "1.15"
1515
julia = "1.6"
1616

1717
[extras]

src/MultiObjectiveAlgorithms.jl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,8 @@ mutable struct Optimizer <: MOI.AbstractOptimizer
102102
solve_time::Float64
103103

104104
function Optimizer(optimizer_factory)
105-
inner = MOI.instantiate(
106-
optimizer_factory;
107-
with_bridge_type = Float64,
108-
with_cache_type = Float64,
109-
)
110105
return new(
111-
inner,
106+
MOI.instantiate(optimizer_factory; with_cache_type = Float64),
112107
nothing,
113108
nothing,
114109
SolutionPoint[],
@@ -191,10 +186,13 @@ function MOI.supports(
191186
end
192187

193188
function MOI.supports(
194-
::Optimizer,
195-
::MOI.ObjectiveFunction{<:MOI.AbstractVectorFunction},
196-
)
197-
return true
189+
model::Optimizer,
190+
::MOI.ObjectiveFunction{F},
191+
) where {F<:MOI.AbstractVectorFunction}
192+
G = MOI.Utilities.scalar_type(F)
193+
H = MOI.Utilities.promote_operation(+, Float64, G, G)
194+
return MOI.supports(model.inner, MOI.ObjectiveFunction{G}()) &&
195+
MOI.supports(model.inner, MOI.ObjectiveFunction{H}())
198196
end
199197

200198
const _ATTRIBUTES = Union{

test/algorithms/Chalmet.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ function test_infeasible()
191191
end
192192

193193
function test_vector_of_variables_objective()
194-
model = MOA.Optimizer(HiGHS.Optimizer)
194+
model = MOI.instantiate(; with_bridge_type = Float64) do
195+
return MOA.Optimizer(HiGHS.Optimizer)
196+
end
195197
MOI.set(model, MOA.Algorithm(), MOA.Chalmet())
196198
MOI.set(model, MOI.Silent(), true)
197199
x = MOI.add_variables(model, 2)

test/algorithms/Dichotomy.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,9 @@ function test_quadratic()
393393
end
394394

395395
function test_vector_of_variables_objective()
396-
model = MOA.Optimizer(HiGHS.Optimizer)
396+
model = MOI.instantiate(; with_bridge_type = Float64) do
397+
return MOA.Optimizer(HiGHS.Optimizer)
398+
end
397399
MOI.set(model, MOA.Algorithm(), MOA.Dichotomy())
398400
MOI.set(model, MOI.Silent(), true)
399401
x = MOI.add_variables(model, 2)

test/algorithms/DominguezRios.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,9 @@ function test_time_limit()
584584
end
585585

586586
function test_vector_of_variables_objective()
587-
model = MOA.Optimizer(HiGHS.Optimizer)
587+
model = MOI.instantiate(; with_bridge_type = Float64) do
588+
return MOA.Optimizer(HiGHS.Optimizer)
589+
end
588590
MOI.set(model, MOA.Algorithm(), MOA.DominguezRios())
589591
MOI.set(model, MOI.Silent(), true)
590592
x = MOI.add_variables(model, 2)

test/algorithms/EpsilonConstraint.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,9 @@ function test_time_limit_large()
418418
end
419419

420420
function test_vector_of_variables_objective()
421-
model = MOA.Optimizer(HiGHS.Optimizer)
421+
model = MOI.instantiate(; with_bridge_type = Float64) do
422+
return MOA.Optimizer(HiGHS.Optimizer)
423+
end
422424
MOI.set(model, MOA.Algorithm(), MOA.EpsilonConstraint())
423425
MOI.set(model, MOI.Silent(), true)
424426
x = MOI.add_variables(model, 2)

test/algorithms/Hierarchical.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ function test_unbounded()
108108
end
109109

110110
function test_vector_of_variables_objective()
111-
model = MOA.Optimizer(HiGHS.Optimizer)
111+
model = MOI.instantiate(; with_bridge_type = Float64) do
112+
return MOA.Optimizer(HiGHS.Optimizer)
113+
end
112114
MOI.set(model, MOA.Algorithm(), MOA.Hierarchical())
113115
MOI.set(model, MOI.Silent(), true)
114116
x = MOI.add_variables(model, 2)

test/algorithms/KirlikSayin.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,9 @@ function test_time_limit()
587587
end
588588

589589
function test_vector_of_variables_objective()
590-
model = MOA.Optimizer(HiGHS.Optimizer)
590+
model = MOI.instantiate(; with_bridge_type = Float64) do
591+
return MOA.Optimizer(HiGHS.Optimizer)
592+
end
591593
MOI.set(model, MOA.Algorithm(), MOA.KirlikSayin())
592594
MOI.set(model, MOI.Silent(), true)
593595
x = MOI.add_variables(model, 2)

test/algorithms/Lexicographic.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ function test_unbounded()
151151
end
152152

153153
function test_vector_of_variables_objective()
154-
model = MOA.Optimizer(HiGHS.Optimizer)
154+
model = MOI.instantiate(; with_bridge_type = Float64) do
155+
return MOA.Optimizer(HiGHS.Optimizer)
156+
end
155157
MOI.set(model, MOA.Algorithm(), MOA.Lexicographic())
156158
MOI.set(model, MOI.Silent(), true)
157159
x = MOI.add_variables(model, 2)

0 commit comments

Comments
 (0)