Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Best solutions for Natural Computing 2023/2024

NotificationsYou must be signed in to change notification settings

mantasu/nat2324

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About

Best assignment solutions forNatural Computing 2023/2024 offered by theUniversity of Edinburgh. The repository contains algorithm implementations forParticle Swarm Optimization (and its variants, i.e.,Cuckoo Search,Bat Algorithm,Differential Evolution),Genetic Algorithm (canonical), andGenetic Programming (tree-based). Two main directories:

  • documents: contains coursework description and my report
  • notebooks: contains experiments for each of the questions

In addition, I attached my coursenotes. These are, however, squeezed into 6 pages which is what is allowed to be used during theNOTES PERMITTED exam.

Feedback

The coursework is worth 40% of the overall course mark, only the report is assessed but the code must be provided. Maximum points (100/100) were achieved with the following feedback:

Fantastic study! Your coursework meets and exceeds expectations, demonstrating a quality that could be considered for publication. Your efforts and achievements are just excellent. Well done!

Assignment Code

The source code (src) mainly contains classes and functions that model certain algorithms and problems. Notebooks focus on experiments with those algorithms and problems. In particular see:

  • problem1.ipynb: experiments for answering question 1 about particle cooperation
  • problem2.ipynb: experiments for answering question 2 about GA and Sumplete
  • problem3.ipynb: experiments for answering question 3 about GP and sequence generation

The experiment result files are not provided, however, they can all be reproduced by rerunning the cells (some may take several hours to run). There is actually no need to run the notebooks since the outputs are left displayed.

Documentation is only written for the major classes

Requirements

Please use at leastPython 3.10. For rendering graphs forGenetic Programming question, please installGraphviz. For example, if you're usingUbuntu:

sudo apt-get install graphviz

There are some package requirements as well. PLease install them as follows:

pip install -r requirements.txt

Disclaimer

Rerunning previous cells

Please also note that the cells are designed to be run in sequence and no previous cell is expected to be rerun. This is because most of teh subsequent cells overwrite the variables created by the previous cells (for easier readability, variable names are intended to be kept the same throughout the notebooks for every experiment). So, for example, instead of initializingN_experiment_1,N_experiment_2, etc., the same variableN is refreshed (with possibly different values) in every subsequent cell.

Although this may not be a good practice for long experiments (due to the results possibly getting lost), this is still intended because all the experiments are saved and can be quickly reloaded, in case we need to rerun the cells (e.g., if we change the style of the plots).

Saving experiment runs

Experiments will be automatically saved as.npz files with names generated from variable and static arguments, i.e., based on parameters that are being experimented with and the default ones. Note that, although for static arguments values are also labeled, e.g., if a static parameter isstatic_param["num_evaluations"] = 5000, then the filename will match that, i.e.,num_evaluations=5000.npz, the same is not done for variable parameters (otherwise there would be too many values), only the parameter names are included, e.g., if a variable parameter isvariable_param['N'] = range(1, 101), then the filename will match only the variable name, i.e.,[N].npz.

For this reason if multiple experiments are performed with different variable parameters, please note that the saved files may override the other ones. So either include some unique ranges for every experiment that uses the same variable parameters or include a dummy label in a static parameters dictionary, e.g.,static_param["version"]=1.

Issues

If the notebooks cannot be run due to failed imports, i.e., becausesys.path.append does not work in an expected way, please perform the following steps:

  1. Movesrc directory tree insidenotebooks folder. The file layout should now look as follows:
    └── path/to/nat2324  ├── notebooks|    ├── src/nat2324# The source code (folders and python files)|    ├── problem1.ipynb# Problem 1 notebook|    ├── problem2.ipynb# Problem 2 notebook|    └── problem3.ipynb# Problem 3 notebook  └── ...# Other files and folders except `src`
  2. Prependsrc. before imports fromnat2324, e.g., the setup cell inproblem1.ipynb would now look as follows:
    importnumpyasnpfromsrc.nat2324.problemsimportObjectivefromsrc.nat2324.algorithmsimportSwarmOptimizationfromsrc.nat2324.utilsimport*

References

Some of the algorithm implementations (particularly inproblem 1) took inspiration from existing repositories, or online tutorials:

Other algorithm implementations were either covered in lectures or inspiration was taken from tutorials.


[8]ページ先頭

©2009-2025 Movatter.jp