I am trying to formulate queuing decisions as an optimization problem, but have little experience in this area. To simplify, say you had $N$ queues, and for every incoming item, the decision you need to make is to which queue this item should be assigned. The optimal assignment would be the one that minimizes the average time an item spends in the system (waiting in a queue + getting processed).
So for n queues, the binary decision variables $x_0, \dots, x_N$ dictating which queue gets assigned are constrained by:
$$x_i \in \{0, 1\}$$ $$\sum_{i=0}^{N} x_i = 1$$
So for any given item, one queue is assigned, and the others not. And my objective function:
$$\text{min}\ Z = \sum_{i=0}^{N} c_i x_i$$
Where $c_i$ is the cost associated with a queue that corresponds to the the expected processing time for this item, plus the expected processing times for all other items in that queue.
So far so good, but now I want to add to a cost of changing the decision from item to item. It turns out that for my particular use case, it takes (a constant) time to switch from one assignment to another, $K$.
I want to be able to add to $c_i x_i$ something like $K|x_i(j-1) - x_i(j)|$ where $j$ is the item index. In other words, to add this switching cost if the new decision differs from the old one. I don't have the mathematical vocabulary to describe this though (or maybe I'm thinking about it the wrong way?) so I would appreciate any advice or pointers.
You're adding a penalty on the absolute value on differences, very standard. To model the absolute values, you introduce new additional variables $z_{ij}$ with the constraints $-z_{ij} \leq x_i(j-1)-x_{i}(j) \leq z_{ij} $ and add the terms $Kz_{ij}$ to the objective. At optimality, one of the constraints will be tight (otherwise you could have made $z_{ij}$ smaller), and thus $z_{ij}$ will model the absolute value.