A Context-aware Learning, Prediction And Mediation Framework For Resource Management In Smart Pervasive Environments