A method for controlling he milking by a milking machine comprises the
steps of: (i) controlling (47) a milking vacuum so that the milking
vacuum is varied through the vacuum levels of a given range, while a
milking animal is milked by the aid of the milking vacuum; (ii)
monitoring (43) a milk flow from the milking animal during the variation
of the vacuum levels; (iii) setting (49) the milking vacuum to the lowest
vacuum level of the given range, for which the milk flow from the milking
animal is at least a given fraction of the highest milk flow monitored
while the milking vacuum is varied; and (iv) keeping (51) the milking
vacuum at the set vacuum level during a following part of the milking of
the milking animal.