Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a notebook demonstrating how to evolve objects #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

engintoklu
Copy link
Collaborator

This pull request adds an example notebook which demonstrates how one can declare and solve an optimization problem that has its dtype set as object, and therefore has a custom solution structure.

While working on the example notebook, one bug, and one genetic algorithm-related shortcoming have been identified and fixed.

The bug was preventing one from instantiating a new ObjectArray with the help of evotorch.tools.as_tensor(..., dtype=object). This bug is fixed by this pull request.

The shortcoming was as follows: when the user defined a custom mutation operator using a regular function, GeneticAlgorithm assumed that the regular function would return a new batch of solutions whose length is equal to the number of solutions it received. This was an unnecessary restriction, and therefore, gets fixed with this pull request.

This commit adds an example notebook which
demonstrates how one can declare and solve an
optimization problem that has its `dtype` set as
`object`, and therefore has a custom solution
structure.

While working on the example notebook, one bug,
and one genetic algorithm-related shortcoming
have been identified and fixed.

The bug was preventing one from instantiating a
new `ObjectArray` with the help of
`evotorch.tools.as_tensor(..., dtype=object)`.
This commit fixes this bug.

The shortcoming was as follows: when the user
defined a custom mutation operator using a
regular function, `GeneticAlgorithm` assumed
that the regular function would return a new
batch of solutions whose length is equal to the
number of solutions it received. This was an
unnecessary restriction, and therefore, got
fixed with this commit.
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 76.73%. Comparing base (5c58566) to head (b74ca43).

Files Patch % Lines
src/evotorch/algorithms/ga.py 76.92% 3 Missing ⚠️
src/evotorch/tools/misc.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #102      +/-   ##
==========================================
- Coverage   76.74%   76.73%   -0.01%     
==========================================
  Files          49       49              
  Lines        7509     7519      +10     
==========================================
+ Hits         5763     5770       +7     
- Misses       1746     1749       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

None yet

1 participant