Bio-inspired cooperative optimization with application to bacteria motility