With the tip of her syringe, Brandi pokes at a grey lump of heroin in a spoon. It’s a new variety of the drug that has shown up on the market in the past few days, and Brandi likes it. “I feel this more, I feel more of the pain resistance,” she says.

Once it has dissolved into a liquid, she injects it into her arm, then uses a fresh needle to inject the skinny arm of another woman. “She does it better than the hospital,” the woman comments.

“I’ll help anybody who needs it,” Brandi explains to public-health researcher Daniel Ciccarone of the University of California, San Francisco, who has been filming the entire process.

Ciccarone’s team has embedded with Brandi — whose name has been changed for this story — in Charleston, West Virginia, documenting her interactions without judgement or interference. Later, the group will analyse this video, in addition to half a dozen other videos of drug users from across the city, logging details big and small. Brandi does not heat the solution on the spoon, for instance, and that may increase the likelihood of spreading viruses such as HIV. And tests reveal that what she’s taking has been laced with fentanyl, a synthetic drug up to 50 times more powerful than heroin.

The researchers will plug these data into powerful computer simulations of Charleston, populated by thousands of virtual Brandis — heroin users and dealers going about their daily routines. They will watch these digital agents buy more heroin as their tolerance increases, form networks with sellers and users and, in some cases, accidentally overdose.

Ciccarone’s is one of several groups using agent-based models to understand what is driving the US opioid epidemic — the dramatic rise over the past two decades in the use of opioids, including prescription pain medications and illegal drugs such as heroin. By studying the motivations and practices of real drug dealers and users, the researchers hope to build agents whose behaviour in the virtual world mimics that in real life.

“We’re trying to turn everything we observe around us into mathematical terms.”

Agent-based models promise to provide a more granular view of the opioid crisis than standard modelling, which is based on average populations, and to capture some of the complexity of the driving forces. This could prove important for demonstrating the effects of opening or closing methadone clinics or needle exchanges. The models allow scientists to compare interventions at almost no cost and could help policymakers to decide how to proceed in the real world. “It’s a very classic and useful way to try and see where is the best place to deploy an intervention to have the biggest effect,” says John Brooks, a medical adviser for the division of HIV/AIDS prevention at the US Centers for Disease Control and Prevention (CDC) in Atlanta, Georgia.

Although such simulations have long been used to model disease outbreaks and have, in some instances, guided public policy, their track record with more complex social behaviour such as drug use is limited, largely owing to sparse data and the breadth of parameters to consider.

Still, scientists hope that agent-based models can lay out scenarios for decision-makers, who are often driven more by politics than data. “The barriers are not scientific or medical,” Ciccarone says. “You can throw $1 billion at West Virginia, and they may or may not know how to use it well.” These virtual worlds can add clarity, says Joshua Epstein, director of the Agent-Based Modeling Lab at New York University. “You can literally watch the thing unfold before your eyes,” he says.

The difference in the details

The US opioid crisis is estimated to kill 115 people per day through overdoses, and has run up US$1 trillion in health-care costs and lost productivity since 2001. It is not the first addiction crisis that the United States has faced, nor is it the most severe. Alcohol use causes many more deaths, and the rate of cocaine overdose among African Americans is similar to the rate of opioid overdose in white Americans1.

But the opioid crisis does have some different driving factors, including the prevalence of prescription drugs, which many have used on the way to abusing illegal drugs, and the introduction of fentanyl, which is often used to boost the potency of heroin and is responsible for a large share of overdose deaths. The epidemic has also hit hard in rural settings, where services and infrastructure for dealing with addiction are scarce. “The demographic now encompasses a population that in the past has not been so affected,” says Nora Volkow, director of the US National Institute on Drug Abuse in Bethesda, Maryland.

As a result, researchers are coming up with fresh ways of thinking about the crisis. It bears similarities to a disease epidemic, for example, in the way it spreads through networks based on personal relationships and physical proximity, says Georgiy Bobashev, a data scientist at the non-profit research institute RTI International in Research Triangle Park, North Carolina. “Nobody is born an addict. Somebody has to teach you how to smoke or how to inject.”

A drug addict outside a suboxone clinic

Youngstown in Ohio has high rates of unemployment and opioid addiction.Credit: Spencer Platt/Getty

These personal networks can be replicated using agent-based modelling. Unlike other types of model, which may rely on average characteristics or relationships between homogeneous groups to inform algorithms, agent-based models allow researchers to see subtle connections between people. “That’s useful because drug use and overdose is inherently personal,” says epidemiologist Brandon Marshall of Brown University in Providence, Rhode Island. Factors such as job loss, mental health or genetics can influence how likely a person is to begin using drugs or become addicted, but those factors might fade into the averages if researchers looked at a population as a whole.

To create an agent-based model, researchers first ‘build’ a virtual town or region, sometimes based on a real place, including buildings such as schools and food shops. They then populate it with agents, using census data to give each one its own characteristics, such as age, race and income, and to distribute the agents throughout the virtual town.

The agents are autonomous but operate within pre-programmed routines — going to work five times a week, for instance. Some behaviours may be more random, such as a 5% chance per day of skipping work, or a 50% chance of meeting a certain person in the agent’s network. Once the system is as realistic as possible, the researchers introduce a variable such as a flu virus, with a rate and pattern of spread based on its real-life characteristics. They then run the simulation to test how the agents’ behaviour shifts when a school is closed or a vaccination campaign is started, repeating it thousands of times to determine the likelihood of different outcomes.

In 2015, data from an agent-based model2 developed at the University of Pittsburgh in Pennsylvania helped California state senator Richard Pan to gain support for a bill on mandatory vaccination in his state. Pan used the simulation to demonstrate to his fellow senators how measles outbreaks could unfold in their home districts. “It certainly made an impact on them,” Pan says. “Instead of just describing it in more abstract terms, [the model] can make it more concrete.” The bill ultimately passed, and immunization rates increased.

As computers have improved, researchers have begun adapting agent-based models to look at sociological and behavioural trends that require more computing power because of the number of variables they contain. Some groups use the technique for crisis modelling, and Australia has begun intervention studies for child obesity on the basis of the findings of an agent-based model.

In response to the opioid epidemic, Bobashev’s group has constructed Pain Town — a generic city complete with 10,000 people suffering from chronic pain, 70 drug dealers, 30 doctors, 10 emergency rooms and 10 pharmacies. The researchers run the model over five simulated years, recording how the situation changes each virtual day.

During this time, the patients’ drug tolerance increases, leading them to find different ways of acquiring drugs. Their behaviour is driven by variables such as the chance that a doctor will increase their prescription, or the likelihood that a dealer will have enough heroin. At a certain threshold, patients become addicted or more likely to overdose. Bobashev’s early data suggest, for example, that requiring doctors to track patients’ medication history can be effective over the long term, but not immediately3.

The model contains many assumptions and simplifications, Bobashev says. For example, it doesn’t capture the fact that the rate at which people develop tolerance and addiction can depend on factors such as genetics, and that whether a person switches from prescription drugs to heroin can depend on the relative availability of the two drugs.

But researchers can adjust models such as Pain Town to test various interventions, such as increasing access to emergency rooms, arresting a dealer or equipping police with naloxone (a drug that reverses opioid overdoses), to see how the system reacts and whether it affects the number of deaths over time. And as models become more sophisticated, the researchers may be able to incorporate more factors, such as people who are not taking pain medications but are susceptible to trying opioids for the first time.

Models can also be useful for understanding why individual places or situations may differ, says Christopher Barrett, a computer scientist at Virginia Tech in Blacksburg. For instance, heroin and fentanyl might be easier to come by in cities near ports, whereas doctors may be the main source of opioids in a suburban or rural setting. Interventions focused on prescribing practices, therefore, would have different effects in each case.

Such models can also reveal feedback loops, such as the link between economic downturns and opioid use. Some epidemiological studies have suggested that factors such as unemployment tend to predict suicide and addiction, especially in white male populations. And addiction can lead to further job loss and lower productivity, harming the economy. Agent-based models could investigate loops such as this, providing ideas for how to mitigate the effects, Barrett says.

In May, Bobashev and Ciccarone presented results from one of their agent-based models at a meeting of the International Society for the Study of Drug Policy in Vancouver, Canada. Their findings suggested that the increased prevalence of white-powder heroin — a newer form of the drug in the United States — may increase the risk of HIV spreading among injection drug users. The reason, also supported by the model, is that unlike black-tar heroin, users don’t need to heat the drug to dissolve it — and heating kills the virus.

Bobashev and Ciccarone are working on models of how younger heroin users begin using the drug. Unlike older users, who experienced the rise of the HIV epidemic in the 1980s, newer users may be less likely to adopt safe practices. The models suggest that the United States may see more localized HIV outbreaks, similar to the recent outbreak in Scott County, Indiana. That region experienced 181 new HIV cases between November 2014 and November 2015, compared with fewer than 5 cases per year previously. Opioid use is thought to be the cause. Agent-based models might help to stem future outbreaks by guiding surveillance priorities.

Bags of drugs bagged up by law enforcement agents

Law enforcement officials have been seizing vast quantities of heroin and the powerful synthetic drug fentanyl, but information on the amount in circulation is hard to come by.Credit: Drew Angerer/Getty

One of the most sophisticated agent-based models is the University of Pittsburgh’s system, known as FRED (A Framework for Reconstructing Epidemiological Dynamics). It fits population census data to maps of geographical regions around the country, allowing researchers to track virtual individuals in the area in a realistic way. It was data from these models that helped to convince Pan and his fellow state senators to pass legislation on mandatory vaccination. The FRED team is now beginning to use the system for opioid modelling, training it on historical trends. Pan, who is also a physician, says he is intrigued by the prospect. “If there’s a way to actually model in different communities which factors would have the biggest impact, that would be helpful,” he says.

Data drought

The models face numerous challenges before they will be ready for widespread adoption, primarily data gaps. Marshall says that researchers struggle to get access to data on opioid prescriptions that are held by manufacturers, pharmacies and law-enforcement agencies. It is also difficult to obtain government information on drug cartels and the type and rate of drugs flowing into the country. Other data simply do not exist in usable form: agencies may record deaths due to drug overdose, for instance, but fail to specify which drug was responsible.

Observing drug users such as Brandi can provide certain types of information more quickly and accurately. “Drug users know their chemicals intimately,” Ciccarone says.

Lee Hoffer is a cultural anthropologist at Case Western Reserve University in Cleveland, Ohio, who studies heroin markets and collaborates with Bobashev. He says the ethnographic data that his group and others are collecting could help to fill some of the information gaps: “We’re trying to enter their world as interlopers to see how they see their life.” After an initial awkward period, he says, drug users tend to become more honest with the researchers, telling them crucial information such as how they form networks with dealers and the cost of drugs.

Understanding the psychology of drug users is also crucial, says Epstein. Most decision-making models assume rational behaviours. In reality, emotions, misinformation and irrational calculations play a major part. “When you put them together you get collections of dynamics that are very dysfunctional.”

Epidemiological data may soon be available to buttress the models. The CDC and the US National Institute on Drug Abuse have started several major surveys of drug-use patterns. A number of states have also begun collecting epidemiological information on trends in overdose and addiction. And research groups such as the University of Pittsburgh team are working with multiple health agencies to collate their findings in a single database, which can inform FRED and other models.

But no matter how advanced the models become, implementing interventions based on their findings is an enormous challenge. Models may reveal socioeconomic contributors that cannot be easily addressed by policies, and politics can stand in the way of proven solutions. In April, Ciccarone had to cancel his work in Charleston, at least for the time being, after a needle-exchange clinic with which he had been collaborating closed owing to political pressure. “They were seeing 300 people on a Wednesday afternoon because there’s a lot of need,” he says. “It’s a huge loss.”

Increasing work is being done to determine the relative impact of interventions. The US National Institutes of Health (NIH) in April announced $96 million for a programme that will partner with health-care systems and local governments to carry out evidence-based public-health interventions in different locations, evaluating them as they go. “This is the first time this [has been] done for a particular substance-abuse disorder,” says Volkow. The NIH is now asking researchers who want to apply for these funds to justify the size and scope of their proposed studies with data from models, including agent-based models.

But these studies will take many years to complete. And Bobashev says that society cannot afford to wait for the science to be perfect. “By the time this data is collected, tens of thousands, if not hundreds of thousands, more deaths will have occurred.”