Complements and substitutes in linear and nonlinear programming