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

Recent matrix changes broke JuMPeR #577

Closed
IainNZ opened this issue Sep 5, 2015 · 13 comments
Closed

Recent matrix changes broke JuMPeR #577

IainNZ opened this issue Sep 5, 2015 · 13 comments
Milestone

Comments

@IainNZ
Copy link
Collaborator

IainNZ commented Sep 5, 2015

using JuMP, JuMPeR
m = RobustModel()
@defVar(m, matvar[1:3,1:3])
@defUnc(m, vecunc[1:3])
@defUnc(m, matunc[1:3,1:3])

b = [1,2,3]
A = eye(3,3)
c = @addConstraint(m, A*vecunc .== b)
julia> c = @addConstraint(m, A*vecunc .== b)
ERROR: MethodError: `addVectorizedConstraint` has no method matching addVectorizedConstraint(::JuMP.Model, ::Array{Any,1})
Closest candidates are:
  addVectorizedConstraint(::JuMP.Model, ::Array{JuMP.GenericRangeConstraint{JuMP.GenericAffExpr{Float64,JuMP.Variable}},N})
  addVectorizedConstraint(::JuMP.Model, ::Array{JuMP.GenericQuadConstraint{JuMP.GenericQuadExpr{Float64,JuMP.Variable}},N})
  addVectorizedConstraint(::JuMP.Model, ::Array{JuMP.GenericRangeConstraint{JuMP.GenericAffExpr{Float64,JuMPeR.Uncertain}},N})
  ...
@IainNZ
Copy link
Collaborator Author

IainNZ commented Sep 5, 2015

As you can see, I have the correct addVectorizedConstraint method defined, but something went screwy with the container. Ideas?

@joehuchette
Copy link
Contributor

Which commit is this on?

@IainNZ
Copy link
Collaborator Author

IainNZ commented Sep 5, 2015

commit d14145b2911125e572ee40c66db679e7872299a6
Author: Joey Huchette <joehuchette@gmail.com>
Date:   Sat Sep 5 14:11:44 2015 -0400

    generalize addToExpression (0 -> zero(C))

JuMPeR any version (e.g. released version v0.2.0 or master)

@joehuchette
Copy link
Contributor

We should have a fallback method for addVectorizedConstraint that handles this. However, it seems that A*vecunc - b is giving an Array{Any}, which is also an issue. It's falling back to a method in arraymath.jl in Base.

@IainNZ
Copy link
Collaborator Author

IainNZ commented Sep 5, 2015

Something I haven't defined maybe?

@joehuchette
Copy link
Contributor

Should still hopefully work, though.

@IainNZ IainNZ added this to the 0.10.2 milestone Sep 5, 2015
@joehuchette
Copy link
Contributor

julia> Base.promote_type(eltype(A*matvar), eltype(b))
JuMP.GenericAffExpr{Float64,JuMP.Variable}

julia> Base.promote_type(eltype(A*matunc), eltype(b))
Any

@joehuchette
Copy link
Contributor

You need to add the equivalent of

Base.promote_rule{R<:Real}(::Type{Variable},::Type{R}       ) = AffExpr
Base.promote_rule(         ::Type{Variable},::Type{AffExpr} ) = AffExpr
Base.promote_rule(         ::Type{Variable},::Type{QuadExpr}) = QuadExpr
Base.promote_rule{R<:Real}(::Type{AffExpr}, ::Type{R}       ) = AffExpr
Base.promote_rule(         ::Type{AffExpr}, ::Type{QuadExpr}) = QuadExpr
Base.promote_rule{R<:Real}(::Type{QuadExpr},::Type{R}       ) = QuadExpr

to JuMPeR, I think.

@IainNZ
Copy link
Collaborator Author

IainNZ commented Sep 5, 2015

Got it, will try that now

@IainNZ
Copy link
Collaborator Author

IainNZ commented Sep 5, 2015

Success! Close this, or is it worth adding the fallback?

@joehuchette
Copy link
Contributor

I'm (hoping) we can solve this completely in JuMP, actually...

@mlubin
Copy link
Member

mlubin commented Sep 29, 2015

Fixed?

@IainNZ
Copy link
Collaborator Author

IainNZ commented Sep 29, 2015

Yep, and tagged

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

No branches or pull requests

3 participants