Skip to content

Commit

Permalink
Merge pull request #61 from ngeiswei/improv-entropy-filter
Browse files Browse the repository at this point in the history
Improve entropy filters management
  • Loading branch information
ngeiswei authored Feb 16, 2022
2 parents 3f9998a + 46266e7 commit 2dbab53
Showing 1 changed file with 20 additions and 18 deletions.
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

0 comments on commit 2dbab53

Please sign in to comment.