Resource Allocation in Elastic Optical Networks with Physical-Layer Impairments