This paper proposes a model to the optimal management of a complex DC microgrid with advanced forecasting method for photovoltaic generation. The strategy is aimed at minimizing the daily total energy cost using a very short-time predictive control procedure. At first, the predicted power of the renewable generation unit is obtained by using an innovative forecasting approach based on the Bayesian technique and Monte Carlo No-U-Turn Sampler method; at a later stage, the predicted power and all the relevant parameters are introduced in a solver for the optimization problem developed in Python language. Finally, the goodness of the model is tested introducing a significant case study. © 2015 IEEE.