-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Hello, I'm just checking to see whether using @NLconstraints/@NLoptimize is possible in infinite opt? If so, is there an example in any of the documentation? I didn't find any.
The following thread: #16 suggests that it was in the cards at some point, but unsure if it was ever fully developed.
The code I'm trying to write includes the following constraints:
@constraint(m, p == min(p_bar, max(zeros(N), transpose(A)*p + c - x)))
which causes an error presumably because of the use of min/max. The error is: MethodError: no method matching isless(::GenericQuadExpr{Float64,GeneralVariableRef}, ::Float64)
Closest candidates are:
isless(!Matched::Float64, ::Float64) at float.jl:465
isless(!Matched::Missing, ::Any) at missing.jl:87
isless(!Matched::AbstractFloat, ::AbstractFloat) at operators.jl:156
...
The second constraint is:
prob(x,c,w) = 1 ./(1 .+exp.(-1000*(x.*c-w))) # approximates indicator function of x*c>=w
JuMP.register(m, :prob, 3, prob)
for i = 1:N
@NLconstraint(m, delta[i] = prob(x[i],c[i],w[i]))
end
This gives the error: MethodError: no method matching register(::InfiniteModel, ::Symbol, ::Int64, ::typeof(prob)). So I assume there's no ability for users to define functions in constraints.
The other way I try to define this constraints:
for i = 1:N
@NLconstraint(m, delta[i] == 1 ./(1 .+exp.(-1000*(x[i].*c[i]-w[i])))) #ensuring prob x*c >= w = delta
end
This gives the error: MethodError: no method matching _init_NLP(::InfiniteModel)
Thank you,