Treatment effect optimisation in dynamic environments