An adaptive agent-based system for deregulated smart grids