In the (famous) Trolley Problem (https://en.wikipedia.org/wiki/Trolley_problem) - a runaway train is out of control and unfortunate people are stuck on two different railway tracks. The railway conductor has a choice to make in deciding which track he should divert the train to:

enter image description here

To me, this sounds like a very (grim and depressing) optimization problem - but does anyone know if this problem has ever been studied from a mathematical perspective?

For example, suppose there are many trains, many tracks and many unfortunate people stuck on these tracks - theoretically, could this be interpreted as a very (grim and depressing) scheduling/allocation problem in which the goal is to decide which tracks to divert which trains to, such that the minimum number of victims are injured?

Is there any literature in which similar types of problems are studied, in which a general form of the Trolley Problem is specifically mentioned?

  • 1
    $\begingroup$ To find relevant literature, first combine your Question's title and exposition, then reduce the combination to a useful precis. Otherwise, why would you even consider about such blatant thinkin? In human terms, it could never matter how many trains or tracks there were; only the unfortunate people… In mathematical terms, how many of anything should be all that mattered. How are those perspectives comparable? $\endgroup$ Commented Mar 13, 2022 at 21:38
  • 2
    $\begingroup$ It is supposed to be absolutely obvious which solution would cause the least harm, that's the point. The question is then; would you take an active action that does harm, if doing nothing leads to greater harm? $\endgroup$ Commented Mar 14, 2022 at 12:42
  • 5
    $\begingroup$ The trolley problem is an optimisation problem in the same way that it's a railway engineering problem. $\endgroup$
    – dbmag9
    Commented Mar 14, 2022 at 14:11
  • $\begingroup$ I'm not sure this is close enough for you, but possibly something along the lines of triage problems, public policy, especially public health policy, that kind of thing? en.wikipedia.org/wiki/Population_impact_measure $\endgroup$ Commented Mar 15, 2022 at 20:05

8 Answers 8


I totally agree with @JorisKinable, that the problem can be formulated as some version of a network flow problem if a clear objective function is known.

But that seems to be the very essence of the Trolley problem: there is no single, clear-cut objective function. If it was just a question of injuring the least amount of people, the problem is trivial in the original version depicted in the picture1. But it is an ethical conundrum, where you cannot objectively quantify the outcome of a decision. Hence, I am inclined to say no, this is not an optimization problem.

1 It is not necessarily trivial in more complicated situations

  • 7
    $\begingroup$ Indeed. Utilitarianism is the idea that ethical actions are those that maximize happiness and well-being, which we can view as an objective function. The trolley problem is often viewed as an argument against a strict utilitarian perspective on ethics. $\endgroup$ Commented Mar 13, 2022 at 13:43
  • $\begingroup$ If it was just a question of injuring the least amount of people, the problem is trivial. Are you saying the network flow problem is trivial even in OP's scenario of "many trains, many tracks and many unfortunate people stuck on these tracks"? Trivial in that a solution method is known, but not trivial computationally, right? $\endgroup$
    – nanoman
    Commented Mar 13, 2022 at 17:30
  • $\begingroup$ It is certainly not trivial finding an optimal solution in the many tracks, many trains, many people case in the sense that a closed form necessarily can be provided. So that statement might have been a stretch $\endgroup$
    – Sune
    Commented Mar 13, 2022 at 17:53
  • $\begingroup$ @Sune 1. I happened to come back and see your reply, but please remember to @. By default, comments are understood as directed at the writer of the question or answer where they are posted (here, yourself), unless @'d at a previous commenter. (My @ to you here is redundant but included for clarity.) Moreover, a previous commenter is not notified of your response unless you @ them. 2. If you acknowledge that your answer contains a "stretch", will you revise it? $\endgroup$
    – nanoman
    Commented Mar 14, 2022 at 9:01
  • $\begingroup$ @MichaelSeifert actually all it takes to end up right back in a strict utilitarian perspective is to imagine a hidden nuke that goes off when you touch the handle. The law of unintended consequences will have it's due. When you play god, don't get it wrong. And beware trolleys bearing ethical conundrums. They indicate some philosopher is messing with you. I mean, who ties people to railroad tracks these days? $\endgroup$ Commented Mar 15, 2022 at 21:58

No, the main point is the ethic behind the choice.

Pulling the lever minimises the number of deaths, but it requires an active action resulting in the death of a person. Not doing anything increase the number of deaths, but removes the burden of the decision. How do we weight action vs inaction is subjective, and whether we should force people to "pull the lever" is also debatable.

So any mathematical treatment is really missing the point and solving another problem. For instance they may solve what should we do in a complicated situation with many trains and switches, but assuming we already know what we would do in the single train scenario.

  • $\begingroup$ I think your answer captures most of the trolley problem, as it is about which "cost function" to choose to define the problem (e.g., minimize the number of dead people, equal chances for all people, etc.) But OP is asking for variants of the problem. And for example, the prisoner's dilemma does not have a solution, but the iterated prisoner's dilemma can be seen as an optimization problem. So variants with more than two railway tracks may also have a solution that does not exist for just two tracks. $\endgroup$
    – allo
    Commented Mar 16, 2022 at 10:32

“Nothing takes place in the world whose meaning is not that of some maximum or minimum.” ― Leonhard Euler

But as in many theoretical and industrial problems, the main difficulty is not to formulate the problem, but to define the objective function...

I think at least two types of costs should be considered: how many people are killed and whether you take actions. Then it is an open question that how one should set the coefficient.


This problem can be formulated as a network flow problem. Each train is a commodity. The train network is represented as a graph. The cost of using an arc is equal to the number of people killed. The trains need to be moved from their origin to their destination with minimum total cost. I don't know the specifics of this bizarre problem, but things get a little weird if 2 trains can use the same arc: does the first train kill the people and the second train gets to use the arc for free? You could treat this variation as a fixed charge network flow problem.

Definitely one of the weirdest questions I've seen.

  • 1
    $\begingroup$ Upvote even throwing away all the ethical dilema and being utitilitarianist about the train delas... $\endgroup$
    – bruno
    Commented Mar 13, 2022 at 23:53

I cover this scenario in my ethics class for IT, so I would like to share my perspective. The trolley problem is a hypothetical scenario that is often used to highlight the issue of imperfect information in utilitarianism.

A very common argument is: the five people are a family, and the single man is a railworker without a family. You calculate the lost happiness, and decide to flip the switch to kill the single man.

What you don't know is that that single man was working as a railway assistant in his spare time as a student, and he was developing a cure for cancer. By sparing the lives of five, you have stopped the cure for cancer and millions will die as a result. The argument is that you could not have known. Not only is this a split-second decision which would affect your access to information, but even if you had all the time in the world to deliberate, you don't know all the "what ifs".

So you essentially operate under an assumption of fixed, incomplete information. What I want to say with my answer, is to consider this an imperfect information issue, on which there is of course plenty of research on.

  • $\begingroup$ A bigger question should be whether either group had made any effort to ensure that wouldn't get splatted. If the railway assistant had notified control that he would be on the line and followed procedures to acquire signal ownership of his block, and the group of five had not followed such procedures but ignored warnings that a train was coming, signalling control should protect the person who followed procedures, rather than the group that created the "dilemma" by their failure to do so. Had the group of five followed procedures, the trolley would have gotten a yellow (caution) signal... $\endgroup$
    – supercat
    Commented Mar 15, 2022 at 15:00
  • $\begingroup$ ...at the entrance to the block before the switch (and possibly the block before that as well), and thus have had time to slow down and stop at the red (danger) signal located just before the switch. While the person in immediate control of the switch might not have a detailed record of all signalling notifications immediately available, the fact that the switch was configured to direct the train toward the group of five would suggest that it was more likely that the lone worker had followed procedures than that the group of five had done so. $\endgroup$
    – supercat
    Commented Mar 15, 2022 at 15:04
  • 1
    $\begingroup$ @supercat uh, that's an extremely subjective call on your part. additional context will help people make better decisions, but it doesn't replace the need to decide how you will evaluate that information. Your solution takes a punitive, personal-responsibility-based approach that many would disagree with. $\endgroup$
    – user371366
    Commented Mar 15, 2022 at 21:17
  • $\begingroup$ @supercat : this has actual implications on self-driving cars. The trolley problem wasn't designed as a real-life analogy, but it might become one for self-driving cars. Should a self-driving car sacrifice its lone occupant to save five pedestrians (for example, if the brakes suddenly stopped working)? Should that decision depend on whether the pedestrians are crossing the street legally or are jaywalking? $\endgroup$
    – vsz
    Commented Mar 16, 2022 at 9:39
  • $\begingroup$ @vsz there is a fantastic website that covers tons of these scenarios: moralmachine.net $\endgroup$
    – marts
    Commented Mar 16, 2022 at 10:30

In a way, I suppose it could be, but at the same time I don't believe it is.

Assuming all variables are known then it could be considered an optimisation algorithm - and self-driving cars would probably have to face at some point (i.e. "I can't stop in time and there's oncoming traffic - do I plough into the pedestrian in my path, or swerve into the oncoming traffic?").

HOWEVER, the whole point of the trolley problem is that you can't possibly know all of the variables in those kind of situations. That's what makes it an ethical conundrum, not an optimisation algorithm... Although, the subjective decision of what to do in answer to this ethical conundrum could be used to drive optimisation algorithms.


This is an ethical problem not a mathematical one. The main question is about determining the cost function to make the choice.

If the cost function were known, there is no mathematical issue. The choice with the lower cost would be taken.

Ethical impacts are much more interesting:

Shall one simply count the number of human lifes?

Shall one attempt to decide the value of each life concerned?

Do we have enough information to decide?

Might our choices intentionally or indirectly be racist or discriminating?

Shall we even try to determine the value knowing we definitely have incomplete information?

What are the consequences for the person making the choice?

Will a (a posteriori) wrong action be punished more severly than inaction?

This problem is a very interesting base for ethical discussions.


Many discussions of the Trolley Problem ignore an important second-order effect: people who are willing to take evasive maneuvers that protect reckless people at the expense of those who would not otherwise have been in their path encourage recklessness. In an extreme case, suppose a group of five people decided to check before crossing the tracks to check how many people were on the other line, and concluded that if there were four or fewer then they would be safe. Should the train operator value the lives of five over the lives of one, or should he value the life of a worker who followed tag-out procedures over the lives of people who would have sacrificed him to avoid the inconvenience of waiting for the trolley to pass?

Even if one replaces the situation with a driver on a road, a similar issue arises: anyone whose path might intersect with a motorist whose path ahead is presently clear should be prepared for the possibility that the motorist might continue along that path. By contrast, it will often not be possible for all other motorists to be prepared for everything the motorist might do to avoid something on his primary path. If a motorist swerves to successfully avoid someone who is running a red light, but ends up colliding with someone else instead, the motorist's actions will have protected a reckless driver at the cost of an innocent one.

To be sure, the automotive version of the problem raises other issues, since the evasive maneuver may replace a T-bone collision with a side-swipe, and it's even possible that the alternative to the side-swipe might have been three-car collision that would have been worse for everyone involved. In general, though, to the extent that the "trolley problem" is an optimization problem, the goal should be to optimize people's ability to avoid making bad decisions in the first place.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.