iCog-Labs-Dev / metta-moses

Meta Optimization Semantic Evolutionary Search
3 stars 14 forks source link

Optimize the `getGuardSetExp` function #132

Closed Yagth closed 1 week ago

Yagth commented 3 weeks ago

Detailed Description

The getGuardSetExp function used in the delete-inconsistent-handle.metta file and defined in the rte-helpers.metta file can be optimized since the operation doesn't necessarily need to be done using iteration. The current implementation is iterating over the expression to determine whether an atom is fit to be considered as a guradSet or not. However this operation can be done in parallel.

This function can be refactored so that it can return guardSets of a given expression without the need to iterator over the expression one at a time.

Context

Refactoring the function as such:

Possible Implementation

A possible implementation could be to make the getGuardSetExp function a non deterministic function that takes an expression and uses superpose to determine whether each item is fit for a guardSet or not. For this purpose, one can define another partial function that takes an atom or expression and returns it if it is fit for a guardSet. This helper function can then be mapped over the superposed atom to be used as a filter.

Yagth commented 3 weeks ago

Refactor getGuardSetExp to utilize non determinism