Optimal management of resources to safeguard the environment