ANL Reference
This package provides a wrapper around NegMAS functionality to generate and run tournaments a la ANL 2024 competition.
You mostly only need to use anl2024_tournament
in your code. The other helpers are provided to allow for a finer control over the scenarios used.
Example Negotiators
The package provides few example negotiators. Of special importance is the MiCRO
negotiator which provides a full implementation of a recently proposed behavioral strategy.
Other negotiators are just wrappers over negotiators provided by NegMAS.
anl.anl2024.negotiators.builtins.micro.MiCRO
Bases: SAONegotiator
A simple implementation of the MiCRO negotiation strategy
Remarks
- This is a simplified implementation of the MiCRO strategy.
- It is not guaranteed to exactly match the published work.
- MiCRO was introduced here: de Jonge, Dave. "An Analysis of the Linear Bilateral ANAC Domains Using the MiCRO Benchmark Strategy." Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence, IJCAI. 2022.
- Note that MiCRO works optimally if both negotiators can concede all the way to agreement. If one of them has a high reservation value preventing it from doing so, or if the allowed number of steps is small, MiCRO will not reach agreement (even against itself).
Source code in anl/anl2024/negotiators/builtins/micro.py
anl.anl2024.negotiators.builtins.nash_seeker.NashSeeker
Bases: SAONegotiator
Assumes that the opponent has a fixed reserved value and seeks the Nash equilibrium.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
opponent_reserved_value |
float
|
Assumed reserved value for the opponent |
0.25
|
nash_factor |
Fraction (or multiple) of the agent utility at the Nash Point (assuming the |
0.9
|
Source code in anl/anl2024/negotiators/builtins/nash_seeker.py
anl.anl2024.negotiators.builtins.rv_fitter.RVFitter
Bases: SAONegotiator
A simple negotiator that uses curve fitting to learn the reserved value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_unique_utilities |
int
|
Number of different offers from the opponent before starting to attempt learning their reserved value. |
10
|
e |
float
|
The concession exponent used for the agent's offering strategy |
5.0
|
stochasticity |
float
|
The level of stochasticity in the offers. |
0.1
|
enable_logging |
bool
|
If given, a log will be stored for the estimates. |
False
|
Remarks:
- Assumes that the opponent is using a time-based offering strategy that offers
the outcome at utility $u(t) = (u_0 - r) - r \exp(t^e)$ where $u_0$ is the utility of
the first offer (directly read from the opponent ufun), $e$ is an exponent that controls the
concession rate and $r$ is the reserved value we want to learn.
- After it receives offers with enough different utilities, it starts finding the optimal values
for $e$ and $r$.
- When it is time to respond, RVFitter, calculates the set of rational outcomes **for both agents**
based on its knowledge of the opponent ufun (given) and reserved value (learned). It then applies
the same concession curve defined above to concede over an ordered list of these outcomes.
- Is this better than using the same concession curve on the outcome space without even trying to learn
the opponent reserved value? Maybe sometimes but empirical evaluation shows that it is not in general.
- Note that the way we check for availability of enough data for training is based on the uniqueness of
the utility of offers from the opponent (for the opponent). Given that these are real values, this approach
is suspect because of rounding errors. If two outcomes have the same utility they may appear to have different
but very close utilities because or rounding errors (or genuine very small differences). Such differences should
be ignored.
- Note also that we start assuming that the opponent reserved value is 0.0 which means that we are only restricted
with our own reserved values when calculating the rational outcomes. This is the best case scenario for us because
we have MORE negotiation power when the partner has LOWER utility.
Source code in anl/anl2024/negotiators/builtins/rv_fitter.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
anl.anl2024.negotiators.builtins.wrappers.Boulware
anl.anl2024.negotiators.builtins.wrappers.Linear
anl.anl2024.negotiators.builtins.wrappers.Conceder
anl.anl2024.negotiators.builtins.wrappers.StochasticBoulware
Bases: AspirationNegotiator
Time-based boulware negotiation strategy (offers above the limit instead of at it)
Source code in anl/anl2024/negotiators/builtins/wrappers.py
anl.anl2024.negotiators.builtins.wrappers.StochasticLinear
Bases: AspirationNegotiator
Time-based linear negotiation strategy (offers above the limit instead of at it)
Source code in anl/anl2024/negotiators/builtins/wrappers.py
anl.anl2024.negotiators.builtins.wrappers.StochasticConceder
Bases: AspirationNegotiator
Time-based conceder negotiation strategy (offers above the limit instead of at it)
Source code in anl/anl2024/negotiators/builtins/wrappers.py
anl.anl2024.negotiators.builtins.wrappers.NaiveTitForTat
Tournaments
anl.anl2024.anl2024_tournament
Runs an ANL 2024 tournament
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scenarios |
tuple[Scenario, ...] | list[Scenario]
|
A list of predefined scenarios to use for the tournament |
tuple()
|
n_scenarios |
int
|
Number of negotiation scenarios to generate specifically for this tournament |
DEFAULT2024SETTINGS['n_scenarios']
|
n_outcomes |
int | tuple[int, int] | list[int]
|
Number of outcomes (or a min/max tuple of n. outcomes) for each scenario |
DEFAULT2024SETTINGS['n_outcomes']
|
competitors |
tuple[type[Negotiator] | str, ...] | list[type[Negotiator] | str]
|
list of competitor agents |
DEFAULT_AN2024_COMPETITORS
|
competitor_params |
Sequence[dict | None] | None
|
If given, parameters to construct each competitor |
None
|
rotate_ufuns |
bool
|
If given, each scenario will be tried with both orders of the ufuns. |
DEFAULT2024SETTINGS['rotate_ufuns']
|
n_repetitions |
int
|
Number of times to repeat each negotiation |
DEFAULT2024SETTINGS['n_repetitions']
|
n_steps |
int | tuple[int, int] | None
|
Number of steps/rounds allowed for the each negotiation (None for no-limit and a 2-valued tuple for sampling from a range) |
DEFAULT2024SETTINGS['n_steps']
|
time_limit |
float | tuple[float, float] | None
|
Number of seconds allowed for the each negotiation (None for no-limit and a 2-valued tuple for sampling from a range) |
DEFAULT2024SETTINGS['time_limit']
|
pend |
float | tuple[float, float]
|
Probability of ending the negotiation every step/round (None for no-limit and a 2-valued tuple for sampling from a range) |
DEFAULT2024SETTINGS['pend']
|
pend_per_second |
float | tuple[float, float]
|
Probability of ending the negotiation every second (None for no-limit and a 2-valued tuple for sampling from a range) |
DEFAULT2024SETTINGS['pend_per_second']
|
step_time_limit |
float | tuple[float, float] | None
|
Time limit for every negotiation step (None for no-limit and a 2-valued tuple for sampling from a range) |
DEFAULT2024SETTINGS['step_time_limit']
|
negotiator_time_limit |
float | tuple[float, float] | None
|
Time limit for all actions of every negotiator (None for no-limit and a 2-valued tuple for sampling from a range) |
DEFAULT2024SETTINGS['negotiator_time_limit']
|
name |
str | None
|
Name of the tournament |
None
|
nologs |
bool
|
If given, no logs will be saved |
False
|
njobs |
int
|
Number of parallel jobs to use. -1 for serial and 0 for all cores |
0
|
plot_fraction |
float
|
Fraction of negotiations to plot. Only used if not nologs |
0.2
|
verbosity |
int
|
Verbosity level. The higher the more verbose |
1
|
self_play |
bool
|
Allow negotiators to run against themselves. |
DEFAULT2024SETTINGS['self_play']
|
randomize_runs |
bool
|
Randomize the order of negotiations |
DEFAULT2024SETTINGS['randomize_runs']
|
save_every |
int
|
Save logs every this number of negotiations |
0
|
save_stats |
bool
|
Save statistics for scenarios |
True
|
known_partner |
bool
|
Allow negotiators to know the type of their partner (through their ID) |
DEFAULT2024SETTINGS['known_partner']
|
final_score |
tuple[str, str]
|
The metric and statistic used to calculate the score. Metrics are: advantage, utility, welfare, partner_welfare and Stats are: median, mean, std, min, max |
DEFAULT2024SETTINGS['final_score']
|
base_path |
Path | None
|
Folder in which to generate the logs folder for this tournament. Default is ~/negmas/anl2024/tournaments |
None
|
scenario_generator |
str | ScenarioGenerator
|
An alternative method for generating bilateral negotiation scenarios. Must receive the number of scenarios and number of outcomes. |
DEFAULT2024SETTINGS['scenario_generator']
|
generator_params |
dict[str, Any] | None
|
Parameters passed to the scenario generator |
DEFAULT2024SETTINGS['generator_params']
|
plot_params |
dict[str, Any] | None
|
If given, overrides plotting parameters. See |
None
|
Returns:
Type | Description |
---|---|
SimpleTournamentResults
|
Tournament results as a |
Source code in anl/anl2024/runner.py
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 |
|
anl.anl2024.DEFAULT_AN2024_COMPETITORS = (RVFitter, NashSeeker, MiCRO, Boulware, Conceder, Linear)
module-attribute
Default set of negotiators (agents) used as competitors
anl.anl2024.DEFAULT_TOURNAMENT_PATH = Path.home() / 'negmas' / 'anl2024' / 'tournaments'
module-attribute
Default location to store tournament logs
anl.anl2024.DEFAULT2024SETTINGS = dict(n_ufuns=2, n_scenarios=50, n_outcomes=(900, 1100), n_steps=(10, 10000), n_repetitions=5, reserved_ranges=((0.0, 1.0), (0.0, 1.0)), competitors=DEFAULT_AN2024_COMPETITORS, rotate_ufuns=False, time_limit=3 * 60, pend=0, pend_per_second=0, step_time_limit=None, negotiator_time_limit=None, self_play=True, randomize_runs=True, known_partner=False, final_score=('advantage', 'mean'), scenario_generator='mix', outcomes_log_uniform=True, generator_params=dict(reserved_ranges=((0.0, 1.0), (0.0, 1.0)), log_uniform=False, zerosum_fraction=0.05, monotonic_fraction=0.25, curve_fraction=0.25, pies_fraction=0.2, pareto_first=False, n_pareto=(0.005, 0.25)))
module-attribute
Default settings for ANL 2024
Helpers (Scenario Generation)
anl.anl2024.ScenarioGenerator = Callable[[int, int | tuple[int, int] | list[int]], list[Scenario]]
module-attribute
Type of callable that can be used for generating scenarios. It must receive the number of scenarios and number of outcomes (as int, tuple or list) and return a list of Scenario
s
anl.anl2024.mixed_scenarios
Generates a mix of zero-sum, monotonic and general scenarios
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_scenarios |
int
|
Number of scenarios to genearate |
DEFAULT2024SETTINGS['n_scenarios']
|
n_outcomes |
int | tuple[int, int] | list[int]
|
Number of outcomes (or a list of range thereof). |
DEFAULT2024SETTINGS['n_outcomes']
|
reserved_ranges |
ReservedRanges
|
the range allowed for reserved values for each ufun. Note that the upper limit will be overridden to guarantee the existence of at least one rational outcome |
DEFAULT2024SETTINGS['reserved_ranges']
|
log_uniform |
bool
|
Use log-uniform instead of uniform sampling if n_outcomes is a tuple giving a range. |
DEFAULT2024SETTINGS['outcomes_log_uniform']
|
zerosum_fraction |
float
|
Fraction of zero-sum scenarios. These are original DivideThePie scenarios |
DEFAULT2024SETTINGS['generator_params']['zerosum_fraction']
|
monotonic_fraction |
float
|
Fraction of scenarios where each ufun is a monotonic function of the received pie. |
DEFAULT2024SETTINGS['generator_params']['monotonic_fraction']
|
curve_fraction |
float
|
Fraction of general and monotonic scenarios that use a curve for Pareto generation instead of a piecewise linear Pareto frontier. |
DEFAULT2024SETTINGS['generator_params']['curve_fraction']
|
pies_fraction |
float
|
Fraction of divide-the-pies multi-issue scenarios |
DEFAULT2024SETTINGS['generator_params']['pies_fraction']
|
pareto_first |
bool
|
If given, the Pareto frontier will always be in the first set of outcomes |
DEFAULT2024SETTINGS['generator_params']['pareto_first']
|
n_ufuns |
int
|
Number of ufuns to generate per scenario |
DEFAULT2024SETTINGS['n_ufuns']
|
n_pareto |
int | float | tuple[float | int, float | int] | list[int | float]
|
Number of outcomes on the Pareto frontier in general scenarios. Can be specified as a number, a tuple of a min and max to sample within, a list of possibilities. Each value can either be an integer > 1 or a fraction of the number of outcomes in the scenario. |
DEFAULT2024SETTINGS['generator_params']['n_pareto']
|
pareto_log_uniform |
bool
|
Use log-uniform instead of uniform sampling if n_pareto is a tuple |
False
|
n_trials |
Number of times to retry generating each scenario if failures occures |
10
|
Returns:
Type | Description |
---|---|
list[Scenario]
|
A list |
Source code in anl/anl2024/runner.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
|
anl.anl2024.pie_scenarios
Creates single-issue scenarios with arbitrary/monotonically increasing utility functions
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_scenarios |
int
|
Number of scenarios to create |
20
|
n_outcomes |
int | tuple[int, int] | list[int]
|
Number of outcomes per scenario. If a tuple it will be interpreted as a min/max range to sample n. outcomes from. If a list, samples from this list will be used (with replacement). |
100
|
reserved_ranges |
ReservedRanges
|
Ranges of reserved values for first and second negotiators |
((0.0, 0.999999), (0.0, 0.999999))
|
log_uniform |
bool
|
If given, the distribution used will be uniform on the logarithm of n. outcomes (only used when n_outcomes is a 2-valued tuple). |
True
|
monotonic |
If true all ufuns are monotonically increasing in the portion of the pie |
False
|
Remarks
- When n_outcomes is a tuple, the number of outcomes for each scenario will be sampled independently.
Source code in anl/anl2024/runner.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
|
anl.anl2024.arbitrary_pie_scenarios
Source code in anl/anl2024/runner.py
anl.anl2024.monotonic_pie_scenarios
Source code in anl/anl2024/runner.py
anl.anl2024.zerosum_pie_scenarios
Creates scenarios all of the DivideThePie variety with proportions giving utility
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_scenarios |
int
|
Number of scenarios to create |
20
|
n_outcomes |
int | tuple[int, int] | list[int]
|
Number of outcomes per scenario (if a tuple it will be interpreted as a min/max range to sample n. outcomes from). |
100
|
reserved_ranges |
ReservedRanges
|
Ranges of reserved values for first and second negotiators |
((0.0, 0.499999), (0.0, 0.499999))
|
log_uniform |
bool
|
If given, the distribution used will be uniform on the logarithm of n. outcomes (only used when n_outcomes is a 2-valued tuple). |
True
|
Remarks
- When n_outcomes is a tuple, the number of outcomes for each outcome will be sampled independently