I want to solve a problem with randomly generated bounds using InfiniteOpt. However, if I don’t specify the number of supports for the parameter, I get an error:
If I specify the number of supports, the problem is solved.
The code:
using JuMP, InfiniteOpt, Ipopt, Random
rng = MersenneTwister(0)
Random.seed!(rng, 0)
aR = 0
bR = 1
dR = (bR-aR).*rand(rng,1,2).+ aR
model = InfiniteModel(Ipopt.Optimizer)
@variable(model, x[1:2] >= 0)
# @infinite_parameter(model, z1 in [minimum(dR), maximum(dR)],num_supports = 10) ######Works
@infinite_parameter(model, z1 in [minimum(dR), maximum(dR)]) ######Doesn't work
@objective(model,Max,x[1]+x[2])
@constraint(model,z1*x[1]+1*x[2]<=2.0)
status=optimize!(model)
The same happens if I fix the random bounds:
using JuMP, InfiniteOpt, Ipopt, Random
dRNotRAndom = [0.8236475079774124, 0.9103565379264364] ###obtained above
model = InfiniteModel(Ipopt.Optimizer)
@variable(model, x[1:2] >= 0)
@infinite_parameter(model, z1 in [minimum(dRNotRAndom), maximum(dRNotRAndom)],num_supports = 10) ###Works
# @infinite_parameter(model, z1 in [minimum(dRNotRAndom), maximum(dRNotRAndom)]) ###Doesn't work
@objective(model,Max,x[1]+x[2])
@constraint(model,z1*x[1]+1*x[2]<=2.0)
@show [minimum(dR), maximum(dR)]
status=optimize!(model)
But approximating them works:
using JuMP, InfiniteOpt, Ipopt, Random
dRNotRAndomApp = [0.82364751, 0.91035654] #####Approximated
model = InfiniteModel(Ipopt.Optimizer)
@variable(model, x[1:2] >= 0)
# @infinite_parameter(model, z1 in [minimum(dRNotRAndomApp), maximum(dRNotRAndomApp)],num_supports = 10) ###Works
@infinite_parameter(model, z1 in [minimum(dRNotRAndomApp), maximum(dRNotRAndomApp)]) ###Works
@objective(model,Max,x[1]+x[2])
@constraint(model,z1*x[1]+1*x[2]<=2.0)
@show [minimum(dR), maximum(dR)]
status=optimize!(model)
Not sure if this is a bug or if I am doing sth wrong.