function solution()
model = Model(Gurobi.Optimizer);set_silent(model)
@variable(model,x[1:3000,1:125],Bin)
@constraint(model,[i=1:3000],sum(x[i,:]) == 5)
@constraint(model,[i=1:125],sum(x[:,i]) == 120)
@NLobjective(model,Min,std(sum(x[:,i] .* x[:,j]) for i in 1:125 for j in (i+1):125))
# println(model)
optimize!(model)
value.(x)
end
Here I wanna minimize the std value ,but I don’t know how to code it correctly.Can someone help me fix it ?
Which version of JuMP are you using? I think starting with 1.15 nonlinear modeling like the kind you’re doing has become much easier: JuMP 1.15.0 is released | JuMP
It’s a problem from the Math Modeling Competition,as you said it has a large number of bilinear terms,so I use the Genetic Algorithm to solve it finally.
No, but the binary variables rule out solvers like Ipopt, and the number of bilinear terms in the expression is very large, so a naive call to Statistics.std didn’t even finish building when I tried to run it.