Skip to content

Commit

Permalink
Adding KGB to the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
blankjul committed Nov 19, 2023
1 parent 65bfd1f commit 52043df
Show file tree
Hide file tree
Showing 8 changed files with 268 additions and 232 deletions.
135 changes: 0 additions & 135 deletions df-problems-kgb-test.py

This file was deleted.

43 changes: 23 additions & 20 deletions docs/source/algorithms/moo/dnsga2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,19 @@
"outputs": [],
"source": [
"from pymoo.algorithms.moo.dnsga2 import DNSGA2\n",
"from pymoo.core.callback import CallbackCollection, Callback\n",
"from pymoo.core.callback import CallbackCollection\n",
"from pymoo.optimize import minimize\n",
"from pymoo.problems.dyn import TimeSimulation\n",
"from pymoo.problems.dynamic.df import DF1\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from pymoo.visualization.video.callback_video import ObjectiveSpaceAnimation\n",
"\n",
"problem = DF1(taut=2, n_var=2)\n",
"\n",
"algorithm = DNSGA2()\n",
"algorithm = DNSGA2(version=\"A\")\n",
"\n",
"simulation = TimeSimulation()\n",
"\n",
"\n",
"class ObjectiveSpaceAnimation(Callback):\n",
"\n",
" def _update(self, algorithm):\n",
" \n",
" if algorithm.n_gen % 20 == 0:\n",
" F = algorithm.opt.get(\"F\")\n",
" pf = algorithm.problem.pareto_front()\n",
"\n",
" plt.clf()\n",
" plt.scatter(F[:, 0], F[:, 1])\n",
" if pf is not None:\n",
" plt.plot(pf[:, 0], pf[:, 1], color=\"black\", alpha=0.7)\n",
"\n",
" plt.show()\n",
"\n",
"res = minimize(problem,\n",
" algorithm,\n",
" termination=('n_gen', 100),\n",
Expand All @@ -80,7 +65,25 @@
]
}
],
"metadata": {},
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
151 changes: 151 additions & 0 deletions docs/source/algorithms/moo/kgb.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
{
"cells": [
{
"cell_type": "raw",
"metadata": {
"raw_mimetype": "text/restructuredtext"
},
"source": [
".. _nb_kgb:"
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"# KGB-DMOEA: Knowledge-Guided Bayesian Dynamic Multi-Objective Evolutionary Algorithm"
]
},
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"KGB-DMOEA is a sophisticated evolutionary algorithm for dynamic multi-objective optimization problems (DMOPs). It employs a knowledge-guided Bayesian classification approach to adeptly navigate and adapt to changing Pareto-optimal solutions in dynamic environments. This algorithm utilizes past search experiences, distinguishing them as beneficial or non-beneficial, to effectively direct the search in new scenarios."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Key Features\n",
"\n",
"\n",
"- **Knowledge Reconstruction-Examination (KRE):** Dynamically re-evaluates historical optimal solutions based on their relevance and utility in the current environment. \n",
"- **Bayesian Classification:** Employs a Naive Bayesian Classifier to forecast high-quality initial populations for new environments.\n",
"- **Adaptive Strategy:** Incorporates dynamic parameter adjustment for optimized performance across varying dynamic contexts."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'pymoo.algorithms.moo.kgb'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m/var/folders/dp/fdf8szyn3zd4kcyh18gxsyvm0000gn/T/ipykernel_78338/2424210873.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mpymoo\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0malgorithms\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmoo\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mkgb\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mKGB\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpymoo\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcore\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcallback\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mCallbackCollection\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpymoo\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0moptimize\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mminimize\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpymoo\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mproblems\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdyn\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mTimeSimulation\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mpymoo\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mproblems\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdynamic\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdf\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mDF1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pymoo.algorithms.moo.kgb'"
]
}
],
"source": [
"from pymoo.algorithms.moo.kgb import KGB\n",
"from pymoo.core.callback import CallbackCollection\n",
"from pymoo.optimize import minimize\n",
"from pymoo.problems.dyn import TimeSimulation\n",
"from pymoo.problems.dynamic.df import DF1\n",
"\n",
"from pymoo.visualization.video.callback_video import ObjectiveSpaceAnimation\n",
"\n",
"problem = DF1(taut=2, n_var=2)\n",
"\n",
"algorithm = KGB()\n",
"\n",
"simulation = TimeSimulation()\n",
"\n",
"res = minimize(problem,\n",
" algorithm,\n",
" termination=('n_gen', 100),\n",
" callback=CallbackCollection(ObjectiveSpaceAnimation(), simulation),\n",
" seed=1,\n",
" verbose=True)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"tags": []
},
"source": [
"### Parameters \n",
"\n",
"- **perc_detect_change (float, optional):** Proportion of the population used to detect environmental changes. \n",
"- **perc_diversity (float, optional):** Proportion of the population allocated for introducing diversity. \n",
"- **c_size (int, optional):** Cluster size.\n",
"- **eps (float, optional):** Threshold for detecting changes. Default: \n",
"- **pertub_dev (float, optional):** Deviation for perturbation in diversity introduction. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### References"
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"Yulong Ye, Lingjie Li, Qiuzhen Lin, Ka-Chun Wong, Jianqiang Li, Zhong Ming. “A knowledge guided Bayesian classification for dynamic multi-objective optimization”. Knowledge-Based Systems, Volume 251, 2022. Link to the paper"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 52043df

Please sign in to comment.