Jump Xpress - Problem with "MAXTIME" parameter

Hello,

When I set the parameter “MAXTIME” for a optimization problem in JUMP with the XPress solver, I have the error “DimensionMismatch(“array could not be broadcast to match destination”)”. However, in the output file I see that the solver found a solution and when I solve the problem without the “MAXTIME” it works fine.

Does somebody know how to fix that?

Thank you in advance,
TM

Could you provide a short code sample reproducing the error?

1 Like

Hello,

@blegat, here is an example.

Without the “MAXTIME”, the problem finds a solution in 18sec. If I set the “MAXTIME”, I obtain the error described above.

using Xpress
using JuMP
using Random
m = Model(()->Xpress.Optimizer(DEFAULTALG=2, PRESOLVE=0, logfile = "zz.log"))
set_optimizer_attribute(m,"MAXTIME", 10)
N = 100
n_on = 10
Node = zeros(N)
for i in N
    Node[i] = i
end
X_node_o = randcycle(MersenneTwister(1234),N)
Y_node_o = randcycle(MersenneTwister(0234),N)
X_node_on = randcycle(MersenneTwister(1234),n_on)
Y_node_on = randcycle(MersenneTwister(0234),n_on)
@variable(m, 0<=P_node[1:N]<=3)
P_on = ones(n_on)*10
N_lines = factorial(big(N))/(2*factorial(big(N-2)))+N*n_on
L = zeros(trunc(Int,N_lines))
I = zeros(Int8,N+n_on,trunc(Int,N_lines))
@variable(m, y[1:trunc(Int,N_lines)])
@variable(m, cap[1:trunc(Int,N_lines)])
@variable(m, b[1:trunc(Int,N_lines)], Int)
l = 1
for i in 1:N
    for j in i+1:N
        I[i,l] = 1
        I[j,l] = -1
        L[l] = (X_node_o[i]-X_node_o[j])^2+(Y_node_o[i]-Y_node_o[j])^2
        global l+=1
    end
    for k in 1:n_on
        I[i,l] = 1
        I[N+k,l] = -1
        L[l] = (X_node_o[i]-X_node_on[k])^2+(Y_node_o[i]-Y_node_on[k])^2
        global l+=1
    end
end
for n in 1:N
    @constraint(m, I[n,:]'*y==P_node[n])
end
for n in 1:n_on
    @constraint(m, I[N+n,:]'*y+P_on[n]==0)
end
for l in 1:trunc(Int, N_lines)
    @constraint(m, cap[l]>= y[l])
    @constraint(m, cap[l]>= -y[l])
    @constraint(m, cap[l]<= b[l]*10)
end
C = 0
for i in 1:trunc(Int, N_lines)
    global C += b[i]*L[i] + L[i]*cap[i]
end
@objective(m, Min, C)
optimize!(m)

Thank you in advance,
KR,
TM

I don’t have Xpress installed, could you provide the complete error and at which line in your script it occurs?

@mbesancon, here is the error I obtain.

LoadError: DimensionMismatch("array could not be broadcast to match destination")
Stacktrace:
 [1] check_broadcast_shape at .\broadcast.jl:509 [inlined]
 [2] check_broadcast_axes at .\broadcast.jl:512 [inlined]
 [3] check_broadcast_axes at .\broadcast.jl:515 [inlined]
 [4] instantiate at .\broadcast.jl:259 [inlined]
 [5] materialize! at .\broadcast.jl:823 [inlined]
 [6] optimize!(::Xpress.Optimizer) at C:\Users\NM5788\.juliapro\JuliaPro_v1.4.2-1\packages\Xpress\kcAft\src\MOI\MOI_wrapper.jl:2156
 [7] optimize!(::MathOptInterface.Bridges.LazyBridgeOptimizer{Xpress.Optimizer}) at C:\Users\NM5788\.juliapro\JuliaPro_v1.4.2-1\packages\MathOptInterface\bygN7\src\Bridges\bridge_optimizer.jl:239
 [8] optimize!(::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at C:\Users\NM5788\.juliapro\JuliaPro_v1.4.2-1\packages\MathOptInterface\bygN7\src\Utilities\cachingoptimizer.jl:189
 [9] optimize!(::Model, ::Nothing; bridge_constraints::Bool, ignore_optimize_hook::Bool, kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\NM5788\.juliapro\JuliaPro_v1.4.2-1\packages\JuMP\YXK4e\src\optimizer_interface.jl:131
 [10] optimize! at C:\Users\NM5788\.juliapro\JuliaPro_v1.4.2-1\packages\JuMP\YXK4e\src\optimizer_interface.jl:107 [inlined] (repeats 2 times)
 [11] top-level scope at \\pegase009\D\users\NM5788\PROMOTION\Test_MAXTIME.jl:55
in expression starting at \\pegase009\D\users\NM5788\PROMOTION\Test_MAXTIME.jl:55

Line 55 is the line

optimize!(m)

KR,
TM

This seems to be a bug. I opened an issue: https://github.com/jump-dev/Xpress.jl/issues/91

2 Likes

You might try making the MAXTIME parameter negative. I don’t have an Xpress license right now either, but I remember having to pass a negative time (in seconds) to get things working in this piece of code.

@JosiahPohl, I tried the same code as above with a MAXTIME of -10, but I have the same error.

Could you try changing this:

m = Model(()->Xpress.Optimizer(DEFAULTALG=2, PRESOLVE=0, logfile = "zz.log"))
set_optimizer_attribute(m,"MAXTIME", -10)

to

m = Model(()->Xpress.Optimizer(MAXTIME=-10, DEFAULTALG=2, PRESOLVE=0, logfile = "zz.log"))

Once again only saying so because it worked in our implementation. The problem might be with the set_optimizer_attribute function and this could be a good temporary work around if you don’t need to set it separately.

@JosiahPohl I tried this formulation as well, with 10 and -10 and I have the same error.

Thank you for your advice even though.

1 Like

Just wanted to make sure you saw that this issue has been addressed by @odow here. Hope that helps!

1 Like