using JuMP
using HiGHS
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
b = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75]
arraySize = length(a)
model = Model(HiGHS.Optimizer)
> @variable(model, quantity[1:arraySize], Int)
> @constraint(model, 0 .<= quantity .<= b .- 1)
> @objective(model, Max, a' * quantity)
> @time begin
optimize!(model)
end
if termination_status(model) == MOI.OPTIMAL
Get the optimal values of x, y, and z
as = value.(quantity)
println(as)
else
println("Optimization failed.")
end
the above code takes 3 seconds to solve equation i want to solve this equation in less than second what can i do please help
This is Julia's compilation latency at work. See https://jump.dev/JuMP.jl/stable/tutorials/getting_started/performance_tips/#The-%22time-to-first-solve%22-issue
If you solve a second model, it takes only a fraction of a second.