Lonely Professor Frink uses science to turn himself into a man whom women find attractive. Then, overwhelmed by the attention, he invents an algorithm to perfectly pair the lonely men and women of Springfield, realizing that scientific exploration is his true love. Meanwhile, Marge, Bart, and Lisa visit Grampa for Valentine's Day and try to rescue the old folks from a drug-induced hallucination that allows them to relive their happiest memories.