The following code optimizes for total mpg in the mtcars dataset. We choose 2 cars from each gear category (3 / 4 / 5 gears). We also add a restriction for max total hp.