This project is designed to simulate an organ transplant system. Its aim is to simulate the organ transplant matching process. To accomplish this, there will be a list of patients in need of an organ transplant within a given network of hospitals. After organs are harvested from a deceased organ donor, the system will find the most optimal match by looking at the list of patients, then the organ will be allocated to the matched patient.
The following criteria are used to determine matches:
- The patient's need must be of the same organ type (kidney, lungs, heart, etc.)
- The patient must be of a compatible blood type (example: patient: AB-, organ: B-)
- The organ must be able to be transported to the patient's hospital while remaining viable (organ-specific time limit)
- The optimal match will be the patient with the highest priority rating who matches all the above criteria
The smallest element within the network is a Node object. Each node represents a specific hospital where both patients and organs can be located. These will represent the 'addresses' of sources and destinations within the graph based on an organ's location and the matched patient's location.
Nodes consist of:
node ID
- a unique identifierlabel
- describes/names the nodeadjacency dictionary
- where the adjacent node's id is the key and another dictionary with two entries is the value. This allows each edge to have two important attributes - weight and status (active or inactive)status
- indicates if a node is active or inactive. If the node is inactive, all edges contained in the adjacency list are consequently inactive as well
The network is a graph that is represented as a collection of nodes. The network represents the entire network of hospitals. The network will be traversed from node to node to. The weights of individual edges traveled will be added together to represent the total cost of the traveled path.
Networks consist of:
network dictionary
- contains a collection ofnode IDs
that point to their correspondingNode
objectslabel
- describes/names the graph
Dijkstra
- finds all shortest paths from a source node in a given graphBloodType
- indicates blood type by letter and polarity (also checks for compatibility between donors and recipients)Organ
- represents a donated organ available for transplant (these will be distributed across the system)Patient
- represents an individual in need of a transplantOrganList
- represents all donor organs currently available to be allocated to patientsWaitList
- represents all patients in need of a transplantGraphBuilder
- builds a random network with N nodesOrganGenerator
- simulates harvesting organs from N patients where each organ has a 75% of being successfully harvested and adds the generated organs to anOrganList
PatientGenerator
- generates N patients each with a random organ need, blood type, priority, and location (node_id
) and adds the generated patients to aWaitList
OrganAllocator
- allocates harvested organs (OrganList
) to the most optimal matching patient (WaitList
)ConnectivityChecker
- determines if a given graph is connectedSubnetworkGenerator
- takes aNetwork
and a collection (OrganList
orWaitList
) and creates a subnetwork containing only nodes where elements of the collection are presentGraphConverter
- converts aNetwork
to aNetworkX
(graph library) object
generate_networks.py
- creates, serializes, and exports random graphmake_tsv.py
- gnerates random edge list in TSV format (for IO)import_edge_list.py
- converts edge list format toNetwork
The Simulator
is designed to create an interactive experience that can be executed through any console. The simulator does this by harnessing the functionality of the GraphBuilder
, PatientGenerator
, OrganGenerator
, and OrganAllocator
classes. This allows users to choose the number of nodes in the network, number of patients on the wait list, and number of bodies to harvest organs from all on the fly.