Cracking the Butterfly Code

A computer model could be the key to rescuing Hawaii’s disappearing butterfly

Brittany Moya del Pino
Published in
12 min readMar 19, 2015


On a weekday evening in Honolulu, Will Haines, a postdoctoral researcher at the University of Hawaii, wheels a large netted cage through the yellowed corridors of Gilmore Hall. Dozens of butterflies flutter against the walls, others rest on the leaves of a potted plant. Yellow banana mash is smeared in dabs on the sides of the cage to serve as food. Sponges are soaked in Gatorade to quench the insects’ thirst.

He pushes them into an elevator and presses “up,” to the roof, where they can take in the sunset. The glorious pinks that wash over the sky seem to put these butterflies in the mood for mating.

These are Kamehameha butterflies, Vanessa tameamea, one of only two butterfly species endemic to Hawaii. Their presence in these islands appears to be shrinking, and no one really understands why. If they die out in Hawaii, their species will have disappeared from the planet.

Haines’s cage houses the only captive-bred colony of Kamehameha butterflies in the world. His ultimate goal is to release them into the wild. But in order to save a species, you first have to know what it needs to survive. Haines has recorded, in detail, the numerous places where he and others have spotted the butterfly. But ecosystems are too complex to offer clear answers.

Rather than resort to guesswork, Haines and other conservation biologists have been turning to a computer program called MaxEnt, short for maximum entropy. Its power lies in a technique that handles uncertainty in data. It is, some say, a computational form of Occam’s razor — the principle that all else being equal, the simplest explanation is the best. This elegant, age-old idea may now help Haines overcome the limitations of his knowledge to secure the future of Hawaii’s favorite insect.

Photo courtesy of Dr. William Haines, University of Hawaii.

I met Haines a few months after moving to Oahu last summer, after I’d read about his work with the Kamehameha butterflies, which is called the Pulelehua Project. He’s a modest guy, age 37, with a quiet voice and thoughtful demeanor — more a back-country hiker than a surfer. He grew up on the rural island of Maui, the grandson of a biochemist who moved to the island to work in the sugar industry. Like a lot of kids, he was fascinated with bugs as a child, he said, “and somehow I never outgrew it.” Honolulu is almost unbearably crowded and noisy for his taste.

We sat at a black bench across from east-facing windows that frame the rising slope of Oahu’s Ko’olau mountain range. Though Hawaii is teeming with plants, insects and animals, the bulk of those species are invasive, he explained, and they are crowding out the natives. He pointed out some examples on the hillside visible through the windows, terraced with craftsman homes and palm trees. “Once you learn what the impacts are and recognize the invasives, you have a very different perspective on what you see here,” he said. “It’s pretty much a wasteland, in terms of native species.”

In a storage area down the hall of his lab, Haines keeps the Kamehameha butterflies’ eggs in plastic condiment cups in an incubator. Once they hatch, the chartreuse caterpillars also live in cups, surviving on food and moisture from leaves. The caterpillars are surprisingly endearing. They have heart-shaped faces and make cute little sleeping tents on the leaves of their host plants, the main one of which is a shrub called māmaki.

Haines knows that to reintroduce the butterflies into the wild successfully, it won’t be enough to place them on their favored trees and shrubs. If that was all it took, these butterflies should be easily spotted in mountain forests on places like Mount Tantalus, the 2,000-foot peak at the northern edge of Honolulu, where they were once common, according to lepidopterists’ records. For some reason, even though their host plants can be found on Mount Tantalus, the butterflies don’t live there anymore.

A week later, Haines allowed me to tag along on a hike on Mount Tantalus with him and his grad student, Colby Maeda, a sturdy 22-year-old from the Big Island whose grandparents emigrated from Japan in the 1920s. To avoid slipping on the muddy trail, Maeda wore weird, cloven-toed boots called tabi shoes, which have sharp spikes on the sole. Tabi shoes are the footwear favored by Japanese fishermen working on slippery ship decks, he told me.

We walked a trail high above the city at an elevation where the mountain is often obscured in cloud and where conservationists have been restoring native plants and pulling out invasive ones for the last 10 years. It’s an area that was once a haven for Kamehameha butterflies. On that day, it felt eerily empty. “They’re really good flyers; you’d think that the butterflies would come back to this place,” Haines wondered aloud, standing in a cluster of the butterflies’ host plant, māmaki, while it drizzled rain. “But that hasn’t happened yet.”

Attempts to restore wild populations can be risky if you don’t know which conditions matter most for a given species to thrive in healthy balance within its environment. Guesswork might lead to wasted resources, or even worse, an ecological catastrophe.

Instead of guessing, researchers like Haines are building computer habitat models that capture all they do know and gloss carefully over what they don’t. Using the program MaxEnt, Haines can generate an astonishingly sophisticated map of places where Kamehameha butterflies should be able to survive. The green and yellow zones on the map depict higher likelihood of suitable habitats. White squares mark where Kamehameha butterflies have actually been found.

Image credit: Dr. William Haines, University of Hawaii

What is maximum entropy and why is MaxEnt named after it? I asked a lot of people this question. One of the Princeton computer scientists who developed the software, a decade ago, gave me a cryptic response. I asked Haines, and he couldn’t really explain, either. I asked a few other scientists, and they recounted something similar to what I remember from college physics. “Entropy is disorder,” they said. Or, “Entropy is the loss of heat.”

It turns out that both of those definitions are incomplete. Entropy can represent disorder if you’re talking about a box full of marbles or a room full of gas. Entropy increase can also describe the process of transferring heat, such as when an ice cube melts on a warm counter. According to the laws of the universe, entropy always increases.

There is, however, another astounding angle to entropy. “Entropy is used to infer what’s going on in the world, independent of the subject.” Adom Giffin, an assistant professor of mathematics at Clarkson University, in New York, explained. Algorithms based on maximum entropy are used to process satellite images, make sense of human language, predict the spread of disease, and even calculate the probable hideouts of terror cells.

I thought the level of insight this algorithm seemed to gather about an ecosystem — about the distribution patterns of living creatures, not just marbles or ice — must be too good to be true. Eventually I tracked down Steven Phillips, who led the development of MaxEnt at Princeton and has since moved on to Colorado. “It’s not an assumption about the creatures, the living things,” he explained. “It’s more a philosophical question about what we should do about things that we don’t know.

“The maximum entropy principle says that if you don’t know something, don’t act as if you do,” he continued. “Don’t assume anything.”

To use MaxEnt, Haines first adds in the GPS coordinates for known Kamehameha butterfly sightings. Then he adds data related to the temperature and rainfall of those places, the sun exposure or cloud cover, the amount of wind and whether the topography is rocky or smooth. Most of this information comes from geographic information system (GIS) databases, such as those maintained by government agencies. Ultimately, he’s aiming for the sum of all that is known about the territory preferences of the butterfly.

Yet each sighting is unique—in terms of factors such as sun intensity — and likely to be biased, because people tend to spot butterflies mainly near hiking trails. These issues create massive uncertainty around what is truly optimal for the insect. MaxEnt cuts through all that haziness to determine what conditions distinguish the white dots on the map above from the the rest of the area under study. It then searches for similar conditions in places where you haven’t yet found your subject. To date, MaxEnt has been downloaded by more than 42,000 unique e-mail addresses around the world.

This formula represents an exponential model of the density of the species that is similar to, but not the same as, the formula used by MaxEnt. Source: William Fithian and Trevor Hastie (2013). Finite sample equivalence in statistical models for presence-only data. The Annals of Applied Statistics (7): 1917–1939.

David Nogues-Bravo, a professor at the University of Copenhagen and director of the International Biogeography Society, has been using these methods to model habitat changes for the woolly mammoth, which might be puzzling given that woolly mammoths have long been extinct. But he is checking whether the algorithm’s predictions match up with paleontological records of the woolly mammoth’s migration and extinction. So far, it’s a match. He has also used it to hypothesize where other creatures, such as new species of frogs, could still be awaiting discovery.

“I think the general public assumes that we know where a species is in every place of the planet, but really, we don’t know,” Nogues-Bravo admitted.

“New species might disappear before we can find them and study them,” he continued, “to understand what services they might provide to us — chemicals for treating different kinds of diseases, for example. And that’s what we would be losing…. It’s one of the most basic questions. But it’s also one of the most important questions.”

Scientists have been using MaxEnt to answer such questions as: Where should a particular species be able to survive in the present time? Where will it need to move in the future given the predictions for climate change? And, if a species invades new territory, such as an island, where might we expect to find it?

To strengthen their habitat model, Haines and Maeda have been gluing butterfly eggs and caterpillars onto māmaki leaves, returning a day or two later to look for signs of predation. Maeda spends hours in the forest standing watch over these eggs and juveniles, hoping to catch in the act what he thinks are the most likely suspects — certain spiders and parasitic wasps — so that the territory risk can be accounted for when they consider the MaxEnt maps.

Will and Colby attach the eggs to tiny pieces of wax paper using wood glue. Then, they dab wood glue onto the māmaki leaves and hope that rain doesn’t wash the eggs away. (Photo at left by Brittany Moya del Pino; photo at right courtesy of Dr. Will Haines)

Not everyone thinks that MaxEnt is the best approach for species habitat modeling. There are some who prefer different algorithms. Some biologists, like Regan Early, forge their own tools. Early is a conservation biologist at the University of Exeter, in the UK. She writes code that incorporates additional types of data , such as land-use ordinances, to improve her maps, which she hopes will spur governments in Britain and the rest of the EU to develop conservation corridors so that species can migrate where the model predicts that they will need to go in the future.

Nearly everyone I spoke with seemed to agree on one thing when it comes to species habitat modeling: They’re doing the best that they can with the information that they have. And that’s what drew me to this story in the beginning. Species habitat modeling programs like MaxEnt seem like the piece that we, the general public, have been missing in conversations about climate change. This is about finding a Plan B for creatures on our planet that might need our help adjusting to the consequences of our actions.

If the Kamehameha butterfly goes extinct, its loss probably won’t devastate the Hawaiian ecosystem. On the other hand, Jessica Hellmann, a researcher at the University of Notre Dame, suggests that because scientists know more about butterflies than most other insects, the loss of one species could be viewed as harbinger of what might happen to the overall class of plant-eating insects as our summers get hotter and our winters get colder.

The Kamehameha butterfly’s value is also cultural. The species is named after the first King Kamehameha, who unified the Hawaiian Islands in the late 1700s and whose dynasty ruled the islands for nearly a century. King Kamehameha is still a revered figure in these parts. You’ll see logos and bumper stickers everywhere that show the monarch with an oar in his hand, the underlying sentiment of which I understand to be something like, “Keep Hawaii Hawaiian.”

In 2009, a group of students in the gifted and talented class at Pearl Ridge Elementary School, on the leeward side of Oahu, proposed that the Kamehameha butterfly be adopted as Hawaii’s official state insect because it represents the “spirit of Aloha.” The state legislators agreed.

Photo courtesy of Dr. William Haines, University of Hawaii.

“When I’m honest with myself,” Haines shared later, “my motivation for practicing conservation and preventing extinction is not because we could not survive without these species, or that the ecosystem would crumble if we remove them. It is more that they are unique, beautiful products of millions of years of evolution, and it would be a shame to let them go extinct, if we can prevent it.”

As he works on deciphering what makes a suitable habitat, Haines is also stacking the butterflies’ odds in another way: He adds genetic diversity to the population in his cage. For that, he and Maeda drove to the North Shore in search butterflies living near an inland koa tree grove that was spotted recently by a nature photographer. Adult Kamehameha butterflies drink the sap of koa trees, which provide them with sugar and water.

The three of us hiked through bamboo groves and along steep hill faces that drop off to a stream far below. Periodically, Haines and Maeda showed the child-like fascination that Haines had mentioned earlier, stopping to admire cool beetles and stick bugs they spotted near the trail. We emerged two hours later into an area that looked distinctly different from what most people see at lower elevations. Absent are the lush, broad-leafed plants that most people think of as tropical. Instead, the hilltop is covered in a dense mat of native uluhe ferns that prevent non-native plants from encroaching on the koa grove. The koa trees are tall and thin, with slender, silvery leaves. They look almost rugged. In the Hawaiian language, the name koa means “warrior,” as well as a few related adjectives such as “strong” and “brave.”

Haines and Maeda set up two homemade butterfly traps using a mixture of bananas and beer in one tray and bananas and yeast in the other. But the butterflies ignored these baits. Instead, they flew high to drink from sap flows on the trees. Their folded wings blended perfectly with the mottled gray pattern of the bark, opening only occasionally to reveal a quick flash of pink.

Maeda netted the first female. Haines caught two more soon after. Gently holding their wings together, Haines slid them into glassine envelopes that prevent them from struggling. These he laid in a plastic food storage container, closing the lid. He placed the tub into his backpack, where the environment was cool and dark.

I checked in with Haines a couple weeks later. He told me that the females had laid eggs back at his lab. After these eggs hatch, the new adults will mate with the lab-bred adults to make babies with genetic fitness similar to butterflies born in the wild. Or at least, that’s what everyone hopes. But we won’t know for sure until later this year, or possibly early next year, when Haines and Maeda release Kamehameha butterflies into the yellow and green zones on their map.

Follow Backchannel: Twitter | Facebook



Brittany Moya del Pino

Freelance science writer and editor