chkwon / Complementarity.jl

provides a modeling interface for mixed complementarity problems (MCP) and math programs with equilibrium problems (MPEC) via JuMP
Other
75 stars 20 forks source link

The complementarity macro (@complementarity) does not include JuMP variables of SparseAxisArray type #37

Closed QinBa closed 4 years ago

QinBa commented 5 years ago

I am using Julia 1.03, IJulia 1.17.0, JuMP 0.19.0. The problem is that the type SparseAxisArray has no field axes.

An example demonstrating the problem is as follow.

using Complementarity, JuMP

m = MCPModel()
@variable(m, x[i=1:4; i%2==0] >= 0)
@mapping(m, F[i=1:4; i%2==0], x[i]+2)
@complementarity(m, F, x)

Error message:

type SparseAxisArray has no field axes

Stacktrace: [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18 [2] top-level scope at /Users/XXX/.julia/packages/Complementarity/Gag1Y/src/mcp.jl:371

chkwon commented 4 years ago

@QinBa At this moment, the package does not support conditional indexing such as i%2==0. You might do:

using Complementarity, JuMP

m = MCPModel()
@variable(m, x[i=1:4] >= 0)
@mapping(m, F[i=1:4], x[i]+2)

for i in 1:4
  if i%2 == 0
    @complementarity(m, F[i], x[i])
  end
end
QinBa commented 4 years ago

Thank you for the response!