MDCHAMP / FreeLunch

Meta-heuristic optimisation suite for python
https://pypi.org/project/freelunch/
MIT License
46 stars 3 forks source link

New Bounding Strategy #29

Closed TimothyRogers closed 3 years ago

TimothyRogers commented 3 years ago

Created Bounder class to implement bounds and address #28

Calls to enforce bounds are now self.bounds(pop) which will ensure all individuals in pop are bounded by the given strategy.

Functionality also exists to iterate over bounds which is a thin wrapper to exposing the ndarray which contains the bounds. This is also done for __len__ and .shape.

Bounds are always stored internally in the Bounder class as an ndarray.

Sticky bounds implemented and replaces old bounding.

codecov-commenter commented 3 years ago

Codecov Report

Merging #29 (57b271e) into main (0068a96) will decrease coverage by 4.54%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #29      +/-   ##
==========================================
- Coverage   98.80%   94.26%   -4.55%     
==========================================
  Files          17       17              
  Lines        1170     1185      +15     
==========================================
- Hits         1156     1117      -39     
- Misses         14       68      +54     
Impacted Files Coverage Δ
tests/test_base.py 100.00% <ø> (ø)
src/freelunch/base.py 100.00% <100.00%> (ø)
src/freelunch/optimisers.py 89.56% <100.00%> (-9.44%) :arrow_down:
src/freelunch/tech.py 62.90% <100.00%> (-35.51%) :arrow_down:
tests/test_optimisers.py 100.00% <100.00%> (ø)
tests/test_tech.py 100.00% <100.00%> (ø)
src/freelunch/zoo.py 94.31% <0.00%> (-4.55%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 0068a96...57b271e. Read the comment docs.

MDCHAMP commented 3 years ago

So as discussed I am reluctant to add another stateful object to handle the bounding and I think it might be cleaner for now to just extend the attributes of base. Afterall any hyperparameters that you want to add to your custum bounding method can just be supplied to the overall hypers attribute for a cleaner data structure imo. I like the bounding API like this though so I am going to implement the call method of bounder a classmethod of base.

MDCHAMP commented 3 years ago

Made the changes as described, should still have the same functionality. I'm pretty sure that python functions are stateful if someone really wanted to hack a non-adaptable stateful bounding method.

Also did some repo tidying.

Can't help but feel that the next big job is going to be documentation

MDCHAMP commented 3 years ago

Reverted the grenade stuff, should be ok to merge now.