The minimization of risk functions is becoming a very important topic due to its interesting applications in Mathematical Finance and Actuarial Mathematics. This paper addresses this issue in a general framework. Many types of risk function may be involved. A general representation theorem of risk functions is used in order to transform the initial optimization problem into an equivalent one that overcomes several mathematical caveats of risk functions. This new problem involves Banach spaces but a mean value theorem for risk measures is stated, and this simplifies the dual problem. Then, optimality is characterized by saddle point properties of a bilinear expression involving the primal and the dual variable. This characterization is signi...