Constrained-Space Optimization and Reinforcement Learning for Complex Tasks