Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve entropy filters management #61

Merged
merged 2 commits into from
Feb 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions rocca/agents/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def __init__(
# Shannon entropy below 0.1, but an atom with truth value (stv
# 0 0.01) has Shannon entropy above 0.1, and an atom with
# truth value (stv 0 0.001) has a Shannon entropy above 0.9.
self.cogscm_maximum_shannon_entropy = 0.9
self.cogscm_maximum_shannon_entropy = 1.0

# Filter out cognitive schematics with a differential entropy
# equal to or lower than this parameter. The differential
Expand All @@ -190,7 +190,7 @@ def __init__(
# This parameter is comparable to
# cogscm_maximum_shannon_entropy but better accounts for
# confidence.
self.cogscm_maximum_differential_entropy = -1e-1
self.cogscm_maximum_differential_entropy = 0.0

# Filter out cognitive schematics with numbers of variables
# above this threshold
Expand Down Expand Up @@ -1042,26 +1042,28 @@ def is_desirable(self, cogscm: Atom) -> bool:
return False

# Check that its Shannon entropy is below the maximum threshold
se = shannon_entropy(cogscm, self.prior_a, self.prior_b)
if self.cogscm_maximum_shannon_entropy < se:
agent_log.fine(
msg
+ "its Shannon entropy {} is greater than {}".format(
se, self.cogscm_maximum_shannon_entropy
if self.cogscm_maximum_shannon_entropy < 1.0:
se = shannon_entropy(cogscm, self.prior_a, self.prior_b)
if self.cogscm_maximum_shannon_entropy < se:
agent_log.fine(
msg
+ "its Shannon entropy {} is greater than {}".format(
se, self.cogscm_maximum_shannon_entropy
)
)
)
return False
return False

# Check that its differential entropy is below the maximum threshold
de = differential_entropy(cogscm, self.prior_a, self.prior_b)
if self.cogscm_maximum_differential_entropy < de:
agent_log.fine(
msg
+ "its differential entropy {} is greater than {}".format(
de, self.cogscm_maximum_differential_entropy
if self.cogscm_maximum_differential_entropy < 0.0:
de = differential_entropy(cogscm, self.prior_a, self.prior_b)
if self.cogscm_maximum_differential_entropy < de:
agent_log.fine(
msg
+ "its differential entropy {} is greater than {}".format(
de, self.cogscm_maximum_differential_entropy
)
)
)
return False
return False

# Check that it has no more variables than allowed
mv = vardecl_size(get_vardecl(cogscm))
Expand Down