A computational strategy for geometry optimization of ionic and covalent excited states, applied to butadiene and hexatriene.