User
- class negmas.elicitation.User(cost=0.0, nmi=None, *args, **kwargs)[source]
Bases:
negmas.types.rational.Rational
Abstract base class for all representations of users used for elicitation
- Parameters
preferences – The real utility function of the user (pass either ufun or preferences).
ufun – The real utility function of the user (pass either ufun or preferences).
cost (
float
) – A cost to be added for every question asked to the user.nmi – [Optional] The
AgentMechanismInterface
representing the negotiation session engaged in by this user using thisufun
.
Attributes Summary
Returns the preferences if it is a CrispUtilityFunction else None
Does the entity has an associated ufun?
Does the entity has an associated ufun?
The unique ID of this entity
A convenient name of the entity (intended primarily for printing/logging/debugging).
The utility function attached to that object
Returns the preferences if it is a ProbUtilityFunction else None
Reserved outcome is the outcome that will be realized by default for this agent.
Reserved value is what the entity gets if no agreement is reached in the negotiation.
- rtype
- rtype
Gets a
UtilityFunction
representing the real utility_function of the userThe unique ID of this entity
Methods Summary
ask
(q)Query the user and get a response.
checkpoint
(path[, file_name, info, ...])Saves a checkpoint of the current object at the given path.
checkpoint_info
(file_name)Returns the information associated with a dump of the object saved in the given file
cost_of_asking
([q, answer_id, ...])Returns the cost of asking the given
Quers
.create
(*args, **kwargs)Creates an object and returns a proxy to it.
Returns a list of elicited queries.
from_checkpoint
(file_name[, return_info])Creates an object from a saved checkpoint
is_satisfied
(constraint[, outcomes])Checks if the given consgtraint is satisfied for the user utility fun and the given outocmes.
on_preferences_changed
(changes)Called to inform the entity that its ufun has changed.
set
([preferences, cost])Sets the ufun and/or cost for this user <
0:desc
>set_preferences
(value[, force])Sets tha utility function/Preferences.
spawn
([spawn_as, spawn_params])spawn_object
(*args, **kwargs)Attributes Documentation
- crisp_ufun
Returns the preferences if it is a CrispUtilityFunction else None
- Return type
UtilityFunction | None
- id
The unique ID of this entity
- name
A convenient name of the entity (intended primarily for printing/logging/debugging).
- preferences
The utility function attached to that object
- Return type
Preferences | None
- prob_ufun
Returns the preferences if it is a ProbUtilityFunction else None
- Return type
ProbUtilityFunction | None
- reserved_outcome
Reserved outcome is the outcome that will be realized by default for this agent.
Remarks:
Reserved outcomes are defined for
OrdinalPreferences
.
See also
- Return type
Outcome | None
- reserved_value
Reserved value is what the entity gets if no agreement is reached in the negotiation.
The reserved value can either be explicity defined for the ufun or it can be the output of the ufun for
None
outcome.- Return type
- ufun
Gets a
UtilityFunction
representing the real utility_function of the user- Return type
- uuid
The unique ID of this entity
Methods Documentation
- checkpoint(path, file_name=None, info=None, exist_ok=False, single_checkpoint=True, step_attribs=('current_step', '_current_step', '_Entity__current_step', '_step'))
Saves a checkpoint of the current object at the given path.
- Parameters
path (
PathLike
) – Full path to a directory to store the checkpointfile_name (
Optional
[str
]) – Name of the file to dump into. If not given, a unique name is createdinfo (
Optional
[dict
[str
,Any
]]) – Information to save with the checkpoint (must be json serializable)exist_ok (
bool
) – If true, override existing dumpsingle_checkpoint (
bool
) – If true, keep a single checkpoint for the last stepstep_attribs (
tuple
[str
,...
]) – Attributes to represent the time-step of the object. Any of the given attributes will be used in the file name generated if single_checkpoint is False. If single_checkpoint is True, the filename will not contain time-step information
- Return type
- Returns
full path to the file used to save the checkpoint
- classmethod checkpoint_info(file_name)
Returns the information associated with a dump of the object saved in the given file
- Parameters
file_name (Path | str) – Name of the object
Returns:
- cost_of_asking(q=None, answer_id=- 1, estimate_answer_cost=True)[source]
Returns the cost of asking the given
Quers
.
- classmethod create(*args, **kwargs)
Creates an object and returns a proxy to it.
- elicited_queries()[source]
Returns a list of elicited queries.
For each elicited query, the following dataclass is returned: ElicitationRecord(query, cost, answer_index, step)
- Return type
- classmethod from_checkpoint(file_name, return_info=False)
Creates an object from a saved checkpoint
- Parameters
file_name (Path | str) –
return_info – If True, tbe information saved when the file was dumped are returned
- Return type
- Returns
Either the object or the object and dump-info as a dict (if return_info was true)
Remarks:
- If info is returned, it is guaranteed to have the following members:
time: Dump time
type: Type of the dumped object
id: ID
name: name
- is_satisfied(constraint, outcomes=typing.List[tuple])[source]
Checks if the given consgtraint is satisfied for the user utility fun and the given outocmes.
- Parameters
constraint (
Constraint
) – TheConstraint
outcome – A list of `Outcome`s to be passed to the constraint along with the user’s ufun.
- Return type
- on_preferences_changed(changes)
Called to inform the entity that its ufun has changed.
- Parameters
changes (
list
[PreferencesChange
]) – An ordered list of changes that happened.
Remarks:
You MUST call the super() version of this function either before or after your code when you are overriding it.
The most general form of change is
PreferencesChange.General
which indicates that you cannot trust anything you knew about the ufun anymore
- set(preferences=None, cost=None)[source]
Sets the ufun and/or cost for this user <
0:desc
>- Parameters
preferences (
Optional
[Preferences
]) – The ufun if given
- set_preferences(value, force=False)
Sets tha utility function/Preferences.
- Parameters
value (Preferences | None) – The value to set to
force – If true,
on_preferecnes_changed()
will always be called even ifvalue
==self.preferences
- Return type
Preferences | None
- classmethod spawn(spawn_as='object', spawn_params=None, *args, **kwargs)
- classmethod spawn_object(*args, **kwargs)