julia-mpsge / MPSGE.jl

MPSGE for Julia
MIT License
14 stars 2 forks source link

AuxConstraints need inequalities #109

Open EliLazarus opened 1 year ago

EliLazarus commented 1 year ago

We need a test model that solves differently as an inequlity or as an equality to test. Potential code, for build_auxconstraints

         ac.equation isa Expr || error("You must pass an expression as an aux constraint.")
# TODO Need >=, and possibly >= , not clear if this works, need an example that solves differently if == or >= to test.
        (ac.equation.head == :call && length(ac.equation.args) == 3 && (ac.equation.args[1] == :(==) || ac.equation.args[1] == :(>=))) || error("Must pass an equation with an == or >= sign.")
        if ac.equation.args[1] == :(==)
              equation_expr = swap_our_param_with_jump_param(jm, :( $(ac.equation.args[2]) - $(ac.equation.args[3]) ))
        elseif ac.equation.args[1] == :(>=)
            equation_expr = swap_our_param_with_jump_param(jm, :( $(ac.equation.args[2]) >= $(ac.equation.args[3]) ))
        end
EliLazarus commented 1 year ago

I can't find or create GAMS code to test against that changes if the constraint is changed between and inequality =g= and an equality =e=. Until there's something to test again, there's no way to know if it's working appropriately.

mitchphillipson commented 2 weeks ago

I actually don't think this is an issue, and if it is then it's a JuMP limitation. Most of this is "I believe", but I think it's correct. Basically PATH is an oriented solver that only sees equalities. For example, $A \ge B$ is passed to PATH as $A-B = 0$ and PATH implicitly understands the orientation. So, strangely, PATH will solve $A-B=0$ differently to $B-A=0$.

EliLazarus commented 2 weeks ago

I'm not sure if this is the same issue as the PATH one. Sorry, I'm not clear on it, but would like to be sure. I know it's a function in MPSGE/GAMS, and according to some documentation, it's necessary, but without replicable examples to test against (as in my comment above), the expected behaviour is unclear, so hard to know. Some consultation might be needed to clarify.