Skip to content

Commit

Permalink
keep build_utility_matrix in informativity
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Imel authored and Nathaniel Imel committed Jan 10, 2024
1 parent 1a4359a commit ef35355
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/ultk/effcomm/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from scipy.special import softmax
from ultk.language.language import Expression, Language
from ultk.language.semantics import Referent
from ultk.effcomm.util import bayes

##############################################################################
# Base communicative agent class
Expand Down
15 changes: 13 additions & 2 deletions src/ultk/effcomm/informativity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from cmath import isclose
from typing import Callable
from ultk.language.language import Language
from ultk.language.semantics import Referent
from ultk.language.semantics import Referent, Universe
from ultk.effcomm.agent import (
Speaker,
Listener,
Expand All @@ -13,7 +13,18 @@
PragmaticSpeaker,
PragmaticListener,
)
from ultk.effcomm.util import build_utility_matrix


def build_utility_matrix(
universe: Universe, utility: Callable[[Referent, Referent], float]
) -> np.ndarray:
"""Construct the square matrix specifying the utility function defined for pairs of meanings, used for computing communicative success."""
return np.array(
[
[utility(ref, ref_) for ref_ in universe.referents]
for ref in universe.referents
]
)


def indicator_utility(ref1: Referent, ref2: Referent) -> float:
Expand Down

0 comments on commit ef35355

Please sign in to comment.