Git Product home page Git Product logo

emergency-request-handler's Introduction

Emergency Request Handler

Using rational agents to effectively respond to emergency requests.

To run:

Only system can create emergencies: py Main.py

System creates emergencies and user can also input emergencies: py Main.py -t

Only user can input emergencies: py Main.py -ot

To terminate:

Ctrl + c

emergency-request-handler's People

Contributors

catarinapedreira avatar daniela-mendes avatar vivokas20 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

kikaleite

emergency-request-handler's Issues

Fix when there is no option

Fix bug when there is no free hospital or no free ambulance to allocate emergency.
maybe put a sleep and wait for emergency to be allocated (in this case maybe have queue of emergencies so other emergencies can steal be allocated by that agent) or just print that it was not possible to allocate emergency

Global TIKs

x = nr de segundos, recebido do terminal
x / 1000 -> milissegundos, pq o time.sleep só aceita segundos

Something like:

While (true):
create_emergency
time.sleep(x / 1000)
allocate_emergency (aqui ja fazemos decrease do fuel e medicine e verificamos se está em replenish)
time.sleep(x / 1000)
check_vehicle_status (apenas para descer o rest, caso o veículo esteja nesse modo)
time.sleep(x / 1000)

-> depois, dentro da allocate, vai ser chamado o move() para todas as amb. alocadas, também com time.sleep(x / 1000) entre cada coordenada que andam

Problemas:

  • Sequencial, a não ser que tenhamos uma thread para cada nova emergência. Overkill?

  • Se for sequencial, nunca vai haver um caso em que uma emergência surge, e ao alocar, o estado de alguns veículos é "assigned" (pq depois de responderem à emergencia já estão available, ou ent replenish, ou rest). Mas (sim, estou a divertir-me com os bolds) se fizermos com threads, se 2 threads estão a tentar alocar ao mesmo tempo, podem lixar-se nas verificações, e alocar veículos que realmente já não estão disponíveis. Por isso acho que teremos de recorrer aos nossos queridos amigos locks 👍

  • Como o x é o mm para tudo, se tivermos um x demasiado pequeno, As emergências random surgem super rápido e os recursos vão ficar ocupados mais rápido , mas se tivermos um x demasiado grande as ambulancias vao demorar bastante mais a mexer-se

Fix zones' bug

When we create a zone with 3, 6, 7, 9, 11, 12 ..... agents, the program crashes (when it attempts to create locations for the hospitals).

The problem is on this line:
location = (random.randint(agents[i].get_area()[0][0], agents[i].get_area()[2][0]), random.randint(agents[i].get_area()[0][1], agents[i].get_area()[1][1]))

Probably for those agents get_area()[0][0] and get_area()[2][0] do not correspond to the limits of x, and get_area()[0][1] and get_area()[1][1] do not correspond to the limits of y.

Any ideas on how to fix this? xD

(Collaborative Behaviour)

In case an agent doesn't have enough resources for an emergency in its zone, it communicates with other agents and asks for help

Fix bug create ambulances

Maybe user has to input minimum 3 ambulances. And it's better that the input is ambulances per zone instead of per hospital

Fix SIVs bug

SIV ambulances are sometimes not created due to the probabilistic distribution and the roundings.

Solution:
Create ambulances per zone, and only after do the distribution per hospitals, maintaining the same probabilities

Ambulances can move

  • To calculate the distance between ambulance and emergency: Manhattan Distance (commented in the Agent class)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.