Skip to content

Fix/demo problems#437

Merged
Yagth merged 10 commits into
devfrom
fix/DemoProblems
Apr 24, 2026
Merged

Fix/demo problems#437
Yagth merged 10 commits into
devfrom
fix/DemoProblems

Conversation

@Yagth

@Yagth Yagth commented Apr 24, 2026

Copy link
Copy Markdown
Member

Description

This branch updates the MOSES MeTTa codebase to use PeTTa-friendly raw expression structures (cons/()) in place of several older collection and list helper patterns, fixes the demo-problems flow, and restores the strict test suite after the migration. These changes resulted an overall 2x performance increase as compared to the latest PeTTa changes and 4x increase as to what things were when testing it against the v1.0.0 PeTTa.

Compared with dev, the branch primarily does four things:

  1. Replaces many List.*-style recursive helper usages with direct expression-backed operations.
  2. Reworks Map, MultiMap, and OS-related logic to use expression-backed containers and simpler helper implementations.
  3. Tested the usage of PeTTa built until function yields a faster performance, although that change isn't pushed here because it depends on making changes to PeTTa.

The resulting diff touches core MOSES flow, utilities, metapopulation/deme handling, feature-selection, scoring, representation logic, and their associated tests.

Motivation and Context

The main motivation for this branch is performance and compatibility with the current PeTTa runtime while keeping MOSES behavior correct.

How Has This Been Tested?

Testing was done both at the individual-file level and across the full strict Python runner.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Yagth added 8 commits March 26, 2026 14:03
## Description
This PR synchronizes `main` with `dev`, introducing a major refactor for
PeTTa interpreter compatibility and structural alignment with OpenCog
Classic MOSES.

### Key Highlights
- **Performance**: Achieved a ~10x speedup by removing redundant `eval`
calls, implementing caching for `scoreTree` and `getCscore`, and
migrating to the PeTTa interpreter.
- **OpenCog Classic Alignment**: Aligned `BuildLogical` complexity, tree
reconstruction (`getCandidateRec`), and reduction rules (`0subsume`)
with classic C++ MOSES behavior.
- **Game Policy Domain**: Extended the framework to support game
strategy evolution (e.g., Tic-Tac-Toe) via a new Strategy Subtree Knob
(SSK) system and `PRIORITIZED-OR` operators.
- **Baseline Players**: Added Minimax and Alpha-Beta Pruned Minimax
players with immediate win detection.
- **CI/CD**: Established a Dockerized testing environment to ensure
stable, persistent validation with PeTTa.

## Motivation and Context
These updates are essential for achieving architectural parity with
OpenCog Classic, resolving performance bottlenecks for larger datasets
(like parity-4), and enabling MOSES to evolve complex game strategies.

## How Has This Been Tested?
- **Performance Benchmarks**: Verified execution time reduction from ~20
mins to ~2 mins on core tasks.
- **Functional Tests**: Validated both Boolean and Game domain workflows
using the new automated CI suite.
- **Domain Validation**: Confirmed correct strategy evolution for
Tic-Tac-Toe and parity/multiplexer results.

## Types of changes
- [x] Bug fix
- [x] New feature
- [x] Breaking change (due to PeTTa migration and structural refactors)

## Checklist:
- [x] Code follows project style.
- [x] Added tests for new features.
- [x] All CI tests passed.
This resulted in almost double the performance of the algorithm. When
tested with the majoirty3 problem in 2 generations, the running time
reduced almost by half.
- Replaced every recursive List functions with the built in constructor of expressions cons and () instead. This resulted in almost double the running speed after testing
- Before the optimization the algorithm used to take around 53 seconds, close to a minute but after it only takes around 18 seconds. This is a huge improvement
- Removed the previous Map, MultiMap and OS with built in expressions and their helpers whenever available and recurision over expressions when not. This gained additional two second performance improvement when tested against 2 generations of majority3 problem with no feature selection
@Yagth Yagth force-pushed the fix/DemoProblems branch from fe20481 to 2a4fbfa Compare April 24, 2026 09:58
@Yagth Yagth force-pushed the fix/DemoProblems branch from 2a4fbfa to 520549f Compare April 24, 2026 09:59
@Yagth Yagth marked this pull request as ready for review April 24, 2026 14:32
@Yagth Yagth merged commit 21d17c6 into dev Apr 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant