A procedure for automatic scheduling of distributed energy resources in medium voltage networks