0

I am trying to connect different agent types by names. So, for example, I have a dataset where I have a list of patient names and their doctors name. I would first like to create two different populations of patients and doctors where each individual agent is assigned a name from the dataset. Then I need to create connections between the two different populations based on the corresponding connections in the data. Anyone know how to do this? Any help appreciated!

AT

AyeTown
  • 831
  • 1
  • 5
  • 20

3 Answers3

1

Let's assume your doctor and patient agent populations are created, and the patient having a parameter called doctorName, and the doctor having a parameter called name. You have to figure out how to do this based on where you get the info from. I will also assume that all doctor names are different.

the doctor will have a link to agents object (from the agent palette) called patientLink as a collection of links and bidirectional, but as a single link on the patient side (called doctorLink on the patient side).

now you can use the following function to connect them:

for(Patient p : patients){
     Doctor doctor=findFirst(doctors,d->d.name.equals(p.doctorName));
     p.doctorLink.connectTo(doctor);
}
Felipe
  • 8,311
  • 2
  • 15
  • 31
0

Here are just a few quick thoughts on this that I hope are helpful in your process: 1) If you want to keep doctors and patients linked, you can craft an agent as a doctor-patient dyad--this could make a lot of sense depending on what your research question is; or 2) If one doctor handles more than one patient, you could also consider forming an agent that is actually a network-type arrangement with the doctor as the central node--again, this depends what your research question is and what your data looks like; or 3) If you want to link doctors with patients based on some rule, consider using a discrete event approach by using a "Match" function from the "Process Modeling Library" palette. Best wishes, LCG

L.C.G.
  • 11
  • 3
0

You should use the "Agent Link" object. This does exactly what you need.

In your case, you will need to write some code looping across your data and setup the links accordingly. Check the example models using AgentLink objects to learn about it and read in the help, there is a lot of stuff on it.

Benjamin
  • 10,603
  • 3
  • 16
  • 28