$ontext Alphametics, Simple formulation This does not work very well. Erwin Kalvelagen AN + ACCELERATING + INFERENTIAL + ENGINEERING + TALE + ELITE + GRANT + FEE + ET + CETERA = ------------- ARTIFICIAL + INTELLIGENCE $offtext set i /A,N,C,E,L,R,T,I,G,F/; alias (i,j); set leading(i) /A,I,E,T,G,F,C/; abort$(card(i) <> 10) "set i should have 10 elements"; parameter v(i); v(i) = ord(i)-1; variables y(i) 'decision variables' x(i,j) 'auxiliary variables for uniqueness' z 'dummy objective variable' ; binary variable x; equation addition 'the actual problem' ydef(i) 'calculate y' xrow(i) 'row sums' xcol(j) 'column sums' dummy_objective ; addition.. 10*y('A')+y('N')+ 1e11*y('A')+1e10*y('C')+1e9*y('C')+1e8*y('E')+1e7*y('L')+1e6*y('E')+1e5*y('R')+1e4*y('A')+1e3*y('T')+100*y('I')+10*y('N')+y('G')+ 1e10*y('I')+1e9*y('N')+1e8*y('F')+1e7*y('E')+1e6*y('R')+1e5*y('E')+1e4*y('N')+1e3*y('T')+100*y('I')+10*y('A')+y('L')+ 1e10*y('E')+1e9*y('N')+1e8*y('G')+1e7*y('I')+1e6*y('N')+1e5*y('E')+1e4*y('E')+1e3*y('R')+100*y('I')+10*y('N')+y('G')+ 1e3*y('T')+100*y('A')+10*y('L')+y('E')+ 1e4*y('E')+1e3*y('L')+100*y('I')+10*y('T')+y('E')+ 1e4*y('G')+1e3*y('R')+100*y('A')+10*y('N')+y('T')+ 100*y('F')+10*y('E')+y('E')+ 10*y('E')+y('T')+ 1e5*y('C')+1e4*y('E')+1e3*y('T')+100*y('E')+10*y('R')+y('A') =e= 1e9*y('A')+1e8*y('R')+1e7*y('T')+1e6*y('I')+1e5*y('F')+1e4*y('I')+1e3*y('C')+100*y('I')+10*y('A')+y('L')+ 1e11*y('I')+1e10*y('N')+1e9*y('T')+1e8*y('E')+1e7*y('L')+1e6*y('L')+1e5*y('I')+1e4*y('G')+1e3*y('E')+100*y('N')+10*y('C')+y('E'); ydef(i).. y(i) =e= sum(j, x(i,j)*v(j)); xrow(i).. sum(j, x(i,j)) =e= 1; xcol(j).. sum(i, x(i,j)) =e= 1; * * bounds on leading digits: they can not be 0 * y.lo(leading) = 1; dummy_objective.. z =e= sum(i, y(i)); model m /all/; solve m using mip minimizing z; option y:0; display y.l;