SF should just figure out a way to keep homeless off public transit. Perhaps they could charge nominal access fees that could be waived by a DL, passport or other proof of residence, and use the extra revenue to fund improved security.
They don't need to do that. Being homeless doesn't mean you are necessarily lacking in morals and public decency. They need to find some way to enforce reasonable behaviour from their paying passengers of whatever status.