Microgrids comprise a variety of distributed energy resources, energy storage devices, and loads. The majority of sources are not suitable for direct connection to the electrical network due to the characteristics of the energy produced, such as low voltage DC power from fuel cells and PV arrays or high frequency AC power from microturbines. Therefore, voltage source converters (VSCs) are required to interface them with the network. In microgrids with the DC distribution network, the DC voltage reference setting for the VSCs operating in the voltage regulator mode, and the optimal power reference settings of the remaining VSCs working in the power dispatcher mode must be pre-determined to maintain the DC voltage within desired margins. In this paper, the problem has been formulated as an optimization problem with VSCs switching and conduction losses selected as the objective function. Computational intelligence techniques, including genetic algorithm (GA) and simulated annealing (SA) based optimization methods, have been employed to solve the optimization problem. The results of the optimal power flow have been compared with a conventional power flow.