This paper aims at automatic generation of optimal sequence of machining operations in setup planning by Genetic Algorithm (GA) based on minimizing the number of setup changes and tool changes, subject to various machining precedence constraints. The GA has been reconstructed as the method of representing an operation is not as simple as assigning it a binary digit as in case of a chromosome in traditional GA but it has to be a distinct real number. Accordingly, the GA operators had to be modified. At the end of each GA cycle, there might be chromosomes having high fitness values but not conforming to constraints. Moreover, due to randomness of GA, the conformable chromosomes might tend to get lost. In order to minimize such losses, the elitist model is used for selection of chromosomes. Furthermore, a special subroutine has been developed to check the chromosomes for conformability and modify/repair those that violate the constraints.