We propose a new stochastic algorithm (generalized simulated annealing) for computationally finding the global minimum of a given (not necessarily convex) energy/cost function defined in a continuous D-dimensional space. This algorithm recovers, as particular cases, the so called classical (Boltzmann machine) and fast (Cauchy machine) simulated annealings, and can be quicker than both. Key-words: simulated annealing; nonconvex optimization; gradient descent; generalized statistical mechanics.