We present an unconstrained optimization reformulation for the stochastic nonlinear complementarity problem in this paper, which aims at minimizing an expected residual defined by the D-gap function. We discuss the existence of a solution to the unconstrained expected residual minimization (UERM) problem. By the quasi-Monte Carlo method, we obtain the discrete approximations of the UERM problem and prove that every accumulation point of minimizers or stationary points of discrete approximation problem is La minimum or stationary point of the UERM problem. We finally apply the UERM formulation to the traffic equilibrium problem.