Grouping variables

Decision variables and their possible values can be ordered so that the optimizer can fix the key decision variables early in the process.

In many applications, there exists a group of key decision variables, such that once these variables are fixed, it is easy to extend the partial solution to the remaining variables.

Information about key variables can be given to the search by way of tuning objects called search phases. An instance of IloSearchPhase (ISearchPhase in the C# API) is created with an array of decision variables and passed to the search as argument to the method setSearchPhases before calling solve and startNewSearch.

Assume that in a model the decision variables in the array x are key variables. In the C++ API, you can pass this information to the search the following way:


    cp.setSearchPhases(IloSearchPhase(env,x));
    cp.solve();

This search phase forces the search to fix (instantiate) the decision variables from the array x before instantiating any other variable in the model.

Instantiation of groups of decision variables can be ordered by using several search phases. The search phases are passed to the search using a search phase array. The decision variables in the first phase are instantiated before the variables in the second one and so on.

Consider for instance, the two phases:


    IloSearchPhase xPhase(env, x);
    IloSearchPhase yPhase(env, y);

If we solve a model by calling:


    IloSearchPhaseArray phaseArray(env);
    phaseArray.add(xPhase);
    phaseArray.add(yPhase);
    cp.setSearchPhases(phaseArray);
    cp.solve();

Decision variables in x will be instantiated before variables in y that in turn will be instantiated before any variables that are not in x and y.

It is important to observe that when using search phases, the phases do not need to cover all variables of the model. The CP Optimizer search will instantiate all variables, and those that do not appear in any search phase will always be instantiated last.