Re:An Intro to Integer Programming for Engineers: Simplified...
by JadeNB on Friday May 26, 2017 @06:33AM
(#14423083)
I'm sorry for the delay; I didn't realise that you'd responded. I couldn't find the O'Keefe book to look up the exact challenge, but I think you've correctly reverse-engineered and solved it. Thanks again!
In this concrete case, we get this by simply adding all_distinct(Ds) to the query. For example:
This yields Ds = [6, 5, 4, 8, 7, 3, 1, 2, 0], in addition to other solutions. Now we only need to add that none of the integers must be 0. We can express this (for example) with the additional constraint Ds ins 1..9: However, when you run this query, you get false in return. This means that there is no solution that satisfies all these constraints at the same time.Therefore, the task you mentioned was probably about the prefices, i.e., the initial segments of the number. We can easily express this with small modifications to the program above:
With this program, we get: This means that there is a solution, and it is in fact unique! This is determined very efficiently thanks to the pruning that is automatically applied by the constraint solver.