The general life history problem concerns the optimal allocation of re
sources to growth, survival and reproduction. We analysed this problem
for a perennial model organism that decides once each year to switch
from growth to reproduction. As a fitness measure we used the Malthusi
an parameter r, which we calculated from the Euler-Lotka equation. Tra
de-offs were incorporated by assuming that fecundity is size dependent
, so that increased fecundity could only be gained by devoting more ti
me to growth and less time to reproduction. To calculate numerically t
he optimal r for different growth dynamics and mortality regimes, we u
sed a simplified version of the simulated annealing method. The major
differences among optimal life histories resulted from different accum
ulation patterns of intrinsic mortalities resulting from reproductive
costs. If these mortalities were accumulated throughout life, i.e. if
they were senescent, a bang-bang strategy was optimal, in which there
was a single switch from growth to reproduction: after the age at matu
rity all resources were allocated to reproduction. If reproductive cos
ts did not carry over from year to year, i.e. if they were not senesce
nt, the optimal resource allocation resulted in a graded switch strate
gy and growth became indeterminate. Our numerical approach brings two
major advantages for solving optimization problems in life history the
ory. First, its implementation is very simple, even for complex models
that are analytically intractable. Such intractability emerged in our
model when we introduced reproductive costs representing an intrinsic
mortality. Second, it is not a backward algorithm. This means that li
fespan does not have to be fixed at the begining of the computation. I
nstead, lifespan itself is a trait that can evolve. We suggest that he
uristic algorithms are good tools for solving complex optimality probl
ems in life history theory, in particular questions concerning the evo
lution of lifespan and senescence.