Hi Alessandro,
Nice work!
I'm attempting to do a similar thing in TRACE 2.
So far I have the internal structure in place which I call MIM... Material Imbalance Matrix.
It is basically an array indexed by the number of pieces of each type and colour.
The array covers all the usual combinations of pieces/pawns.
There can be 0 to 8 pawns for either side.
WN,WB,WR,WQ,BN,BB,BR and BQ are limited to a max of 2 - to keep the array size reasonable - otherwise it just returns MIM_UNKNOWN and I let the eval handle it impartially.
The array is by nature symmetrically redundant for white and black - I haven't yet worked out how to take best advantage of this fact - and thus reduce the memory/cache overhead. (I think you would solve this issue quickly.)
Each individual record contains:
1. a favourability factor (this is the 'hard to tune' part)
2. a recognizer constant eg KNNKP, KPPKP - so I can directly call a custom eval routine for simple endings.
3. who can win flags... to recognize dead draws and/or draw boundaries
4. a drawishness factor.
I don't keep track of bishop square colour yet although I know I should as this is very important in material imbalances. But, its 'early days', and its not hard to modify the structure to include it.
Its kind of funny that we have worked in exact reverse - you have completed the PGN analysis and I've done the internal representation.
We were collaborating without knowing it
I don't normally share code (because people would laugh at it) but you are welcome to my mim.h and mim.cpp modules. Just drop me a line.
BTW, my wife Trace ___loved___ her trip to Italy in April this year - love is just not a strong enough word, I have the photos to prove it... we are now both bonified Limoncello aholics. Anyway! Back on topic....
Conceptually, MIM should work well as long as the eval doesn't duplicate the effects of the material imbalances... ie. by applying bonuses twice by mistake... for example the two bishops would already be rewarded in the mim favourability factor...
As to your questions...
Now for the help request! Smile I have several questions...
1) what do you think of this approach?
2) can you spot some mistake or need more information?
3) if the approach is good, what could be a good way for an engine to use this data?
1. I think you are a genius.

2. Maybe human GM games would be a more reliable source of MI knowledge. Maybe not.
3. As mentioned, the MIM matrix would be a brilliant approach, sublime for its simplicity, excellent for its elegance, and ingenious for its ingenuity.
Erm, yes, I'm a complete idiot at the best of times.
Hope this helps you, cheers!
Ross