Contents
Domain
Illustration
Methods
Conclusions |
Domain
This agent takes in a layout of a city, the number of starting cabs
(all placed at the dispatch office at the begining), and a list of customers
that are defined by their location and thier destination (and a possible
list of unknown people, that the agent doen't "see"). Each Cab that is
unassigned, gets assigned to the closest person, and moves to pick that
person up and drop him/her off at thier destination. After which the cab
is reassigned to another person (if there are any more) to pick up and
drop off. The cab is assigned to the closest person that no other cab has
be assigned to. Also, there could be people on the map that need a ride,
that didn't call in. Any unassigned cabs are ordered to look for these
people and report if they find one. Even cabs that already have something
to do, keep thier eyes open for new customers. The items that exist in
the world of the agent are the cabs and thier status, the people and thier
status, and the known geography of the city. The dispatcher, called direct(_),
thinks about what cabs should be doing and each of the cabs recieve orders
from the dispatcher (which are general orders), and think on thier own
of how to follow those orders. This creates a two sectioned agent, with
one part interacting with the cabs, and the other part (the cabs themselves)
interatcting with the enviornment. The cabs are only told what person to
pick up closest to them. They have to sucsessfully navagate the map on
thier own to pick the person up and take them to the correct destination.
If the dispatcher doesn't give them any orders, the cabs have to act more
independently, by activly searching the enviornment by randomly driving
around, to give the dispatcher valuable information as to where new customers
may be.
cabdispatcher.pl
Illustration
This progam is run through an number of different methods:
run(NumberOfAvailableNewCabs, ListOfPeopleToPickup).
- this is the basic one. It takes a number of cabs, adds
it to the city, and a list of people with locations and destinations, and
adds them to the city. After which the program moves each of the cabs till
they pick up all the people. If a cab drops off a person, it is marked
unassigned. It is then assigned to the closest unassigned person to pick
up.
Illustration1.txt
run(NumberOfAvailableNewCabs, ListOfPeopleToPickup, CustomersUnknowntoAgent)
- this ones a bit more intresting. It is just like the last
one, but it has a list of unknown customers. The agent doesn't see these
customers unless a cab happens to be at the same location that the customer
is at. If the cab sees the person the person is added to the list of customers
to pick up, and the next time through the loop, an unassigned cab will
be assigned to it. If a cab has no customer to pick up, it will move randomly
through the map looking for new customers
Illustration2.txt
Each of the two previous can be done by stepping through the program
one step at a time. This makes it so for large lists of cabs and customers,
the user can see whats going on in each case instead of the program wizzing
by faster then you can see. A step is defined by 5 things happening
1. direct(_) ordering all unassigned cabs to pick up the closest person
to them if there are any people that need to be assigned to a cab.
2. pickupPeople(CabList) having each cab see if the person they are
assigned to pick up happens to be at the location they are at. If so, put
the person in the cab
3. dropPeople(Cablist) having each cab see if has brought the person
in thier cab (if there is a person in thier cab) to the approprate location.
In which case, the cab drops the person off and awaits new orders from
direct(_)
4. moveCab(Cablist) each cab moves down a street to the next location
it should go to. It could be heading to pick someone up, drop them off,
or if they don't have any customers to take anywhere, it randomly will
go up a street to wherever it may lead to find new customers.
5. look(Cablist) has each cab look at its current location to see if
there is anyone unknown to the agent, and add them to the list of people
the agent knows about.
run(step, NumberOfAvailableNewCabs, ListOfPeopleToPickup).
run(step, NumberOfAvailableNewCabs, ListOfPeopleToPickup,
CustomersUnknowntoAgent).
I am not bothering with the illustration of these. They are the same
as above, but just execute only one loop of the program. To continue to
the next loop the user simply types "r." , or "runc." to finish the program
in continuous mode.
run(addpeople, ListOfPeopleToPickup).
run(addcabs, NumberOfAvailableNewCabs).
run(addunknowns, Unknowns).
These each add new people, new cabs, or new unknown customers to the
map, and make one more step through the program. This is done because my
program works dynamically, where new elements can be added at any time
and the agent has to deal with these new additions. To get the map clear
of all objects (cabs, customers, unknown customers)type "clear."
Even after all jobs are taken care of, the cabs remain in thier locations
on the map, so you can add new customers, and those cabs will come alive
again chasing down people to pick up or searching actively for them
Methods
Assert and retract were used to keep a database of all objects. Cabs
and customers each had four fields, like so:
%cab(Location, PersonInCab, PersonToPickup, CabNumber).
%customer(Location, CabFetchingPerson, Destination, PersonNumber).
for CabFetchingPerson, this was set as unknownToAgent, if they havent
been spoted yet. The customer's location was set to be CabNumber to signify
that they were in the cab. CabFetchingPerson was to keep track of who is
getting this customer. This was useful in keeping all cabs from going after
the same person.
I used a frame system to refer to steps in time for all the many things
these cabs had to do and the direct(_) to give orders for. This was a continous
loop, that cycled until all customers were taken care of, or if set to
step, would just do one of everything before exiting.
Conclusions
YOUR FINAL THOUGHTS (by jerry springer)
When cabs fight over customers chaos sweeps over us all. In some cases
a good mediator would make out emotional disputes settle out. If you happen
to have relatives that need to be picked up, sometimes it may be best to
have another cab pick them up (even if he/she is pregnant with your baby).
Rob's agent understands your feelings and will help resolve them in a non-violent
manner (unlike the way I normally see things work out). I greatly endorse
Rob's project. |