On the Optimization of Multiple Applications for Sensor Networks