OPTIMIZING THE OPERATION AND ALLOCATING THE COST OF SHARED ENERGY