Resource and Task Allocation in Distributed Environments . A Multi-Agent System Approach