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

Equality constraints #17

Closed hhoeschle closed 6 years ago

hhoeschle commented 7 years ago

Hallo,

I wonder if there is a default way to implement equality constraints. F(x) = 0 , x \in \mathbb{R}

At the moment, I create two positive variables and a nonlinear expression to design a free variable in combination with an equality constraint:

@variable(model, lambda1 >= 0)
@variable(model, lambda2 >= 0)
@NLexpression(model, lambda,
    lambda1 - lambda2)

@mapping(model, market_lambda1,
    + sum(xname[s] for s in scenarios)
    + sum(ynoname[s] for s in scenarios if INDEX[s] > 0)
    - 10)
@complementarity(model, market_lambda1, lambda1)

@mapping(model, market_lambda2,
    - sum(xname[s] for s in scenarios)
    - sum(ynoname[s] for s in scenarios if INDEX[s] > 0)
    + 10)
@complementarity(model, market_lambda2, lambda2)

or is this simply the same as:

@variable(model, lambda)

@mapping(model, market_lambda,
    + sum(xname[s] for s in scenarios)
    + sum(ynoname[s] for s in scenarios if INDEX[s] > 0)
    - 10)
@complementarity(model, market_lambda, lambda)

maybe we could improve the documentation accordingly?

Regards, Hanspeter

chkwon commented 7 years ago

I think these two must be the same. Do you obtain the same results from the both codes?