Optimizing quantum control pulses with complex constraints and few variables through autodifferentiation