A smart hierarchical transactive energy system in the presence of renewable energies, and demand-side management