A Cost-Based Model for Service Discovery in Smart Environments