For a class of Petri nets whose uncontrollable influence subnets are forward synchronization and backward conflict-free nets, this paper proposes an algorithm to transform a given generalized mutual exclusion constraint (GMEC) into an optimal admissible one. Based on the proposed constraint transformation, a method is given to synthesize an optimal monitor-based supervisors. The proposed method utilizes an optimal monitor-based supervisor to enforce a GMEC containing infinite elements, which has not been seen in any prior research. Moreover, it has higher computational efficiency at the expense of application scope than some existing methods. An example is used to illustrate the application of the proposed method.