You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import MathOptInterface, CDDLib
const MOI = MathOptInterface
functionpowers(degree::Int, x::F) where {F <:Real}
local ret = F[1for _ in0:degree]
for i in1:degree
ret[i +1] = x * ret[i]
end
ret
endsets(pts::Vector{Tuple{F, F}}) where {F <:Real} =map(p -> MOI.GreaterThan(p[2]), pts)
saf(cs::Vector{F}, vars::T) where {F <:Real, T <:Any} =
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(cs, vars), zero(F))
safs(degree::Int, pts::Vector{Tuple{F, F}}, vars::T) where {F <:Real, T <:Any} =map(p ->saf(powers(degree, p[1]), vars), pts)
constrain(lp::Opt, degree::Int, pts::Vector{Tuple{F, F}}) where
{Opt <:MOI.AbstractOptimizer, F <:Real} =
MOI.add_constraints(lp,
safs(degree, pts, MOI.add_variables(lp, degree +1)),
sets(pts))
constrain(::Type{F}) where {F <:Real} =constrain(CDDLib.Optimizer{F}(), 5, Tuple{F, F}[(0, 1//2), (1, 7//3)])
With this example code constrain(Float64) and constrain(Rational{BigInt}) both lead to MOI errors about the model not supporting the constraint:
MathOptInterface.UnsupportedConstraint{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.GreaterThan{Float64}}: `MathOptInterface.ScalarAffineFunction{Float64}`-in-`MathOptInterface.GreaterThan{Float64}` constraint is not supported by the model.
Using Interval instead of GreaterThan results in a similar error, but LessThan seems to work. Not sure whether this is intended behavior.
The text was updated successfully, but these errors were encountered:
With this example code
constrain(Float64)
andconstrain(Rational{BigInt})
both lead to MOI errors about the model not supporting the constraint:Using Interval instead of GreaterThan results in a similar error, but LessThan seems to work. Not sure whether this is intended behavior.
The text was updated successfully, but these errors were encountered: