jameshughes89 / cs4XX-EvolutionaryComputation

CS 4XX: Evolutionary Computation
http://csci340.com/
GNU General Public License v3.0
5 stars 14 forks source link

:new: :mortar_board: :art: Add cultural algorithms #246

Closed lxy3300 closed 8 months ago

lxy3300 commented 9 months ago

What

Add site content related to cultural algorithm.

Why

This is for my lecture and my topic is cultural algorithm.

Where

Create a cultural-algorithms directory under /site/student-lectures, which contains added files. Add the cultural-algorithm site to toctree in index.rst.

How

Add rst file about the content of cultural algorithms. Add a figure showing the components of the cultural algorithm. Add a Python file for an example of the cultural algorithm.

lxy3300 commented 9 months ago

Move the code to the src directory and change the name to cultrual_algorithm.py. Add test_cultural_algorithm.py for unit tests under the test directory.

Changes for the code part:

  1. Change the name of fitness_function to value_fitness, and add two unit tests test_value_fitness_returns_correct_value and test_value_fitness_raises_value_error.
  2. Change the initialize_population function to a piece of code in the main part.
  3. Modify the accept function, and add a unit test test_initialize_belief_space_returns_correct_value.
  4. Modify the update function to a pure function, and add the corresponding unit test test_update_returns_correct_value.
  5. Modify all influence functions to pure functions, and add the corresponding unit tests.
  6. Fix errors in the influence_method_4 function.
  7. Remove useless comments.

Changes for the cultural-algoritms.rst:

  1. In the introduction, add descriptions of cultural algorithms.
  2. I made this figure, referencing a figure from a paper. The paper is listed first in the references.
  3. Add captions to the figure.
  4. Fix some grammatical errors.
lxy3300 commented 9 months ago

Thanks for the feedback!

Fix bugs in cultural_algorithm.py: I found that update and all influence functions are still impure, so I changed the copy to deepcopy.

Modify test_cultural_algorithm.py:

  1. Use subtests to test_value_fitness_returns_correct_value and test_value_fitness_raises_value_error.
  2. Separate the test_initialize_belief_space_returns_correct_value into 2 functions and modify the tests.
  3. Separate the test_update_returns_correct_value into 2 functions.
  4. For test_influence_method_1_returns_correct_value, it should have all cases since it just has one case? But I still add one test case.
  5. For other influence functions, I add one test case. This test case covers all cases under if condition.
lxy3300 commented 9 months ago

I'm not sure what I did. I wanted to resolve the conflict, so I fetched the new main for rebase, finally pushed, and then my pull request has more of everything under novelty search.

lxy3300 commented 9 months ago

I changed the description of the belief space, the original description had some errors.

jameshughes89 commented 8 months ago

I'm not sure what I did. I wanted to resolve the conflict, so I fetched the new main for rebase, finally pushed, and then my pull request has more of everything under novelty search.

It's because the PR was not up to date with the main branch. I updated it --- problem solved.