The design of a four-link knee prosthesis mechanism with two locking systems activated during the flexion/extension phase is presented. The first is geometric, totally mechanical and activated by the user's weight. The second is variable and is activated automatically when walking on irregular or special surfaces is required. The links' dimensions were selected using the differential evolutionary optimization algorithm to follow the trajectory of the poloid generated during human walking. Motion simulation is performed in the Adams view program to validate the trajectory tracking during walking and the operation of the locking systems using the angles obtained from the Opensim program. The plots obtained for the motion in the simulations show that a poloid tracking was generated in 92% as with a healthy knee, particularly in walking and sitting positions. The physical and virtual prototypes are presented and their movement is described when used by a person. During the physical tests, the flexion-extension movement of the mechanism was observed in an approximate range of 0-130°, following the desired trajectory of the poloid. The variable locking system locks the leg in the stay and when seated, allowing free movement during gait.