In the future, China will shut down a factory before it even pollutes -- or so it hopes, as it deploys big data in the fight against bad air.
In Beijing's environmental bureau, a team of engineers tend to giant mainframe computers that keep a watchful eye on the city's pollution.
Using everything from factories' infrared profiles to social media posts, the machines can call up three-day pollution forecasts with resolution of up to one kilometre squared and detect trends up to 10 days out.
The computer program, developed by IBM, is one of several high-tech measures, ranging from drones and satellites to remote sensors, that China is deploying to deal with its chronic pollution.
It seeks to solve an incongruous reality: In a country where security cameras are ubiquitous and Communist authorities operate a vast public surveillance system, accurate information about pollution remains scarce -- even to officials.
As a result, Beijing and its neighbouring provinces "can't coordinate joint defence and joint control" of their anti-smog efforts, leaving rogue companies to "secretly discharge and secretly dump", said Chen Long, chief executive officer of Encanwell, which develops air quality monitoring and early warning systems.
The company is trying to achieve total pollution awareness: the ability to know, with perfect accuracy, where haze comes from and use that information to predict and preempt its future sources.
China has found itself in a double bind in the face of a relentless assault from bad air that put the capital on its first-ever air quality red alert this month.
Ahead of the 2008 Olympics, China closed factories across the region, halting construction and pulling half of all private cars off the roads. It was an effective strategy, but came at an estimated cost in the hundreds of millions of dollars.
Ensuring blue skies for major events such as last year's APEC summit, the World Athletics Championships in August and a World War II anniversary parade, required a similar brute force approach that inflicted collateral damage on the economy in the country, where growth is slowing.
Failure to act, on the other hand, runs the risk of inflaming public discontent -- a perpetual source of concern for the government, part of whose claim to legitimacy rests on maintaining an image of supreme competence.
"It's a complicated problem. It has an impact on society, on industry, on the economy, on health," said Herve Robin, chief technology officer of Airvisual.com, a China-based social enterprise developing tools for a global pollution monitoring network.
Choking pollution descended on Beijing twice in the past two weeks, and the country's meteorological bureau expects it may come twice more before the month is out.
"If each time the weather conditions are not good for pollution, they shut down everything, then it would be every week," Robin said.
Improving prediction capabilities through increased monitoring is a key part of the plan to trade in the country's anti-pollution sledgehammer for a scalpel.
In July, leadership in Beijing vowed to establish a national network for detecting pollution that will incorporate multiple technologies on land, in the air and space.
So far, the IBM software has achieved only 75 percent accuracy for its 10-day forecasts, developers say.
The hope is that by the time Beijing hosts the Winter Olympics in 2022, the technology "will be able to target specific activities in particular locations and times with the maximum effect, but with much less impact on economic activity and the daily lives of citizens", said Zhang Meng, an IBM scientist working on the project with Beijing.
But despite progress in digital monitoring, dealing with polluters is still primarily an analogue process.
During Beijing's red alert this month, the country's environmental bureau dispatched 12 teams of inspectors to deal with thousands of companies in high-polluting industries in the capital and surrounding areas.
The city's social media account posted a running log of its own enforcement efforts, including fines for factories that had failed to activate legally required pollution reduction systems.
Some factories install the equipment but do not use it "because it costs money to run" and affects productivity, Robin said.
Currently, the capital has fewer than 40 govermnent environmental monitoring stations. Achieving the resolution necessary to precisely pinpoint polluters in a "big city like Delhi or Beijing or Paris, takes a couple of thousand", according to Robin.
The capital may someday achieve that level of surveillance, but for the time being "you have to start from where you are," Shen Xiaowei, director of IBM's China research, told AFP.
"The physical world has not been perfectly monitored -- yet."