In the Solver Platform SDK, you can model problems that involve ordering or permutations of choices easily with an **"alldifferent" constraint**, which specifies that a set of variables should have integer valuesfrom 1 to N, all of them different at the solution.

#### Basic Constraint Programming - The Alldifferent Constraint

To specify that a set of variables should be "alldifferent" at the solution, you simply set their **IntegerType** property. The Solver Platform SDK allows you to define multiple alldifferent groups in a single problem -- so you also set the **GroupIndex** property to specify the group to which each variable belongs:

`for (i=0; i<n; i++) // "foreach" may be used in some languages`

{

problem.Variables("MyVars").IntegerType[i] = Integer_Type_Alldifferent;

problem.Variables("MyVars").GroupIndex[i] = 1;

}

If you're programming in a procedural language such as C, you can accomplish the same thing with:

`_Integer_Type MyAllDiff[nvars]; int MyGroup[nvars];`

for (i=0; i<n; i++)

{

MyAllDiff[i] = Integer_Type_Alldifferent;

MyGroup[i] = 1;

}

SolverVarIntegerTypeSet (problem, L"MyVars", MyAllDiff);

SolverVarGroupIndexSet (problem, L"MyVars", MyGroup);

Problems involving **ordering or permutations** of choices are very difficult to model using conventional constraints, even with integer variables. An example is the famous **Traveling Salesman Problem (TSP)**, where a salesman must choose the order of cities to visit so as to minimize travel time, and each city must be visited exactly once. In the Solver Platform SDK, you can model this kind of problem easily with an "alldifferent" constraint.

**All Solver engines ** in the Solver Platform SDK supports this new type of constraint. The Branch & Bound process used by the LP/Quadratic and GRG nonlinear Solvers is extended to handle "alldifferent" constraints as a native type, and the hybrid Evolutionary / Classical Solver implements these constraints using mutation and crossover operators for permutations.

**Plug-in Solver Engines** also support the "alldifferent" constraint, implementing it in different ways. This allows you to model the problem in a high-level way, and try a variety of Solver engines to see which one yields the best performance on your problem.