| Non-linear optimization problem is one of the difficult problems in optimization fields. It is hard to be solved independently with traditional optimization methods. The random search methods provide a new way to solve this kind of the problems. As a new population-based stochastic global optimization algorithm, electromagnetism-like mechanism (EM) method simulates the attraction-repulsion mechanism between the charged particles in the electromagnetic field. Based on the mechanism the particles can gradually move to the optimal solution. It has been successfully used to solve unconstrained optimization problems. In the paper, an EM method is improved and it is used to solve non-linear constrained and unconstrained optimization problems. The main works are as follows:Firstly, an improved EM method is proposed by analyzing the optimal mechanism of electromagnetism-like mechanism method. There are three main improvements including: (1) designing a new local search; (2) modifying the formulas of each particle's total force vector, and (3) adding Gaussian mutation to the algorithm. Then the global convergence of the proposed algorithm is proved and the simulations are made. The results indicate the performance of the proposed EM method is better than that of the original EM method.Secondly, a new fitness function is proposed by using penalty function and the constrained optimization problem is transformed into an unconstrained optimization problem. Based on the characteristics of EM method, a proper local search scheme is designed according to the property of the constrained optimization problems, and the formulas for calculating the particle charge and force are re-defined so that it is much easier for EM method to guide particles to move from infeasible solutions to feasible solutions, and finally approach to optimal solution. Based on these, a new EM method is proposed. Numerical simulation results indicate that the proposed EM algorithm is effective. |