Duty is assigned in crew lobby on roaster basis. Usually a loco pilot get a section known to him and near to crew lobby station. Loco is assigned to his knowledge and experience specific to that type of loco. Fir example - if a LP know how to operate WDP-4D, he may get WDP-4D of any shed. Instructions/constraints related to loco or shed are clearly written inside loco.
If a LP is trained to operate both d-loco and e-loco, then both kind of loco can be assigned to him.