exercism / problem-specifications

Shared metadata for exercism exercises.
MIT License
326 stars 540 forks source link

Exercise idea: Airplane Boarding Simulation #1475

Open SaschaMann opened 5 years ago

SaschaMann commented 5 years ago

There aren't a lot of modelling or simulation exercises right now. After watching a CGP Grey video recently, I thought it would be interesting to simulate the boarding process of an airplane and compare different methods. This could also work well as an exercise. It seems only suitable as a side exercise, though.

I haven't fully thought this through and I'm not even sure if this kind of exercise fits exercism well, but the responses on Slack were positive, so I decided to post the general idea here regardless.

There are a few methods to board an airplane that are used in practice and also some unpractical, but theoretically more efficient, ones:

(Visualisation of them) (* Watch the video for an explanation, or if you're more interested, check out Optimal boarding method for airline passengers and Experimental test of airplane boarding methods (paywall warning))

The exercise would be about simulating the process and potentially comparing them in regards to the time it takes to fully board the plane. A bonus task could be a visualisation of the results or the process.

My naïve implementation would be to discretise the process, with a grid representing the aisle and seats and each action taking one time unit to do. The passengers would enter the grid in a specific order based on the used method. There would be multiple actions each passenger can do:

  1. Move forward in queue/aisle
  2. Store the carry-on in the overhead compartment
  3. Take a seat
  4. Make room for another passenger that has a seat further on the outside (e.g. aisle is already sitting, next passenger needs to move into window seat)

A few parameters could be changed:

There are a few questions I don't know how to answer yet:

  1. Would the exercise say how to model the process or should the student come up with it?
  2. Depending on 1), do we solely test for results (this works regardless of the chosen implementation) or also the individual actions/steps (this would likely require the model to be part of the exercise)?
  3. Should a comparison be part of the exercise, or should it be enough to implement a single method (which?)?

As I said above, I'm really not sure if and how this would work, so please don't hesitate to share your thoughts & ideas on how a general exercise about a simulation of airplane boarding would work, especially if they're completely different to my ideas above :)

kytrinyx commented 5 years ago

At first blush I think this could be a pretty fun (and potentially quite complex) exercise. I agree with your initial assessment that this would likely only be suitable as a side exercise, since this would probably have lots of complexity, lots of approaches, and therefore be quite challenging to mentor efficiently.

I suspect that this is also a pretty big exercise (maybe larger than any of our existing ones?) so it may be suitable towards the very end of a track.

I think the challenge would be to come up with how to model it, and I have no idea how we would check only for the result. Maybe we would need the model to "log" each action that it does, and be able to verify that the log is correct for given inputs? I have no idea.

I get the sense that having more than one model in a single exercise would be complicated. Maybe the exercise is to write something that knows how to model this sort of thing, but doesn't actually implement any particular model, and then all the models themselves and comparisons could be described as things you can do with the model, but are not necessarily part of the exercise?

SaschaMann commented 5 years ago

I suspect that this is also a pretty big exercise (maybe larger than any of our existing ones?) so it may be suitable towards the very end of a track.

I agree it belongs towards the end of a track, as an interesting bonus challenge that combines a lot of concepts learned before. I'm not sure about its size, though. There are other exercises, like custom-set or sgf-parsing, that are probably bigger in terms of lines of code, but this one might require more thinking/planning ahead of implementing it than most other exercises.

I think the challenge would be to come up with how to model it, and I have no idea how we would check only for the result. Maybe we would need the model to "log" each action that it does, and be able to verify that the log is correct for given inputs? I have no idea.

That could work.

We could also test how many steps it takes to completely board the plane, which would be the obvious return value anyway. However, this doesn't take order or correctness of the actions into account.

I get the sense that having more than one model in a single exercise would be complicated. Maybe the exercise is to write something that knows how to model this sort of thing, but doesn't actually implement any particular model, and then all the models themselves and comparisons could be described as things you can do with the model, but are not necessarily part of the exercise?

The main difference between the boarding methods would be the "queue", the order in which people board the plane. The process on the plane itself is identical because the behaviour of the passengers is always the same. The queue itself is pretty straightforward, so this could given as part of the tests or description.


I'll put together an example on what a solution could look like. Maybe that'll make it easier to think of what the tests and requirements should be.

sshine commented 5 years ago

I like the idea.

I'd like to see an example that involves code, as I don't know exactly how much of the air plane environment you want to simulate and to which degree you want this to be a concurrent simulation.