I have a MILP (Xpress) constraint, which is doing what I want it to, but I'm struggling to translate it into a LaTeX friendly mathematical expression.

The below code enforces that in the matrix $V$, the sum of the row indexed at seat, is less than or equal to the element in vector seat_vars, indexed at seat. In plain English, one or zero viewers can be assigned to each seat; put another may, at most one person could be assigned to each seat.

for seat in seat_vars.keys():
    constraint = [V[seat, v] for v in range(1, num_viewers+1)]
    sum_ = solver.Sum(constraint)
    solver.Add(sum_ <= seat_vars[seat])

What is the proper mathematical way to express this in LaTeX?

The best I've got so far is

$$ \sum_{i=1}^{n} V_{\text{seat},i} \leq \text{seatvars}_{\text{seat}} $$

However, I'm unsure how to "for loop" over every seat; eg this constraint holds for each seat.


1 Answer 1


$\sum_{i=1}^n V_{seat,i} \le seatvars_{seat} \quad \forall seat \in\ $seatVars
Looping 'for' in done by $\forall$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.