Skip to content

Commit 572f1a9

Browse files
S-furiDanySK
authored andcommitted
fix(sapere): keep observing for neighbrhoods LSA spaces changes
1 parent c14fbdf commit 572f1a9

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

alchemist-incarnation-sapere/src/main/java/it/unibo/alchemist/model/sapere/conditions/LsaNeighborhoodCondition.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,16 @@ public LsaNeighborhoodCondition(
5252
super(molecule, node);
5353
this.environment = environment;
5454

55-
// We depend on every neighbor's concentration of the target molecule.
56-
// An update is triggered only when a molecule matching the generalized template
57-
// is added or removed in any neighbor.
55+
// We depend on every neighbor's LsaSpace.
56+
// An update is triggered whenever a neighbor's LSA space changes.
5857
addObservableDependency(ObservableExtensions.INSTANCE.switchMap(
5958
environment.getNeighborhood(node).map(Neighborhood::getNeighbors),
6059
neighbors ->
6160
ObservableExtensions.INSTANCE.combineLatest(
6261
neighbors.stream()
6362
.filter(it -> it instanceof ILsaNode)
64-
.map(neighbor ->
65-
neighbor.observeConcentration(molecule.generalize())
66-
).toList(),
63+
.map(neighbor -> ((ILsaNode) neighbor).observeLsaSpace())
64+
.toList(),
6765
space -> space
6866
)
6967
));

alchemist-incarnation-sapere/src/main/java/it/unibo/alchemist/model/sapere/conditions/LsaStandardCondition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class LsaStandardCondition extends AbstractLsaCondition {
4949
public LsaStandardCondition(final ILsaMolecule mol, final ILsaNode n) {
5050
super(n, Sets.newHashSet(new ILsaMolecule[] {mol}));
5151

52-
addObservableDependency(n.observeConcentration(mol.generalize()));
52+
addObservableDependency(n.observeLsaSpace());
5353
setValidity(valid);
5454
setPropensity(MutableObservable.Companion.observe(-1d));
5555

0 commit comments

Comments
 (0)