Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected expression type MathOptInterface.ScalarAffineFunction #110

Closed
votroto opened this issue Mar 5, 2024 · 2 comments · Fixed by #112
Closed

Unexpected expression type MathOptInterface.ScalarAffineFunction #110

votroto opened this issue Mar 5, 2024 · 2 comments · Fixed by #112

Comments

@votroto
Copy link
Contributor

votroto commented Mar 5, 2024

Running

using JuMP, PolyJuMP, Gurobi
model = Model(() -> PolyJuMP.QCQP.Optimizer(Gurobi.Optimizer()))

@variable(model, 0 <= x <= 1)
@constraint(model, (0 + x) * (x * x) == 0)

optimize!(model)

results in

LoadError: PolyJuMP.InvalidNLExpression("Unexpected expression type `MathOptInterface.ScalarAffineFunction{Float64}` of `0.0 + 1.0 MOI.VariableIndex(1)`")

P.S. I am so sorry @blegat and thank you for your time on developing this package.

@odow
Copy link
Member

odow commented Mar 5, 2024

This is an easy fix. We're missing _to_polynomial for ScalarAffine and ScalarQuadratic near here:

function _to_polynomial!(d, ::Type{T}, vi::MOI.VariableIndex) where {T}
if !haskey(d, vi)
d[vi] = MP.similar_variable(VarType, Symbol("x[$(vi.value)]"))
end
return d[vi]
end

p.s., as you can probably tell @votroto, the QCQP solver is still a little under development. No one has tested the rough edges yet 😄 but that's for finding these issues!

@blegat
Copy link
Member

blegat commented Mar 6, 2024

@votroto Please don't be sorry, thanks for taking the time to report all the edge cases ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants