Unfortunately, I also do not know how to embed 0-1-knapsack specific inequalities with the odd number solution requirement. However, I know how to generate cuts that will reduce the search space whenever an even number of items is picked. So, let $x^{*} \in \mathbb{R}^{n}$ be an optimal, eventually fractional, solution. If $\sum_{j} x^{*}_j$ is an integer even number, then we can say that $\sum_{j \in I} x_j - \sum_{k \notin I} x_k \leqslant |I| - 1$, where $I = \{j : x^*_j > 0\}$. With these thoughts in mind, fluidly we design the below separation algorithm (callback):
- Get $x^{*}$ and $I$.
- If $\sum_{j} x_j^{*}$ is integer and even then:
- Add $\sum_{j \in I} x_j - \sum_{k \notin I} x_k \leqslant |I| - 1$ to the formulation.
Actually, we can play a little bit with the addition of a new variable; as you commented earlier. Let $y \in \mathbb{N}$ be a natural variable, then we can force the formulation, on its integer solution space, to consider only $\sum_{j} x_j$ as odd numbers, if we say that $\sum_{j} x_j = 2 y + 1$.
Furthermore, we can try out new branching rules, where we basically branch on odd numbers.
- Get $x^{*}$
- Let $F = \lfloor \frac{\sum_{j} x^*_j}{2} \rfloor$, and $C = \lceil \frac{\sum_{j} x^*_j}{2} \rceil$
- If $C = F$ then:
- start branching on $x_j$
- exit
- If $F$ is odd then:
- branch on $\sum_{j} x_j \leqslant F$
- branch on $\sum_{j} x_j \geqslant C + 1$
- else:
- branch on $\sum_{j} x_j \leqslant F - 1$
- branch on $\sum_{j} x_j \geqslant C$
Case anyone has any questions or suggestions, please feel free.
UPDATE 1: Updating step 3 of the first algorithm. ps.: thanks @RobPratt for the observation and the edge case.