Solution to optimization problems using Hopfield models