We introduce a model for the global optimization problem of nectar harvesting by flower visitors, e.g., nectar-feeding bats, as a generalization of the (multiple) traveling-salesperson problem (TSP). The model includes multiple independent animals and many flowers with time-dependent content. This provides an ensemble of realistic combinatorial optimization problems, in contrast to previously studied models like random Satisfiability or standard TSP. We numerically studied the optimum harvesting of these foragers, with parameters obtained from experiments, by using genetic algorithms. For the distribution of travel distances, we find a power-law (or Levy) distribution, as often found for natural foragers. Note, in contrast to many models, we make no assumption about the nature of the flight-distance distribution, the power law just emerges. This is in contrast to the TSP, where we find in the present study an exponential tail. Furthermore, the optimization problem exhibits a {phase transition}, similar to the TSP, at a critical value for the amount of nectar which can be harvested. This phase transition coincides with a dramatic increase in the typical running time of the optimization algorithm. For the value of the critical exponent nu, describing the divergence of the correlation length, we find nu=1.7(4), which is on the other hand compatible with the value found for the TSP. Finally, we also present data from field experiments in Costa Rica for the resource use for freely visiting flower bats. We found that the temporal patterns in experiments and model agree remarkably, confirming our model. Also the data show that the bats are able to memorize the positions of food sources and optimize, at least partially, their routes.