Composable optimization for robotics simulation and control