I found today that placing a cut in an ideal loop causes it to become non-ideal, and adds a -100 penalty to the ideal loop filter. Placing a cut in a non-ideal loop does not increase the filter penalty. Placing a cut in a sheet or helix does not cause a score penalty. Placing a cut between a sheet or helix and an ideal loop does cause the score penalty. All of this could be used to check in a script if a loop is ideal or not.
Manually set all the SS before running script. Check score with filters on and filters off - difference is filter score. Find a loop. Place a cut in it. Check score with filters on and off. Did filter score go down by 100? If yes, the loop was already ideal - undo the cut. If no, the loop either a) was not ideal and needs to be worked on, or b) is currently considered to be part of a sheet or helix. Not sure how to tell these two conditions apart.