Yes this is an integer programming problem. You can write it as:
minimize |x1 - x2| + |x2 - x3| + ... + |xn-1 - xn|
subject to x1 + x2 + x3 + ... + xn == c,
xi == Ai1*yi1 + Ai2*yi2 + ... + Aip*yip, i=1,...,n,
yi1 + yi2 + ... + yip == 1, i=1,...,n,
yij binary for i=1,...,n j=1,...,p,
xi integer for i=1,...,n,
here the Aij are known input data that describe what integers a particular value of xi may take on. Below is a concrete example with 3 variables (n=3), where each xi can take on one of two integer values (p=2). That is x1 can be 1 or 3, x2 can be 3 or 4, x3 can be 2 or 3.
minimize |x1 - x2| + |x2 - x3|
subject to x1 + x2 + x3 == 8,
x1 == 1*y11 + 3*y12,
x2 == 3*y21 + 4*y22,
x3 == 2*y31 + 3*y32,
y11 + y12 == 1,
y21 + y22 == 1,
y31 + y32 == 1,
yij binary i=1,2,3 j=1,2
xi integer i=1,2,3
You can reformulate the above problem as a MIP (a mixed integer program) by creating
a new set of variables u to represent the objective function.
minimize u1 + u2 + ... + un
subject to ui >= xi - xi+1, i=1,...,n-1,
ui >= xi+1 - xi, i=1,...,n-1,
x1 + x2 + x3 + ... + xn == c,
xi == Ai1*yi1 + Ai2*yi2 + ... + Aip*yip, i=1,...,n,
yi1 + yi2 + ... + yip == 1, i=1,...,n,
yij binary for i=1,...,n j=1,...,p,
xi integer for i=1,...,n,
ui real for i=1,...,n-1,
You can use any standard MIP solver to solve the above problem.