Formulate the integer linear programming problem to maximize the expected aggregate action for the team of gymnastics For future Olympics, the Gymnastics Federation can choose
between 6 contestants, and you need 3 of them to participate both in the balance beams
as in parallel bars. The Olympic committee requires that 4
people at each event. The following table shows the average ratings of
each gymnast and their coach assumed that their performance would be similar in the future
competition. Formulate the integer linear programming problem to choose the
gymnasts who participate in each exercise in such a way as to maximize the
expected aggregate action (sum of each gymnast's score) for the team.




Gymnasts
Balance beams
Bars




1
88
79


2
94
83


3
92
85


4
75
87


5
87
81


6
91
86




My try:
Maximize:  $$88x_1+79x_2+94x_3+83x_4+92x_5+85x_6+75x_7+87x_8+87x_8+87x_9+81x_{10}+91x_{11}+86x_{12}$$
restricted to: $$\sum_{i=1}^6x_{2i}=4$$
$$\sum_{i=1}^6x_{2i-1}=4$$
For $x_i\in\{0,1\}$ for all $i\in\{1,2,3,4,5,6\}$
I'm not sure how to simplify the restriction of having 3
gymnasts to participate both in the balance beams as in parallel bars. Any suggestions would be great!
The easiest way to do it would be to actually have three sets of variables:

$x_1, x_2, \dots, x_6$ to indicate that a contestant is participating in the first event only;
$y_1, y_2, \dots, y_6$ to indicate that a contestant is participating in the second event only;
$z_1, z_2, \dots, z_6$ to indicate that a contestant is participating in both events.

You'll need to modify your existing constraints to use $x_i + z_i$ to test if a contestant is participating in the first event, and $y_i + z_i$ for the second. To make sure that at most one of these is true for a contestant, you'll need to add the constraint $x_i + y_i + z_i \le 1$ for all $i$. Finally, the condition you had trouble with can now be written as $$z_1 + z_2 + z_3 + z_4 + z_5 + z_6 = 3.$$
You need to set $x_i \le 1$ to finish off your LP formulation. Strictly you have an IP (integer programming) and depending on how you're solving the LP, you can usually specify that the values must be integers in the software. In any case this type of problem may well give you integer values for the $x_i$. If not, then you need to search for integer points near your optimal solution.
It worries me that you don't seem to have addressed the constraint that three must compete in both events...