Optimal thermal energy management of a distributed energy system comprising a solar membrane distillation plant and a greenhouse