On-farm fertilizer production optimization