How to get all possible combinations of a list in Netlogo (without value duplications in the list & using Netlogo)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get all possible combinations of a list in Netlogo (without value duplications in the list & using Netlogo)

westlife1002
I am struggling to write a Netlogo program that could allow me to find all
combinations from a list. Below is one example of my situation I want to
model.

I have a list of five agent: [agent1, agent2, agent3, agent4, agent5] I want
to know how to get all the possible combinations and the combinations must
be with a fixed size (e.g. if size = 3, then the combination scenarios
should be [agent1, agent2, agent3], [agent1, agent2, agent4],[agent1,
agent2, agent5],[agent1, agent3, agent4], ..........

in this way, I would be able to work out a cost performance from each unique
combination where 3 agents can interact with each other to determine that
cost, and I would be able to find the best combination (i.e. the best 3
agents who can work together to deliver the minimal cost).

I need a mass production way to do this work in Netlogo modelling
environment so that later on I could change the parameters such as size and
the total number of agents. Appreciate for the code demonstration!




--
Sent from: http://netlogo-users.18673.x6.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: How to get all possible combinations of a list in Netlogo (without value duplications in the list & using Netlogo)

Alan G Isaac-2
On 11/2/2017 3:35 PM, westlife1002 [hidden email] [netlogo-users] wrote:
> I am struggling to write a Netlogo program that could allow me to find all
> combinations from a list.




You already posted this question on StackExchange,
and it has an existing answer there.