Improving the dissolved oxygen concentration and deriving an optimal sludge

You are a consultant who has been hired by a city to help reduce organic matter in their system while improving the dissolved oxygen concentration and deriving an optimal sludge to ultimately bag and sell as an agricultural soil conditioner. What equation(s) would you use to calculate the number of days the sludge must remain in the anaerobic digester in order to maximize volatile organic digestion and still produce a favorable sludge high in nitrogen and phosphorus? Be sure and explain the chemistry behind your equation selections.