-
Notifications
You must be signed in to change notification settings - Fork 15
/
baseline.py
69 lines (54 loc) · 1.8 KB
/
baseline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
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
import time
from typing import Optional, Union
from .base import BaseElicitor
from ..common import MechanismState
from ..outcomes import Outcome
from ..utilities import (
IPUtilityFunction,
UtilityDistribution,
UtilityValue,
)
__all__ = ["DummyElicitor", "FullKnowledgeElicitor"]
class DummyElicitor(BaseElicitor):
"""
A dummy elicitation algorithm that does not do any elicitation.
"""
def utility_on_rejection(
self, outcome: "Outcome", state: MechanismState
) -> UtilityValue:
return self.reserved_value
def can_elicit(self) -> bool:
return True
def elicit_single(self, state: MechanismState):
return False
def init_elicitation(
self,
ufun: Optional[Union["IPUtilityFunction", "UtilityDistribution"]],
**kwargs,
):
super().init_elicitation(ufun=ufun, **kwargs)
strt_time = time.perf_counter()
self.offerable_outcomes = self._ami.outcomes
self._elicitation_time += time.perf_counter() - strt_time
class FullKnowledgeElicitor(BaseElicitor):
"""
An elicitor that does not *need* to do any elicitation because it has full access
to the user ufun.
"""
def utility_on_rejection(
self, outcome: "Outcome", state: MechanismState
) -> UtilityValue:
return self.reserved_value
def can_elicit(self) -> bool:
return True
def elicit_single(self, state: MechanismState):
return False
def init_elicitation(
self,
ufun: Optional[Union["IPUtilityFunction", "UtilityDistribution"]],
**kwargs,
):
super().init_elicitation(ufun=self.user.ufun)
strt_time = time.perf_counter()
self.offerable_outcomes = self._ami.outcomes
self._elicitation_time += time.perf_counter() - strt_time