Skip to content

Commit ef99912

Browse files
committed
B3 README.md & data files
1 parent 8062b7b commit ef99912

File tree

13 files changed

+10117
-11
lines changed

13 files changed

+10117
-11
lines changed

FlightSelection/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
## Group B - Exercise 3
2+
3+
### Context
4+
An Airline has to schedule $N$ flights during a predefined time period.\
5+
Each flight can be referenced using an id $(1, 2, 3 ... N)$.
6+
7+
The airline has pre-generated $M$ flight combinations (pairings).\
8+
Each pairing $P_i$ (where $ 1 \le i \le M$), may include a subset of the flights $1, 2, 3 ... N$. It is **feasible**, and is assigned to a **specific captain**.
9+
10+
The task is to select a subset of the available pairings, so that
11+
each flight is assigned to **exactly 1 captain**.
12+
13+
A $P_i$ pairing has a cost of $C_i$. The **sum of costs** of the selected pairings, is the **total cost** for the selection.
14+
15+
### Task
16+
You will use [get_flight_data(I, N, P, C)](./flight_data.pl) to get pre-generated pairings.
17+
- `I` is an index number, from **1 to 16**.
18+
- `N` returns the number of flights.
19+
- `P` returns the pairings (list of lists).
20+
- `C` returns a list with the pairing costs.
21+
22+
Implement a `flights(I, Pairings, Cost)` predicate:
23+
- `I` is the index number to be provided to `get_flight_data`.
24+
- `Pairings` returns the optimal pairings selection.
25+
- `Cost` returns the total cost of the selection.
26+
27+
### Execution Example
28+
Input:
29+
30+
?- member(I, [1, 2, 3, 4]),
31+
write('I = '), writeln(I),
32+
flights(I, Pairings,Cost),
33+
write('Pairings = '), writeln(Pairings),
34+
write('Cost = '), writeln(Cost), nl, fail.
35+
36+
37+
Output:
38+
39+
I = 1
40+
Pairings = [[1, 2, 3, 7] / 10,
41+
[5, 8] / 12,
42+
[4, 9, 10] / 34,
43+
[6] / 34]
44+
Cost = 90
45+
46+
I = 2
47+
Pairings = [[1, 2, 5, 8] / 10,
48+
[3, 6, 9] / 25,
49+
[4, 7, 10] / 20]
50+
Cost = 55
51+
52+
I = 3
53+
Pairings = [[6, 9] / 32,
54+
[2, 5, 8] / 10,
55+
[1, 3, 4, 7, 10] / 28]
56+
Cost = 70
57+
58+
I = 4
59+
Pairings = [[1, 5, 11] / 2,
60+
[7, 10, 12] / 3,
61+
[2, 9, 15, 16] / 1,
62+
[4, 8, 14] / 2,
63+
[3, 6, 13] / 1]
64+
Cost = 9
65+
66+
### Implementation
67+
- The `flights` predicate is implemented in `flights.pl`, along with several helper predicates.
68+
- The `get_flight_data` predicate was pre-implemented in `flight_data.pl`.
69+
- The `acsdata` directory contains data used by `get_flight_data`, for indexes from 7 up to 16.

0 commit comments

Comments
 (0)