A linear optimisation model for distributed energy systems