Feeding dairy cattle with safe compound feed helps farmers to ensure food safety. However, several ingredients often used in compound feed production can be contaminated with aflatoxin B1 (AFB1), which may result into milk contaminated with aflatoxin M1. Given the number of ingredients and their amounts used in the production of compound feed, it is very costly to check every batch of ingredients for AFB1 contamination. Which is the reason, why a risk-based approach is taken in the latest years. This study aimed to estimate the probability of AFB1 contamination of compound feed for dairy cattle, and to limit this contamination, by optimisation of the compound feed formulation, using a modelling approach. The modelling approach comprised integrating a linear optimisation programming model to a Monte Carlo simulation model. This model was applied to the case of producing compound feed for dairy cattle in the Netherlands, using national monitoring data on AFB1 contamination in feed materials collected in the period 2000-2010. Results from this case study showed the model can be used to produce safe compound feed with the lowest possible probability of AFB1 contamination.