currently, the way the inequality constraint is built is very involved. The code can be simplified significantly by using .add_linear_inequality_constraint.
If the goal is to teach users how to work with slack variables, using a higher-level function is not needed. However, more users can expand this example to an application, if it's simplified.