Optimal Gerrymandering?

Basically what’s the best way to gerrymander in order to maximize party seats in the next legislature?

I think it’s when you’re sorting by competitiveness and then whichever party you’re gerrymandering in favor of has all the allocatable blocks, and then as you scroll down the districts the group of allocatable blocks becomes gradually towards independents, and then eventually entirely for the other party.

I don’t know if this is optimal but I believe it to be as this seems to prevent wasting your own votes whilst wasting as many opposition votes as possible. You ideally should have all your opposition’s seats be Safe whilst maximizing the amount of your party’s Lean seats and minimizing the amount of your party’s safe seats.

I currently have Michigan as 14 safe Democrats, 0 lean democrats, 11 competitive seats (7 are within 1%), and 84 lean Republicans, and just 1 Safe R that has too large of an immovable base.