Researchers at the University of California, riverside have created a computer program for plug-in hybrid electric vehicles that learns how to save fuel, improving fuel efficiency by more than 30 percent.

P.H.E.V.S. Can use either gasoline or electric power. Lab tests have shown the most efficient way for them to run is to switch between power from the battery and gas throughout the trip, rather than running exclusively on the battery then switching to gas when it runs out.

The key to optimizing fuel efficiency, then, lies in making the vehicle learn when to use which energy source, according to Matt Barth, who led the research.

The number of electric vehicles — including P.H.E.V.S., battery-electric and fuel cell electric passenger light-duty vehicles — on roads worldwide rose to a record high of 2 million in 2016, but the vehicles are still only a small fraction of new cars sales.