Abstract This paper proposes a new method of pocketing toolpath computation based on an optimization problem with constraints. Generally, the calculated toolpath has to minimize the machining time and respect a maximal effort on the tool during machining. Using this point of view, the toolpath can be considered as the result of an optimization in which the objective is to minimize the travel time and the constraints are to check the forces applied to the tool. Thus a method based on this account and using an optimization algorithm is proposed to compute toolpaths for pocket milling. After a review of pocketing toolpath computation methods, the framework of the optimization problem is defined. A modeling of the problem is then proposed and a solving method is presented. Finally, applications and experiments on machine tools are studied to illustrate the advantages of this method.