There's
mod_macro that might be useful. I don't think it does calculations, though, so you might need to do some things yourself. Maybe you could indeed generate the conf files yourself and use
Include or
IncludeOptional.
I'd like to note that generating port numbers based on domains might work, at first, but if you delete a domain from the list, the numbers will shift. So, a=>16010, b=>16020, c=>16030, etc, becomes a=>16010, c=>16020, for example.
For doing the actual reverse proxying, you should probably read
this and/or
this.