Pyhop travelling example with more features.
You are able to pay at most $m to get from park to home in at most t minutes.
You need to get a proper plan for doing this.
You are starting at hh:00 (for any hh in {00, 01, ..., 23}).
I used the following map:
Distances are measured in km.
You are able to board a taxi in any place.
The price for the taxi is $(20 + 1.5 * distance).
The taxi goes at 20 km/h.
There are buses leaving every 10 minutes (6 per hour), starting from hh:00 (for hh in {00, 01, ..., 23}). You are able to board/unboard buses at following points:
- Park
- Intersection 1
- Intersection 2
- Intersection 3
The bus goes at 15 km/h.
The price for the bus is $(1 + 0.1 * distance).
You need to wait for bus if it goes away.
You are also able to walk on foot.
Walking on foot is at 5 km/h.
I defined the following operators and methods:
There is one defined operator for walking:
def walk(state, who, from_place, to_place)It defines changing place from from_place to to_place.
It also measures how much time does the walking require.
There is one defined method for walking:
def travel_on_foot(_, a, from_place, to_place)It performs walking from from_place to to_place.
There are 3 operators for travelling by taxi:
- Calling the cab
def call_taxi(state, a, from_place)It performs calling the taxi (which takes 10 minutes).
- Riding a taxi
def ride_taxi(state, a, from_place, to_place)It performs changing location from from_place to to_place.
It also measures the time that passes during the ride.
- Paying the driver
def pay_driver(state, a)It performs paying the taxi fare to driver.
There is one defined method for travelling by taxi:
def travel_by_taxi(state, a, from_place, to_place)It performs travelling by taxi from from_place to to_place.
There are 3 operators for travelling by bus:
- Getting into bus
def get_into_bus(state, a, from_place, to_place)It performs getting into bus (which time varies due to the bus schedule and current time).
- Riding a bus
def ride_bus(state, a, from_place, to_place)It performs changing location from from_place to to_place.
It also measures the time that passes during the ride.
- Paying for the ticket
def pay_for_bus(state, a)It performs paying the bus fare.
There is one defined method for travelling by bus:
def travel_by_bus(state, a, from_place, to_place)It performs travelling by bus from from_place to to_place.
We assume that we're travelling from park to home and we have $8 money and 180 min to get into destination.
The derived plan:
result = [('get_into_bus', 'me', 'park', 'intersection1'),
('ride_bus', 'me', 'park', 'intersection1'),
('pay_for_bus', 'me'),
('get_into_bus', 'me', 'intersection1', 'intersection2'),
('ride_bus', 'me', 'intersection1', 'intersection2'),
('pay_for_bus', 'me'),
('get_into_bus', 'me', 'intersection2', 'intersection3'),
('ride_bus', 'me', 'intersection2', 'intersection3'),
('pay_for_bus', 'me'),
('walk', 'me', 'intersection3', 'home')] We assume that we're travelling from park to home and we have $80 money and 100 min to get into destination.
The derived plan:
result = [('get_into_bus', 'me', 'park', 'intersection1'),
('ride_bus', 'me', 'park', 'intersection1'),
('pay_for_bus', 'me'),
('call_taxi', 'me', 'intersection1'),
('ride_taxi', 'me', 'intersection1', 'intersection2'),
('pay_driver', 'me'),
('get_into_bus', 'me', 'intersection2', 'intersection3'),
('ride_bus', 'me', 'intersection2', 'intersection3'),
('pay_for_bus', 'me'),
('call_taxi', 'me', 'intersection3'),
('ride_taxi', 'me', 'intersection3', 'home'),
('pay_driver', 'me')] We assume that we're travelling from park to home and we have $140 money and 250 min to get into destination.
The derived plan:
result = [('call_taxi', 'me', 'park'),
('ride_taxi', 'me', 'park', 'home'),
('pay_driver', 'me')] We assume that we're travelling from park to home and we have $50 money and 100 min to get into destination.
The derived plan:
False(There is no possible plan for this configuration).
