An important issue in power systems is the optimal operation of microgrids with demand-side management. The implementation of demand-side management programs, on the one hand, reduces the cost of operating the power system, and on the other hand, the implementation of such programs requires financial incentive policies. In this paper, the problem of the optimal operation of microgrids along with demand-side management (DSM) is formulated as an optimization problem. Load shifting is considered an effective solution in demand-side management. The objective function of this problem is to minimize the total operating costs of the power system and the cost of load shifting, and the constraints of the problem include operating constraints and executive restrictions for load shifting. Due to the dimensions of the problem, the simultaneous combination of a genetic algorithm and an ABC is used in such a way that by solving the OPF problem with an ABC algorithm and applying it to the structure of the genetic algorithm, the main problem will be solved. Finally, the proposed method is evaluated under the influence of various factors, including the types of production units, the types of loads, the unit uncertainty, sharing with the grid, and electricity prices all based on different scenarios. To confirm the proposed method, the results were compared with different algorithms on the IEEE 33-bus network, which was able to reduce costs by 57.01%.