This is not a trivial problem to solve, as I would have to assume how your factory works and i would have to scan regularly and switch between sciences to try if it gets better, costing UPS and do weird switches.
still gone waste science packs then. at some point u only cycle endless techs.
so you either overbuild all outer planets packs what will always lead to spoiled packs or u cycle from hand.
both cases bother me :(
I know its not a trivial problem :) Setting research via circuits is something that was asked for often in the last years and now its more important then ever.
Maybe the devs will change it into the base game.
They should allow multiple researches at the same time.
That would solve the issue, since switching wastes productivity, while if you researched 2 things simultaneously at 50% speed, productivity could not be wasted and if the science packs for one are not here, just research the other tech without the speed halving.