Perimeter and cost optimization