Intelligent Behavior in Autonomous Agents through Optimization and Learning