Skip to content

Commit

Permalink
examples
Browse files Browse the repository at this point in the history
  • Loading branch information
erelsgl committed Apr 14, 2024
1 parent bd4c731 commit ae91b11
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 48 deletions.
24 changes: 12 additions & 12 deletions examples/courses.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,18 @@ print(divide(fairpyx.algorithms.almost_egalitarian_with_donation, instance=rando
```

```
{'s1': ['c2', 'c3'], 's2': ['c2', 'c3'], 's3': ['c1', 'c3'], 's4':
['c1', 'c3'], 's5': ['c1', 'c2'], 's6': ['c1', 'c3'], 's7': ['c1',
'c2'], 's8': ['c1', 'c2'], 's9': ['c1', 'c3'], 's10': ['c3']}
{'s1': ['c2'], 's2': ['c1', 'c2'], 's3': ['c1', 'c3'], 's4': ['c1',
'c3'], 's5': ['c1', 'c2'], 's6': ['c1', 'c3'], 's7': ['c2', 'c3'],
's8': ['c2', 'c3'], 's9': ['c1', 'c3'], 's10': ['c1', 'c3']}
{'s1': ['c2', 'c3'], 's2': ['c2', 'c3'], 's3': ['c2', 'c3'], 's4':
['c1', 'c2', 'c3'], 's5': ['c1', 'c2', 'c3'], 's6': ['c1', 'c3'],
's7': ['c1', 'c3'], 's8': ['c1'], 's9': ['c1'], 's10': ['c1']}
{'s1': ['c2'], 's2': ['c3'], 's3': ['c1', 'c3'], 's4': ['c1', 'c3'],
's5': ['c1', 'c2'], 's6': ['c1', 'c2', 'c3'], 's7': ['c1', 'c2'],
's8': ['c1', 'c3'], 's9': ['c1', 'c3'], 's10': ['c2', 'c3']}
{'s1': ['c1', 'c2'], 's2': ['c2', 'c3'], 's3': ['c1', 'c2'], 's4':
['c1', 'c2'], 's5': ['c1', 'c2'], 's6': ['c1', 'c2'], 's7': ['c2',
'c3'], 's8': ['c3'], 's9': ['c3'], 's10': ['c3']}
{'s1': ['c1'], 's2': ['c3'], 's3': ['c1'], 's4': ['c1', 'c2'], 's5':
['c1', 'c2'], 's6': ['c1', 'c2'], 's7': ['c2', 'c3'], 's8': ['c2',
'c3'], 's9': ['c2', 'c3'], 's10': ['c2', 'c3']}
{'s1': ['c1', 'c3'], 's2': ['c1', 'c2', 'c3'], 's3': ['c1', 'c3'],
's4': ['c1', 'c3'], 's5': ['c1', 'c2', 'c3'], 's6': ['c2'], 's7':
['c2'], 's8': ['c2'], 's9': ['c2'], 's10': ['c2']}
{'s1': ['c2'], 's2': ['c2', 'c3'], 's3': ['c1'], 's4': ['c1', 'c3'],
's5': ['c2', 'c3'], 's6': ['c1', 'c2'], 's7': ['c1', 'c2'], 's8':
['c2', 'c3'], 's9': ['c3'], 's10': ['c1', 'c2']}
```


Expand Down
42 changes: 14 additions & 28 deletions examples/input_formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ print(allocation)
```

```
[[11 51 26 40 92 22 25 9 26 44 52 98]
[58 55 4 57 48 3 24 24 51 84 97 2]
[ 6 5 31 66 74 95 11 21 81 28 98 28]
[ 9 50 8 9 37 24 42 22 90 15 36 11]
[43 73 76 60 30 20 4 11 1 54 68 86]]
{0: [4], 1: [0, 7, 9], 2: [5, 10], 3: [6, 8], 4: [1, 2, 3, 11]}
[[96 51 98 31 1 62 36 50 21 47 97 29]
[58 91 31 79 42 60 49 86 64 88 39 56]
[88 81 73 16 67 65 92 26 52 3 60 6]
[91 55 72 43 10 61 97 21 89 97 69 35]
[ 9 96 39 82 59 68 52 78 93 87 84 26]]
{0: [2], 1: [7, 11], 2: [0, 4], 3: [6, 9], 4: [1, 3, 5, 8, 10]}
```


Expand All @@ -84,12 +84,12 @@ There are several input formats for agent capacities. You can set the same capac


```python
allocation = divide(fairpyx.algorithms.almost_egalitarian_allocation, valuations=valuations, agent_capacities=2) # , explanation_logger=fairpyx.ConsoleExplanationLogger()
allocation = divide(fairpyx.algorithms.almost_egalitarian_allocation, valuations=valuations, agent_capacities=2)
print(allocation)
```

```
{0: [4, 11], 1: [0, 9], 2: [5, 10], 3: [6, 8], 4: [1, 2]}
{0: [2, 10], 1: [5, 7], 2: [0, 6], 3: [8, 9], 4: [1, 3]}
```


Expand All @@ -98,26 +98,12 @@ Or different capacities to different agents:


```python
allocation = divide(fairpyx.algorithms.almost_egalitarian_allocation, valuations=valuations, agent_capacities=[1,2,3,2,1]) # , explanation_logger=fairpyx.ConsoleExplanationLogger()
allocation = divide(fairpyx.algorithms.almost_egalitarian_allocation, valuations=valuations, agent_capacities=[1,2,3,2,1])
print(allocation)
```

```
{0: [3], 1: [0, 9], 2: [4, 5, 10], 3: [1, 8], 4: [11]}
```



There are several input formats for agent capacities. You can set the same capacity to all agents:


```python
allocation = divide(fairpyx.algorithms.almost_egalitarian_allocation, valuations=valuations, agent_capacities=2) # , explanation_logger=fairpyx.ConsoleExplanationLogger()
print(allocation)
```

```
{0: [4, 11], 1: [0, 9], 2: [5, 10], 3: [6, 8], 4: [1, 2]}
{0: [10], 1: [1, 7], 2: [0, 2, 4], 3: [6, 9], 4: [8]}
```


Expand All @@ -131,8 +117,8 @@ print(allocation)
```

```
{0: [1, 4, 9, 11], 1: [0, 3, 9, 10], 2: [4, 5, 8, 10], 3: [1, 5, 6,
8], 4: [0, 2, 3, 11]}
{0: [1, 2, 5, 10], 1: [1, 3, 7, 9], 2: [0, 2, 4, 6], 3: [0, 6, 8, 9],
4: [3, 7, 8, 10]}
```


Expand All @@ -146,8 +132,8 @@ print(allocation)
```

```
{0: [1, 4, 11], 1: [0, 3, 7, 9], 2: [3, 5, 10], 3: [5, 6, 7, 8], 4:
[1, 2, 9, 11]}
{0: [0, 2, 10], 1: [3, 7, 11], 2: [1, 4, 5, 6], 3: [5, 8, 9, 11], 4:
[1, 3, 7, 9]}
```


Expand Down
10 changes: 2 additions & 8 deletions examples/input_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,12 @@

#' There are several input formats for agent capacities. You can set the same capacity to all agents:

allocation = divide(fairpyx.algorithms.almost_egalitarian_allocation, valuations=valuations, agent_capacities=2) # , explanation_logger=fairpyx.ConsoleExplanationLogger()
allocation = divide(fairpyx.algorithms.almost_egalitarian_allocation, valuations=valuations, agent_capacities=2)
print(allocation)

#' Or different capacities to different agents:

allocation = divide(fairpyx.algorithms.almost_egalitarian_allocation, valuations=valuations, agent_capacities=[1,2,3,2,1]) # , explanation_logger=fairpyx.ConsoleExplanationLogger()
print(allocation)


#' There are several input formats for agent capacities. You can set the same capacity to all agents:

allocation = divide(fairpyx.algorithms.almost_egalitarian_allocation, valuations=valuations, agent_capacities=2) # , explanation_logger=fairpyx.ConsoleExplanationLogger()
allocation = divide(fairpyx.algorithms.almost_egalitarian_allocation, valuations=valuations, agent_capacities=[1,2,3,2,1])
print(allocation)

#' Similarly, you can set the same capacity to all items:
Expand Down

0 comments on commit ae91b11

Please sign in to comment.