Hi OR Experts, I am trying to solve this problem with MILP after having tried heuristic methods with no success.
(It is a cryptography challenge) Find P , P' and variables Mk ϵ E subject to: Ck = P(Ak) + P'(Mk) (mod 26) where Ck ϵ E and Ak ϵ E are known constants, for k = 1 to 49 The Mk are subject to 36 extra linear constraints. More generally, the question is: Is there a simple way/trick to index an array of variables by a variable, in a linear way ? Any advice is greatly appreciated. Note: the (mod 26) is not an issue, as Ck = P(Ak) + P'(Mk) (mod 26) can be transformed into 
Hi, My suggestion is to have a look at Constraint Programming which is available within CPLEX. I posted an example of a GCHQ puzzle at and you will see
where x and start are decision variables. So a yes there is a trivial way to your question: Is there a simple way/trick to index an array of variables by a variable, in a linear way ? but not in a linear way! regards answered 30 Jan '16, 11:23 AlexFleischer thank you . However, CPLEX is not affordable for a simple enthusiast ... lpsolve and CBC do not have this feature. I don't know of any free CP software
(30 Jan '16, 12:00)
Alain
If your problem is not too big you may use the free community edition http://www01.ibm.com/software/websphere/products/optimization/cplexstudiocommunityedition/ or free academic initiative if you are allowed to. You may also try pay as you go in the cloud. regards
(30 Jan '16, 12:34)
AlexFleischer
1
I concur with Alex about using CP (and with using CPOptimizer if possible). If CPOptimizer is not an option, there are a number of free constraint solvers. You might want to have a look a MiniZinc, which combines an IDE, modeling language and a few free solvers (plus links to others, I think).
(31 Jan '16, 16:35)
Paul Rubin ♦♦

Instead of linearizing m(k,i) * x'(i,j), you might try linearizing m(k,i) * P'(i), which is a product of binary and bounded integer variables. Explicitly, introduce bounded integer variable z(k,i) for that product, use linear constraints 26 (1  m(k,i)) <= z(k,i)  P'(i) <= 26 (1  m(k,i)) to enforce the rule that m(k,i) = 1 implies z(k,i) = P'(i), and use linear constraints 0 <= z(k,i) <= 26 m(k,i) to enforce the rule that m(k,i) = 0 implies z(k,i) = 0. answered 31 Jan '16, 10:42 Rob Pratt @Rob Pratt: thank you for your time.
(31 Jan '16, 11:23)
Alain
Sorry, I had omitted some constraints, and I have now edited my answer to include them. Your second constraint is indeed a valid tightening of my z(k,i)  P'(i) <= 26 (1  m(k,i)). But it seems that you also need z(k,i) >= 0. By the way, you might see better performance by declaring the P, P', and z variables to be (doublybounded) integers. Although they will automatically be integervalued when x, x', and M are, explicitly declaring them to be integer variables allows the solver more latitude in branching.
(31 Jan '16, 13:37)
Rob Pratt
