Complementarity.jl icon indicating copy to clipboard operation
Complementarity.jl copied to clipboard

Handle restricted domains on equations

Open mitchphillipson opened this issue 1 year ago • 0 comments

The issue I'm solving is when we have a set $A = B\cup C$, a variable, $x$ defined on $A$ where $x$ is fixed on $C$. Any equation, $F$, that is complementary to $x$ can be restricted to only the set $B$. For example, ` @variable(m, x[A])

#fix x on C

@mapping(m, F[B], ...) @complementary(m,F,x) `

Currently this throws an error as complementarity loops over the domain of $x$. I'm suggesting several changes:

  1. Add a field to ComplementarityType called "fixed_variable" and adjust add_complementarity to default this value to false.
  2. In complementarity add a check to determine if an element of $x$ is also a element of $F$, if not set the fixed_variable flag to true and add an NL_expression which is just 0.
  3. When solving check to ensure all variables that claim to be fixed, are fixed. If not raise an error.

The motivation for this comes from having a large model with many fixed variables. These changes will decrease model complexity, build time, and solve time.

I've also created some tests, to test fixing variables at different times and not fixing all required variables.

Mitch

mitchphillipson avatar Oct 17 '22 16:10 mitchphillipson