I guess I have a simple problem, but I can't find a fitting solution.
I have a certain amount periods $D$, and every period is described by the decision variable $X_d$. What I want to do is set a binary Variable $N_d$ to 1, if the value $X_d$ is not equal to $X_{d-1}$. So if the value $X$ changes between two periods, the binary variable should be $1$. If it stays the same, the binary variable should be $0$.
So far I'm struggeling with not being allowed to use the absolute value of the difference of $X_d$ and $X_{d-1}$ to keep the problem linear.
My first idea was: $$ |X_{d-1} - X_d| \times 0.01 \leq N_d \quad \textrm{for } d > 1 $$
I hope you can understand my problem and I would appreciate any help!
Best regards, Seba