Integer Programs - How to force the solution to be in multiples of an integer?

So I'm trying to create this IP that has an optimal solution where all the variables are integers, and are all in multiples of a number, like 3. ( so the variables in the solution would have to be either 0,3,6,9,12,etc.)

I code in R, and it's pretty easy to set the constraint that the solution must be in integers ( = TRUE), but I am unsure of how to have it in a multiple of a number. What changes do I have to make within the Ax <= b formulation? Your help would be greatly appreciated! As of right now, I am fairly lost on how to actually do that


To do this, you can define some integer variable x and then define y = 3*x. Now y is integer and a multiple of 3.

For instance, consider a trivial IP that finds the maximum multiple of 3 that is less than or equal to 10 (of course, the main motivation here is to embed this within a more complicated integer program). You could do this with:

mod <- lp(direction = "max",
 = c(0, 1),  # (x, y)
          const.mat = rbind(c(3, -1),  # 3x - y = 0
                            c(0, 1)),  # y <= 10
          const.dir = c("=", "<="),
          const.rhs = c(0, 10),
 = TRUE)
# [1] 9

As I understand it, your criterion is that the mod 3 of the answer is 0. If so, what about mod(intResult,3) == 0?

Since I don't write in your language, the above may not be valid R, but I think you will get the idea, since the above is valid C, assuming that mod is the name of a function that returns intResult modulo 3.


 ? Can this be expressed using Integer Programming or Constraint Programming?
 ? Real time Integer/Binary programming (microSecond compute time)
 ? what kind of heuristics must be used for an integrated production planning and transportation MIP?
 ? Algorithm for choosing products for a given set of features at minimum cost?
 ? Arbitrary precision integer programming solvers?
 ? Mixed integer programming with quadratic obj and quadratic constraints?
 ? MATLAB has crashed when using CPLEX API for linear programming
 ? Formulating a bilinear optimization program as an integer linear program
 ? Maximising the benefit of a given scenario
 ? What size tour can I reasonably expect to solve with GLPK?