From be9aeba6d7827bb8d46436b7ed37d609909b427b Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Tue, 25 Apr 2023 13:50:00 +1200 Subject: [PATCH] Change SetVariableNames to default false (#216) --- src/MOI_wrapper/MOI_wrapper.jl | 9 +++++---- test/MOI_wrapper.jl | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/MOI_wrapper/MOI_wrapper.jl b/src/MOI_wrapper/MOI_wrapper.jl index 399b021..cb2af0a 100644 --- a/src/MOI_wrapper/MOI_wrapper.jl +++ b/src/MOI_wrapper/MOI_wrapper.jl @@ -53,12 +53,13 @@ Create a new Cbc Optimizer. ## Variable names -By default, Cbc.jl will pass variable names to the C model. In some instances, -this has caused segfaults. Disable names being passed to the C model using +By default, Cbc.jl will not pass variable names to the C model because, in some +instances, this has caused segfaults. Enable names being passed to the C model +using: ```julia using JuMP, Cbc model = Model( - optimizer_with_attributes(Cbc.Optimizer, Cbc.SetVariableNames() => false), + optimizer_with_attributes(Cbc.Optimizer, Cbc.SetVariableNames() => true), ) ``` """ @@ -88,7 +89,7 @@ mutable struct Optimizer <: MOI.AbstractOptimizer false, nothing, nothing, - true, + false, ) finalizer(Cbc_deleteModel, model) return model diff --git a/test/MOI_wrapper.jl b/test/MOI_wrapper.jl index be851b2..c2379f8 100644 --- a/test/MOI_wrapper.jl +++ b/test/MOI_wrapper.jl @@ -436,6 +436,7 @@ function test_variable_name() x = MOI.add_variable(model) MOI.set(model, MOI.VariableName(), x, name) cbc = Cbc.Optimizer() + MOI.set(cbc, Cbc.SetVariableNames(), true) index_map = MOI.copy_to(cbc, model) @test MOI.get(cbc, MOI.VariableName(), index_map[x]) == inner end @@ -451,6 +452,8 @@ function test_segfault() MOI.read_from_file(src, joinpath(@__DIR__, "segfault.mof.json")) cbc = Cbc.Optimizer() @test MOI.supports(cbc, Cbc.SetVariableNames()) + @test MOI.get(cbc, Cbc.SetVariableNames()) == false + MOI.set(cbc, Cbc.SetVariableNames(), true) @test MOI.get(cbc, Cbc.SetVariableNames()) == true MOI.set(cbc, Cbc.SetVariableNames(), false) @test MOI.get(cbc, Cbc.SetVariableNames()) == false