Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Remainder Puzzle I (math04) Problem: Is there a number which gives a remainder of 1 when divided by 3, and a remainder of 2 when divided by 4, and a remainder of 3 when divided by 5 and nally a remainder of 4 when divided by 6? Find the smallest such number, if any exists. (see [2] and [3]). Modeling Steps The unknown number when divided by 3, 4, 5, 6 leaves a remainder of 1, 2, 3, 4. 1. Let the unknown integer number be N . 2. We introduce an aditional 4 integer variables x1 , x2 , x3 , and x4 representing the results of the divisions without remainder. 3. If N divided by three leaves a remainder of 1, then x1 = (N − 1)/3 must be an integer number. 4. If N divided by four leaves a remainder of 2, then x2 = (N −2)/4 must be an integer number. 5. If N divided by ve leaves a remainder of 3, then x4 = (N − 3)/5 must be an integer number. 6. If N divided by six leaves a remainder 4, then x4 = (N − 4)/6 must be an integer number. 7. The four requirements can be expressed as follows : (N − i)/(i + 2) = xi , for all i ∈ {1 . . . 4} 8. We want to nd the smaller number N , that fulls the requirements. Therefore, N is minimized in the objective function. The complete model code in LPL for this model is as follows (see [1]): Listing 1: The Model model math04 "Remainder Puzzle I"; set i := [1..4]; integer variable x{i}; N; constraint A{i}: (N-i)/(i+2) = x[i]; minimize obj: N; Write(’The smallest such number N is %d\n’, N); end Solution: The solution is: N = 58. The vector x is (19, 14, 11, 9). The second smallest number which fulls the requirements is N = 118. Question (Answer see ) 1. Find the second smallest number that fulls the requirements. 1 2. Add the requirement that the number N must be divisible by 13. 3. Find the 10 smallest numbers which full the requirements. Answer (Question see ) 1. Add the lower bound of 59 to variable N and solve again. Or, add the constraint: constraint B: N >= 59; The next solution found is N = 118. 2. Add a new integer variable, say M , then add the following constraint: constraint C: N = 13*M; The smallest such number is N = 598. 3. The simplest way to achive this is to add a loop to the model and solve the model each time with a modied lower bound on N . (This model is implemented in the next section math04a1 ). References [1] T. Hürlimann. Reference Manual for the LPL Modelling Language, most recent version. www.virtual-optima.com. [2] B.A. Kordemsky. [3] Clare Nolan. html. The Moscow Puzzles. Charles Scribner's Sons, 1972. http://www.chlond.demon.co.uk/academic/puzzles. 1 http://lpl.unifr.ch/lpl/Solver.jsp?name=/math04a 2