pkalivas / radiate

A genetic programming engine which evolves solutions through asynchronous speciation.
MIT License
147 stars 16 forks source link

Remove almost all unsafe code and fixed a memory leak in `Evtree` #2

Closed Neopallium closed 4 years ago

Neopallium commented 4 years ago

The only unsafe left is in the IterMut and the parent references. Down to only 7 unsafe usages in radiate_matrix_evtree crate and no unsafe in the other crates.

Split Evtree so that the tree code is now generic and separate from the NeuralNetwork & Genome logic.

Fixed the level order iterator (it was returning all left node first) and added some unit tests to test the iterators.

The only way to remove the remaining unsafe code would be to use something like Rc<RefCell<>> and Weak references for the parent.

pkalivas commented 4 years ago

Thanks for this, I appreciate the time/work form a more experienced rust developer. I just update radiate (1.1.55) and evtree (1.0.1) on crates.