In this paper, we propose a design algorithm for an optimal supervisor for guaranteeing the trimness of the controlled system. We generalize the earlier work of Kumar and Grag based on the induced flow network of a given discrete event system. Specifically, the proposed algorithm is directly applicable to a discrete event system and minimizes the net cost of the optimal supervisor, which ensures that the controlled system is a trim generator with a polynomial-order computational complexity.