Optimizing tasks and workflows efficiently