Thu 19 Dec 2013 07:33:11 PM UTC, original submission:
The following line invokes glpk to solve an integer problem. But sadly GLPK returns a solution that is not legal. If the solution was legal then A*x1 should be [0,0].
N=8; arow=10.^[0:N-1]-410.^[N-1:-1:0]; A=[arow;-arow];b=[0;0];c=[N-1:-1:0]; lb=zeros(1,N);ub=9ones(1,N);[x1,x2,x3,x4]=glpk (c, A, b, lb, ub, "UU", repmat("I",[1,N]), -1), A*x1
x1 =
1
9
9
9
9
9
9
7
x2 = 196.00
x3 = 171
x4 =
scalar structure containing the fields:
time = 0
mem = 0
ans =
3
-3
If glpk has found an illegal solution, then the solver should probably warn he user that the solution is illegal. Perhaps the wrapper could perform an extra check to make sure that glpk is right.
Note: You can change the problem size by changing N. if you choose N=7, the the code tuns nicely.
BTW: The code find numbers such as 2199978 that fullfills
4*2199978 = 8799912
IN other words you can reverse the ciphers by multiplying with 4.
|