This thesis is devoted to the spread of virus in human society. First, we modified the original basic epidemiological model, and divide the system into M different types. The optimal control problem is formulated for the changes of compartments in different states. The total cost is then minimized, the Pontryagin maximum principle is used to solve this nonlinear optimal control problem. Next, we prove that the optimal policy has the simple structure. Finally, we fit the propagation process of this model using Matlab. Consider the situation where there are only two types of virus in the system, and compare the two types of virus appear at the same time and at different times.