1. A computer-implemented method for resource management, comprising: receiving, in a computer, a definition of a set of resource consumers, resources for allocation to the resource consumers, and constraints applying to the allocation of the resources; associating respective variables in the computer with the resource consumers, and identifying the resources as values applicable to the variables, thereby defining respective domains of the values for the variables; identifying a group of the variables as preferred variables based on respective values that were assigned to the variables in a previous allocation of the resources; finding, by the computer, an assignment of the values to the variables that satisfies the constraints by repeatedly performing, while the group contains one or more of the variables, the steps of: choosing a variable from the group; instantiating the chosen variable with a value; removing the chosen variable from the group; and pruning the domains of the other variables by propagation of the constraints responsively to the value of the chosen variable; and assigning the resources to the resource consumers responsively to the assignment of the values to the variables.