Sorry, big post incoming, that's what I get for sleeping at night, but having an interest in the thread!
I apologize for not being clearer. It is easy to take things for granted when you spend all day staring at it.
Lets say, in your example, that the scripted target template says '4 light armour, 5 motorised and 1 infantry regiment' and is named 'light_armor_default'. The system goes through the existing template designs, finds the latest for light armor and matches it against the target, only the design does not have any infantry, but 4 light armor and 5 motorized. The largst of the design and the target relates to 5 + 4 + 1 = 10 slots, but only 9 of them are matching, because of the missing infantry. This would mean that the end calculation would be 9/10 = 0.9, so a match score of 0.9, or if you will; 90% matching.
Thank you very much

. I definitely understand it enough now to be able to play around and fill in any gaps. Sounds great btw, thanks as always, both for your work, and helping me keep up

.
still testing things, but there is a bonus you can get that reduces the air superiority needed (to say 0%). I'm looking at giving at least japan one after perl harbor gambit/strike usa so they can do surprise attacks.
I think this helps deal with a Taranto and Pearl Harbour, but adds other issues into the mix, and it all falls apart in terms of allied (mainly Commonwealth) raids against German and Italian ports before the Allies established air superiority over the continent. The Germans built u-boat pens in Kiel in 1941/42, long before the Allies had air superiority over northern Germany, and they built them because the allies were bombing them. It's also a fairly inconsistent fix in terms of intuitiveness, if it's possible to send strategic or tactical bombers in where there isn't air superiority, but port strikes are a no go, because the target happens to be a port instead of a factory or enemy unit.
Maybe, instead of requiring air superiority, tone down the damage (the vast, vast majority of port strikes didn't actually do a whole lot of damage - it's just people generally only talk about the port strikes that did

) of a standard port strike, and have the bonus be a bonus to the effectiveness of a port strike in special circumstances. That's likely to lead to more long-term plausible situations, rather than effectively removing a whole class of allied bombing missions from the game.
Longer term (this is more a suggestion, ignore if in a hurry/over me making suggestions

), in my dream of dreams, I'd prefer strategic and port bombing to be organised in a 'raid' based system (so air superiority remains iterative and over time, but bombing happens in discrete waves, like port strikes, but one element of these bombing raids is a combat resolution step against the level of defending fights, involving planes shot down, disruption and what-have-you). Raids would also have some kind of cooldown (preferably per plane, but maybe per-wing for ease of UI/calculation) representing maintenance, to reflect that fact that it wasn't possible for the bombers to be literally going on a raid every day (I'm afraid I'm all ships in the research at the moment, not sure where to go looking for a complete list of air operations to get an idea for how frequent sustainable raids would be).
That way, you could have air wings set to raid regularly (so it's not micro-ey), but bombing raids are still an event, perhaps with (optional) notifications after raids similar to port strikes, or after particularly successful raids, or something - would give the strategic air war more character, and engage players more with it. Everyone's talking about port strikes because they happen, while strategic bombing, despite involving some of the largest air operations in history, is a footnote.
In history, ports were for most of the war a safe haven. Fleets could sit in port for years and not be sunk by aircraft. Why was this? Defensive air superiority and AA at the port.
How is this then not a fix?
There are plenty of examples of bombing raids on ports taken out without air superiority. Brest, St. Nazaire, Kiel, and Naples, amongst others, were all bombed without air superiority. The issue is less that bombers didn't fly when there wasn't air superiority (they did, all the time, against ports and other targets), but more that bombing ports via level bombing was about as accurate as bombing cities through level bombing, which isn't very much. At the moment, port strikes are trying to represent the accuracy of low-level torpedo bombers, and dive bombers, surprising a port's defenders and achieving spectacular results (Pearl Harbour and Taranto) vs high altitude level bombing (Naples, Kiel, Brest, etc

, and they'll never, ever be able to do both with the same mechanic.
One thing to think about in regards to port strikes: the Germans were pretty effective at mitigating the effect of the strikes on their submarine bases by building protective concrete fortifications. I don't believe they ever tried to extend this protection past submarines, since they weren't much interested in a surface fleet, but I would think in theory that it would be possible if you put enough resources into it. You wouldn't save the port from damage, but you would mitigate the effect on the ships. Is this something that we'd consider "covered" by the game's current defensive buildings?
This is a really good idea. The British stopped bombing Brest because they couldn't penetrate the u-boat pens, so the Germans were able to operate submarines from (metaphorically) right below the nose of bomber command.