Start value Gurobi error

I am a casual/academic user of optimization with Julia/JuMP, and I noticed there is the possibility to include initial solution setting the function set_start_value, but I just want to set initially some variables of my whole model. I use Gurobi with solver, and the bellow code is the part that I added the start values:

for i in 1:n
    for j in 1:m
        set_start_value(X[i,j], XFITSP[i,j])
        set_start_value(Y[i,j], YFITSP[i,j])
    end
end

tempo = time()
status = optimize!(modelo)
tempo = time() - tempo

My model has 3 group of variables: X, Y and W. If I listed only two groups, it returned this error:

Academic license - for non-commercial use only
Academic license - for non-commercial use only
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
Warning, invalid warm-start basis discarded
ERROR: LoadError: MathOptInterface.SetAttributeNotAllowed{MathOptInterface.VariablePrimalStart}: Setting attribute MathOptInterface.VariablePrimalStart() cannot be performed. You may want to use a CachingOptimizer in AUTOMATIC mode or you may need to call reset_optimizer before doing this operation if the CachingOptimizer is in MANUAL mode.
Stacktrace:
[1] #throw_set_error_fallback#13(::MathOptInterface.SetAttributeNotAllowed{MathOptInterface.VariablePrimalStart}, ::Function, ::Gurobi.Optimizer, ::MathOptInterface.VariablePrimalStart, ::MathOptInterface.VariableIndex, ::Nothing) at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\attributes.jl:318
[2] throw_set_error_fallback(::Gurobi.Optimizer, ::MathOptInterface.VariablePrimalStart, ::MathOptInterface.VariableIndex, ::Nothing) at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\attributes.jl:317
[3] set(::Gurobi.Optimizer, ::MathOptInterface.VariablePrimalStart, ::MathOptInterface.VariableIndex, ::Nothing) at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\attributes.jl:295
[4] _broadcast_getindex_evalf at .\broadcast.jl:578 [inlined]
[5] _broadcast_getindex at .\broadcast.jl:551 [inlined]
[6] getindex at .\broadcast.jl:511 [inlined]
[7] macro expansion at .\broadcast.jl:843 [inlined]
[8] macro expansion at .\simdloop.jl:73 [inlined]
[9] copyto! at .\broadcast.jl:842 [inlined]
[10] copyto! at .\broadcast.jl:797 [inlined]
[11] copy at .\broadcast.jl:773 [inlined]
[12] materialize at .\broadcast.jl:753 [inlined]
[13] set(::Gurobi.Optimizer, ::MathOptInterface.VariablePrimalStart, ::Array{MathOptInterface.VariableIndex,1}, ::Array{Union{Nothing, Float64},1}) at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\attributes.jl:291
[14] set(::MathOptInterface.Bridges.LazyBridgeOptimizer{Gurobi.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.VariablePrimalStart, ::Array{MathOptInterface.VariableIndex,1}, ::Array{Union{Nothing, Float64},1}) at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\Bridges\bridgeoptimizer.jl:222
[15] _pass_attributes(::MathOptInterface.Bridges.LazyBridgeOptimizer{Gurobi.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Array{MathOptInterface.AbstractVariableAttribute,1}, ::Tuple{DataType}, ::Tuple{Array{MathOptInterface.VariableIndex,1}}, ::Tuple{Array{MathOptInterface.VariableIndex,1}}, ::typeof(MathOptInterface.set)) at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\Utilities\copy.jl:141
[16] pass_attributes at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\Utilities\copy.jl:111 [inlined]
[17] pass_attributes at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\Utilities\copy.jl:109 [inlined]
[18] default_copy_to(::MathOptInterface.Bridges.LazyBridgeOptimizer{Gurobi.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}, ::Bool) at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\Utilities\copy.jl:192
[19] #automatic_copy_to#61 at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\Utilities\copy.jl:15 [inlined]
[20] #automatic_copy_to at .\none:0 [inlined]
[21] #copy_to#1 at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\Bridges\bridgeoptimizer.jl:91 [inlined]
[22] (::getfield(MathOptInterface, Symbol("#kw##copy_to")))(::NamedTuple{(:copy_names,),Tuple{Bool}}, ::typeof(MathOptInterface.copy_to), ::MathOptInterface.Bridges.LazyBridgeOptimizer{Gurobi.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Bridges.AllBridgedConstraints{Float64}}}, ::MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}) at .\none:0
[23] attach_optimizer(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}}) at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\Utilities\cachingoptimizer.jl:130
[24] optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{JuMP._MOIModel{Float64}}}) at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\MathOptInterface\C3lip\src\Utilities\cachingoptimizer.jl:166
[25] #optimize!#79(::Bool, ::Bool, ::Function, ::Model, ::Nothing) at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\JuMP\ibcEh\src\optimizer_interface.jl:132
[26] optimize! at C:\Users\Miguel.juliapro\JuliaPro_v1.1.1.1\packages\JuMP\ibcEh\src\optimizer_interface.jl:105 [inlined] (repeats 2 times)
[27] top-level scope at none:0
in expression starting at C:\Users\Miguel\Documents\model.jl:110

If I include the third group of variable W, it didn’t return any error, just the warning “Warning, invalid warm-start basis discarded” and the solution without any initial solution. I already read the topic Warning, invalid warm-start basis discarded , but I didn’t understand how i can fix this situation. Furthermore, i have a friend with a similar code that tested in his computer and had suscess

I doing correctly?

Some extra information would be good.

  1. Which are the versions of Julia and the JuMP.jl and Gurobi.jl packages, what version of Gurobi are you using (not the Julia Package, the solver itself)? You can do ] status (or import Pkg; Pkg.status()) inside the Julia REPL to get it. If you use a project (i.e., are running the code in a folder with Project.toml and Manifest.toml), you need to Pkg.activate("folder_path") first.
  2. Can you post a complete code that can be run to reproduce the problem?

If the code worked for your friend and not for you, then the problem is probably the versions you are using. If possible ask your friend the questions in (1) too.

Of course,

The versions you request:
[2e9cd046] Gurobi v0.6.0 (I downloaded Gurobi 8.1.1 if you need know too)
[4076af6c] JuMP v0.19.2

The reduced code (with only 2 groups of variable):

using JuMP, Gurobi

modelo = Model(with_optimizer(Gurobi.Optimizer))

linha=size(C,1)
coluna=size(C,2)
n=linha
m=coluna


for i in 1:n
 for j in 1:m
    if i==j
     C[i,j]=10^6
    end
  end
end


@variable(modelo, X[1:n,1:m], Bin)
@variable(modelo, G[1:n,1:m]>=0)



function Caixeiro(C, X)
    SomaObj = 0
    for i in 1:n
        for j in 1:m
           if i!=j
               SomaObj = SomaObj + C[i,j]*X[i,j]
           end

        end
    end
    return SomaObj
end



@objective(modelo, Min, Caixeiro(C,X))

@constraint(modelo, con[i = 1:n], sum(X[i,j] for j in 1:m)-X[i,i]==1)
@constraint(modelo, con2[j = 1:m], sum(X[i,j] for i in 1:n)-X[j,j]==1)



for i in 2:n
    @constraint(modelo, sum(G[j,i] for j in 1:n)-sum(G[i,j] for j in 2:n)==1)
end

for i in 1:n
    for j in 2:n
        if i != j
            @constraint(modelo, G[i,j]>=0)
            @constraint(modelo, G[i,j]<=(n-1)*X[i,j])
        end
    end
end


for i in 1:n
    for j in 1:m
        set_start_value(X[i,j], XFITSP[i,j])
        set_start_value(G[i,j], 0)
    end
end

tempo = time()
status = optimize!(modelo)
tempo = time() - tempo

This code return any error, only the warning and without any initial solution, if I exclude

set_start_value(G[i,j], 0)

It returns the same error I quote before

1 Like

Please update to the latest versions: JuMP 0.21 and Gurobi.jl 0.8. This bug has been fixed.

1 Like

Nice, sorry for be so layman in this topic but how can i update?

Cause i did Pkg.update()/Pkg;update(“Gurobi”)/Pkg;update(“JuMP”) and the versions are always the same, returning this to Gurobi update:

julia> Pkg.update(“Gurobi”)
Updating registry at C:\Users\Miguel\.juliapro\JuliaPro_v1.1.1.1\registries\JuliaPro
Updating git-repo https://pkg.juliacomputing.com//registry/JuliaPro
Resolving package versions…
Updating C:\Users\Miguel\.juliapro\JuliaPro_v1.1.1.1\environments\v1.1\Project.toml
[no changes]
Updating C:\Users\Miguel\.juliapro\JuliaPro_v1.1.1.1\environments\v1.1\Manifest.toml
[no changes]

and this to JuMP update:

julia> Pkg.update(“JuMP”)
Updating registry at C:\Users\Miguel\.juliapro\JuliaPro_v1.1.1.1\registries\JuliaPro
Updating git-repo https://pkg.juliacomputing.com//registry/JuliaPro
Resolving package versions…
Updating C:\Users\Miguel\.juliapro\JuliaPro_v1.1.1.1\environments\v1.1\Project.toml
[no changes]
Updating C:\Users\Miguel\.juliapro\JuliaPro_v1.1.1.1\environments\v1.1\Manifest.toml
[no changes]

1 Like

Don’t use JuliaPro. It uses a different registry which means you don’t get access to the latest fixes. Just install the regular version of Julia.

1 Like

Ok, thanks so much!

1 Like