Үүнийг мессежээр илгээх: Distributed optimization for structured programs and its application to energy management in a building district