Optimal merging of rolls near a plane boundary