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
16 changes: 16 additions & 0 deletions test/Utilities/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,22 @@ function test_index_map()
return
end

function test_copy_names_unsupported()
src = MOI.Utilities.Model{Float64}()
MOI.set(src, MOI.Name(), "Abc")
x = MOI.add_variable(src)
MOI.set(src, MOI.VariableName(), x, "x")
c = MOI.add_constraint(src, 1.0 * x, MOI.LessThan(1.0))
MOI.set(src, MOI.ConstraintName(), c, "c")
dest = MOI.Utilities.MockOptimizer(
MOI.Utilities.Model{Float64}();
supports_names = false,
)
index_map = MOI.copy_to(dest, src)
@test MOI.get(dest, MOI.VariableName(), index_map[x]) == ""
return
end

end # module

TestCopy.runtests()
27 changes: 27 additions & 0 deletions test/Utilities/mockoptimizer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,33 @@ function test_modify_not_allowed()
return
end

function test_get_fallback_constraint_dual()
model = MOI.Utilities.MockOptimizer(MOI.Utilities.Model{Float64}())
x = MOI.add_variables(model, 2)
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
f = MOI.VectorOfVariables(x)
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
c = MOI.add_constraint(model, f, MOI.Nonnegatives(2))
@test_throws(
ErrorException(
"Fallback getter for variable constraint dual does not support objective function of type $(MOI.VectorOfVariables). Please report this issue to the solver wrapper package.",
),
MOI.Utilities.get_fallback(model, MOI.ConstraintDual(), c),
)
return
end

struct SetByOptimizeAttribute <: MOI.AbstractOptimizerAttribute end

MOI.is_set_by_optimize(::SetByOptimizeAttribute) = true

function test_is_set_by_optimize_optimizer_attribute()
model = MOI.Utilities.MockOptimizer(MOI.Utilities.Model{Float64}())
MOI.set(model, SetByOptimizeAttribute(), 1.23)
@test MOI.get(model, SetByOptimizeAttribute()) == 1.23
return
end

end # module

TestMockOptimizer.runtests()
Loading