SebastienEveno / mckinseysolvegame

Solves the McKinsey Solve Game by finding a sustainable food chain from a given list of species.
MIT License
4 stars 2 forks source link

Adding a maximum for number of animals possible in the foodchain. #12

Closed Stefan142 closed 5 months ago

Stefan142 commented 9 months ago

Hi, Love the feature you provided. I did want to perhaps request a certain feature. Would it be possible to also specify the maximum number of species possible in the food chain?

SebastienEveno commented 9 months ago

Hi Stefan, sure I can work on that. Can you provide me with your use case and an example?

manolaki commented 6 months ago

You can modify the parameters in for loop in line 28 of optimization_service.py to impose a maximum number of species possible in the food chain

SebastienEveno commented 6 months ago

Yes I can but I wanted to understand a bit more the context - as I think the given data by mckinsey will give only one possible solution

FIlippoLeveraro commented 5 months ago

I think the idea is to limit the number of species in the solver to 8 (what is requested by the game). If the best solution involves the presence of 10 species, but the game allows you to just put 8, then removing 2 of them, not necessarily gives you a balanced ecosystem.

SebastienEveno commented 5 months ago

That makes sense. I just thought the end user would not randomly remove the species to get to 8, but I guess it's not easy given just the list of species names. I will set the maximum length to 8 by default. If you have any other idea to improve the tool, let me know.

Thank you!

SebastienEveno commented 5 months ago

I just set the maximum food chain length to 8.

manolaki commented 5 months ago

I think the idea is to limit the number of species in the solver to 8 (what is requested by the game). If the best solution involves the presence of 10 species, but the game allows you to just put 8, then removing 2 of them, not necessarily gives you a balanced ecosystem.

As your code finds, the game may have multiple solutions having different number of species: there's no "best solution". The game asks for a food chain that contains exactly 8 species. Even though a 8-species solution may not be unique, any 8-species solution would work. So, the best solution for the ones who want to solve the game with the help of your library is to restrict food chain length to 8 (both from min and max sides).