Text this: Dynamic programming for the control of power quality in inbalanced medium voltage networks with distributed generation