\$title Bilevel model with phantom vars owned by leader (EMPBP06,SEQ=716) \$ontext Test handling of phantom vars (i.e. vars that disappear when KKT conditions are formed) owned by the leader in a bilevel program. Contributor: Steve Dirkse, February 2017 \$offtext positive variables v1 'outer one' v2 'outer two' vv 'outer fluff' / LO 0.52525, L 2.52525, UP 5.52525 / y 'inner one' ; variables objout 'outer objective' objin 'inner objective' ; equations defout defin ; defout.. objout =e= 1/2*sqr(v1-4/5) + 1/2*sqr(v2-1/5) + 1/2*sqr(y-1); defin.. objin =e= 1/2*sqr(y) - y - v1*y + 2*v2*y + 3.875 * vv; v1.L = 0.75; v1.up = 1; v2.L = 0.25; v2.up = 1; y.up = 1; model m / all /; \$echo bilevel v1 v2 vv min objin * defin > "%emp.info%" solve m us emp min objout; abort\$[abs(v1.L - 0.8) > 1e-4] 'bad v1.L', v1.L; abort\$[abs(v2.L - 0.2) > 1e-4] 'bad v2.L', v2.L; abort\$[abs( y.L - 1.0) > 1e-4] 'bad y.L', y.L; scalar innerObj; innerObj = 1/2*sqr(y.L) - y.L - v1.L*y.L + 2*v2.L*y.L + 3.875 * vv.L; abort\$[abs(objin.L - innerObj) > 1e-4] 'bad objIn.L', objIn.L, innerObj;