diff --git a/README.md b/README.md new file mode 100644 index 00000000..565f2629 --- /dev/null +++ b/README.md @@ -0,0 +1,224 @@ +# **Geatpy2** +The Genetic and Evolutionary Algorithm Toolbox for Python with high performance. + +![Travis](https://travis-ci.org/geatpy-dev/geatpy.svg?branch=master) +[![Package Status](https://img.shields.io/pypi/status/geatpy.svg)](https://pypi.org/project/geatpy/) +![Python](https://img.shields.io/badge/python->=3.5-green.svg) +![Pypi](https://img.shields.io/badge/pypi-2.7.0-blue.svg) +[![Download](https://img.shields.io/pypi/dm/geatpy.svg)](https://pypi.python.org/pypi/geatpy) +[![License](https://img.shields.io/pypi/l/geatpy.svg)](https://github.com/geatpy-dev/geatpy/blob/master/LICENSE) +[![Gitter](https://badges.gitter.im/geatpy2/community.svg)](https://gitter.im/geatpy2/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) + +## Introduction +* **Website (including documentation)**: http://www.geatpy.com +* **Demo** : https://github.com/geatpy-dev/geatpy/tree/master/geatpy/demo +* **Pypi page** : https://pypi.org/project/geatpy/ +* **Contact us**: http://geatpy.com/index.php/about/ +* **Bug reports**: https://github.com/geatpy-dev/geatpy/issues +* **Notice**: http://geatpy.com/index.php/notice/ +* **FAQ**: http://geatpy.com/index.php/faq/ + +The features of Geatpy: + +* Capability of solving single-objective, multi-objectives, many-objectives and combinatorial optimization problems fast. + +* A huge number of operators with high performance of evolutionary algorithms (selection, recombination, mutation, migration...). + +* Support numerous encodings for the chromosome of the population. + +* Many evolutionary algorithm templates, including GA, DE, ES for single/multi-objective(s) evolution. + +* Multiple population evolution. + +* Support polysomy evolution. + +* Parallelization and distribution of evaluations. + +* Testbeds containing most common benchmarks functions. + +* Support tracking analysis of the evolution iteration. + +* Many evaluation metrics of algorithms. + +## Improvement of Geatpy 2.7.0 + +* Add a new way to define the aim function of the problem. + +* Support calculating objectives and constraints for the variables of only one individual. + +* Add a optimize function to do the optimization more convenient. + +* Add new open-source plotting functions. + +* Remove the dependency on scipy. + +* A new and faster core. + +## Installation +1.Installing online: + + pip install geatpy + +2.From source: + + python setup.py install + +or + + pip install .whl + +**Attention**: Geatpy requires numpy>=1.17.0 and matplotlib>=3.0.0, the installation program won't help you install them so that you have to install both of them by yourselves. + +## Versions + +**Geatpy** must run under **Python**3.5, 3.6, 3.7, 3.8, 3.9, or 3.10 in Windows x32/x64, Linux x64 or MacOS x64. + +There are different versions for **Windows**, **Linux** and **Mac**, you can download them from http://geatpy.com/ + +The version of **Geatpy** on github is the latest version suitable for **Python** >= 3.5 + +You can also **update** Geatpy by executing the command: + + pip install --upgrade geatpy + +If something wrong happened, such as decoding error about 'utf8' of pip, run this command instead or execute it as an administrator: + + pip install --upgrade --user geatpy + +Quick start +----------- + +Here is the UML figure of Geatpy2. + +![image](https://github.com/geatpy-dev/geatpy/blob/master/structure.png) + +For solving a multi-objective optimization problem, you can use **Geatpy** mainly in two steps: + +1.Write down the aim function and some relevant settings in a derivative class named **MyProblem**, which is inherited from **Problem** class: + +```python +"""MyProblem.py""" +import numpy as np +import geatpy as ea +class MyProblem(ea.Problem): # Inherited from Problem class. + def __init__(self, M): # M is the number of objects. + name = 'DTLZ1' # Problem's name. + maxormins = [1] * M # All objects are need to be minimized. + Dim = M + 4 # Set the dimension of decision variables. + varTypes = [0] * Dim # Set the types of decision variables. 0 means continuous while 1 means discrete. + lb = [0] * Dim # The lower bound of each decision variable. + ub = [1] * Dim # The upper bound of each decision variable. + lbin = [1] * Dim # Whether the lower boundary is included. + ubin = [1] * Dim # Whether the upper boundary is included. + # Call the superclass's constructor to complete the instantiation + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + def aimFunc(self, pop): # Write the aim function here, pop is an object of Population class. + Vars = pop.Phen # Get the decision variables + XM = Vars[:,(self.M-1):] + g = np.array([100 * (self.Dim - self.M + 1 + np.sum(((XM - 0.5)**2 - np.cos(20 * np.pi * (XM - 0.5))), 1))]).T + ones_metrix = np.ones((Vars.shape[0], 1)) + pop.ObjV = 0.5 * np.fliplr(np.cumprod(np.hstack([ones_metrix, Vars[:,:self.M-1]]), 1)) * np.hstack([ones_metrix, 1 - Vars[:, range(self.M - 2, -1, -1)]]) * np.tile(1 + g, (1, self.M)) + def calReferObjV(self): # Calculate the theoretic global optimal solution here. + uniformPoint, ans = ea.crtup(self.M, 10000) # create 10000 uniform points. + realBestObjV = uniformPoint / 2 + return realBestObjV +``` + +2.Instantiate **MyProblem** class and a derivative class inherited from **Algorithm** class in a Python script file "main.py" then execute it. **For example**, trying to find the pareto front of **DTLZ1**, do as the following: + +```python +"""main.py""" +import geatpy as ea # Import geatpy +from MyProblem import MyProblem # Import MyProblem class +if __name__ == '__main__': + M = 3 # Set the number of objects. + problem = MyProblem(M) # Instantiate MyProblem class + # Instantiate a algorithm class. + algorithm = ea.moea_NSGA3_templet(problem, + ea.Population(Encoding='RI', NIND=100), # Set 100 individuals. + MAXGEN=500, # Set the max iteration number. + logTras=1) # Set the frequency of logging. If it is zero, it would not log. + # Do the optimization + res = ea.optimize(algorithm, verbose=False, drawing=1, outputMsg=True, drawLog=True, saveFlag=True) + +``` + +Run the "main.py" and the part of the result is: + +![image](https://github.com/geatpy-dev/geatpy/blob/master/geatpy/testbed/moea_test/result/Pareto%20Front%20Plot.svg) + +Execution time: 0.3650233745574951 s + +Evaluation number: 45500 + +The number of non-dominated solutions is: 91 + +gd: 0.00033 + +igd: 0.02084 + +hv: 0.84061 + +spacing: 0.00158 + +For solving another problem: **Ackley-30D**, which has only one object and 30 decision variables, what you need to do is almost the same as above. + +1.Write the aim function in "MyProblem.py". + +```python +import numpy as np +import geatpy as ea +class Ackley(ea.Problem): # Inherited from Problem class. + def __init__(self, D = 30): + name = 'Ackley' # Problem's name. + M = 1 # Set the number of objects. + maxormins = [1] * M # All objects are need to be minimized. + Dim = D # Set the dimension of decision variables. + varTypes = [0] * Dim # Set the types of decision variables. 0 means continuous while 1 means discrete. + lb = [-32.768] * Dim # The lower bound of each decision variable. + ub = [32.768] * Dim # The upper bound of each decision variable. + lbin = [1] * Dim # Whether the lower boundary is included. + ubin = [1] * Dim # Whether the upper boundary is included. + # Call the superclass's constructor to complete the instantiation + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + def aimFunc(self, pop): # Write the aim function here, pop is an object of Population class. + x = pop.Phen # Get the decision variables + n = self.Dim + f = np.array([-20 * np.exp(-0.2*np.sqrt(1/n*np.sum(x**2, 1))) - np.exp(1/n * np.sum(np.cos(2 * np.pi * x), 1)) + np.e + 20]).T + return f, CV + def calReferObjV(self): # Calculate the global optimal solution here. + realBestObjV = np.array([[0]]) + return realBestObjV +``` + +2.Write "main.py" to execute the algorithm templet to solve the problem. + +```python +import geatpy as ea # import geatpy +import numpy as np +from MyProblem import Ackley +if __name__ == '__main__': + # Instantiate MyProblem class. + problem = Ackley(30) + # Instantiate a algorithm class. + algorithm = ea.soea_DE_rand_1_bin_templet(problem, + ea.Population(Encoding='RI', NIND=20), + MAXGEN=1000, # Set the max times of iteration. + logTras=1) # Set the frequency of logging. If it is zero, it would not log. + algorithm.mutOper.F = 0.5 # Set the F of DE + algorithm.recOper.XOVR = 0.2 # Set the Cr of DE (Here it is marked as XOVR) + # Do the optimization + res = ea.optimize(algorithm, verbose=False, drawing=1, outputMsg=True, drawLog=True, saveFlag=True, dirName='result') +``` + +Part of the result is: + +![image](https://github.com/geatpy-dev/geatpy/blob/master/geatpy/testbed/soea_test/result/Trace%20Plot.svg) + +Execution time: 0.256328821182251 s + +Evaluation number: 20000 + +The best objective value is: 3.209895993450118e-08 + +To get more tutorials, please link to http://www.geatpy.com. diff --git a/_core/Linux/lib64/v3.6/awGA.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/awGA.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..55d0685b Binary files /dev/null and b/_core/Linux/lib64/v3.6/awGA.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/boundfix.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/boundfix.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..d1ffc77c Binary files /dev/null and b/_core/Linux/lib64/v3.6/boundfix.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/bs2int.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/bs2int.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..35662b87 Binary files /dev/null and b/_core/Linux/lib64/v3.6/bs2int.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/bs2real.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/bs2real.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..97661a27 Binary files /dev/null and b/_core/Linux/lib64/v3.6/bs2real.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/bs2ri.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/bs2ri.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..a35b9e9e Binary files /dev/null and b/_core/Linux/lib64/v3.6/bs2ri.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/cdist.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/cdist.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..360fd879 Binary files /dev/null and b/_core/Linux/lib64/v3.6/cdist.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/crowdis.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/crowdis.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..b099ec29 Binary files /dev/null and b/_core/Linux/lib64/v3.6/crowdis.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/crtbp.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/crtbp.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..1c4c4ad8 Binary files /dev/null and b/_core/Linux/lib64/v3.6/crtbp.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/crtfld.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/crtfld.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..99093a9f Binary files /dev/null and b/_core/Linux/lib64/v3.6/crtfld.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/crtgp.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/crtgp.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..a4bfb1ff Binary files /dev/null and b/_core/Linux/lib64/v3.6/crtgp.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/crtidp.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/crtidp.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..2dacdf46 Binary files /dev/null and b/_core/Linux/lib64/v3.6/crtidp.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/crtip.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/crtip.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..51451a68 Binary files /dev/null and b/_core/Linux/lib64/v3.6/crtip.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/crtpc.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/crtpc.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..777c50d9 Binary files /dev/null and b/_core/Linux/lib64/v3.6/crtpc.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/crtpp.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/crtpp.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..01b69822 Binary files /dev/null and b/_core/Linux/lib64/v3.6/crtpp.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/crtri.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/crtri.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..ab169c92 Binary files /dev/null and b/_core/Linux/lib64/v3.6/crtri.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/crtrp.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/crtrp.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..c9c1e7ad Binary files /dev/null and b/_core/Linux/lib64/v3.6/crtrp.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/crtup.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/crtup.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..c49aef00 Binary files /dev/null and b/_core/Linux/lib64/v3.6/crtup.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/dup.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/dup.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..f660da4e Binary files /dev/null and b/_core/Linux/lib64/v3.6/dup.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/ecs.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/ecs.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..d08cbfba Binary files /dev/null and b/_core/Linux/lib64/v3.6/ecs.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/etour.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/etour.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..c3497529 Binary files /dev/null and b/_core/Linux/lib64/v3.6/etour.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/indexing.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/indexing.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..4eebaa8a Binary files /dev/null and b/_core/Linux/lib64/v3.6/indexing.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/indicator.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/indicator.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..d6263b94 Binary files /dev/null and b/_core/Linux/lib64/v3.6/indicator.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mergecv.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mergecv.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..cfe7b7bc Binary files /dev/null and b/_core/Linux/lib64/v3.6/mergecv.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/migrate.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/migrate.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..605ac370 Binary files /dev/null and b/_core/Linux/lib64/v3.6/migrate.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/moeaplot.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/moeaplot.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..65e69a4d Binary files /dev/null and b/_core/Linux/lib64/v3.6/moeaplot.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mselecting.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mselecting.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..69d78f18 Binary files /dev/null and b/_core/Linux/lib64/v3.6/mselecting.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mutate.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mutate.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..2e04e3c3 Binary files /dev/null and b/_core/Linux/lib64/v3.6/mutate.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mutbga.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mutbga.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..1655f9dd Binary files /dev/null and b/_core/Linux/lib64/v3.6/mutbga.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mutbin.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mutbin.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..e906fa91 Binary files /dev/null and b/_core/Linux/lib64/v3.6/mutbin.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mutde.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mutde.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..f25cd99e Binary files /dev/null and b/_core/Linux/lib64/v3.6/mutde.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mutgau.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mutgau.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..382b43ad Binary files /dev/null and b/_core/Linux/lib64/v3.6/mutgau.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mutinv.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mutinv.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..3e607697 Binary files /dev/null and b/_core/Linux/lib64/v3.6/mutinv.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mutmove.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mutmove.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..ddc8fc8b Binary files /dev/null and b/_core/Linux/lib64/v3.6/mutmove.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mutpolyn.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mutpolyn.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..814b1d1a Binary files /dev/null and b/_core/Linux/lib64/v3.6/mutpolyn.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mutpp.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mutpp.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..5d1a4f8f Binary files /dev/null and b/_core/Linux/lib64/v3.6/mutpp.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mutswap.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mutswap.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..4f38955b Binary files /dev/null and b/_core/Linux/lib64/v3.6/mutswap.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/mutuni.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/mutuni.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..fb29e6ba Binary files /dev/null and b/_core/Linux/lib64/v3.6/mutuni.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/ndsortDED.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/ndsortDED.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..8b023acc Binary files /dev/null and b/_core/Linux/lib64/v3.6/ndsortDED.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/ndsortESS.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/ndsortESS.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..2ecc0192 Binary files /dev/null and b/_core/Linux/lib64/v3.6/ndsortESS.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/ndsortTNS.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/ndsortTNS.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..29c6bb61 Binary files /dev/null and b/_core/Linux/lib64/v3.6/ndsortTNS.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/otos.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/otos.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..05dcb0a8 Binary files /dev/null and b/_core/Linux/lib64/v3.6/otos.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/pbi.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/pbi.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..383b2ddc Binary files /dev/null and b/_core/Linux/lib64/v3.6/pbi.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/powing.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/powing.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..2f814573 Binary files /dev/null and b/_core/Linux/lib64/v3.6/powing.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/ranking.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/ranking.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..77962873 Binary files /dev/null and b/_core/Linux/lib64/v3.6/ranking.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/rcs.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/rcs.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..5006efb2 Binary files /dev/null and b/_core/Linux/lib64/v3.6/rcs.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/recdis.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/recdis.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..e43da2f8 Binary files /dev/null and b/_core/Linux/lib64/v3.6/recdis.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/recint.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/recint.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..363a2c50 Binary files /dev/null and b/_core/Linux/lib64/v3.6/recint.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/reclin.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/reclin.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..4118265b Binary files /dev/null and b/_core/Linux/lib64/v3.6/reclin.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/recndx.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/recndx.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..31c48145 Binary files /dev/null and b/_core/Linux/lib64/v3.6/recndx.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/recombin.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/recombin.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..ffc2e5ea Binary files /dev/null and b/_core/Linux/lib64/v3.6/recombin.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/recsbx.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/recsbx.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..7d65cb92 Binary files /dev/null and b/_core/Linux/lib64/v3.6/recsbx.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/refgselect.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/refgselect.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..c607a415 Binary files /dev/null and b/_core/Linux/lib64/v3.6/refgselect.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/refselect.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/refselect.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..c7fb1951 Binary files /dev/null and b/_core/Linux/lib64/v3.6/refselect.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/ri2bs.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/ri2bs.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..af61fec4 Binary files /dev/null and b/_core/Linux/lib64/v3.6/ri2bs.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/rps.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/rps.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..5825423e Binary files /dev/null and b/_core/Linux/lib64/v3.6/rps.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/rwGA.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/rwGA.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..479348fc Binary files /dev/null and b/_core/Linux/lib64/v3.6/rwGA.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/rws.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/rws.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..2ac176bf Binary files /dev/null and b/_core/Linux/lib64/v3.6/rws.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/scaling.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/scaling.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..b0e5ede9 Binary files /dev/null and b/_core/Linux/lib64/v3.6/scaling.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/selecting.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/selecting.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..e62bf9b2 Binary files /dev/null and b/_core/Linux/lib64/v3.6/selecting.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/soeaplot.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/soeaplot.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..a1a6d79b Binary files /dev/null and b/_core/Linux/lib64/v3.6/soeaplot.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/sus.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/sus.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..1b7ee7ff Binary files /dev/null and b/_core/Linux/lib64/v3.6/sus.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/tcheby.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/tcheby.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..aec8db1a Binary files /dev/null and b/_core/Linux/lib64/v3.6/tcheby.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/tour.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/tour.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..5e31b3a0 Binary files /dev/null and b/_core/Linux/lib64/v3.6/tour.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/trcplot.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/trcplot.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..c0820008 Binary files /dev/null and b/_core/Linux/lib64/v3.6/trcplot.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/urs.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/urs.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..6b07df68 Binary files /dev/null and b/_core/Linux/lib64/v3.6/urs.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/varplot.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/varplot.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..e267fc89 Binary files /dev/null and b/_core/Linux/lib64/v3.6/varplot.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/xovbd.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/xovbd.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..cd759a73 Binary files /dev/null and b/_core/Linux/lib64/v3.6/xovbd.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/xovdp.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/xovdp.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..bf3c0399 Binary files /dev/null and b/_core/Linux/lib64/v3.6/xovdp.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/xovexp.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/xovexp.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..cb0eb9b8 Binary files /dev/null and b/_core/Linux/lib64/v3.6/xovexp.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/xovox.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/xovox.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..aa60a102 Binary files /dev/null and b/_core/Linux/lib64/v3.6/xovox.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/xovpmx.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/xovpmx.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..43d60980 Binary files /dev/null and b/_core/Linux/lib64/v3.6/xovpmx.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/xovsec.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/xovsec.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..8bf28a4d Binary files /dev/null and b/_core/Linux/lib64/v3.6/xovsec.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/xovsh.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/xovsh.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..4d292010 Binary files /dev/null and b/_core/Linux/lib64/v3.6/xovsh.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/xovsp.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/xovsp.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..2ce072fa Binary files /dev/null and b/_core/Linux/lib64/v3.6/xovsp.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Linux/lib64/v3.6/xovud.cpython-36m-x86_64-linux-gnu.so b/_core/Linux/lib64/v3.6/xovud.cpython-36m-x86_64-linux-gnu.so new file mode 100644 index 00000000..5cedd5e9 Binary files /dev/null and b/_core/Linux/lib64/v3.6/xovud.cpython-36m-x86_64-linux-gnu.so differ diff --git a/_core/Windows/lib64/v3.6/awGA.pyd b/_core/Windows/lib64/v3.6/awGA.pyd new file mode 100644 index 00000000..c8e5f06c Binary files /dev/null and b/_core/Windows/lib64/v3.6/awGA.pyd differ diff --git a/_core/Windows/lib64/v3.6/boundfix.pyd b/_core/Windows/lib64/v3.6/boundfix.pyd new file mode 100644 index 00000000..ca10fe92 Binary files /dev/null and b/_core/Windows/lib64/v3.6/boundfix.pyd differ diff --git a/_core/Windows/lib64/v3.6/bs2int.pyd b/_core/Windows/lib64/v3.6/bs2int.pyd new file mode 100644 index 00000000..8443ebbf Binary files /dev/null and b/_core/Windows/lib64/v3.6/bs2int.pyd differ diff --git a/_core/Windows/lib64/v3.6/bs2real.pyd b/_core/Windows/lib64/v3.6/bs2real.pyd new file mode 100644 index 00000000..7fd49852 Binary files /dev/null and b/_core/Windows/lib64/v3.6/bs2real.pyd differ diff --git a/_core/Windows/lib64/v3.6/bs2ri.pyd b/_core/Windows/lib64/v3.6/bs2ri.pyd new file mode 100644 index 00000000..5f08ced3 Binary files /dev/null and b/_core/Windows/lib64/v3.6/bs2ri.pyd differ diff --git a/_core/Windows/lib64/v3.6/cdist.pyd b/_core/Windows/lib64/v3.6/cdist.pyd new file mode 100644 index 00000000..e2e246b2 Binary files /dev/null and b/_core/Windows/lib64/v3.6/cdist.pyd differ diff --git a/_core/Windows/lib64/v3.6/crowdis.pyd b/_core/Windows/lib64/v3.6/crowdis.pyd new file mode 100644 index 00000000..bd67285b Binary files /dev/null and b/_core/Windows/lib64/v3.6/crowdis.pyd differ diff --git a/_core/Windows/lib64/v3.6/crtbp.pyd b/_core/Windows/lib64/v3.6/crtbp.pyd new file mode 100644 index 00000000..16f121c0 Binary files /dev/null and b/_core/Windows/lib64/v3.6/crtbp.pyd differ diff --git a/_core/Windows/lib64/v3.6/crtfld.pyd b/_core/Windows/lib64/v3.6/crtfld.pyd new file mode 100644 index 00000000..7a6fcab9 Binary files /dev/null and b/_core/Windows/lib64/v3.6/crtfld.pyd differ diff --git a/_core/Windows/lib64/v3.6/crtgp.pyd b/_core/Windows/lib64/v3.6/crtgp.pyd new file mode 100644 index 00000000..2f281dfa Binary files /dev/null and b/_core/Windows/lib64/v3.6/crtgp.pyd differ diff --git a/_core/Windows/lib64/v3.6/crtidp.pyd b/_core/Windows/lib64/v3.6/crtidp.pyd new file mode 100644 index 00000000..495eee00 Binary files /dev/null and b/_core/Windows/lib64/v3.6/crtidp.pyd differ diff --git a/_core/Windows/lib64/v3.6/crtip.pyd b/_core/Windows/lib64/v3.6/crtip.pyd new file mode 100644 index 00000000..49dc653b Binary files /dev/null and b/_core/Windows/lib64/v3.6/crtip.pyd differ diff --git a/_core/Windows/lib64/v3.6/crtpc.pyd b/_core/Windows/lib64/v3.6/crtpc.pyd new file mode 100644 index 00000000..f99c4f97 Binary files /dev/null and b/_core/Windows/lib64/v3.6/crtpc.pyd differ diff --git a/_core/Windows/lib64/v3.6/crtpp.pyd b/_core/Windows/lib64/v3.6/crtpp.pyd new file mode 100644 index 00000000..72ba6002 Binary files /dev/null and b/_core/Windows/lib64/v3.6/crtpp.pyd differ diff --git a/_core/Windows/lib64/v3.6/crtri.pyd b/_core/Windows/lib64/v3.6/crtri.pyd new file mode 100644 index 00000000..bd5f1b80 Binary files /dev/null and b/_core/Windows/lib64/v3.6/crtri.pyd differ diff --git a/_core/Windows/lib64/v3.6/crtrp.pyd b/_core/Windows/lib64/v3.6/crtrp.pyd new file mode 100644 index 00000000..581e8bd2 Binary files /dev/null and b/_core/Windows/lib64/v3.6/crtrp.pyd differ diff --git a/_core/Windows/lib64/v3.6/crtup.pyd b/_core/Windows/lib64/v3.6/crtup.pyd new file mode 100644 index 00000000..0bd2ffb5 Binary files /dev/null and b/_core/Windows/lib64/v3.6/crtup.pyd differ diff --git a/_core/Windows/lib64/v3.6/dup.pyd b/_core/Windows/lib64/v3.6/dup.pyd new file mode 100644 index 00000000..3ea82b6e Binary files /dev/null and b/_core/Windows/lib64/v3.6/dup.pyd differ diff --git a/_core/Windows/lib64/v3.6/ecs.pyd b/_core/Windows/lib64/v3.6/ecs.pyd new file mode 100644 index 00000000..5e91c163 Binary files /dev/null and b/_core/Windows/lib64/v3.6/ecs.pyd differ diff --git a/_core/Windows/lib64/v3.6/etour.pyd b/_core/Windows/lib64/v3.6/etour.pyd new file mode 100644 index 00000000..7d0d89bd Binary files /dev/null and b/_core/Windows/lib64/v3.6/etour.pyd differ diff --git a/_core/Windows/lib64/v3.6/indexing.pyd b/_core/Windows/lib64/v3.6/indexing.pyd new file mode 100644 index 00000000..393ab5ce Binary files /dev/null and b/_core/Windows/lib64/v3.6/indexing.pyd differ diff --git a/_core/Windows/lib64/v3.6/indicator.pyd b/_core/Windows/lib64/v3.6/indicator.pyd new file mode 100644 index 00000000..61c8119e Binary files /dev/null and b/_core/Windows/lib64/v3.6/indicator.pyd differ diff --git a/_core/Windows/lib64/v3.6/mergecv.pyd b/_core/Windows/lib64/v3.6/mergecv.pyd new file mode 100644 index 00000000..1470898a Binary files /dev/null and b/_core/Windows/lib64/v3.6/mergecv.pyd differ diff --git a/_core/Windows/lib64/v3.6/migrate.pyd b/_core/Windows/lib64/v3.6/migrate.pyd new file mode 100644 index 00000000..3c9e417c Binary files /dev/null and b/_core/Windows/lib64/v3.6/migrate.pyd differ diff --git a/_core/Windows/lib64/v3.6/moeaplot.pyd b/_core/Windows/lib64/v3.6/moeaplot.pyd new file mode 100644 index 00000000..f04075a4 Binary files /dev/null and b/_core/Windows/lib64/v3.6/moeaplot.pyd differ diff --git a/_core/Windows/lib64/v3.6/mselecting.pyd b/_core/Windows/lib64/v3.6/mselecting.pyd new file mode 100644 index 00000000..64df8a65 Binary files /dev/null and b/_core/Windows/lib64/v3.6/mselecting.pyd differ diff --git a/_core/Windows/lib64/v3.6/mutate.pyd b/_core/Windows/lib64/v3.6/mutate.pyd new file mode 100644 index 00000000..3d258250 Binary files /dev/null and b/_core/Windows/lib64/v3.6/mutate.pyd differ diff --git a/_core/Windows/lib64/v3.6/mutbga.pyd b/_core/Windows/lib64/v3.6/mutbga.pyd new file mode 100644 index 00000000..ba72235a Binary files /dev/null and b/_core/Windows/lib64/v3.6/mutbga.pyd differ diff --git a/_core/Windows/lib64/v3.6/mutbin.pyd b/_core/Windows/lib64/v3.6/mutbin.pyd new file mode 100644 index 00000000..931a924d Binary files /dev/null and b/_core/Windows/lib64/v3.6/mutbin.pyd differ diff --git a/_core/Windows/lib64/v3.6/mutde.pyd b/_core/Windows/lib64/v3.6/mutde.pyd new file mode 100644 index 00000000..501bbb62 Binary files /dev/null and b/_core/Windows/lib64/v3.6/mutde.pyd differ diff --git a/_core/Windows/lib64/v3.6/mutgau.pyd b/_core/Windows/lib64/v3.6/mutgau.pyd new file mode 100644 index 00000000..ced70b04 Binary files /dev/null and b/_core/Windows/lib64/v3.6/mutgau.pyd differ diff --git a/_core/Windows/lib64/v3.6/mutinv.pyd b/_core/Windows/lib64/v3.6/mutinv.pyd new file mode 100644 index 00000000..19887766 Binary files /dev/null and b/_core/Windows/lib64/v3.6/mutinv.pyd differ diff --git a/_core/Windows/lib64/v3.6/mutmove.pyd b/_core/Windows/lib64/v3.6/mutmove.pyd new file mode 100644 index 00000000..d8264439 Binary files /dev/null and b/_core/Windows/lib64/v3.6/mutmove.pyd differ diff --git a/_core/Windows/lib64/v3.6/mutpolyn.pyd b/_core/Windows/lib64/v3.6/mutpolyn.pyd new file mode 100644 index 00000000..8a0df5a2 Binary files /dev/null and b/_core/Windows/lib64/v3.6/mutpolyn.pyd differ diff --git a/_core/Windows/lib64/v3.6/mutpp.pyd b/_core/Windows/lib64/v3.6/mutpp.pyd new file mode 100644 index 00000000..042f275c Binary files /dev/null and b/_core/Windows/lib64/v3.6/mutpp.pyd differ diff --git a/_core/Windows/lib64/v3.6/mutswap.pyd b/_core/Windows/lib64/v3.6/mutswap.pyd new file mode 100644 index 00000000..968a8990 Binary files /dev/null and b/_core/Windows/lib64/v3.6/mutswap.pyd differ diff --git a/_core/Windows/lib64/v3.6/mutuni.pyd b/_core/Windows/lib64/v3.6/mutuni.pyd new file mode 100644 index 00000000..c52ba337 Binary files /dev/null and b/_core/Windows/lib64/v3.6/mutuni.pyd differ diff --git a/_core/Windows/lib64/v3.6/ndsortDED.pyd b/_core/Windows/lib64/v3.6/ndsortDED.pyd new file mode 100644 index 00000000..518773e1 Binary files /dev/null and b/_core/Windows/lib64/v3.6/ndsortDED.pyd differ diff --git a/_core/Windows/lib64/v3.6/ndsortESS.pyd b/_core/Windows/lib64/v3.6/ndsortESS.pyd new file mode 100644 index 00000000..a49f5cab Binary files /dev/null and b/_core/Windows/lib64/v3.6/ndsortESS.pyd differ diff --git a/_core/Windows/lib64/v3.6/ndsortTNS.pyd b/_core/Windows/lib64/v3.6/ndsortTNS.pyd new file mode 100644 index 00000000..5c952e76 Binary files /dev/null and b/_core/Windows/lib64/v3.6/ndsortTNS.pyd differ diff --git a/_core/Windows/lib64/v3.6/otos.pyd b/_core/Windows/lib64/v3.6/otos.pyd new file mode 100644 index 00000000..a782ed51 Binary files /dev/null and b/_core/Windows/lib64/v3.6/otos.pyd differ diff --git a/_core/Windows/lib64/v3.6/pbi.pyd b/_core/Windows/lib64/v3.6/pbi.pyd new file mode 100644 index 00000000..d67e7019 Binary files /dev/null and b/_core/Windows/lib64/v3.6/pbi.pyd differ diff --git a/_core/Windows/lib64/v3.6/powing.pyd b/_core/Windows/lib64/v3.6/powing.pyd new file mode 100644 index 00000000..bfeea06b Binary files /dev/null and b/_core/Windows/lib64/v3.6/powing.pyd differ diff --git a/_core/Windows/lib64/v3.6/ranking.pyd b/_core/Windows/lib64/v3.6/ranking.pyd new file mode 100644 index 00000000..6ade9425 Binary files /dev/null and b/_core/Windows/lib64/v3.6/ranking.pyd differ diff --git a/_core/Windows/lib64/v3.6/rcs.pyd b/_core/Windows/lib64/v3.6/rcs.pyd new file mode 100644 index 00000000..6b720a7e Binary files /dev/null and b/_core/Windows/lib64/v3.6/rcs.pyd differ diff --git a/_core/Windows/lib64/v3.6/recdis.pyd b/_core/Windows/lib64/v3.6/recdis.pyd new file mode 100644 index 00000000..f0ef2650 Binary files /dev/null and b/_core/Windows/lib64/v3.6/recdis.pyd differ diff --git a/_core/Windows/lib64/v3.6/recint.pyd b/_core/Windows/lib64/v3.6/recint.pyd new file mode 100644 index 00000000..296f9d5a Binary files /dev/null and b/_core/Windows/lib64/v3.6/recint.pyd differ diff --git a/_core/Windows/lib64/v3.6/reclin.pyd b/_core/Windows/lib64/v3.6/reclin.pyd new file mode 100644 index 00000000..58e139c4 Binary files /dev/null and b/_core/Windows/lib64/v3.6/reclin.pyd differ diff --git a/_core/Windows/lib64/v3.6/recndx.pyd b/_core/Windows/lib64/v3.6/recndx.pyd new file mode 100644 index 00000000..5aedd75b Binary files /dev/null and b/_core/Windows/lib64/v3.6/recndx.pyd differ diff --git a/_core/Windows/lib64/v3.6/recombin.pyd b/_core/Windows/lib64/v3.6/recombin.pyd new file mode 100644 index 00000000..78a2922d Binary files /dev/null and b/_core/Windows/lib64/v3.6/recombin.pyd differ diff --git a/_core/Windows/lib64/v3.6/recsbx.pyd b/_core/Windows/lib64/v3.6/recsbx.pyd new file mode 100644 index 00000000..774cc1fd Binary files /dev/null and b/_core/Windows/lib64/v3.6/recsbx.pyd differ diff --git a/_core/Windows/lib64/v3.6/refgselect.pyd b/_core/Windows/lib64/v3.6/refgselect.pyd new file mode 100644 index 00000000..52db2c95 Binary files /dev/null and b/_core/Windows/lib64/v3.6/refgselect.pyd differ diff --git a/_core/Windows/lib64/v3.6/refselect.pyd b/_core/Windows/lib64/v3.6/refselect.pyd new file mode 100644 index 00000000..077c46d5 Binary files /dev/null and b/_core/Windows/lib64/v3.6/refselect.pyd differ diff --git a/_core/Windows/lib64/v3.6/ri2bs.pyd b/_core/Windows/lib64/v3.6/ri2bs.pyd new file mode 100644 index 00000000..575dd468 Binary files /dev/null and b/_core/Windows/lib64/v3.6/ri2bs.pyd differ diff --git a/_core/Windows/lib64/v3.6/rps.pyd b/_core/Windows/lib64/v3.6/rps.pyd new file mode 100644 index 00000000..bd38620a Binary files /dev/null and b/_core/Windows/lib64/v3.6/rps.pyd differ diff --git a/_core/Windows/lib64/v3.6/rwGA.pyd b/_core/Windows/lib64/v3.6/rwGA.pyd new file mode 100644 index 00000000..d6d2a085 Binary files /dev/null and b/_core/Windows/lib64/v3.6/rwGA.pyd differ diff --git a/_core/Windows/lib64/v3.6/rws.pyd b/_core/Windows/lib64/v3.6/rws.pyd new file mode 100644 index 00000000..003a261c Binary files /dev/null and b/_core/Windows/lib64/v3.6/rws.pyd differ diff --git a/_core/Windows/lib64/v3.6/scaling.pyd b/_core/Windows/lib64/v3.6/scaling.pyd new file mode 100644 index 00000000..ecb80e89 Binary files /dev/null and b/_core/Windows/lib64/v3.6/scaling.pyd differ diff --git a/_core/Windows/lib64/v3.6/selecting.pyd b/_core/Windows/lib64/v3.6/selecting.pyd new file mode 100644 index 00000000..489ce06b Binary files /dev/null and b/_core/Windows/lib64/v3.6/selecting.pyd differ diff --git a/_core/Windows/lib64/v3.6/soeaplot.pyd b/_core/Windows/lib64/v3.6/soeaplot.pyd new file mode 100644 index 00000000..6f25c75d Binary files /dev/null and b/_core/Windows/lib64/v3.6/soeaplot.pyd differ diff --git a/_core/Windows/lib64/v3.6/sus.pyd b/_core/Windows/lib64/v3.6/sus.pyd new file mode 100644 index 00000000..34717bfa Binary files /dev/null and b/_core/Windows/lib64/v3.6/sus.pyd differ diff --git a/_core/Windows/lib64/v3.6/tcheby.pyd b/_core/Windows/lib64/v3.6/tcheby.pyd new file mode 100644 index 00000000..ca3286cf Binary files /dev/null and b/_core/Windows/lib64/v3.6/tcheby.pyd differ diff --git a/_core/Windows/lib64/v3.6/tour.pyd b/_core/Windows/lib64/v3.6/tour.pyd new file mode 100644 index 00000000..5ff6e386 Binary files /dev/null and b/_core/Windows/lib64/v3.6/tour.pyd differ diff --git a/_core/Windows/lib64/v3.6/trcplot.pyd b/_core/Windows/lib64/v3.6/trcplot.pyd new file mode 100644 index 00000000..745af26b Binary files /dev/null and b/_core/Windows/lib64/v3.6/trcplot.pyd differ diff --git a/_core/Windows/lib64/v3.6/urs.pyd b/_core/Windows/lib64/v3.6/urs.pyd new file mode 100644 index 00000000..275fb921 Binary files /dev/null and b/_core/Windows/lib64/v3.6/urs.pyd differ diff --git a/_core/Windows/lib64/v3.6/varplot.pyd b/_core/Windows/lib64/v3.6/varplot.pyd new file mode 100644 index 00000000..2635aa92 Binary files /dev/null and b/_core/Windows/lib64/v3.6/varplot.pyd differ diff --git a/_core/Windows/lib64/v3.6/xovbd.pyd b/_core/Windows/lib64/v3.6/xovbd.pyd new file mode 100644 index 00000000..cd0346e3 Binary files /dev/null and b/_core/Windows/lib64/v3.6/xovbd.pyd differ diff --git a/_core/Windows/lib64/v3.6/xovdp.pyd b/_core/Windows/lib64/v3.6/xovdp.pyd new file mode 100644 index 00000000..61d1ab2b Binary files /dev/null and b/_core/Windows/lib64/v3.6/xovdp.pyd differ diff --git a/_core/Windows/lib64/v3.6/xovexp.pyd b/_core/Windows/lib64/v3.6/xovexp.pyd new file mode 100644 index 00000000..a865fb78 Binary files /dev/null and b/_core/Windows/lib64/v3.6/xovexp.pyd differ diff --git a/_core/Windows/lib64/v3.6/xovox.pyd b/_core/Windows/lib64/v3.6/xovox.pyd new file mode 100644 index 00000000..e762be48 Binary files /dev/null and b/_core/Windows/lib64/v3.6/xovox.pyd differ diff --git a/_core/Windows/lib64/v3.6/xovpmx.pyd b/_core/Windows/lib64/v3.6/xovpmx.pyd new file mode 100644 index 00000000..da2a8e2a Binary files /dev/null and b/_core/Windows/lib64/v3.6/xovpmx.pyd differ diff --git a/_core/Windows/lib64/v3.6/xovsec.pyd b/_core/Windows/lib64/v3.6/xovsec.pyd new file mode 100644 index 00000000..88aa0fd3 Binary files /dev/null and b/_core/Windows/lib64/v3.6/xovsec.pyd differ diff --git a/_core/Windows/lib64/v3.6/xovsh.pyd b/_core/Windows/lib64/v3.6/xovsh.pyd new file mode 100644 index 00000000..92cb07c4 Binary files /dev/null and b/_core/Windows/lib64/v3.6/xovsh.pyd differ diff --git a/_core/Windows/lib64/v3.6/xovsp.pyd b/_core/Windows/lib64/v3.6/xovsp.pyd new file mode 100644 index 00000000..98e2f5fa Binary files /dev/null and b/_core/Windows/lib64/v3.6/xovsp.pyd differ diff --git a/_core/Windows/lib64/v3.6/xovud.pyd b/_core/Windows/lib64/v3.6/xovud.pyd new file mode 100644 index 00000000..50f267c2 Binary files /dev/null and b/_core/Windows/lib64/v3.6/xovud.pyd differ diff --git a/geatpy/Algorithm.py b/geatpy/Algorithm.py new file mode 100644 index 00000000..66edf802 --- /dev/null +++ b/geatpy/Algorithm.py @@ -0,0 +1,829 @@ +# -*- coding: utf-8 -*- +import time +import warnings +import numpy as np +import geatpy as ea + + +class Algorithm: + """ +Algorithm : class - 算法类的顶级父类 + +描述: + 算法设置类是用来存储与算法运行参数设置相关信息的一个类。 + +属性: + name : str - 算法名称(可以自由设置名称)。 + + problem : class - 问题类的对象。 + + population : class - 种群对象。 + + MAXGEN : int - 最大进化代数。 + + currentGen : int - 当前进化的代数。 + + MAXTIME : float - 时间限制(单位:秒)。 + + timeSlot : float - 时间戳(单位:秒)。 + + passTime : float - 已用时间(单位:秒)。 + + MAXEVALS : int - 最大评价次数。 + + evalsNum : int - 当前评价次数。 + + MAXSIZE : int - 最优个体的最大数目。 + + outFunc : function - 提供给用户自定义的函数,它在每发生一次进化时被调用。如果没有定义,则默认为None。 + + logTras : int - Tras即周期的意思,该参数用于设置在进化过程中每多少代记录一次日志信息。 + 设置为0表示不记录日志信息。 + 注:此时假如设置了“每10代记录一次日志”而导致最后一代没有被记录, + 则会补充记录最后一代的信息,除非找不到可行解。 + + log : Dict - 日志记录。其中包含2个基本的键:'gen'和'eval',其他键的定义由该算法类的子类实现。 + 'gen'的键值为一个list列表,用于存储日志记录中的每一条记录对应第几代种群。 + 'eval'的键值为一个list列表,用于存储进化算法的评价次数。 + 注:若设置了logTras为0,则不会记录日志,此时log会被设置为None。 + + verbose : bool - 表示是否在输入输出流中打印输出日志信息。 + + stopMsg : str - 记录进化终止原因的字符串。 + + dirName : str - 用于指明文件保存的路径。用于把绘图文件保存在此目录下。 + 当缺省或为None时,默认dirName='',此时如果绘制图片,图片会被保存在执行文件的所在目录下。 + +函数: + __init__() : 构造函数,定义一些属性,并初始化一些静态参数。 + + initialization() : 在进化前对算法类的一些动态参数进行初始化操作,具体功能需要在继承类中实现。 + + run() : 执行函数,具体功能需要在继承类中实现。 + + logging() : 用于在进化过程中记录日志,具体功能需要在继承类中实现。 + + stat() : 用于分析当代种群的信息,具体功能需要在继承类中实现。 + + terminated() : 计算是否需要终止进化,具体功能需要在继承类中实现。 + + finishing () : 进化完成后调用的函数,具体功能需要在继承类中实现。 + + check() : 用于检查种群对象的ObjV和CV的数据是否有误。 + + call_aimFunc() : 用于调用问题类中的aimFunc()或evalVars()进行计算ObjV和CV(若有约束)。 + + display() : 用于在进化过程中进行一些输出,需要依赖属性verbose和log属性。 + +""" + + def __init__(self, + problem, + population, + MAXGEN = None, + MAXTIME = None, + MAXEVALS = None, + MAXSIZE = None, + logTras = None, + verbose = None, + outFunc = None, + dirName = None, + **kwargs): + + """ + 描述: + 构造函数。 + + """ + + if dirName is None: + dirName = '' + if dirName != '': + dirName += '/' + + # 静态属性 + self.name = 'Algorithm' + self.problem = problem + self.population = population + self.MAXGEN = MAXGEN + self.MAXTIME = MAXTIME + self.MAXEVALS = MAXEVALS + self.MAXSIZE = MAXSIZE + self.logTras = 1 if logTras is None else logTras + self.verbose = True if verbose is None else verbose + self.outFunc = outFunc + self.dirName = dirName + # 动态属性 + self.currentGen = None + self.timeSlot = None + self.passTime = None + self.evalsNum = None + self.log = None + self.stopMsg = '' + # 初始化种群的译码矩阵 + if isinstance(population, ea.Population): + if population.ChromNum == 1: # 如果是单染色体种群 + if population.Field is None: + self.population = ea.Population(Encoding=population.Encoding, + Field=(problem.varTypes, problem.ranges, problem.borders), + NIND=population.sizes) + else: # 如果是多染色体种群 + if population.Fields is None: + self.population = ea.PsyPopulation(Encodings=population.Encodings, + Fields=(problem.varTypes, problem.ranges, problem.borders), + NIND=population.sizes, + EncoIdxs=population.EncoIdxs) + + def initialization(self): + pass + + def run(self, pop): + pass + + def logging(self, pop): + pass + + def stat(self, pop): + pass + + def terminated(self, pop): + pass + + def finishing(self, pop): + pass + + def check(self, pop): + + """ + 描述: + 用于检查种群对象的ObjV和CV的数据是否有误。 + + 输入参数: + pop : class - 种群对象。 + + 输出参数: + 无输出参数。 + + """ + + # 检测数据非法值 + if np.any(np.isnan(pop.ObjV)): + warnings.warn( + "Warning: Some elements of ObjV are NAN, please check the calculation of ObjV.(" + "ObjV的部分元素为NAN,请检查目标函数的计算。)", + RuntimeWarning) + elif np.any(np.isinf(pop.ObjV)): + warnings.warn( + "Warning: Some elements of ObjV are Inf, please check the calculation of ObjV.(" + "ObjV的部分元素为Inf,请检查目标函数的计算。)", + RuntimeWarning) + if pop.CV is not None: + if np.any(np.isnan(pop.CV)): + warnings.warn( + "Warning: Some elements of CV are NAN, please check the calculation of CV.(CV的部分元素为NAN,请检查CV的计算。)", + RuntimeWarning) + elif np.any(np.isinf(pop.CV)): + warnings.warn( + "Warning: Some elements of CV are Inf, please check the calculation of CV.(CV的部分元素为Inf,请检查CV的计算。)", + RuntimeWarning) + + def call_aimFunc(self, pop): + + """ + 描述: 调用问题类的aimFunc()或evalVars()完成种群目标函数值和违反约束程度的计算。 + + 例如:population为一个种群对象,则调用call_aimFunc(population)即可完成目标函数值的计算。 + 之后可通过population.ObjV得到求得的目标函数值,population.CV得到违反约束程度矩阵。 + + 输入参数: + pop : class - 种群对象。 + + 输出参数: + 无输出参数。 + + """ + + pop.Phen = pop.decoding() # 染色体解码 + if self.problem is None: + raise RuntimeError('error: problem has not been initialized. (算法类中的问题对象未被初始化。)') + self.problem.evaluation(pop) # 调用问题类的evaluation() + self.evalsNum = self.evalsNum + pop.sizes if self.evalsNum is not None else pop.sizes # 更新评价次数 + # 格式检查 + if not isinstance(pop.ObjV, np.ndarray) or pop.ObjV.ndim != 2 or pop.ObjV.shape[0] != pop.sizes or \ + pop.ObjV.shape[1] != self.problem.M: + raise RuntimeError('error: ObjV is illegal. (目标函数值矩阵ObjV的数据格式不合法,请检查目标函数的计算。)') + if pop.CV is not None: + if not isinstance(pop.CV, np.ndarray) or pop.CV.ndim != 2 or pop.CV.shape[0] != pop.sizes: + raise RuntimeError('error: CV is illegal. (违反约束程度矩阵CV的数据格式不合法,请检查CV的计算。)') + + def display(self): + + """ + 描述: + 该函数打印日志log中每个键值的最后一条数据。假如log中只有一条数据或没有数据,则会打印表头。 + 该函数将会在子类中被覆盖,以便进行更多其他的输出展示。 + + """ + + self.passTime += time.time() - self.timeSlot # 更新用时记录,不计算display()的耗时 + headers = [] + widths = [] + values = [] + for key in self.log.keys(): + # 设置单元格宽度 + if key == 'gen': + if self.MAXGEN is None: + width = 5 + else: + width = max(3, len(str(self.MAXGEN - 1))) # 因为字符串'gen'长度为3,所以最小要设置长度为3 + elif key == 'eval': + width = 8 # 因为字符串'eval'长度为4,所以最小要设置长度为4 + else: + width = 13 # 预留13位显示长度,若数值过大,表格将无法对齐,此时若要让表格对齐,需要自定义算法类重写该函数 + headers.append(key) + widths.append(width) + value = self.log[key][-1] if len(self.log[key]) != 0 else "-" + if isinstance(value, float): + values.append("%.5E" % value) # 格式化浮点数,输出时只保留至小数点后5位 + else: + values.append(value) + if len(self.log['gen']) == 1: # 打印表头 + header_regex = '|'.join(['{}'] * len(headers)) + header_str = header_regex.format(*[str(key).center(width) for key, width in zip(headers, widths)]) + print("=" * len(header_str)) + print(header_str) + print("-" * len(header_str)) + if len(self.log['gen']) != 0: # 打印表格最后一行 + value_regex = '|'.join(['{}'] * len(values)) + value_str = value_regex.format(*[str(value).center(width) for value, width in zip(values, widths)]) + print(value_str) + self.timeSlot = time.time() # 更新时间戳 + + +class MoeaAlgorithm(Algorithm): # 多目标优化算法类的父类 + + """ + 描述: + 此为多目标进化优化算法类的父类,所有多目标优化算法类均继承自该父类。 + + 对比于父类该类新增的变量和函数: + + drawing : int - 绘图方式的参数, + 0表示不绘图; + 1表示绘制最终结果图; + 2表示实时绘制目标空间动态图; + 3表示实时绘制决策空间动态图。 + + draw() : 绘图函数。 + + """ + + def __init__(self, + problem, + population, + MAXGEN = None, + MAXTIME = None, + MAXEVALS = None, + MAXSIZE = None, + logTras = None, + verbose = None, + outFunc = None, + drawing = None, + dirName = None, + **kwargs): + + """ + 描述: + 在该构造函数里只初始化静态参数以及对动态参数进行定义。 + + """ + + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, dirName) # 先调用父类构造函数 + self.drawing = 1 if drawing is None else drawing + # 以下为用户不需要设置的属性 + self.plotter = None # 存储绘图对象 + + def __str__(self): + info = {} + info['Algorithm Name'] = self.name + info['Algorithm MAXGEN'] = self.MAXGEN + info['Algorithm MAXTIME'] = self.MAXTIME + info['Algorithm MAXEVALS'] = self.MAXEVALS + return str(info) + + def initialization(self): + + """ + 描述: + 该函数用于在进化前对算法类的一些动态参数进行初始化操作。 + 该函数需要在执行算法类的run()函数的一开始被调用,同时开始计时, + 以确保所有这些参数能够被正确初始化。 + + """ + + self.ax = None # 初始化ax + self.passTime = 0 # 初始化passTime + self.log = None # 初始化log + self.currentGen = 0 # 初始为第0代 + self.evalsNum = 0 # 初始化评价次数为0 + self.log = {'gen': [], 'eval': []} if self.logTras != 0 else None # 初始化log + self.timeSlot = time.time() # 开始计时 + + def logging(self, pop): + + """ + 描述: + 用于在进化过程中记录日志。该函数在stat()函数里面被调用。 + 如果需要在日志中记录其他数据,需要在自定义算法类中重写该函数。 + + 输入参数: + pop : class - 种群对象。 + + 输出参数: + 无输出参数。 + + """ + + self.passTime += time.time() - self.timeSlot # 更新用时记录,不计算logging的耗时 + if len(self.log['gen']) == 0: # 初始化log的各个键值 + self.log['gd'] = [] + self.log['igd'] = [] + self.log['hv'] = [] + self.log['spacing'] = [] + self.log['gen'].append(self.currentGen) + self.log['eval'].append(self.evalsNum) # 记录评价次数 + [levels, _] = ea.ndsortDED(pop.ObjV, needLevel=1, CV=pop.CV, maxormins=self.problem.maxormins) # 非支配分层 + NDSet = pop[np.where(levels == 1)[0]] # 只保留种群中的非支配个体,形成一个非支配种群 + if self.problem.ReferObjV is not None: + self.log['gd'].append(ea.indicator.GD(NDSet.ObjV, self.problem.ReferObjV)) # 计算GD指标 + self.log['igd'].append(ea.indicator.IGD(NDSet.ObjV, self.problem.ReferObjV)) # 计算IGD指标 + self.log['hv'].append(ea.indicator.HV(NDSet.ObjV), ) # 计算HV指标 + else: + self.log['gd'].append(None) + self.log['igd'].append(None) + self.log['hv'].append(ea.indicator.HV(NDSet.ObjV)) # 计算HV指标 + self.log['spacing'].append(ea.indicator.Spacing(NDSet.ObjV)) # 计算Spacing指标 + self.timeSlot = time.time() # 更新时间戳 + + def draw(self, pop, EndFlag=False): + + """ + 描述: + 该函数用于在进化过程中进行绘图。该函数在stat()以及finishing函数里面被调用。 + + 输入参数: + pop : class - 种群对象。 + + EndFlag : bool - 表示是否是最后一次调用该函数。 + + 输出参数: + 无输出参数。 + + """ + + if not EndFlag: + self.passTime += time.time() - self.timeSlot # 更新用时记录,不计算画图的耗时 + # 绘制动画 + if self.drawing == 2: + # 绘制目标空间动态图 + if pop.ObjV.shape[1] == 2 or pop.ObjV.shape[1] == 3: + if self.plotter is None: + self.plotter = ea.PointScatter(self.problem.M, grid=True, legend=True, title='Pareto Front Plot') + self.plotter.refresh() + self.plotter.add(pop.ObjV, color='red', label='MOEA PF at ' + str(self.currentGen) + ' Generation') + else: + if self.plotter is None: + self.plotter = ea.ParCoordPlotter(self.problem.M, grid=True, legend=True, title='Parallel Coordinate Plot') + self.plotter.refresh() + self.plotter.add(pop.ObjV, color='red', label='MOEA Objective Value at ' + str(self.currentGen) + ' Generation') + self.plotter.draw() + elif self.drawing == 3: + # 绘制决策空间动态图 + if self.plotter is None: + self.plotter = ea.ParCoordPlotter(self.problem.Dim, grid=True, legend=True, title='Variables Value Plot') + self.plotter.refresh() + self.plotter.add(pop.Phen, marker='o', color='blue', label='Variables Value at ' + str(self.currentGen) + ' Generation') + self.plotter.draw() + self.timeSlot = time.time() # 更新时间戳 + else: + # 绘制最终结果图 + if self.drawing != 0: + if self.plotter is not None: # 若绘制了动画,则保存并关闭动画 + self.plotter.createAnimation() + self.plotter.close() + if pop.ObjV.shape[1] == 2 or pop.ObjV.shape[1] == 3: + figureName = 'Pareto Front Plot' + self.plotter = ea.PointScatter(self.problem.M, grid=True, legend=True, title=figureName, saveName=self.dirName + figureName) + self.plotter.add(self.problem.ReferObjV, color='gray', alpha=0.1, label='True PF') + self.plotter.add(pop.ObjV, color='red', label='MOEA PF') + self.plotter.draw() + else: + figureName = 'Parallel Coordinate Plot' + self.plotter = ea.ParCoordPlotter(self.problem.M, grid=True, legend=True, title=figureName, saveName=self.dirName + figureName) + self.plotter.add(self.problem.TinyReferObjV, color='gray', alpha=0.5, label='True Objective Value') + self.plotter.add(pop.ObjV, color='red', label='MOEA Objective Value') + self.plotter.draw() + + def stat(self, pop): + + """ + 描述: + 该函数用于分析当代种群的信息。 + 该函数会在terminated()函数里被调用。 + + 输入参数: + pop : class - 种群对象。 + + 输出参数: + 无输出参数。 + + """ + + feasible = np.where(np.all(pop.CV <= 0, 1))[0] if pop.CV is not None else np.arange(pop.sizes) # 找到满足约束条件的个体的下标 + if len(feasible) > 0: + feasiblePop = pop[feasible] # 获取满足约束条件的个体 + if self.logTras != 0 and self.currentGen % self.logTras == 0: + self.logging(feasiblePop) # 记录日志 + if self.verbose: + self.display() # 打印日志 + self.draw(feasiblePop) # 展示输出 + + def terminated(self, pop): + + """ + 描述: + 该函数用于判断是否应该终止进化,population为传入的种群对象。 + 该函数会在各个具体的算法类的run()函数中被调用。 + + 输入参数: + pop : class - 种群对象。 + + 输出参数: + True / False。 + + """ + + self.check(pop) # 检查种群对象的关键属性是否有误 + self.stat(pop) # 进行统计分析 + self.passTime += time.time() - self.timeSlot # 更新耗时 + # 调用outFunc() + if self.outFunc is not None: + if not callable(self.outFunc): + raise RuntimeError('outFunc must be a function. (如果定义了outFunc,那么它必须是一个函数。)') + self.outFunc(self, pop) + self.timeSlot = time.time() # 更新时间戳 + # 判断是否终止进化, + if self.MAXGEN is None and self.MAXTIME is None and self.MAXEVALS is None: + raise RuntimeError('error: MAXGEN, MAXTIME, and MAXEVALS cannot be all None. (MAXGEN, MAXTIME, 和MAXEVALS不能全为None)') + terminatedFlag = False + if self.MAXGEN is not None and self.currentGen + 1 >= self.MAXGEN: # 由于代数是从0数起,因此在比较currentGen和MAXGEN时需要对currentGen加1 + self.stopMsg = 'The algotirhm stepped because it exceeded the generation limit.' + terminatedFlag = True + if self.MAXTIME is not None and self.passTime >= self.MAXTIME: + self.stopMsg = 'The algotirhm stepped because it exceeded the time limit.' + terminatedFlag = True + if self.MAXEVALS is not None and self.evalsNum >= self.MAXEVALS: + self.stopMsg = 'The algotirhm stepped because it exceeded the function evaluation limit.' + terminatedFlag = True + if terminatedFlag: + return True + else: + self.currentGen += 1 # 进化代数+1 + return False + + def finishing(self, pop, globalNDSet=None): + + """ + 描述: + 进化完成后调用的函数。 + + 输入参数: + pop : class - 种群对象。 + + globalNDSet : class - (可选参数)全局存档。 + + 输出参数: + [NDSet, pop],其中pop为种群类型;NDSet的类型与pop的一致。 + + """ + if globalNDSet is None: + # 得到非支配种群 + [levels, _] = ea.ndsortDED(pop.ObjV, needLevel=1, CV=pop.CV, maxormins=self.problem.maxormins) # 非支配分层 + NDSet = pop[np.where(levels == 1)[0]] # 只保留种群中的非支配个体,形成一个非支配种群 + if NDSet.CV is not None: # CV不为None说明有设置约束条件 + NDSet = NDSet[np.where(np.all(NDSet.CV <= 0, 1))[0]] # 最后要彻底排除非可行解 + else: + NDSet = globalNDSet + if self.logTras != 0 and NDSet.sizes != 0 and ( + len(self.log['gen']) == 0 or self.log['gen'][-1] != self.currentGen): # 补充记录日志和输出 + self.logging(NDSet) + if self.verbose: + self.display() + self.passTime += time.time() - self.timeSlot # 更新用时记录,因为已经要结束,因此不用再更新时间戳 + self.draw(NDSet, EndFlag=True) # 显示最终结果图 + if self.plotter is not None: + self.plotter.show() + # 返回帕累托最优个体以及最后一代种群 + return [NDSet, pop] + + +class SoeaAlgorithm(Algorithm): # 单目标优化算法类父类 + + """ + 描述: + 此为单目标进化优化算法类的父类,所有单目标优化算法类均继承自该父类。 + + 对比于父类该类新增的变量和函数: + + drawing : int - 绘图方式的参数, + 0表示不绘图; + 1表示绘制进化过程中种群的平均及最优目标函数值变化图; + 2表示实时绘制历史最优个体的目标空间过程动画; + 3表示实时绘制历史最优个体的决策空间动态图。 + + trappedValue : int - 进化算法陷入停滞的判断阈值。 + + maxTrappedCount : int - “进化停滞”计数器最大上限值。 + + ----------------- 以下为用户不需要设置的属性 ----------------- + + BestIndi : class - 存储算法所找到的最优的个体。 + + trace : dict - 进化记录器,可以看作是一个内部日志,用于记录每一代种群的一些信息。 + 它与算法类的log类似,它有两个键:'f_best'以及'f_avg'。 + 'f_best'的键值为一个list列表,存储着每一代种群最优个体的目标函数值; + 'f_avg'的键值为一个list列表,存储着每一代种群所有个体的平均目标函数值。 + + trappedCount : int - “进化停滞”计数器。 + + draw() : 绘图函数。 + + """ + + def __init__(self, + problem, + population, + MAXGEN = None, + MAXTIME = None, + MAXEVALS = None, + MAXSIZE = None, + logTras = None, + verbose = None, + outFunc = None, + drawing = None, + trappedValue = None, + maxTrappedCount = None, + dirName = None, + **kwargs): + + """ + 描述: + 在该构造函数里只初始化静态参数以及对动态参数进行定义。 + + """ + + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, dirName) # 先调用父类构造函数 + self.trappedValue = 0 if trappedValue is None else trappedValue + self.maxTrappedCount = 1000 if maxTrappedCount is None else maxTrappedCount + self.drawing = 1 if drawing is None else drawing + # 以下为用户不需要设置的属性 + self.BestIndi = None # 存储算法所找到的最优的个体 + self.trace = None # 进化记录器 + self.trappedCount = None # 定义trappedCount,在initialization()才对其进行初始化为0 + self.plotter = None # 存储绘图对象 + + def __str__(self): + info = {} + info['Algorithm Name'] = self.name + info['Algorithm MAXGEN'] = self.MAXGEN + info['Algorithm MAXTIME'] = self.MAXTIME + info['Algorithm MAXEVALS'] = self.MAXEVALS + info['Algorithm trappedValue'] = self.trappedValue + info['Algorithm maxTrappedCount'] = self.maxTrappedCount + return str(info) + + def initialization(self): + + """ + 描述: + 该函数用于在进化前对算法类的一些动态参数进行初始化操作。 + 该函数需要在执行算法类的run()函数的一开始被调用,同时开始计时, + 以确保所有这些参数能够被正确初始化。 + + """ + + self.ax = None # 初始化ax + self.passTime = 0 # 初始化passTime + self.trappedCount = 0 # 初始化“进化停滞”计数器 + self.currentGen = 0 # 初始为第0代 + self.evalsNum = 0 # 初始化评价次数为0 + self.BestIndi = ea.Population(None, None, 0) # 初始化BestIndi为空的种群对象 + self.log = {'gen': [], 'eval': []} if self.logTras != 0 else None # 初始化log + self.trace = {'f_best': [], 'f_avg': []} # 重置trace + # 开始计时 + self.timeSlot = time.time() + + def logging(self, pop): + + """ + 描述: + 用于在进化过程中记录日志。该函数在stat()函数里面被调用。 + 如果需要在日志中记录其他数据,需要在自定义算法类中重写该函数。 + + 输入参数: + pop : class - 种群对象。 + + 输出参数: + 无输出参数。 + + """ + + self.passTime += time.time() - self.timeSlot # 更新用时记录,不计算logging的耗时 + if len(self.log['gen']) == 0: # 初始化log的各个键值 + self.log['f_opt'] = [] + self.log['f_max'] = [] + self.log['f_avg'] = [] + self.log['f_min'] = [] + self.log['f_std'] = [] + self.log['gen'].append(self.currentGen) + self.log['eval'].append(self.evalsNum) # 记录评价次数 + self.log['f_opt'].append(self.BestIndi.ObjV[0][0]) # 记录算法所找到的最优个体的目标函数值 + self.log['f_max'].append(np.max(pop.ObjV)) + self.log['f_avg'].append(np.mean(pop.ObjV)) + self.log['f_min'].append(np.min(pop.ObjV)) + self.log['f_std'].append(np.std(pop.ObjV)) + self.timeSlot = time.time() # 更新时间戳 + + def draw(self, pop, EndFlag=False): + + """ + 描述: + 该函数用于在进化过程中进行绘图。该函数在stat()以及finishing函数里面被调用。 + + 输入参数: + pop : class - 种群对象。 + + EndFlag : bool - 表示是否是最后一次调用该函数。 + + 输出参数: + 无输出参数。 + + """ + + if not EndFlag: + self.passTime += time.time() - self.timeSlot # 更新用时记录,不计算画图的耗时 + # 绘制动画 + if self.drawing == 2: + # 绘制迭代变化图 + trace_best = np.array(self.trace['f_best']) + if len(trace_best) > 10: + xtickList = list(range(len(trace_best) - 10 + 1, len(trace_best) + 1)) + trace_best = trace_best[len(trace_best) - 10:] + else: + xtickList = list(range(1, len(trace_best)+1)) + num = len(trace_best) + if self.plotter is None: + self.plotter = ea.ParCoordPlotter(num, grid=True, legend=True, title='Objective Value Trace Plot') + self.plotter.refresh() + self.plotter.Dimension = num + self.plotter.xtickList = xtickList + self.plotter.add(trace_best, color='blue', label='Best Objective Value') + self.plotter.draw() + elif self.drawing == 3: + # 绘制决策空间动态图 + if self.plotter is None: + self.plotter = ea.ParCoordPlotter(self.problem.Dim, grid=True, legend=True, title='Variables Value Plot') + self.plotter.refresh() + self.plotter.add(pop.Phen, marker='o', color='blue', label='Variables Value at ' + str(self.currentGen) + ' Generation') + self.plotter.draw() + self.timeSlot = time.time() # 更新时间戳 + else: + # 绘制最终结果图 + if self.drawing != 0: + if self.plotter is not None: # 若绘制了动画,则保存并关闭动画 + self.plotter.createAnimation() + self.plotter.close() + trace_best = np.array(self.trace['f_best']) + trace_avg = np.array(self.trace['f_avg']) + num = len(trace_best) + figureName = 'Trace Plot' + self.plotter = ea.ParCoordPlotter(num, grid=True, legend=True, title=figureName, coordLabels=['Generation Number', 'Value'], saveName=self.dirName + figureName) + self.plotter.add(trace_avg, color='blue', label='Average Objective Value') + self.plotter.add(trace_best, color='orange', label='Best Objective Value') + self.plotter.draw() + + def stat(self, pop): + + """ + 描述: + 该函数用于分析、记录和打印当代种群的信息。 + 该函数会在terminated()函数里被调用。 + + 输入参数: + pop : class - 种群对象。 + + 输出参数: + 无输出参数。 + + """ + + # 进行进化记录 + feasible = np.where(np.all(pop.CV <= 0, 1))[0] if pop.CV is not None else np.arange(pop.sizes) # 找到满足约束条件的个体的下标 + if len(feasible) > 0: + feasiblePop = pop[feasible] + bestIndi = feasiblePop[np.argmax(feasiblePop.FitnV)] # 获取最优个体 + if self.BestIndi.sizes == 0: + self.BestIndi = bestIndi # 初始化global best individual + else: + delta = (self.BestIndi.ObjV - bestIndi.ObjV) * self.problem.maxormins if \ + self.problem.maxormins is not None else self.BestIndi.ObjV - bestIndi.ObjV + # 更新“进化停滞”计数器 + self.trappedCount += 1 if np.abs(delta) < self.trappedValue else 0 + # 更新global best individual + if delta > 0: + self.BestIndi = bestIndi + # 更新trace + self.trace['f_best'].append(bestIndi.ObjV[0][0]) + self.trace['f_avg'].append(np.mean(feasiblePop.ObjV)) + if self.logTras != 0 and self.currentGen % self.logTras == 0: + self.logging(feasiblePop) # 记录日志 + if self.verbose: + self.display() # 打印日志 + self.draw(self.BestIndi) # 展示输出 + + def terminated(self, pop): + + """ + 描述: + 该函数用于判断是否应该终止进化,population为传入的种群对象。 + 该函数会在各个具体的算法类的run()函数中被调用。 + + 输入参数: + pop : class - 种群对象。 + + 输出参数: + True / False。 + + """ + + self.check(pop) # 检查种群对象的关键属性是否有误 + self.stat(pop) # 分析记录当代种群的数据 + self.passTime += time.time() - self.timeSlot # 更新耗时 + # 调用outFunc() + if self.outFunc is not None: + if type(self.outFunc) != 'function': + raise RuntimeError('outFunc must be a function. (如果定义了outFunc,那么它必须是一个函数。)') + self.outFunc(self, pop) + self.timeSlot = time.time() # 更新时间戳 + # 判断是否终止进化, + if self.MAXGEN is None and self.MAXTIME is None and self.MAXEVALS is None: + raise RuntimeError('error: MAXGEN, MAXTIME, and MAXEVALS cannot be all None. (MAXGEN, MAXTIME, 和MAXEVALS不能全为None)') + terminatedFlag = False + if self.MAXGEN is not None and self.currentGen + 1 >= self.MAXGEN: # 由于代数是从0数起,因此在比较currentGen和MAXGEN时需要对currentGen加1 + self.stopMsg = 'The algotirhm stepped because it exceeded the generation limit.' + terminatedFlag = True + if self.MAXTIME is not None and self.passTime >= self.MAXTIME: + self.stopMsg = 'The algotirhm stepped because it exceeded the time limit.' + terminatedFlag = True + if self.MAXEVALS is not None and self.evalsNum >= self.MAXEVALS: + self.stopMsg = 'The algotirhm stepped because it exceeded the function evaluation limit.' + terminatedFlag = True + if self.trappedCount >= self.maxTrappedCount: + self.stopMsg = 'The algotirhm stepped because it exceeded the trapped count limit.' + terminatedFlag = True + if terminatedFlag: + return True + else: + self.currentGen += 1 # 进化代数+1 + return False + + def finishing(self, pop): + + """ + 描述: + 进化完成后调用的函数。 + + 输入参数: + pop : class - 种群对象。 + + 输出参数: + [self.BestIndi, pop],其中pop为种群类型;BestIndi的类型与pop的一致。 + + 注意: + 若没有找到可行解,则返回的self.BestIndi为None。 + + """ + + feasible = np.where(np.all(pop.CV <= 0, 1))[0] if pop.CV is not None else np.arange(pop.sizes) # 找到满足约束条件的个体的下标 + if len(feasible) > 0: + feasiblePop = pop[feasible] + if self.logTras != 0 and (len(self.log['gen']) == 0 or self.log['gen'][-1] != self.currentGen): # 补充记录日志和输出 + self.logging(feasiblePop) + if self.verbose: + self.display() + self.passTime += time.time() - self.timeSlot # 更新用时记录,因为已经要结束,因此不用再更新时间戳 + self.draw(pop, EndFlag=True) # 显示最终结果图 + if self.plotter: + self.plotter.show() + # 返回最优个体以及最后一代种群 + return [self.BestIndi, pop] diff --git a/geatpy/Population.py b/geatpy/Population.py new file mode 100644 index 00000000..ac49814f --- /dev/null +++ b/geatpy/Population.py @@ -0,0 +1,378 @@ +# -*- coding: utf-8 -*- +import os +import numpy as np +import geatpy as ea + + +class Population: + """ +Population : class - 种群类 + +描述: + 种群类是用来存储种群相关信息的一个类。 + +属性: + sizes : int - 种群规模,即种群的个体数目。 + + ChromNum : int - 染色体的数目,即每个个体有多少条染色体。 + + Encoding : str - 染色体编码方式, + 'BG':二进制/格雷编码; + 'RI':实整数编码,即实数和整数的混合编码; + 'P':排列编码。 + 相关概念:术语“实值编码”包含实整数编码和排列编码, + 它们共同的特点是染色体不需要解码即可直接表示对应的决策变量。 + "实整数"指的是种群染色体既包含实数的小数,也包含实数的整数。 + 特殊用法: + 设置Encoding=None,此时种群类的Field,Chrom成员属性将被设置为None, + 种群将不携带与染色体直接相关的信息,可以减少不必要的数据存储, + 这种用法可以在只想统计非染色体直接相关的信息时使用, + 尤其可以在多种群进化优化过程中对个体进行统一的适应度评价时使用。 + + Field : array - 译码矩阵,可以是FieldD或FieldDR(详见Geatpy数据结构)。 + 2.7.0版本之后,可以把问题类对象的varTypes、ranges、borders放到一个tuple中传入到此处, + 即Field = (varTypes, ranges, borders) + 此时将调用crtfld自动构建Field。 + + Chrom : array - 种群染色体矩阵,每一行对应一个个体的一条染色体。 + + Lind : int - 种群染色体长度。 + + ObjV : array - 种群目标函数值矩阵,每一行对应一个个体的目标函数值,每一列对应一个目标。 + + FitnV : array - 种群个体适应度列向量,每个元素对应一个个体的适应度,最小适应度为0。 + + CV : array - CV(Constraint Violation Value)是用来定量描述违反约束条件程度的矩阵,每行对应一个个体,每列对应一个约束。 + 注意:当没有设置约束条件时,CV设置为None。 + + Phen : array - 种群表现型矩阵(即种群各染色体解码后所代表的决策变量所组成的矩阵)。 + +函数: + 详见源码。 + +""" + + def __init__(self, Encoding, Field=None, NIND=None, Chrom=None, ObjV=None, FitnV=None, CV=None, Phen=None): + + """ + 描述: 种群类的构造函数,用于实例化种群对象,例如: + import geatpy as ea + population = ea.Population(Encoding, Field, NIND), + NIND为所需要的个体数。 + 此时得到的population还没被真正初始化,仅仅是完成种群对象的实例化。 + 该构造函数必须传入Chrom,才算是完成种群真正的初始化。 + 因此一开始可以只传入Encoding, Field以及NIND来完成种群对象的实例化, + 其他属性可以后面再通过计算进行赋值。 + 特殊用法1: + 可以利用ea.Population(Encoding, Field, 0)来创建一个“空种群”,即不含任何个体的种群对象。 + 特殊用法2: + 直接用ea.Population(Encoding)构建一个只包含编码信息的空种群。 + + """ + + if NIND is None: + NIND = 0 + if isinstance(NIND, int) and NIND >= 0: + self.sizes = NIND + else: + raise RuntimeError('error in Population: Size error. (种群规模设置有误,必须为非负整数。)') + self.ChromNum = 1 + self.Encoding = Encoding + if Encoding is None: + self.Field = None + self.Chrom = None + self.Lind = 0 + else: + if Field is None: + self.Field = None + else: + if type(Field) == tuple: + self.Field = ea.crtfld(Encoding, *Field) + else: + self.Field = Field.copy() + self.Chrom = Chrom.copy() if Chrom is not None else None + self.Lind = Chrom.shape[1] if Chrom is not None else 0 + self.ObjV = ObjV.copy() if ObjV is not None else None + self.FitnV = FitnV.copy() if FitnV is not None else None + self.CV = CV.copy() if CV is not None else None + self.Phen = Phen.copy() if Phen is not None else None + + def initChrom(self, NIND=None): + + """ + 描述: 初始化种群染色体矩阵。 + + 输入参数: + NIND : int - (可选参数)用于修改种群规模。 + 当其不缺省时,种群在初始化染色体矩阵前会把种群规模调整为NIND。 + + 输出参数: + 无输出参数。 + + """ + + if NIND is not None: + self.sizes = NIND # 重新设置种群规模 + self.Chrom = ea.crtpc(self.Encoding, self.sizes, self.Field) # 生成染色体矩阵 + self.Lind = self.Chrom.shape[1] # 计算染色体的长度 + self.ObjV = None + self.FitnV = None + self.CV = None + + def decoding(self): + + """ + 描述: 种群染色体解码。 + + """ + + if self.Encoding == 'BG': # 此时Field实际上为FieldD + Phen = ea.bs2ri(self.Chrom, self.Field) # 把二进制/格雷码转化为实整数 + elif self.Encoding == 'RI' or self.Encoding == 'P': + Phen = self.Chrom.copy() + else: + raise RuntimeError( + 'error in Population.decoding: Encoding must be ''BG'' or ''RI'' or ''P''. (' + '编码设置有误,解码时Encoding必须为''BG'', ''RI'' 或 ''P''。)') + return Phen + + def copy(self): + + """ + copy : function - 种群的复制 + 用法: + 假设pop是一个种群矩阵,那么:pop1 = pop.copy()即可完成对pop种群的复制。 + + """ + + return Population(self.Encoding, + self.Field, + self.sizes, + self.Chrom, + self.ObjV, + self.FitnV, + self.CV, + self.Phen) + + def __getitem__(self, index): + + """ + 描述: 种群的切片,即根据index下标向量选出种群中相应的个体组成一个新的种群。 + + 用法: 假设pop是一个包含多于2个个体的种群矩阵,那么: + pop1 = pop[[0,1]]即可得到由pop种群的第1、2个个体组成的种群。 + + 注意: index必须为一个slice或者为一个Numpy ndarray类型的一维数组或者为一个list类型的列表或者为一个整数, + 该函数不对传入的index参数的合法性进行更详细的检查。 + + """ + + # 计算切片后的长度以及对index进行格式处理 + if not isinstance(index, (slice, np.ndarray, list)): + if 'int' not in str(type(index)): + raise RuntimeError( + 'error in Population: index must be an integer, a 1-D list, or a 1-D array. (' + 'index必须是一个整数,一维的列表或者一维的向量。)') + if isinstance(index, slice): + NIND = (index.stop - (index.start if index.start is not None else 0)) // ( + index.step if index.step is not None else 1) + index_array = index + else: + index_array = np.array(index).reshape(-1) + if index_array.dtype == bool: + NIND = int(np.sum(index_array)) + else: + NIND = len(index_array) + if len(index_array) == 0: + index_array = [] + if self.Encoding is None: + NewChrom = None + else: + if self.Chrom is None: + raise RuntimeError('error in Population: Chrom is None. (种群染色体矩阵未初始化。)') + NewChrom = self.Chrom[index_array] + return Population(self.Encoding, + self.Field, + NIND, + NewChrom, + self.ObjV[index_array] if self.ObjV is not None else None, + self.FitnV[index_array] if self.FitnV is not None else None, + self.CV[index_array] if self.CV is not None else None, + self.Phen[index_array] if self.Phen is not None else None) + + def shuffle(self): + + """ + shuffle : function - 打乱种群个体的个体顺序 + 用法: 假设pop是一个种群矩阵,那么,pop.shuffle()即可完成对pop种群个体顺序的打乱。 + + """ + + shuff = np.arange(self.sizes) + np.random.shuffle(shuff) # 打乱顺序 + if self.Encoding is None: + self.Chrom = None + else: + if self.Chrom is None: + raise RuntimeError('error in Population: Chrom is None. (种群染色体矩阵未初始化。)') + self.Chrom = self.Chrom[shuff, :] + self.ObjV = self.ObjV[shuff, :] if self.ObjV is not None else None + self.FitnV = self.FitnV[shuff] if self.FitnV is not None else None + self.CV = self.CV[shuff, :] if self.CV is not None else None + self.Phen = self.Phen[shuff, :] if self.Phen is not None else None + + def __setitem__(self, index, pop): # 种群个体赋值(种群个体替换) + + """ + 描述: 种群个体的赋值 + 用法: 假设pop是一个包含多于2个个体的种群矩阵,pop1是另一个包含2个个体的种群矩阵,那么 + pop[[0,1]] = pop1,即可完成将pop种群的第1、2个个体赋值为pop1种群的个体。 + 注意: index必须为一个slice或者为一个Numpy ndarray类型的一维数组或者为一个list类型的列表或者为一个整数, + 该函数不对传入的index参数的合法性进行更详细的检查。 + 此外,进行种群个体替换后,该函数不会对适应度进行主动重置, + 如果因个体替换而需要重新对所有个体的适应度进行评价,则需要手写代码更新种群的适应度。 + + """ + + # 对index进行格式处理 + if not isinstance(index, (slice, np.ndarray, list)): + if 'int' not in str(type(index)): + raise RuntimeError( + 'error in Population: index must be an integer, a 1-D list, or a 1-D array. (' + 'index必须是一个整数,一维的列表或者一维的向量。)') + if isinstance(index, slice): + index_array = index + else: + index_array = np.array(index).reshape(-1) + if len(index_array) == 0: + index_array = [] + if self.Encoding is not None: + if self.Encoding != pop.Encoding: + raise RuntimeError('error in Population: Encoding disagree. (两种群染色体的编码方式必须一致。)') + if self.Field is not None and pop.Field is not None: + if not np.all(self.Field == pop.Field): + raise RuntimeError('error in Population: Field disagree. (两者的译码矩阵必须一致。)') + if self.Chrom is None: + raise RuntimeError('error in Population: Chrom is None. (种群染色体矩阵未初始化。)') + self.Chrom[index_array] = pop.Chrom + if self.ObjV is not None: + if pop.ObjV is None: + raise RuntimeError('error in Population: ObjV disagree. (两者的目标函数值矩阵必须要么同时为None要么同时不为None。)') + self.ObjV[index_array] = pop.ObjV + if self.FitnV is not None: + if pop.FitnV is None: + raise RuntimeError('error in Population: FitnV disagree. (两者的适应度列向量必须要么同时为None要么同时不为None。)') + self.FitnV[index_array] = pop.FitnV + if self.CV is not None: + if pop.CV is None: + raise RuntimeError('error in Population: CV disagree. (两者的违反约束程度矩阵必须要么同时为None要么同时不为None。)') + self.CV[index_array] = pop.CV + if self.Phen is not None: + if pop.Phen is None: + raise RuntimeError('error in Population: Phen disagree. (两者的表现型矩阵必须要么同时为None要么同时不为None。)') + self.Phen[index_array] = pop.Phen + self.sizes = self.Phen.shape[0] # 更新种群规模 + + def __add__(self, pop): + + """ + 描述: 种群个体合并。 + + 用法: 假设pop1, pop2是两个种群,它们的个体数可以相等也可以不相等,此时 + pop = pop1 + pop2,即可完成对pop1和pop2两个种群个体的合并。 + + 注意: + 进行种群合并后,该函数不会对适应度进行主动重置, + 如果因种群合并而需要重新对所有个体的适应度进行评价,则需要手写代码更新种群的适应度。 + + """ + + if self.Encoding is None: + NewChrom = None + else: + if self.Encoding != pop.Encoding: + raise RuntimeError('error in Population: Encoding disagree. (两种群染色体的编码方式必须一致。)') + if self.Chrom is None or pop.Chrom is None: + raise RuntimeError('error in Population: Chrom is None. (种群染色体矩阵未初始化。)') + if self.Field is not None and pop.Field is not None: + if not np.all(self.Field == pop.Field): + raise RuntimeError('error in Population: Field disagree. (两者的译码矩阵必须一致。)') + NewChrom = np.vstack([self.Chrom, pop.Chrom]) + NIND = self.sizes + pop.sizes # 得到合并种群的个体数 + return Population(self.Encoding, + self.Field, + NIND, + NewChrom, + np.vstack([self.ObjV, pop.ObjV]) if self.ObjV is not None and pop.ObjV is not None else None, + np.vstack( + [self.FitnV, pop.FitnV]) if self.FitnV is not None and pop.FitnV is not None else None, + np.vstack([self.CV, pop.CV]) if self.CV is not None and pop.CV is not None else None, + np.vstack([self.Phen, pop.Phen]) if self.Phen is not None and pop.Phen is not None else None) + + def __len__(self): + + """ + 描述: 计算种群规模。 + + 用法: 假设pop是一个种群,那么len(pop)即可得到该种群的个体数。 + 实际上,种群规模也可以通过pop.sizes得到。 + + """ + + return self.sizes + + def save(self, dirName='Population Info'): + + """ + 描述: 该函数将在字符串dirName所指向的文件夹下保存种群的信息,其中: + "Encoding.txt"保存种群的染色体编码; + "Field.csv"保存种群染色体的译码矩阵; + "Chrom.csv"保存种群的染色体矩阵; + "ObjV.csv"保存种群的目标函数矩阵; + "FitnV.csv"保存种群个体的适应度列向量; + "CV.csv"保存种群个体的违反约束程度矩阵; + "Phen.csv"保存种群染色体表现型矩阵; + 注意:该函数不会对种群的合法性进行检查。 + + """ + + if self.sizes > 0: + if not os.path.exists(dirName): + os.makedirs(dirName) + with open(dirName + '/Encoding.txt', 'w') as file: + file.write(str(self.Encoding)) + if self.Encoding is not None: + if self.Field is not None: + np.savetxt(dirName + '/Field.csv', self.Field, delimiter=',') + np.savetxt(dirName + '/Chrom.csv', self.Chrom, delimiter=',') + if self.ObjV is not None: + np.savetxt(dirName + '/ObjV.csv', self.ObjV, delimiter=',') + if self.FitnV is not None: + np.savetxt(dirName + '/FitnV.csv', self.FitnV, delimiter=',') + if self.CV is not None: + np.savetxt(dirName + '/CV.csv', self.CV, delimiter=',') + if self.Phen is not None: + np.savetxt(dirName + '/Phen.csv', self.Phen, delimiter=',') + + def getInfo(self): + """ + 获取种群的设置信息。 + """ + + info = {} + info['Type'] = 'Population' + info['Population Encoding:'] = self.Encoding + info['Population ChromNum'] = self.ChromNum + info['Population Field:'] = self.Field + info['Population size:'] = self.sizes + return info + + def __str__(self): + info = self.getInfo() + info['Population Chrom'] = self.Chrom + info['Population Lind'] = self.Lind + info['Population FitnV'] = self.FitnV + info['Population ObjV'] = self.ObjV + info['Population CV'] = self.CV + info['Population Phen'] = self.Phen + return str(info) \ No newline at end of file diff --git a/geatpy/Problem.py b/geatpy/Problem.py new file mode 100644 index 00000000..881f027d --- /dev/null +++ b/geatpy/Problem.py @@ -0,0 +1,286 @@ +# -*- coding: utf-8 -*- +import os +import numpy as np + + +class Problem: + + """ +Problem : Class - 问题类 + +描述: + 问题类是用来存储与待求解问题相关信息的一个类。 + +属性: + name : str - 问题名称(可以自由设置名称)。 + + M : int - 目标维数,即有多少个优化目标。 + + maxormins : array - 目标函数最小最大化标记的Numpy ndarray一维数组,1表示最小化,-1表示最大化,例如: + array([1,1,-1,-1]),表示前2个目标是最小化,后2个目标是最大化。 + + Dim : int - 决策变量维数,即有多少个决策变量。 + + varTypes : array - 连续或离散标记,是Numpy ndarray类型的一维数组, + 0表示对应的决策变量是连续的;1表示对应的变量是离散的。 + + lb : array - 存储着各个变量的下界。 + + ub : array - 存储着各个变量的上界。 + + ranges : array - 决策变量范围矩阵,第一行对应决策变量的下界,第二行对应决策变量的上界。 + + borders : array - 决策变量范围的边界矩阵,第一行对应决策变量的下边界,第二行对应决策变量的上边界, + 0表示范围中不含边界,1表示范围包含边界。 + + ReferObjV : array - 存储着目标函数参考值的矩阵,每一行对应一组目标函数参考值,每一列对应一个目标函数。 + + TinyReferObjV : array - 从ReferObjV中均匀抽取的数目更少的目标函数参考值矩阵。 + +函数: + aimFunc(pop) : 目标函数,需要在继承类即自定义的问题类中实现,或是传入已实现的函数。 + 其中pop为Population类的对象,代表一个种群, + pop对象的Phen属性(即种群染色体的表现型)等价于种群所有个体的决策变量组成的矩阵, + 该函数根据该Phen计算得到种群所有个体的目标函数值组成的矩阵,并将其赋值给pop对象的ObjV属性。 + 若有约束条件,则在计算违反约束程度矩阵CV后赋值给pop对象的CV属性(详见Geatpy数据结构)。 + 该函数不返回任何的返回值,求得的目标函数值保存在种群对象的ObjV属性中。 + 例如:population为一个种群对象,则调用aimFunc(population)即可完成目标函数值的计算, + 此时可通过population.ObjV得到求得的目标函数值,population.CV得到违反约束程度矩阵。 + 注意:在子类中,aimFunc()和evalVars()两者只能重写一个。 + + evalVars(v) : 用于直接传入决策变量矩阵来计算对应的目标函数矩阵和违反约束程度矩阵。该函数需要被子类重写。 + + evaluation(pop) : 调用aimFunc()或evalVars()计算传入种群的目标函数值和违反约束程度。 + + calReferObjV() : 计算目标函数参考值,需要在继承类中实现,或是传入已实现的函数。 + + getReferObjV() : 获取目标函数参考值。 + +""" + + def __init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin=None, ubin=None, aimFunc=None, evalVars=None, calReferObjV=None): + + """ + 描述: + 构造函数。 + """ + + self.name = name + self.M = M + self.maxormins = None if np.all(maxormins == 1) or maxormins is None else np.array(maxormins) + self.Dim = Dim + self.varTypes = np.array(varTypes) + self.lb = np.array(lb) + self.ub = np.array(ub) + self.ranges = np.array([lb, ub]) # 初始化ranges(决策变量范围矩阵) + if lbin is None: + lbin = [1] * Dim + if ubin is None: + ubin = [1] * Dim + self.borders = np.array([lbin, ubin]) # 初始化borders(决策变量范围边界矩阵) + self.aimFunc = aimFunc if aimFunc is not None else self.aimFunc # 初始化目标函数接口 + self.evalVars = evalVars if evalVars is not None else self.evalVars + self.calReferObjV = calReferObjV if calReferObjV is not None else self.calReferObjV # 初始化理论最优值计算函数接口 + self.ReferObjV = self.getReferObjV() # 计算目标函数参考值 + if self.ReferObjV is not None: + if self.ReferObjV.shape[0] > 100: + chooseIdx = np.linspace(0, self.ReferObjV.shape[0] - 1, 100).astype(np.int32) + self.TinyReferObjV = self.ReferObjV[chooseIdx, :] + else: + self.TinyReferObjV = self.ReferObjV + else: + self.TinyReferObjV = None + + def aimFunc(self, pop): + + """ + 描述: + 该函数需要被子类重写,用于计算整个种群的目标函数矩阵和违反约束程度矩阵。 + + 注意: + 如果执行到这里抛出了异常,说明自定义的问题类既没有重写aimFunc(),也没有重写evalVars()。 + aimFunc和evalVars两者中必须有一个被子类重写。 + 若子类同时重写了aimFunc和evalVars,则evalVars无效。 + + 输入参数: + pop : class - 种群对象 + + 输出参数: + 无输出参数。 + + """ + + raise RuntimeError('error in Problem: aim function has not been initialized. (未在问题子类中设置目标函数!)') + + def evalVars(self, Vars): + + """ + 描述: + evalVars即evaluate variables,用于直接传入决策变量矩阵来计算对应的目标函数矩阵和违反约束程度矩阵。该函数需要被子类重写。 + + 用法: + ObjV = evalVars(Vars) + ObjV, CV = evalVars(Vars) + + 注意: + 如果执行到这里抛出了异常,说明自定义的问题类既没有重写aimFunc(),也没有重写evalVars()。 + aimFunc和evalVars两者的其中一个必须有一个被子类重写。 + 若子类同时重写了aimFunc和evalVars,则evalVars无效。 + + 输入参数: + Vars : array - 决策变量矩阵。每一行代表一组决策变量。 + + 输出参数: + ObjV : array - 目标函数值矩阵。 + + CV : array - 违反约束程度矩阵。 + + """ + + raise RuntimeError('error in Problem: aim function has not been initialized. (未在问题子类中设置目标函数!)') + + @staticmethod + def single(func): + """ + 描述: 装饰器single。通过给目标函数添加装饰器,可以更专注于问题的模型本身。因为此时传入自定义目标函数的只有一个个体或一组决策变量。 + 用法: 1. 给aimFunc()加上single装饰器标记后,可以让aimFunc()的传入参数:种群对象pop只有一个个体。 + 2. 给evalVars()加上single装饰器标记后,可以让evalVars()的传入参数:Vars变成Numpy ndarray一维数组。即只传入一组决策变量。 + """ + def wrapper(param): + if type(param) == np.ndarray: + if param.ndim == 1: + param = np.atleast_2d(param) + elif param.ndim > 2: + raise RuntimeError('Invalid input parameter of evalVars. (evalVars的传入参数非法,必须为Numpy ndarray一维数组或二维数组。)') + return_object = func(param[0, :]) + if type(return_object) != tuple: + ObjV = [return_object] + for i in range(1, param.shape[0]): + Vars = param[i, :] + ObjV_i = func(Vars) + ObjV.append(np.atleast_1d(ObjV_i)) + return np.vstack(ObjV) + else: + ObjV_i, CV_i = return_object + ObjV = [ObjV_i] + CV = [CV_i] + for i in range(1, param.shape[0]): + Vars = param[i, :] + return_object = func(Vars) + ObjV_i, CV_i = return_object + ObjV.append(np.atleast_1d(ObjV_i)) + CV.append(np.atleast_1d(CV_i)) + return np.vstack(ObjV), np.vstack(CV) + else: + pop = param + ObjV = [] + CV = [] + for i in range(param.sizes): + pop_i = param[i] + func(pop_i) + ObjV.append(pop_i.ObjV[0, :]) + CV.append(pop_i.CV[0, :]) + pop.ObjV = np.vstack(ObjV) + pop.CV = np.vstack(CV) + + return wrapper + + def evaluation(self, pop): + + """ + 描述: + 调用aimFunc()或evalVars()计算传入种群的目标函数值和违反约束程度。 + 注意: + 若子类同时重写了aimFunc和evalVars,则evalVars无效。 + + 输入参数: + pop : class - 种群对象。 + + """ + + aimFuncCallFlag = False + evalVarsCallFlag = False + # 先尝试执行aimFunc() + if self.aimFunc.__name__ != 'wrapper': # 检查目标函数是否套了装饰器 + if self.aimFunc.__module__ != 'geatpy.Problem': + aimFuncCallFlag = True + else: # 若套了装饰器,则aimFunc一定被重写了。 + aimFuncCallFlag = True + if aimFuncCallFlag: + self.aimFunc(pop) + else: # 再尝试执行evalVars() + if self.evalVars.__name__ != 'wrapper': + if self.evalVars.__module__ != 'geatpy.Problem': + evalVarsCallFlag = True + else: # 若套了装饰器,则evalVars一定被重写了。 + evalVarsCallFlag = True + if evalVarsCallFlag: + return_object = self.evalVars(pop.Phen) + if type(return_object) != tuple: + pop.ObjV = return_object + else: + pop.ObjV, pop.CV = return_object + if not aimFuncCallFlag and not evalVarsCallFlag: + raise RuntimeError('error in Problem: one of the function aimFunc and evalVars should be rewritten. (aimFunc和evalVars两个函数必须至少有一个被子类重写。)') + + def calReferObjV(self): + + """ + 描述: + 如果待优化的模型知道理论全局最优解,则可以在自定义问题类里重写该函数,求出理论全局最优解对应的目标函数值矩阵。 + + """ + + return None + + def getReferObjV(self, reCalculate=False): + + """ + 描述: + 该函数用于读取/计算问题的目标函数参考值,这个参考值可以是理论上的全局最优解的目标函数值,也可以是人为设定的非最优的目标函数参考值。 + 在获取或计算出理论全局最优解后, + 结果将被按照“问题名称_目标维数_决策变量个数.csv”的文件命名保存到referenceObjV文件夹内。 + + 输入参数: + reCalculate : bool - 表示是否要调用calReferObjV()来重新计算目标函数参考值。 + 当缺省时默认为False。 + + 输出参数: + referenceObjV : array - 存储着目标函数参考值的矩阵,每一行对应一组目标函数参考值,每一列对应一个目标函数。 + + """ + + if not reCalculate: + if self.calReferObjV.__module__ != 'geatpy.Problem': + # 尝试读取数据 + if os.path.exists('referenceObjV'): + if os.path.exists('referenceObjV/' + self.name + '_M' + str(self.M) + '_D' + str(self.Dim) + '.csv'): + return np.atleast_2d(np.loadtxt('referenceObjV/' + self.name + '_M' + str(self.M) + '_D' + str(self.Dim) + '.csv', + delimiter=',')) + # 若找不到数据,则调用calReferObjV()计算目标函数参考值 + referenceObjV = self.calReferObjV() + if referenceObjV is not None: + # 简单检查referenceObjV的合法性 + if not isinstance(referenceObjV, np.ndarray) or referenceObjV.ndim != 2 or referenceObjV.shape[1] != self.M: + raise RuntimeError( + 'error: ReferenceObjV is illegal. (目标函数参考值矩阵的数据格式不合法,请检查自定义问题类中的calReferObjV(' + ')函数的代码,假如没有目标函数参考值,则在问题类中不需要定义calReferObjV()函数。)') + # 保存数据 + if not os.path.exists('referenceObjV'): + os.makedirs('referenceObjV') + np.savetxt('referenceObjV/' + self.name + '_M' + str(self.M) + '_D' + str(self.Dim) + '.csv', referenceObjV, + delimiter=',') + self.ReferObjV = referenceObjV + return referenceObjV + + def __str__(self): + info = {} + info['name'] = self.name + info['M'] = self.M + info['maxormins'] = self.maxormins + info['Dim'] = self.Dim + info['varTypes'] = self.varTypes + info['lb'] = self.lb + info['ub'] = self.ub + info['borders'] = self.borders + return str(info) \ No newline at end of file diff --git a/geatpy/PsyPopulation.py b/geatpy/PsyPopulation.py new file mode 100644 index 00000000..70743f00 --- /dev/null +++ b/geatpy/PsyPopulation.py @@ -0,0 +1,428 @@ +# -*- coding: utf-8 -*- +import os +import numpy as np +import geatpy as ea + + +class PsyPopulation(ea.Population): + """ +PsyPopulation : class - 多染色体种群类(Popysomy Population) + +描述: + 多染色体种群类是用来存储每个个体包含多条染色体的种群相关信息的一个类。 + 该类和种群类Population似,不同之处是可以包含多条染色体,因此支持复杂的混合编码。 + +属性: + sizes : int - 种群规模,即种群的个体数目。 + + ChromNum : int - 染色体的数目,即每个个体有多少条染色体。 + + Encodings : list - 存储各染色体编码方式的列表。每个元素的取值如下: + 'BG':二进制/格雷编码; + 'RI':实整数编码,即实数和整数的混合编码; + 'P':排列编码。 + 相关概念:术语“实值编码”包含实整数编码和排列编码, + 它们共同的特点是染色体不需要解码即可直接表示对应的决策变量。 + "实整数"指的是种群染色体既包含实数的小数,也包含实数的整数。 + 特殊用法: + 设置Encoding=None,此时种群类的Fields,Chroms成员属性将被设置为None, + 种群将不携带与染色体直接相关的信息,可以减少不必要的数据存储, + 这种用法可以在只想统计非染色体直接相关的信息时使用, + 尤其可以在多种群进化优化过程中对个体进行统一的适应度评价时使用。 + + Fields : list - 存储各染色体对应的译码矩阵的列表。 + 2.7.0版本之后,可以把问题类对象的varTypes、ranges、borders放到一个tuple中传入到此处, + 即Field = (varTypes, ranges, borders) + 此时将调用crtfld自动构建Field。 + + Chroms : list - 存储种群各染色体矩阵的列表。 + + Linds : list - 存储种群各染色体长度的列表。 + + ObjV : array - 种群目标函数值矩阵,每一行对应一个个体的目标函数值,每一列对应一个目标。 + + FitnV : array - 种群个体适应度列向量,每个元素对应一个个体的适应度,最小适应度为0。 + + CV : array - CV(Constraint Violation Value)是用来定量描述违反约束条件程度的矩阵,每行对应一个个体,每列对应一个约束。 + 注意:当没有设置约束条件时,CV设置为None。 + + Phen : array - 种群表现型矩阵(即染色体解码后所代表的决策变量所组成的矩阵)。 + + EncoIdxs : list - 表示每个染色体编码哪些变量。 + 例如:EncoIdxs = [[0], [1,2,3,4]],表示一共有5个变量,其中第一个变量编码成第一条子染色体;后4个变量编码成第 + 二条子染色体。 + +函数: + 详见源码。 + +""" + + def __init__(self, Encodings, Fields=None, NIND=None, Chroms=None, ObjV=None, FitnV=None, CV=None, Phen=None, EncoIdxs=None): + + """ + 描述: 种群类的构造函数,用于实例化种群对象,例如: + import geatpy as ea + population = ea.PsyPopulation(Encodings, Fields, NIND), + NIND为所需要的个体数, + 此时得到的population还没被真正初始化,仅仅是完成种群对象的实例化。 + 该构造函数必须传入Chroms,才算是完成种群真正的初始化。 + 因此一开始可以只传入Encodings, Fields以及NIND来完成种群对象的实例化, + 其他属性可以后面再通过计算进行赋值。 + 特殊用法1: + 可以利用ea.PsyPopulation(Encodings, Fields, 0)来创建一个“空种群”,即不含任何个体的种群对象。 + 特殊用法2: + 直接用ea.PsyPopulation(Encodings)构建一个只包含编码信息的空种群。 + + """ + + if NIND is None: + NIND = 0 + if isinstance(NIND, int) and NIND >= 0: + self.sizes = NIND + else: + raise RuntimeError('error in PysPopulation: Size error. (种群规模设置有误,必须为非负整数。)') + self.EncoIdxs = EncoIdxs + self.Encodings = Encodings + if Encodings is None: + self.Fields = None + self.Chroms = None + self.Linds = 0 + self.ChromNum = 2 # 随意设置一个大于1的值 + else: + self.ChromNum = len(Encodings) + if self.ChromNum == 1: + raise RuntimeError( + 'error in PysPopulation: ChromNum must be bigger than 1. (' + '使用PysPopulation类时,染色体数目必须大于1,否则应该使用Population类。)') + if Fields is None: + self.Fields = None + else: + if type(Fields) == tuple: + self.Fields = [] + if len(EncoIdxs) != len(Encodings): + raise RuntimeError('error in PysPopulation: Dimension disagree. (EncoIdxs的元素个数与Encodings的不一致。)') + for i, Encoding in enumerate(Encodings): + params = [] + for item in Fields: + if item.ndim == 1: + params.append(item[EncoIdxs[i]]) + elif item.ndim == 2: + params.append(item[:, EncoIdxs[i]]) + else: + raise RuntimeError('error in PysPopulation: Parameter error. (参数错误,详见文件头的注释。)') + params = tuple(params) + self.Fields.append(ea.crtfld(Encoding, *params)) + else: + self.Fields = Fields.copy() + self.Chroms = [None] * self.ChromNum # 初始化Chroms为元素是None的列表 + self.Linds = [] + if Chroms is None: + self.Linds = [0] * self.ChromNum + else: + for i in range(self.ChromNum): + if Chroms[i] is not None: + self.Linds.append(Chroms[i].shape[1]) + self.Chroms[i] = Chroms[i].copy() if Chroms[i] is not None else None + else: + self.Linds.append(0) + self.ObjV = ObjV.copy() if ObjV is not None else None + self.FitnV = FitnV.copy() if FitnV is not None else None + self.CV = CV.copy() if CV is not None else None + self.Phen = Phen.copy() if Phen is not None else None + + def initChrom(self, NIND=None): + + """ + 描述: 初始化种群染色体矩阵。 + + 输入参数: + NIND : int - (可选参数)用于修改种群规模。 + 当其不缺省时,种群在初始化染色体矩阵前会把种群规模调整为NIND。 + + 输出参数: + 无输出参数。 + + """ + + if NIND is not None: + self.sizes = NIND # 重新设置种群规模 + # 遍历各染色体矩阵进行初始化 + for i in range(self.ChromNum): + self.Chroms[i] = ea.crtpc(self.Encodings[i], self.sizes, self.Fields[i]) # 生成染色体矩阵 + self.Linds.append(self.Chroms[i].shape[1]) # 计算染色体的长度 + self.ObjV = None + self.FitnV = np.ones((self.sizes, 1)) # 默认适应度全为1 + self.CV = None + + def decoding(self): + + """ + 描述: 种群染色体解码。 + + """ + + Phen = np.ones((self.sizes, 0)) # 初始化一个空的矩阵 + # 遍历各染色体矩阵进行解码 + for i in range(self.ChromNum): + if self.Encodings[i] == 'BG': # 此时Field实际上为FieldD + tempPhen = ea.bs2ri(self.Chroms[i], self.Fields[i]) # 把二进制/格雷码转化为实整数 + elif self.Encodings[i] == 'RI' or self.Encodings[i] == 'P': + tempPhen = self.Chroms[i].copy() + else: + raise RuntimeError( + 'error in PsyPopulation.decoding: Encoding must be ''BG'' or ''RI'' or ''P''. (' + '编码设置有误,Encoding必须为''BG'', ''RI'' 或 ''P''。)') + Phen = np.hstack([Phen, tempPhen]) + + return Phen + + def copy(self): + + """ + copy : function - 种群的复制 + 用法: + 假设pop是一个种群矩阵,那么:pop1 = pop.copy()即可完成对pop种群的复制。 + + """ + + return PsyPopulation(self.Encodings, + self.Fields, + self.sizes, + self.Chroms, + self.ObjV, + self.FitnV, + self.CV, + self.Phen, + self.EncoIdxs) + + def __getitem__(self, index): + + """ + 描述: 种群的切片,即根据index下标向量选出种群中相应的个体组成一个新的种群。 + 用法: 假设pop是一个包含多于2个个体的种群矩阵,那么: + pop1 = pop[[0,1]]即可得到由pop种群的第1、2个个体组成的种群。 + 注意: index必须为一个slice或者为一个Numpy ndarray类型的一维数组或者为一个list类型的列表或者为一个整数, + 该函数不对传入的index参数的合法性进行更详细的检查。 + + """ + + # 计算切片后的长度 + if not isinstance(index, (slice, np.ndarray, list)): + if 'int' not in str(type(index)): + raise RuntimeError( + 'error in Population: index must be an integer, a 1-D list, or a 1-D array. (' + 'index必须是一个整数,一维的列表或者一维的向量。)') + if isinstance(index, slice): + NIND = (index.stop - (index.start if index.start is not None else 0)) // ( + index.step if index.step is not None else 1) + index_array = index + else: + index_array = np.array(index).reshape(-1) + if index_array.dtype == bool: + NIND = int(np.sum(index_array)) + else: + NIND = len(index_array) + if len(index_array) == 0: + index_array = [] + if self.Encodings is None: + NewChroms = None + else: + NewChroms = [] + for i in range(self.ChromNum): + if self.Chroms[i] is None: + raise RuntimeError('error in PsyPopulation: Chrom[i] is None. (种群染色体矩阵未初始化。)') + NewChroms.append(self.Chroms[i][index_array]) + return PsyPopulation(self.Encodings, + self.Fields, + NIND, + NewChroms, + self.ObjV[index_array] if self.ObjV is not None else None, + self.FitnV[index_array] if self.FitnV is not None else None, + self.CV[index_array] if self.CV is not None else None, + self.Phen[index_array] if self.Phen is not None else None, + self.EncoIdxs) + + def shuffle(self): + + """ + shuffle : function - 打乱种群个体的个体顺序 + 用法: 假设pop是一个种群矩阵,那么,pop.shuffle()即可完成对pop种群个体顺序的打乱。 + + """ + + shuff = np.arange(self.sizes) + np.random.shuffle(shuff) # 打乱顺序 + if self.Encodings is None: + self.Chroms = None + for i in range(self.ChromNum): + if self.Chroms[i] is None: + raise RuntimeError('error in PsyPopulation: Chrom[i] is None. (种群染色体矩阵未初始化。)') + self.Chroms[i] = self.Chroms[i][shuff, :] + self.ObjV = self.ObjV[shuff, :] if self.ObjV is not None else None + self.FitnV = self.FitnV[shuff] if self.FitnV is not None else None + self.CV = self.CV[shuff, :] if self.CV is not None else None + self.Phen = self.Phen[shuff, :] if self.Phen is not None else None + + def __setitem__(self, index, pop): # 种群个体赋值(种群个体替换) + + """ + 描述: 种群个体的赋值 + 用法: 假设pop是一个包含多于2个个体的种群矩阵,pop1是另一个包含2个个体的种群矩阵,那么 + pop[[0,1]] = pop1,即可完成将pop种群的第1、2个个体赋值为pop1种群的个体。 + 注意: index必须为一个slice或者为一个Numpy ndarray类型的一维数组或者为一个list类型的列表或者为一个整数, + 该函数不对传入的index参数的合法性进行更详细的检查。 + 此外,进行种群个体替换后,该函数不会对适应度进行主动重置, + 如果因个体替换而需要重新对所有个体的适应度进行评价,则需要手写代码更新种群的适应度。 + + """ + + # 对index进行格式处理 + if not isinstance(index, (slice, np.ndarray, list)): + if 'int' not in str(type(index)): + raise RuntimeError( + 'error in Population: index must be an integer, a 1-D list, or a 1-D array. (' + 'index必须是一个整数,一维的列表或者一维的向量。)') + if isinstance(index, slice): + index_array = index + else: + index_array = np.array(index).reshape(-1) + if len(index_array) == 0: + index_array = [] + if self.Encodings is not None: + if self.Fields is not None and pop.Fields is not None: + for i in range(self.ChromNum): + if self.Encodings[i] != pop.Encodings[i]: + raise RuntimeError('error in PsyPopulation: Encoding disagree. (两种群染色体的编码方式必须一致。)') + if not np.all(self.Fields[i] == pop.Fields[i]): + raise RuntimeError('error in PsyPopulation: Field disagree. (两者的译码矩阵必须一致。)') + if self.Chroms[i] is None: + raise RuntimeError('error in PsyPopulation: Chrom[i] is None. (种群染色体矩阵未初始化。)') + self.Chroms[i][index_array] = pop.Chroms[i] + if self.ObjV is not None: + if pop.ObjV is None: + raise RuntimeError('error in PsyPopulation: ObjV disagree. (两者的目标函数值矩阵必须要么同时为None要么同时不为None。)') + self.ObjV[index_array] = pop.ObjV + if self.FitnV is not None: + if pop.FitnV is None: + raise RuntimeError('error in PsyPopulation: FitnV disagree. (两者的适应度列向量必须要么同时为None要么同时不为None。)') + self.FitnV[index_array] = pop.FitnV + if self.CV is not None: + if pop.CV is None: + raise RuntimeError('error in PsyPopulation: CV disagree. (两者的违反约束程度矩阵必须要么同时为None要么同时不为None。)') + self.CV[index_array] = pop.CV + if self.Phen is not None: + if pop.Phen is None: + raise RuntimeError('error in PsyPopulation: Phen disagree. (两者的表现型矩阵必须要么同时为None要么同时不为None。)') + self.Phen[index_array] = pop.Phen + self.sizes = self.Phen.shape[0] # 更新种群规模 + + def __add__(self, pop): + + """ + 描述: 种群个体合并 + 用法: 假设pop1, pop2是两个种群,它们的个体数可以相等也可以不相等,此时 + pop = pop1 + pop2,即可完成对pop1和pop2两个种群个体的合并。 + 注意: + 进行种群合并后,该函数不会对适应度进行主动重置, + 如果因种群合并而需要重新对所有个体的适应度进行评价,则需要手写代码更新种群的适应度。 + + """ + + if self.Encodings is None: + NewChroms = None + else: + NewChroms = [None] * self.ChromNum + for i in range(self.ChromNum): + if self.Encodings[i] != pop.Encodings[i]: + raise RuntimeError('error in PsyPopulation: Encoding disagree. (两种群染色体的编码方式必须一致。)') + if not np.all(self.Fields[i] == pop.Fields[i]): + raise RuntimeError('error in PsyPopulation: Field disagree. (两者的译码矩阵必须一致。)') + if self.Chroms[i] is None or pop.Chroms[i] is None: + raise RuntimeError('error in PsyPopulation: Chrom is None. (种群染色体矩阵未初始化。)') + NewChroms[i] = np.vstack([self.Chroms[i], pop.Chroms[i]]) + NIND = self.sizes + pop.sizes # 得到合并种群的个体数 + return PsyPopulation(self.Encodings, + self.Fields, + NIND, + NewChroms, + np.vstack( + [self.ObjV, pop.ObjV]) if self.ObjV is not None and pop.ObjV is not None else None, + np.vstack( + [self.FitnV, pop.FitnV]) if self.FitnV is not None and pop.FitnV is not None else None, + np.vstack([self.CV, pop.CV]) if self.CV is not None and pop.CV is not None else None, + np.vstack( + [self.Phen, pop.Phen]) if self.Phen is not None and pop.Phen is not None else None, + self.EncoIdxs) + + def __len__(self): + + """ + 描述: 计算种群规模 + 用法: 假设pop是一个种群,那么len(pop)即可得到该种群的个体数。 + 实际上,种群规模也可以通过pop.sizes得到。 + + """ + + return self.sizes + + def save(self, dirName='Population Info'): + + """ + 描述: 该函数将在字符串dirName所指向的文件夹下保存种群的信息,其中: + "Encodingsi.txt"保存种群的染色体编码,i为0,1,2,3...; + "Fieldsi.csv"保存种群染色体的译码矩阵,i为0,1,2,3...; + "Chromsi.csv"保存种群的染色体矩阵,i为0,1,2,3...; + "ObjV.csv"保存种群的目标函数矩阵; + "FitnV.csv"保存种群个体的适应度列向量; + "CV.csv"保存种群个体的违反约束程度矩阵; + "Phen.csv"保存种群染色体表现型矩阵; + 注意:该函数不会对种群的合法性进行检查。 + + """ + + if self.sizes > 0: + if not os.path.exists(dirName): + os.makedirs(dirName) + if self.Encodings is not None: + if self.Fields is not None: + for i in range(self.ChromNum): + with open(dirName + '/Encodings' + str(i) + '.txt', 'w') as file: + file.write(str(self.Encodings[i])) + np.savetxt(dirName + '/Fields' + str(i) + '.csv', self.Fields[i], delimiter=',') + if self.Chroms[i] is not None: + np.savetxt(dirName + '/Chroms' + str(i) + '.csv', self.Chroms[i], delimiter=',') + if self.ObjV is not None: + np.savetxt(dirName + '/ObjV.csv', self.ObjV, delimiter=',') + if self.FitnV is not None: + np.savetxt(dirName + '/FitnV.csv', self.FitnV, delimiter=',') + if self.CV is not None: + np.savetxt(dirName + '/CV.csv', self.CV, delimiter=',') + if self.Phen is not None: + np.savetxt(dirName + '/Phen.csv', self.Phen, delimiter=',') + if self.EncoIdxs is not None: + with open(dirName + '/EncoIdxs.txt', 'w') as file: + file.write(str(self.EncoIdxs)) + + def getInfo(self): + """ + 获取种群的设置信息。 + """ + + info = {} + info['Type'] = 'PsyPopulation' + info['Population Encoding:'] = self.Encodings + info['Population EncoIdxs'] = self.EncoIdxs + info['Population ChromNum'] = self.ChromNum + info['Population Field:'] = self.Fields + info['Population size:'] = self.sizes + return info + + def __str__(self): + info = self.getInfo() + info['Population Chrom'] = self.Chroms + info['Population Lind'] = self.Linds + info['Population FitnV'] = self.FitnV + info['Population ObjV'] = self.ObjV + info['Population CV'] = self.CV + info['Population Phen'] = self.Phen + return str(info) diff --git a/geatpy/__init__.py b/geatpy/__init__.py new file mode 100644 index 00000000..f2442c3e --- /dev/null +++ b/geatpy/__init__.py @@ -0,0 +1,180 @@ +# -*- coding: utf-8 -*- +""" +import all libs of geatpy + +""" + +__author__ = "Geatpy Team" +__version__ = "2.7.0" + +# import the core +from geatpy.core.awGA import awGA +from geatpy.core.boundfix import boundfix +from geatpy.core.bs2int import bs2int +from geatpy.core.bs2real import bs2real +from geatpy.core.bs2ri import bs2ri +from geatpy.core.cdist import cdist +from geatpy.core.crowdis import crowdis +from geatpy.core.crtbp import crtbp +from geatpy.core.crtfld import crtfld +from geatpy.core.crtgp import crtgp +from geatpy.core.crtidp import crtidp +from geatpy.core.crtip import crtip +from geatpy.core.crtpc import crtpc +from geatpy.core.crtpp import crtpp +from geatpy.core.crtri import crtri +from geatpy.core.crtrp import crtrp +from geatpy.core.crtup import crtup +from geatpy.core.dup import dup +from geatpy.core.ecs import ecs +from geatpy.core.etour import etour +from geatpy.core.indexing import indexing +import geatpy.core.indicator +from geatpy.core.mergecv import mergecv +from geatpy.core.migrate import migrate +from geatpy.core.moeaplot import moeaplot +from geatpy.core.mselecting import mselecting +from geatpy.core.mutate import mutate +from geatpy.core.mutbga import mutbga +from geatpy.core.mutbin import mutbin +from geatpy.core.mutde import mutde +from geatpy.core.mutgau import mutgau +from geatpy.core.mutinv import mutinv +from geatpy.core.mutmove import mutmove +from geatpy.core.mutpolyn import mutpolyn +from geatpy.core.mutpp import mutpp +from geatpy.core.mutswap import mutswap +from geatpy.core.mutuni import mutuni +from geatpy.core.ndsortDED import ndsortDED +from geatpy.core.ndsortESS import ndsortESS +from geatpy.core.ndsortTNS import ndsortTNS +from geatpy.core.otos import otos +from geatpy.core.pbi import pbi +from geatpy.core.powing import powing +from geatpy.core.ranking import ranking +from geatpy.core.rcs import rcs +from geatpy.core.recdis import recdis +from geatpy.core.recint import recint +from geatpy.core.reclin import reclin +from geatpy.core.recndx import recndx +from geatpy.core.recombin import recombin +from geatpy.core.recsbx import recsbx +from geatpy.core.refgselect import refgselect +from geatpy.core.refselect import refselect +from geatpy.core.ri2bs import ri2bs +from geatpy.core.rps import rps +from geatpy.core.rwGA import rwGA +from geatpy.core.rws import rws +from geatpy.core.scaling import scaling +from geatpy.core.selecting import selecting +from geatpy.core.soeaplot import soeaplot +from geatpy.core.sus import sus +from geatpy.core.tcheby import tcheby +from geatpy.core.tour import tour +from geatpy.core.trcplot import trcplot +from geatpy.core.urs import urs +from geatpy.core.varplot import varplot +from geatpy.core.xovbd import xovbd +from geatpy.core.xovdp import xovdp +from geatpy.core.xovexp import xovexp +from geatpy.core.xovox import xovox +from geatpy.core.xovpmx import xovpmx +from geatpy.core.xovsec import xovsec +from geatpy.core.xovsh import xovsh +from geatpy.core.xovsp import xovsp +from geatpy.core.xovud import xovud + +# import classes and mathods +from geatpy.Algorithm import Algorithm +from geatpy.Algorithm import MoeaAlgorithm +from geatpy.Algorithm import SoeaAlgorithm +from geatpy.optimize import optimize +from geatpy.Population import Population +from geatpy.Problem import Problem +from geatpy.PsyPopulation import PsyPopulation +from geatpy.core import indicator + +# import visualization +from geatpy.visualization.PointScatter import PointScatter +from geatpy.visualization.ParCoordPlotter import ParCoordPlotter + +# import benchmarks +import geatpy.benchmarks + +# import operators +from geatpy.operators.migration.Migrate import Migrate +from geatpy.operators.mutation.Mutation import Mutation +from geatpy.operators.mutation.Mutbga import Mutbga +from geatpy.operators.mutation.Mutbin import Mutbin +from geatpy.operators.mutation.Mutde import Mutde +from geatpy.operators.mutation.Mutgau import Mutgau +from geatpy.operators.mutation.Mutinv import Mutinv +from geatpy.operators.mutation.Mutmove import Mutmove +from geatpy.operators.mutation.Mutpolyn import Mutpolyn +from geatpy.operators.mutation.Mutpp import Mutpp +from geatpy.operators.mutation.Mutswap import Mutswap +from geatpy.operators.mutation.Mutuni import Mutuni +from geatpy.operators.recombination.Recdis import Recdis +from geatpy.operators.recombination.Recint import Recint +from geatpy.operators.recombination.Reclin import Reclin +from geatpy.operators.recombination.Recndx import Recndx +from geatpy.operators.recombination.Recombination import Recombination +from geatpy.operators.recombination.Recsbx import Recsbx +from geatpy.operators.recombination.Xovbd import Xovbd +from geatpy.operators.recombination.Xovdp import Xovdp +from geatpy.operators.recombination.Xovexp import Xovexp +from geatpy.operators.recombination.Xovox import Xovox +from geatpy.operators.recombination.Xovpmx import Xovpmx +from geatpy.operators.recombination.Xovsec import Xovsec +from geatpy.operators.recombination.Xovsh import Xovsh +from geatpy.operators.recombination.Xovsp import Xovsp +from geatpy.operators.recombination.Xovud import Xovud +# import moea algorithms +from geatpy.algorithms.moeas.awGA.moea_awGA_templet import moea_awGA_templet +from geatpy.algorithms.moeas.awGA.moea_psy_awGA_templet import moea_psy_awGA_templet +from geatpy.algorithms.moeas.moead.moea_MOEAD_DE_templet import moea_MOEAD_DE_templet +from geatpy.algorithms.moeas.moead.moea_MOEAD_archive_templet import moea_MOEAD_archive_templet +from geatpy.algorithms.moeas.moead.moea_MOEAD_templet import moea_MOEAD_templet +from geatpy.algorithms.moeas.nsga2.moea_NSGA2_DE_templet import moea_NSGA2_DE_templet +from geatpy.algorithms.moeas.nsga2.moea_NSGA2_archive_templet import moea_NSGA2_archive_templet +from geatpy.algorithms.moeas.nsga2.moea_NSGA2_templet import moea_NSGA2_templet +from geatpy.algorithms.moeas.nsga2.moea_psy_NSGA2_archive_templet import moea_psy_NSGA2_archive_templet +from geatpy.algorithms.moeas.nsga2.moea_psy_NSGA2_templet import moea_psy_NSGA2_templet +from geatpy.algorithms.moeas.nsga3.moea_NSGA3_DE_templet import moea_NSGA3_DE_templet +from geatpy.algorithms.moeas.nsga3.moea_NSGA3_templet import moea_NSGA3_templet +from geatpy.algorithms.moeas.nsga3.moea_psy_NSGA3_templet import moea_psy_NSGA3_templet +from geatpy.algorithms.moeas.pps.moea_PPS_MOEAD_DE_archive_templet import moea_PPS_MOEAD_DE_archive_templet +from geatpy.algorithms.moeas.rvea.moea_RVEA_RES_templet import moea_RVEA_RES_templet +from geatpy.algorithms.moeas.rvea.moea_RVEA_templet import moea_RVEA_templet +from geatpy.algorithms.moeas.rvea.moea_psy_RVEA_RES_templet import moea_psy_RVEA_RES_templet +from geatpy.algorithms.moeas.rvea.moea_psy_RVEA_templet import moea_psy_RVEA_templet +from geatpy.algorithms.soeas.DE.DE_best_1_L.soea_DE_best_1_L_templet import soea_DE_best_1_L_templet +# import soea algorithms +from geatpy.algorithms.soeas.DE.DE_best_1_bin.soea_DE_best_1_bin_templet import soea_DE_best_1_bin_templet +from geatpy.algorithms.soeas.DE.DE_currentToBest_1_L.soea_DE_currentToBest_1_L_templet import \ + soea_DE_currentToBest_1_L_templet +from geatpy.algorithms.soeas.DE.DE_currentToBest_1_bin.soea_DE_currentToBest_1_bin_templet import \ + soea_DE_currentToBest_1_bin_templet +from geatpy.algorithms.soeas.DE.DE_currentToRand_1.soea_DE_currentToRand_1_templet import soea_DE_currentToRand_1_templet +from geatpy.algorithms.soeas.DE.DE_rand_1_L.soea_DE_rand_1_L_templet import soea_DE_rand_1_L_templet +from geatpy.algorithms.soeas.DE.DE_rand_1_bin.soea_DE_rand_1_bin_templet import soea_DE_rand_1_bin_templet +from geatpy.algorithms.soeas.DE.DE_targetToBest_1_L.soea_DE_targetToBest_1_L_templet import \ + soea_DE_targetToBest_1_L_templet +from geatpy.algorithms.soeas.DE.DE_targetToBest_1_bin.soea_DE_targetToBest_1_bin_templet import \ + soea_DE_targetToBest_1_bin_templet +from geatpy.algorithms.soeas.ES.ES_1_plus_1.soea_ES_1_plus_1_templet import soea_ES_1_plus_1_templet +from geatpy.algorithms.soeas.ES.ES_miu_plus_lambda.soea_ES_miu_plus_lambda_templet import \ + soea_ES_miu_plus_lambda_templet +from geatpy.algorithms.soeas.GA.EGA.soea_EGA_templet import soea_EGA_templet +from geatpy.algorithms.soeas.GA.EGA.soea_psy_EGA_templet import soea_psy_EGA_templet +from geatpy.algorithms.soeas.GA.SEGA.soea_SEGA_templet import soea_SEGA_templet +from geatpy.algorithms.soeas.GA.SEGA.soea_multi_SEGA_templet import soea_multi_SEGA_templet +from geatpy.algorithms.soeas.GA.SEGA.soea_psy_SEGA_templet import soea_psy_SEGA_templet +from geatpy.algorithms.soeas.GA.SGA.soea_GGAP_SGA_templet import soea_GGAP_SGA_templet +from geatpy.algorithms.soeas.GA.SGA.soea_SGA_templet import soea_SGA_templet +from geatpy.algorithms.soeas.GA.SGA.soea_psy_GGAP_SGA_templet import soea_psy_GGAP_SGA_templet +from geatpy.algorithms.soeas.GA.SGA.soea_psy_SGA_templet import soea_psy_SGA_templet +from geatpy.algorithms.soeas.GA.steadyGA.soea_psy_steadyGA_templet import soea_psy_steadyGA_templet +from geatpy.algorithms.soeas.GA.steadyGA.soea_steadyGA_templet import soea_steadyGA_templet +from geatpy.algorithms.soeas.GA.studGA.soea_psy_studGA_templet import soea_psy_studGA_templet +from geatpy.algorithms.soeas.GA.studGA.soea_studGA_templet import soea_studGA_templet diff --git a/geatpy/algorithms/moeas/awGA/moea_awGA_templet.py b/geatpy/algorithms/moeas/awGA/moea_awGA_templet.py new file mode 100644 index 00000000..3c5ae4dc --- /dev/null +++ b/geatpy/algorithms/moeas/awGA/moea_awGA_templet.py @@ -0,0 +1,88 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 +from geatpy.algorithms.moeas.awGA.updateNDSet import updateNDSet # 导入该算法类所需的外部函数 + + +class moea_awGA_templet(ea.MoeaAlgorithm): + """ +moea_awGA_templet : class - 多目标进化优化awGA算法类 + +算法描述: + 采用awGA进行多目标优化。 + +参考文献: + [1] Gen M,CHeng R. Genetic Algorithms and Engineering Optimization[M]. + New York: John Wiley & Sons,2000 + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'awGA' + self.selFunc = 'tour' # 选择方式,采用锦标赛选择 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encoding == 'BG': + self.recOper = ea.Xovud(XOVR=1) # 生成部均匀交叉算子对象 + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.recOper = ea.Xovud(XOVR=1) # 生成部均匀交叉算子对象 + self.mutOper = ea.Mutuni(Pm=1 / self.problem.Dim, Alpha=False, Middle=False) # 生成均匀变异算子对象 + self.extraMutOper = ea.Mutgau(Pm=1 / self.problem.Dim, Sigma3=False, + Middle=False) # 额外生成一个高斯变异算子对象,对标准差放大3倍 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.MAXSIZE = population.sizes # 非支配解集大小限制 + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + problem = self.problem + population = self.population + NIND = population.sizes + MAXSIZE = self.MAXSIZE + if MAXSIZE is None: # 检查MAXSIZE,默认取2倍的种群规模 + MAXSIZE = 2 * NIND + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + NDSet = updateNDSet(population, problem.maxormins, MAXSIZE) # 计算适应度和得到全局非支配种群 + self.evalsNum = population.sizes # 记录评价次数 + # ===========================开始进化============================ + while not self.terminated(population): + uniChrom = np.unique(NDSet.Chrom, axis=0) + repRate = 1 - uniChrom.shape[0] / NDSet.sizes # 计算NDSet中的重复率 + # 选择个体去进化形成子代 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + offspring.Chrom = self.recOper.do(offspring.Chrom) # 重组 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + if population.Encoding == 'RI' and repRate > 0.1: + offspring.Chrom = self.extraMutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 执行额外的变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + population = population + offspring # 父代种群和育种种群合并 + NDSet = updateNDSet(population, problem.maxormins, MAXSIZE, NDSet) # 计算合并种群的适应度及更新NDSet + # 保留个体到下一代 + population = population[ea.selecting('dup', population.FitnV, NIND)] # 选择,保留NIND个个体 + if NDSet.CV is not None: # CV不为None说明有设置约束条件 + NDSet = NDSet[np.where(np.all(NDSet.CV <= 0, 1))[0]] # 最后要彻底排除非可行解 + return self.finishing(population, NDSet) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/awGA/moea_psy_awGA_templet.py b/geatpy/algorithms/moeas/awGA/moea_psy_awGA_templet.py new file mode 100644 index 00000000..7145e40b --- /dev/null +++ b/geatpy/algorithms/moeas/awGA/moea_psy_awGA_templet.py @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 +from geatpy.algorithms.moeas.awGA.updateNDSet import updateNDSet # 导入该算法类所需的外部函数 + + +class moea_psy_awGA_templet(ea.MoeaAlgorithm): + """ +moea_psy_awGA_templet : class - 多染色体的多目标进化优化awGA算法类 + +算法描述: + 采用awGA进行多目标优化。 + 该算法类是内置算法类moea_awGA_templet的多染色体版本。 + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + +参考文献: + [1] Gen M,CHeng R. Genetic Algorithms and Engineering Optimization[M]. + New York: John Wiley & Sons,2000 + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'psy-awGA' + self.selFunc = 'tour' # 选择方式,采用锦标赛选择 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encodings[i] == 'BG': + recOper = ea.Xovud(XOVR=1) # 生成部均匀交叉算子对象 + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + recOper = ea.Xovud(XOVR=1) # 生成部均匀交叉算子对象 + mutOper = ea.Mutuni(Pm=1 / self.problem.Dim, Alpha=False, Middle=False) # 生成均匀变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + self.extraMutOper = ea.Mutgau(Pm=1 / self.problem.Dim, Sigma3=False, Middle=False) # 额外生成一个高斯变异算子对象,对标准差放大3倍 + self.MAXSIZE = population.sizes # 非支配解集大小限制 + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + problem = self.problem + population = self.population + NIND = population.sizes + MAXSIZE = self.MAXSIZE + if MAXSIZE is None: # 检查MAXSIZE,默认取2倍的种群规模 + MAXSIZE = 2 * NIND + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + self.call_aimFunc(population) # 计算种群的目标函数值 + NDSet = updateNDSet(population, problem.maxormins, MAXSIZE) # 计算适应度和得到全局非支配种群 + self.evalsNum = population.sizes # 记录评价次数 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查,故应确保prophetPop是一个种群类且拥有合法的Chrom、ObjV、Phen等属性) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择个体去进化形成子代 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + # 进行进化操作,分别对各个种群染色体矩阵进行重组和变异 + for i in range(population.ChromNum): + uniChrom = np.unique(NDSet.Chroms[i], axis=0) + repRate = 1 - uniChrom.shape[0] / NDSet.sizes # 计算NDSet中的重复率 + offspring.Chroms[i] = self.recOpers[i].do(offspring.Chroms[i]) # 重组 + offspring.Chroms[i] = self.mutOpers[i].do(offspring.Encodings[i], offspring.Chroms[i], + offspring.Fields[i]) # 变异 + if population.Encodings[i] == 'RI' and repRate > 0.1: + offspring.Chroms[i] = self.extraMutOper.do(offspring.Encodings[i], offspring.Chroms[i], + offspring.Fields[i]) # 执行额外的变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + # 父代种群和育种种群合并 + population = population + offspring + NDSet = updateNDSet(population, problem.maxormins, MAXSIZE, NDSet) # 计算合并种群的适应度及更新NDSet + # 保留个体到下一代 + population = population[ea.selecting('dup', population.FitnV, NIND)] # 选择,保留NIND个个体 + if NDSet.CV is not None: # CV不为None说明有设置约束条件 + NDSet = NDSet[np.where(np.all(NDSet.CV <= 0, 1))[0]] # 最后要彻底排除非可行解 + return self.finishing(population, NDSet) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/awGA/updateNDSet.py b/geatpy/algorithms/moeas/awGA/updateNDSet.py new file mode 100644 index 00000000..ff00b3b9 --- /dev/null +++ b/geatpy/algorithms/moeas/awGA/updateNDSet.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +def updateNDSet(population, maxormins, MAXSIZE, NDSet=None): + """ +描述: + 用于计算种群个体的适应度及更新全局非支配种群。 +输入参数: + population : Population - 种群对象。 + + maxormins : array - 优化目标的最大最小化标记Numpy ndarray一维数组。 + + MAXSIZE : int - 示全局非支配个体的最大数目。 + + NDSet : Population - (可选参数)全局非支配个体, + 若缺省或为None时,NDSet为所传入种群的非支配个体组成的种群。 + +输出参数: + NDSet : Population - (可选参数)全局非支配种群。 + + 种群适应度FitnV已经在函数中进行更新,因此这该参数不用返回。 + + """ + + [levels, criLevel] = ea.ndsortDED(population.ObjV, None, 1, population.CV, maxormins) # 只对个体划分出第一层 + CombinObjV = ea.awGA(population.ObjV, population.CV, maxormins) # 计算适应性权重以及多目标的加权单目标 + population.FitnV = (np.max(CombinObjV) - CombinObjV + 0.5) / ( + np.max(CombinObjV) - np.min(CombinObjV) + 0.5) # 计算种群适应度 + # 更新NDSet + if NDSet is None: + return population[np.where(levels == 1)[0]] + else: + tempPop = population[np.where(levels == 1)[0]] + NDSet # 将种群可行个体与NDSet合并 + [levels, criLevel] = ea.ndsortDED(tempPop.ObjV, None, 1, tempPop.CV, maxormins) # 只对个体划分出第一层 + liveIdx = np.where(levels == 1)[0] # 选择非支配个体 + NDSet = tempPop[liveIdx] + # 对种群中被NDSet支配的个体进行惩罚 + punishFlag = np.zeros(population.sizes) + punishFlag[np.where(liveIdx < population.sizes)[0]] = 1 + population.FitnV[np.where(punishFlag == 0)[0]] *= 0.5 + if len(liveIdx) > MAXSIZE: # 若要保留下来的NDSet个体数大于MAXSIZE,则根据拥挤距离进行筛选 + dis = ea.crowdis(NDSet.ObjV, levels[liveIdx]) # 计算拥挤距离 + NDSet = NDSet[ea.selecting('dup', np.array([dis]).T, MAXSIZE)] # 进行筛选 + return NDSet diff --git a/geatpy/algorithms/moeas/moead/moea_MOEAD_DE_templet.py b/geatpy/algorithms/moeas/moead/moea_MOEAD_DE_templet.py new file mode 100644 index 00000000..92fecca1 --- /dev/null +++ b/geatpy/algorithms/moeas/moead/moea_MOEAD_DE_templet.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_MOEAD_DE_templet(ea.MoeaAlgorithm): + """ +moea_MOEAD_DE_templet : class - 多目标进化MOEA/D-DE算法类(采用可行性法则处理约束) + +算法描述: + 采用MOEA/D-DE(不设全局最优存档)进行多目标优化,算法详见参考文献[1]。 + 注:MOEA/D不适合在Python上实现,在Python上,MOEA/D的性能会大幅度降低。 + +参考文献: + [1] Li H , Zhang Q . Multiobjective Optimization Problems With Complicated + Pareto Sets, MOEA/D and NSGA-II[J]. IEEE Transactions on Evolutionary + Computation, 2009, 13(2):284-302. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'MOEA/D-DE' + if population.Encoding == 'RI': + self.F = 0.5 # DE的F + self.Cr = 1.9 # DE的Cr + self.mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''RI''.') + self.neighborSize = None # 邻域大小,当设置为None时,将会自动设置为等于种群规模的十分之一 + if self.problem.M <= 2: + self.decomposition = ea.tcheby # 采用切比雪夫权重聚合法 + else: + self.decomposition = ea.pbi # 采用pbi权重聚合法 + self.Ps = 0.9 # (Probability of Selection)表示进化时有多大的概率只从邻域中选择个体参与进化 + self.Nr = 2 # MOEAD-DE中的参数nr,默认为2 + + def reinsertion(self, indices, population, offspring, idealPoint, referPoint): + + """ + 描述: + 重插入更新种群个体。 + + """ + + weights = referPoint[indices, :] + pop_ObjV = population.ObjV[indices, :] # 获取邻居个体的目标函数值 + pop_CV = population.CV[indices, :] if population.CV is not None else None # 获取邻居个体的违反约束程度矩阵 + CombinObjV = self.decomposition(pop_ObjV, weights, idealPoint, pop_CV, self.problem.maxormins) + off_CombinObjV = self.decomposition(offspring.ObjV, weights, idealPoint, offspring.CV, self.problem.maxormins) + population[indices[np.where(off_CombinObjV <= CombinObjV)[0][:self.Nr]]] = offspring + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + uniformPoint, NIND = ea.crtup(self.problem.M, population.sizes) # 生成在单位目标维度上均匀分布的参考点集 + population.initChrom(NIND) # 初始化种群染色体矩阵,此时种群规模将调整为uniformPoint点集的大小,initChrom函数会把种群规模给重置 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + # 确定邻域大小 + if self.neighborSize is None: + self.neighborSize = population.sizes // 10 + self.neighborSize = max(self.neighborSize, 2) # 确保不小于2 + # 生成由所有邻居索引组成的矩阵 + neighborIdx = np.argsort(ea.cdist(uniformPoint, uniformPoint), axis=1, kind='mergesort')[:, :self.neighborSize] + neighborIdx_list = [] + for i in range(population.sizes): + neighborIdx_list.append(neighborIdx[i, :]) + offspring = ea.Population(population.Encoding, population.Field, 1) # 实例化一个种群对象用于存储进化的后代(每一代只进化生成一个后代) + # 计算理想点 + idealPoint = ea.crtidp(population.ObjV, population.CV, self.problem.maxormins) + # ===========================开始进化============================ + while not self.terminated(population): + select_rands = np.random.rand(population.sizes) # 生成一组随机数 + Masks = np.random.rand(population.sizes, population.Lind) < self.Cr + for i in range(population.sizes): + if select_rands[i] < self.Ps: + indices = neighborIdx_list[i] + else: + indices = np.arange(population.sizes) + r = indices[ea.rps(len(indices), 2)] # 随机选择两个索引作为差分向量的索引 + r1, r2 = r[0], r[1] # 得到差分向量索引 + offspring.Chrom = population.Chrom[[i], :] + Mask = Masks[i] + offspring.Chrom[0][Mask] = offspring.Chrom[0][Mask] + self.F * ( + population.Chrom[r1][Mask] - population.Chrom[r2][Mask]) + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 多项式变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + # 更新理想点 + idealPoint = ea.crtidp(offspring.ObjV, offspring.CV, self.problem.maxormins, idealPoint) + # 重插入更新种群个体 + self.reinsertion(indices, population, offspring, idealPoint, uniformPoint) + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/moead/moea_MOEAD_archive_templet.py b/geatpy/algorithms/moeas/moead/moea_MOEAD_archive_templet.py new file mode 100644 index 00000000..3266a109 --- /dev/null +++ b/geatpy/algorithms/moeas/moead/moea_MOEAD_archive_templet.py @@ -0,0 +1,141 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_MOEAD_archive_templet(ea.MoeaAlgorithm): + """ +moea_MOEAD_archive_templet : class - 带全局存档的多目标进化MOEA/D算法类(采用可行性法则处理约束) + +算法描述: + 采用MOEA/D进行多目标优化,算法详见参考文献[1],不同之处是本算法类在每一代进化完成后会更新全局存档。 + 注:MOEA/D不适合在Python上实现,在Python上,MOEA/D的性能会大幅度降低。 + +参考文献: + [1] Qingfu Zhang, Hui Li. MOEA/D: A Multiobjective Evolutionary Algorithm + Based on Decomposition[M]. IEEE Press, 2007. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'MOEA/D-archive' + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=1, Half_N=True) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encoding == 'BG': + self.recOper = ea.Xovud(XOVR=1, Half_N=True) # 生成均匀交叉算子对象 + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.recOper = ea.Recsbx(XOVR=1, n=20, Half_N=True) # 生成模拟二进制交叉算子对象 + self.mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.neighborSize = None # 邻域大小,当设置为None时,将会自动设置为等于种群规模 + if self.problem.M <= 2: + self.decomposition = ea.tcheby # 采用切比雪夫权重聚合法 + else: + self.decomposition = ea.pbi # 采用pbi权重聚合法 + self.Ps = 0.9 # (Probability of Selection)表示进化时有多大的概率只从邻域中选择个体参与进化 + self.MAXSIZE = None # 全局非支配解存档的大小限制,这里设为None,表示后面将默认设为10倍的种群个体数 + + def reinsertion(self, indices, population, offspring, idealPoint, referPoint): + + """ + 描述: + 重插入更新种群个体。 + + """ + + weights = referPoint[indices, :] + pop_ObjV = population.ObjV[indices, :] # 获取邻居个体的目标函数值 + pop_CV = population.CV[indices, :] if population.CV is not None else None # 获取邻居个体的违反约束程度矩阵 + CombinObjV = self.decomposition(pop_ObjV, weights, idealPoint, pop_CV, self.problem.maxormins) + off_CombinObjV = self.decomposition(offspring.ObjV, weights, idealPoint, offspring.CV, self.problem.maxormins) + population[indices[np.where(off_CombinObjV <= CombinObjV)[0]]] = offspring + + def updateNDSet(self, population, globalNDSet=None): + + """ + 描述: + 更新globalNDSet。 + + """ + + if globalNDSet is None: + globalNDSet = population + else: + globalNDSet = population + globalNDSet # 将population与全局归档集合并 + if globalNDSet.CV is not None: # CV不为None说明有设置约束条件 + globalNDSet = globalNDSet[np.where(np.all(globalNDSet.CV <= 0, 1))[0]] # 排除非可行解 + if globalNDSet.sizes != 0: + [levels, criLevel] = ea.ndsortDED(globalNDSet.ObjV, None, None, globalNDSet.CV, + self.problem.maxormins) # 非支配排序 + globalNDSet = globalNDSet[np.where(levels == 1)[0]] + if globalNDSet.sizes > self.MAXSIZE: + globalNDSet = globalNDSet[ea.rps(globalNDSet.sizes, self.MAXSIZE)] # 采用rps随机排列选择,控制全局存档的大小 + return globalNDSet + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + uniformPoint, NIND = ea.crtup(self.problem.M, population.sizes) # 生成在单位目标维度上均匀分布的参考点集 + population.initChrom(NIND) # 初始化种群染色体矩阵,此时种群规模将调整为uniformPoint点集的大小,initChrom函数会把种群规模给重置 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + # 确定邻域大小 + if self.neighborSize is None: + self.neighborSize = population.sizes + self.neighborSize = max(self.neighborSize, 2) # 确保不小于2 + # 生成由所有邻居索引组成的矩阵 + neighborIdx = np.argsort(ea.cdist(uniformPoint, uniformPoint), axis=1, kind='mergesort')[:, :self.neighborSize] + neighborIdx_list = [] + for i in range(population.sizes): + neighborIdx_list.append(neighborIdx[i, :]) + offspring = ea.Population(population.Encoding, population.Field, 1) # 实例化一个种群对象用于存储进化的后代(每一代只进化生成一个后代) + # 计算理想点 + idealPoint = ea.crtidp(population.ObjV, population.CV, self.problem.maxormins) + # 创建全局存档 + if self.MAXSIZE is None: + self.MAXSIZE = 10 * population.sizes # 默认为10倍的种群个体数 + globalNDSet = self.updateNDSet(population) # 创建全局存档,该全局存档贯穿进化始终,随着进化不断更新 + # ===========================开始进化============================ + while not self.terminated(population): + select_rands = np.random.rand(population.sizes) # 生成一组随机数 + for i in range(population.sizes): + indices = neighborIdx_list[i] # 得到邻居索引 + if select_rands[i] < self.Ps: + chooseIdx = indices[ea.rps(self.neighborSize, 2)] # 只从邻域中选择 + else: + chooseIdx = ea.rps(population.sizes, 2) + matting_Chrom = population.Chrom[chooseIdx, :] # 选出2条来自被选个体的染色体 + # 对选出的个体进行进化操作 + offspring.Chrom = self.recOper.do(matting_Chrom) # 重组 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + # 更新理想点 + idealPoint = ea.crtidp(offspring.ObjV, offspring.CV, self.problem.maxormins, idealPoint) + # 重插入更新种群个体 + self.reinsertion(indices, population, offspring, idealPoint, uniformPoint) + # 完成当代的进化后,更新全局存档 + globalNDSet = self.updateNDSet(population, globalNDSet) + return self.finishing(population, globalNDSet) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/moead/moea_MOEAD_templet.py b/geatpy/algorithms/moeas/moead/moea_MOEAD_templet.py new file mode 100644 index 00000000..cbe5b022 --- /dev/null +++ b/geatpy/algorithms/moeas/moead/moea_MOEAD_templet.py @@ -0,0 +1,113 @@ +# -*- coding: utf-8 -*- +import numpy as np +from numpy.linalg import svd +import geatpy as ea # 导入geatpy库 + + +class moea_MOEAD_templet(ea.MoeaAlgorithm): + """ +moea_MOEAD_templet : class - 多目标进化MOEA/D算法类(采用可行性法则处理约束) + +算法描述: + 采用MOEA/D(不设全局最优存档)进行多目标优化,算法详见参考文献[1]。 + 注:MOEA/D不适合在Python上实现,在Python上,MOEA/D的性能会大幅度降低。 + +参考文献: + [1] Qingfu Zhang, Hui Li. MOEA/D: A Multiobjective Evolutionary Algorithm + Based on Decomposition[M]. IEEE Press, 2007. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'MOEA/D' + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=1, Half_N=True) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encoding == 'BG': + self.recOper = ea.Xovud(XOVR=1, Half_N=True) # 生成均匀交叉算子对象 + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.recOper = ea.Recsbx(XOVR=1, n=20, Half_N=True) # 生成模拟二进制交叉算子对象 + self.mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.neighborSize = None # 邻域大小,当设置为None时,将会自动设置为等于种群规模 + if self.problem.M <= 2: + self.decomposition = ea.tcheby # 采用切比雪夫权重聚合法 + else: + self.decomposition = ea.pbi # 采用pbi权重聚合法 + self.Ps = 0.9 # (Probability of Selection)表示进化时有多大的概率只从邻域中选择个体参与进化 + + def reinsertion(self, indices, population, offspring, idealPoint, referPoint): + + """ + 描述: + 重插入更新种群个体。 + + """ + + weights = referPoint[indices, :] + pop_ObjV = population.ObjV[indices, :] # 获取邻居个体的目标函数值 + pop_CV = population.CV[indices, :] if population.CV is not None else None # 获取邻居个体的违反约束程度矩阵 + CombinObjV = self.decomposition(pop_ObjV, weights, idealPoint, pop_CV, self.problem.maxormins) + off_CombinObjV = self.decomposition(offspring.ObjV, weights, idealPoint, offspring.CV, self.problem.maxormins) + population[indices[np.where(off_CombinObjV <= CombinObjV)[0]]] = offspring + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + uniformPoint, NIND = ea.crtup(self.problem.M, population.sizes) # 生成在单位目标维度上均匀分布的参考点集 + population.initChrom(NIND) # 初始化种群染色体矩阵,此时种群规模将调整为uniformPoint点集的大小,initChrom函数会把种群规模给重置 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + # 确定邻域大小 + if self.neighborSize is None: + self.neighborSize = population.sizes + self.neighborSize = max(self.neighborSize, 2) # 确保不小于2 + # 生成由所有邻居索引组成的矩阵 + neighborIdx = np.argsort(ea.cdist(uniformPoint, uniformPoint), axis=1, kind='mergesort')[:, :self.neighborSize] + neighborIdx_list = [] + for i in range(population.sizes): + neighborIdx_list.append(neighborIdx[i, :]) + offspring = ea.Population(population.Encoding, population.Field, 1) # 实例化一个种群对象用于存储进化的后代(每一代只进化生成一个后代) + # 计算理想点 + idealPoint = ea.crtidp(population.ObjV, population.CV, self.problem.maxormins) + # ===========================开始进化============================ + while not self.terminated(population): + select_rands = np.random.rand(population.sizes) # 生成一组随机数 + for i in range(population.sizes): + indices = neighborIdx_list[i] # 得到邻居索引 + if select_rands[i] < self.Ps: + chooseIdx = indices[ea.rps(self.neighborSize, 2)] # 只从邻域中选择 + else: + chooseIdx = ea.rps(population.sizes, 2) + matting_Chrom = population.Chrom[chooseIdx, :] # 选出2条来自被选个体的染色体 + # 对选出的个体进行进化操作 + offspring.Chrom = self.recOper.do(matting_Chrom) # 重组 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + # 更新理想点 + idealPoint = ea.crtidp(offspring.ObjV, offspring.CV, self.problem.maxormins, idealPoint) + # 重插入更新种群个体 + self.reinsertion(indices, population, offspring, idealPoint, uniformPoint) + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/nsga2/moea_NSGA2_DE_templet.py b/geatpy/algorithms/moeas/nsga2/moea_NSGA2_DE_templet.py new file mode 100644 index 00000000..264f26a3 --- /dev/null +++ b/geatpy/algorithms/moeas/nsga2/moea_NSGA2_DE_templet.py @@ -0,0 +1,101 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_NSGA2_DE_templet(ea.MoeaAlgorithm): + """ +moea_NSGA2_DE_templet : class - 基于NSGA-II-DE算法的多目标进化算法类 + +算法描述: + 采用NSGA-II-DE进行多目标优化, + 与NSGA-II不同的是,该算法把NSGA-II中的子代生成部分替换成DE/rand/1/bin。 + +参考文献: + [1] Deb K , Pratap A , Agarwal S , et al. A fast and elitist multiobjective + genetic algorithm: NSGA-II[J]. IEEE Transactions on Evolutionary + Computation, 2002, 6(2):0-197. + + [2] Tanabe R., Fukunaga A. (2014) Reevaluating Exponential Crossover in + Differential Evolution. In: Bartz-Beielstein T., Branke J., Filipič B., + Smith J. (eds) Parallel Problem Solving from Nature – PPSN XIII. PPSN 2014. + Lecture Notes in Computer Science, vol 8672. Springer, Cham + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'NSGA2-DE' + if self.problem.M < 10: + self.ndSort = ea.ndsortESS # 采用ENS_SS进行非支配排序 + else: + self.ndSort = ea.ndsortTNS # 高维目标采用T_ENS进行非支配排序,速度一般会比ENS_SS要快 + self.selFunc = 'tour' # 选择方式,采用锦标赛选择 + if population.Encoding == 'RI': + self.mutOper = ea.Mutde(F=0.5) # 生成差分变异算子对象 + self.recOper = ea.Xovbd(XOVR=0.5, Half_N=True) # 生成二项式分布交叉算子对象,这里的XOVR即为DE中的Cr + else: + raise RuntimeError('编码方式必须为''RI''.') + + def reinsertion(self, population, offspring, NUM): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + NUM为所需要保留到下一代的个体数目。 + 注:这里对原版NSGA-II进行等价的修改:先按帕累托分级和拥挤距离来计算出种群个体的适应度, + 然后调用dup选择算子(详见help(ea.dup))来根据适应度从大到小的顺序选择出个体保留到下一代。 + 这跟原版NSGA-II的选择方法所得的结果是完全一样的。 + + """ + + # 父子两代合并 + population = population + offspring + # 选择个体保留到下一代 + [levels, criLevel] = self.ndSort(population.ObjV, NUM, None, population.CV, + self.problem.maxormins) # 对NUM个个体进行非支配分层 + dis = ea.crowdis(population.ObjV, levels) # 计算拥挤距离 + population.FitnV[:, 0] = np.argsort(np.lexsort(np.array([dis, -levels])), kind='mergesort') # 计算适应度 + chooseFlag = ea.selecting('dup', population.FitnV, NUM) # 调用低级选择算子dup进行基于适应度排序的选择,保留NUM个个体 + return population[chooseFlag] + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom() # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + [levels, criLevel] = self.ndSort(population.ObjV, NIND, None, population.CV, + self.problem.maxormins) # 对NIND个个体进行非支配分层 + population.FitnV = (1 / levels).reshape(-1, 1) # 直接根据levels来计算初代个体的适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行差分进化操作 + r0 = ea.selecting(self.selFunc, population.FitnV, NIND) # 得到基向量索引 + offspring = population.copy() # 存储子代种群 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field, [r0]) # 变异 + tempPop = population + offspring # 当代种群个体与变异个体进行合并(为的是后面用于重组) + offspring.Chrom = self.recOper.do(tempPop.Chrom) # 重组 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + population = self.reinsertion(population, offspring, NIND) # 重插入生成新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/nsga2/moea_NSGA2_archive_templet.py b/geatpy/algorithms/moeas/nsga2/moea_NSGA2_archive_templet.py new file mode 100644 index 00000000..fcc261a2 --- /dev/null +++ b/geatpy/algorithms/moeas/nsga2/moea_NSGA2_archive_templet.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_NSGA2_archive_templet(ea.MoeaAlgorithm): + """ +moea_NSGA2_archive_templet : class - 带全局存档的多目标进化NSGA-II算法类 + +算法描述: + 采用带全局存档(globalNDSet)的NSGA-II进行多目标优化。 + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'NSGA2-archive' + if self.problem.M < 10: + self.ndSort = ea.ndsortESS # 采用ENS_SS进行非支配排序 + else: + self.ndSort = ea.ndsortTNS # 高维目标采用T_ENS进行非支配排序,速度一般会比ENS_SS要快 + self.selFunc = 'tour' # 选择方式,采用锦标赛选择 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encoding == 'BG': + self.recOper = ea.Xovud(XOVR=1) # 生成均匀交叉算子对象 + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.recOper = ea.Recsbx(XOVR=1, n=20) # 生成模拟二进制交叉算子对象 + self.mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.MAXSIZE = 10 * population.sizes # 全局非支配解存档的大小限制,默认为10倍的种群个体数 + + def reinsertion(self, population, offspring, NUM, globalNDSet): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + NUM为所需要保留到下一代的个体数目,globalNDSet为全局非支配解存档。 + + """ + + # 父子两代合并 + population = population + offspring + globalNDSet = population + globalNDSet # 将population与全局存档合并 + # 非支配排序分层 + [levels, criLevel] = self.ndSort(globalNDSet.ObjV, None, None, globalNDSet.CV, self.problem.maxormins) + # 更新全局存档 + globalNDSet = globalNDSet[np.where(levels == 1)[0]] + if globalNDSet.CV is not None: # CV不为None说明有设置约束条件 + globalNDSet = globalNDSet[np.where(np.all(globalNDSet.CV <= 0, 1))[0]] # 排除非可行解 + if globalNDSet.sizes > self.MAXSIZE: + dis = ea.crowdis(globalNDSet.ObjV, np.ones(globalNDSet.sizes)) # 计算拥挤距离 + globalNDSet = globalNDSet[np.argsort(-dis)[:self.MAXSIZE]] # 根据拥挤距离选择符合个数限制的解保留在存档中 + # 选择个体保留到下一代 + levels = levels[: population.sizes] # 得到与population个体对应的levels + dis = ea.crowdis(population.ObjV, levels) # 计算拥挤距离 + population.FitnV[:, 0] = np.argsort(np.lexsort(np.array([dis, -levels])), kind='mergesort') # 计算适应度 + chooseFlag = ea.selecting('dup', population.FitnV, NUM) # 调用低级选择算子dup进行基于适应度排序的选择,保留NUM个个体 + return population[chooseFlag], globalNDSet + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom() # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + [levels, criLevel] = self.ndSort(population.ObjV, NIND, None, population.CV, + self.problem.maxormins) # 对NIND个个体进行非支配分层 + population.FitnV = (1 / levels).reshape(-1, 1) # 直接根据levels来计算初代个体的适应度 + globalNDSet = population[np.where(levels == 1)[0]] # 创建全局存档,该全局存档贯穿进化始终,随着进化不断更新 + if globalNDSet.CV is not None: # CV不为None说明有设置约束条件 + globalNDSet = globalNDSet[np.where(np.all(globalNDSet.CV <= 0, 1))[0]] # 排除非可行解 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择个体参与进化 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + # 对选出的个体进行进化操作 + offspring.Chrom = self.recOper.do(offspring.Chrom) # 重组 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + population, globalNDSet = self.reinsertion(population, offspring, NIND, globalNDSet) # 重插入生成新一代种群,同时更新全局存档 + return self.finishing(population, globalNDSet) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/nsga2/moea_NSGA2_templet.py b/geatpy/algorithms/moeas/nsga2/moea_NSGA2_templet.py new file mode 100644 index 00000000..8446fe55 --- /dev/null +++ b/geatpy/algorithms/moeas/nsga2/moea_NSGA2_templet.py @@ -0,0 +1,100 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_NSGA2_templet(ea.MoeaAlgorithm): + """ +moea_NSGA2_templet : class - 多目标进化NSGA-II算法类 + +算法描述: + 采用NSGA-II进行多目标优化,算法详见参考文献[1]。 + +参考文献: + [1] Deb K , Pratap A , Agarwal S , et al. A fast and elitist multiobjective + genetic algorithm: NSGA-II[J]. IEEE Transactions on Evolutionary + Computation, 2002, 6(2):0-197. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'NSGA2' + if self.problem.M < 10: + self.ndSort = ea.ndsortESS # 采用ENS_SS进行非支配排序 + else: + self.ndSort = ea.ndsortTNS # 高维目标采用T_ENS进行非支配排序,速度一般会比ENS_SS要快 + self.selFunc = 'tour' # 选择方式,采用锦标赛选择 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encoding == 'BG': + self.recOper = ea.Xovud(XOVR=1) # 生成均匀交叉算子对象 + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.recOper = ea.Recsbx(XOVR=1, n=20) # 生成模拟二进制交叉算子对象 + self.mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + + def reinsertion(self, population, offspring, NUM): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + NUM为所需要保留到下一代的个体数目。 + 注:这里对原版NSGA-II进行等价的修改:先按帕累托分级和拥挤距离来计算出种群个体的适应度, + 然后调用dup选择算子(详见help(ea.dup))来根据适应度从大到小的顺序选择出个体保留到下一代。 + 这跟原版NSGA-II的选择方法所得的结果是完全一样的。 + + """ + + # 父子两代合并 + population = population + offspring + # 选择个体保留到下一代 + [levels, _] = self.ndSort(population.ObjV, NUM, None, population.CV, self.problem.maxormins) # 对NUM个个体进行非支配分层 + dis = ea.crowdis(population.ObjV, levels) # 计算拥挤距离 + population.FitnV[:, 0] = np.argsort(np.lexsort(np.array([dis, -levels])), kind='mergesort') # 计算适应度 + chooseFlag = ea.selecting('dup', population.FitnV, NUM) # 调用低级选择算子dup进行基于适应度排序的选择,保留NUM个个体 + return population[chooseFlag] + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom() # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + [levels, _] = self.ndSort(population.ObjV, NIND, None, population.CV, self.problem.maxormins) # 对NIND个个体进行非支配分层 + population.FitnV = (1 / levels).reshape(-1, 1) # 直接根据levels来计算初代个体的适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择个体参与进化 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + # 对选出的个体进行进化操作 + offspring.Chrom = self.recOper.do(offspring.Chrom) # 重组 + # if self.currentGen > self.MAXGEN * 0.5: + # offspring.Chrom = ea.mutmani(offspring.Encoding, offspring.Chrom, offspring.Field, self.problem.M-1) + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + population = self.reinsertion(population, offspring, NIND) # 重插入生成新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/nsga2/moea_psy_NSGA2_archive_templet.py b/geatpy/algorithms/moeas/nsga2/moea_psy_NSGA2_archive_templet.py new file mode 100644 index 00000000..c8043410 --- /dev/null +++ b/geatpy/algorithms/moeas/nsga2/moea_psy_NSGA2_archive_templet.py @@ -0,0 +1,114 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_psy_NSGA2_archive_templet(ea.MoeaAlgorithm): + """ +moea_psy_NSGA2_archive_templet : class - 带全局存档的多染色体多目标进化NSGA-II算法类 + +描述: + 采用带全局存档(globalNDSet)的NSGA-II进行多目标优化。 + 该算法类是内置算法类moea_NSGA2_archive_templet的多染色体版本。 + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'psy-NSGA2-archive' + if self.problem.M < 10: + self.ndSort = ea.ndsortESS # 采用ENS_SS进行非支配排序 + else: + self.ndSort = ea.ndsortTNS # 高维目标采用T_ENS进行非支配排序,速度一般会比ENS_SS要快 + self.selFunc = 'tour' # 选择方式,采用锦标赛选择 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encodings[i] == 'BG': + recOper = ea.Xovud(XOVR=1) # 生成均匀交叉算子对象 + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + recOper = ea.Recsbx(XOVR=1, n=20) # 生成模拟二进制交叉算子对象 + mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + self.MAXSIZE = 10 * population.sizes # 全局非支配解存档的大小限制,默认为10倍的种群个体数 + + def reinsertion(self, population, offspring, NUM, globalNDSet): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + NUM为所需要保留到下一代的个体数目,globalNDSet为全局非支配解存档。 + """ + + # 父子两代合并 + population = population + offspring + globalNDSet = population + globalNDSet # 将population与全局存档合并 + # 非支配排序分层 + [levels, criLevel] = self.ndSort(globalNDSet.ObjV, None, None, globalNDSet.CV, self.problem.maxormins) + # 更新全局存档 + globalNDSet = globalNDSet[np.where(levels == 1)[0]] + if globalNDSet.CV is not None: # CV不为None说明有设置约束条件 + globalNDSet = globalNDSet[np.where(np.all(globalNDSet.CV <= 0, 1))[0]] # 排除非可行解 + if globalNDSet.sizes > self.MAXSIZE: + dis = ea.crowdis(globalNDSet.ObjV, np.ones(globalNDSet.sizes)) # 计算拥挤距离 + globalNDSet = globalNDSet[np.argsort(-dis)[:self.MAXSIZE]] # 根据拥挤距离选择符合个数限制的解保留在存档中 + # 选择个体保留到下一代 + levels = levels[: population.sizes] # 得到与population个体对应的levels + dis = ea.crowdis(population.ObjV, levels) # 计算拥挤距离 + population.FitnV[:, 0] = np.argsort(np.lexsort(np.array([dis, -levels])), kind='mergesort') # 计算适应度 + chooseFlag = ea.selecting('dup', population.FitnV, NUM) # 调用低级选择算子dup进行基于适应度排序的选择,保留NUM个个体 + return population[chooseFlag], globalNDSet + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom() # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + [levels, criLevel] = self.ndSort(population.ObjV, NIND, None, population.CV, + self.problem.maxormins) # 对NIND个个体进行非支配分层 + population.FitnV = (1 / levels).reshape(-1, 1) # 直接根据levels来计算初代个体的适应度 + globalNDSet = population[np.where(levels == 1)[0]] # 创建全局存档,该全局存档贯穿进化始终,随着进化不断更新 + if globalNDSet.CV is not None: # CV不为None说明有设置约束条件 + globalNDSet = globalNDSet[np.where(np.all(globalNDSet.CV <= 0, 1))[0]] # 排除非可行解 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择个体参与进化 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + # 进行进化操作,分别对各个种群染色体矩阵进行重组和变异 + for i in range(population.ChromNum): + offspring.Chroms[i] = self.recOpers[i].do(offspring.Chroms[i]) # 重组 + offspring.Chroms[i] = self.mutOpers[i].do(offspring.Encodings[i], offspring.Chroms[i], + offspring.Fields[i]) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + population, globalNDSet = self.reinsertion(population, offspring, NIND, globalNDSet) # 重插入生成新一代种群,同时更新全局存档 + return self.finishing(population, globalNDSet) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/nsga2/moea_psy_NSGA2_templet.py b/geatpy/algorithms/moeas/nsga2/moea_psy_NSGA2_templet.py new file mode 100644 index 00000000..d5e5b391 --- /dev/null +++ b/geatpy/algorithms/moeas/nsga2/moea_psy_NSGA2_templet.py @@ -0,0 +1,109 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_psy_NSGA2_templet(ea.MoeaAlgorithm): + """ +moea_psy_NSGA2_templet : class - 多染色体的多目标进化NSGA-II算法类 + +描述: + 采用NSGA-II进行多目标优化,算法详见参考文献[1]。 + 该算法类是内置算法类moea_NSGA2_templet的多染色体版本。 + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + +参考文献: + [1] Deb K , Pratap A , Agarwal S , et al. A fast and elitist multiobjective + genetic algorithm: NSGA-II[J]. IEEE Transactions on Evolutionary + Computation, 2002, 6(2):0-197. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'psy-NSGA2' + if self.problem.M < 10: + self.ndSort = ea.ndsortESS # 采用ENS_SS进行非支配排序 + else: + self.ndSort = ea.ndsortTNS # 高维目标采用T_ENS进行非支配排序,速度一般会比ENS_SS要快 + self.selFunc = 'tour' # 选择方式,采用锦标赛选择 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encodings[i] == 'BG': + recOper = ea.Xovud(XOVR=1) # 生成均匀交叉算子对象 + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + recOper = ea.Recsbx(XOVR=1, n=20) # 生成模拟二进制交叉算子对象 + mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + + def reinsertion(self, population, offspring, NUM): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + NUM为所需要保留到下一代的个体数目。 + 注:这里对原版NSGA-II进行等价的修改:先按帕累托分级和拥挤距离来计算出种群个体的适应度, + 然后调用dup选择算子(详见help(ea.dup))来根据适应度从大到小的顺序选择出个体保留到下一代。 + 这跟原版NSGA-II的选择方法所得的结果是完全一样的。 + """ + + # 父子两代合并 + population = population + offspring + # 选择个体保留到下一代 + [levels, criLevel] = self.ndSort(population.ObjV, NUM, None, population.CV, + self.problem.maxormins) # 对NUM个个体进行非支配分层 + dis = ea.crowdis(population.ObjV, levels) # 计算拥挤距离 + population.FitnV[:, 0] = np.argsort(np.lexsort(np.array([dis, -levels])), kind='mergesort') # 计算适应度 + chooseFlag = ea.selecting('dup', population.FitnV, NUM) # 调用低级选择算子dup进行基于适应度排序的选择,保留NUM个个体 + return population[chooseFlag] + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom() # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + [levels, criLevel] = self.ndSort(population.ObjV, NIND, None, population.CV, + self.problem.maxormins) # 对NIND个个体进行非支配分层 + population.FitnV = (1 / levels).reshape(-1, 1) # 直接根据levels来计算初代个体的适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择个体参与进化 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + # 进行进化操作,分别对各个种群染色体矩阵进行重组和变异 + for i in range(population.ChromNum): + offspring.Chroms[i] = self.recOpers[i].do(offspring.Chroms[i]) # 重组 + offspring.Chroms[i] = self.mutOpers[i].do(offspring.Encodings[i], offspring.Chroms[i], + offspring.Fields[i]) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + population = self.reinsertion(population, offspring, NIND) # 重插入生成新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/nsga3/moea_NSGA3_DE_templet.py b/geatpy/algorithms/moeas/nsga3/moea_NSGA3_DE_templet.py new file mode 100644 index 00000000..449da452 --- /dev/null +++ b/geatpy/algorithms/moeas/nsga3/moea_NSGA3_DE_templet.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +import geatpy as ea # 导入geatpy库 + + +class moea_NSGA3_DE_templet(ea.MoeaAlgorithm): + """ +moea_NSGA3_DE_templet : class - 多目标进化优化NSGA-III-DE算法类 + +算法描述: + 采用NSGA-III-DE进行多目标优化, + 与NSGA-III不同的是,该算法把NSGA-III中的子代生成部分替换成DE/rand/1/bin。 + 注意:在初始化染色体时,种群规模会被修正为NSGA-III所用的参考点集的大小。 + +参考文献: + [1] Deb K , Jain H . An Evolutionary Many-Objective Optimization Algorithm + Using Reference-Point-Based Nondominated Sorting Approach, Part I: + Solving Problems With Box Constraints[J]. IEEE Transactions on + Evolutionary Computation, 2014, 18(4):577-601. + + [2] Tanabe R., Fukunaga A. (2014) Reevaluating Exponential Crossover in + Differential Evolution. In: Bartz-Beielstein T., Branke J., Filipič B., + Smith J. (eds) Parallel Problem Solving from Nature – PPSN XIII. PPSN 2014. + Lecture Notes in Computer Science, vol 8672. Springer, Cham + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'NSGA3-DE' + if self.problem.M < 10: + self.ndSort = ea.ndsortESS # 采用ENS_SS进行非支配排序 + else: + self.ndSort = ea.ndsortTNS # 高维目标采用T_ENS进行非支配排序,速度一般会比ENS_SS要快 + self.selFunc = 'tour' # 基向量选择方式,采用锦标赛选择 + if population.Encoding == 'RI': + self.mutOper = ea.Mutde(F=0.5) # 生成差分变异算子对象 + self.recOper = ea.Xovbd(XOVR=0.5, Half_N=True) # 生成二项式分布交叉算子对象,这里的XOVR即为DE中的Cr + else: + raise RuntimeError('编码方式必须为''RI''.') + self.F = 0.5 # 差分变异缩放因子(可以设置为一个数也可以设置为一个列数与种群规模数目相等的列向量) + self.pc = 0.2 # 交叉概率 + + def reinsertion(self, population, offspring, NUM, uniformPoint): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + NUM为所需要保留到下一代的个体数目。 + + """ + + # 父子两代合并 + population = population + offspring + # 选择个体保留到下一代 + [levels, criLevel] = self.ndSort(population.ObjV, NUM, None, population.CV, + self.problem.maxormins) # 对NUM个个体进行非支配分层 + chooseFlag = ea.refselect(population.ObjV, levels, criLevel, NUM, uniformPoint, + self.problem.maxormins) # 根据参考点的“入龛”个体筛选 + return population[chooseFlag] + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + uniformPoint, NIND = ea.crtup(self.problem.M, population.sizes) # 生成在单位目标维度上均匀分布的参考点集 + population.initChrom(NIND) # 初始化种群染色体矩阵,此时种群规模将调整为uniformPoint点集的大小,initChrom函数会把种群规模给重置 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行差分进化操作 + offspring = population.copy() # 存储子代种群 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + tempPop = population + offspring # 当代种群个体与变异个体进行合并(为的是后面用于重组) + offspring.Chrom = self.recOper.do(tempPop.Chrom) # 重组 + self.call_aimFunc(offspring) # 计算目标函数值 + # 重插入生成新一代种群 + population = self.reinsertion(population, offspring, NIND, uniformPoint) + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/nsga3/moea_NSGA3_templet.py b/geatpy/algorithms/moeas/nsga3/moea_NSGA3_templet.py new file mode 100644 index 00000000..2a139f08 --- /dev/null +++ b/geatpy/algorithms/moeas/nsga3/moea_NSGA3_templet.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +import geatpy as ea # 导入geatpy库 + + +class moea_NSGA3_templet(ea.MoeaAlgorithm): + """ +moea_NSGA3_templet : class - 多目标进化优化NSGA-III算法类 + +算法描述: + 采用NSGA-III进行多目标优化。 + 注意:在初始化染色体时,种群规模会被修正为NSGA-III所用的参考点集的大小。 + +参考文献: + [1] Deb K , Jain H . An Evolutionary Many-Objective Optimization Algorithm + Using Reference-Point-Based Nondominated Sorting Approach, Part I: + Solving Problems With Box Constraints[J]. IEEE Transactions on + Evolutionary Computation, 2014, 18(4):577-601. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'NSGA3' + if self.problem.M < 10: + self.ndSort = ea.ndsortESS # 采用ENS_SS进行非支配排序 + else: + self.ndSort = ea.ndsortTNS # 高维目标采用T_ENS进行非支配排序,速度一般会比ENS_SS要快 + self.selFunc = 'urs' # 选择方式,采用无约束随机选择 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encoding == 'BG': + self.recOper = ea.Xovud(XOVR=1) # 生成均匀交叉算子对象 + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.recOper = ea.Recsbx(XOVR=1, n=20) # 生成模拟二进制交叉算子对象 + self.mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + + def reinsertion(self, population, offspring, NUM, uniformPoint): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + NUM为所需要保留到下一代的个体数目。 + """ + + # 父子两代合并 + population = population + offspring + # 选择个体保留到下一代 + [levels, criLevel] = self.ndSort(population.ObjV, NUM, None, population.CV, + self.problem.maxormins) # 对NUM个个体进行非支配分层 + chooseFlag = ea.refselect(population.ObjV, levels, criLevel, NUM, uniformPoint, + self.problem.maxormins) # 根据参考点的“入龛”个体筛选 + return population[chooseFlag] + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + uniformPoint, NIND = ea.crtup(self.problem.M, population.sizes) # 生成在单位目标维度上均匀分布的参考点集 + population.initChrom(NIND) # 初始化种群染色体矩阵,此时种群规模将调整为uniformPoint点集的大小,initChrom函数会把种群规模给重置 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择个体参与进化 + offspring = population[ea.selecting(self.selFunc, population.sizes, NIND)] + # 对选出的个体进行进化操作 + offspring.Chrom = self.recOper.do(offspring.Chrom) # 重组 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + # 重插入生成新一代种群 + population = self.reinsertion(population, offspring, NIND, uniformPoint) + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/nsga3/moea_psy_NSGA3_templet.py b/geatpy/algorithms/moeas/nsga3/moea_psy_NSGA3_templet.py new file mode 100644 index 00000000..35d53f04 --- /dev/null +++ b/geatpy/algorithms/moeas/nsga3/moea_psy_NSGA3_templet.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +import geatpy as ea # 导入geatpy库 + + +class moea_psy_NSGA3_templet(ea.MoeaAlgorithm): + """ +moea_psy_NSGA3_templet : class - 多染色体的多目标进化优化NSGA-III算法类 + +描述: + 采用NSGA-III进行多目标优化。 + 该算法类是内置算法类moea_NSGA3_templet的多染色体版本。 + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + 注意:在初始化染色体时,种群规模会被修正为NSGA-III所用的参考点集的大小。 + +参考文献: + [1] Deb K , Jain H . An Evolutionary Many-Objective Optimization Algorithm + Using Reference-Point-Based Nondominated Sorting Approach, Part I: + Solving Problems With Box Constraints[J]. IEEE Transactions on + Evolutionary Computation, 2014, 18(4):577-601. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'psy-NSGA3' + if self.problem.M < 10: + self.ndSort = ea.ndsortESS # 采用ENS_SS进行非支配排序 + else: + self.ndSort = ea.ndsortTNS # 高维目标采用T_ENS进行非支配排序,速度一般会比ENS_SS要快 + self.selFunc = 'urs' # 选择方式,采用无约束随机选择 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encodings[i] == 'BG': + recOper = ea.Xovud(XOVR=1) # 生成均匀交叉算子对象 + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + recOper = ea.Recsbx(XOVR=1, n=20) # 生成模拟二进制交叉算子对象 + mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + + def reinsertion(self, population, offspring, NUM, uniformPoint): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + NUM为所需要保留到下一代的个体数目。 + """ + + # 父子两代合并 + population = population + offspring + # 选择个体保留到下一代 + [levels, criLevel] = self.ndSort(population.ObjV, NUM, None, population.CV, + self.problem.maxormins) # 对NUM个个体进行非支配分层 + chooseFlag = ea.refselect(population.ObjV, levels, criLevel, NUM, uniformPoint, + self.problem.maxormins) # 根据参考点的“入龛”个体筛选 + return population[chooseFlag] + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + uniformPoint, NIND = ea.crtup(self.problem.M, population.sizes) # 生成在单位目标维度上均匀分布的参考点集 + population.initChrom(NIND) # 初始化种群染色体矩阵,此时种群规模将调整为uniformPoint点集的大小,initChrom函数会把种群规模给重置 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择个体参与进化 + offspring = population[ea.selecting(self.selFunc, population.sizes, NIND)] + # 进行进化操作,分别对各个种群染色体矩阵进行重组和变异 + for i in range(population.ChromNum): + offspring.Chroms[i] = self.recOpers[i].do(offspring.Chroms[i]) # 重组 + offspring.Chroms[i] = self.mutOpers[i].do(offspring.Encodings[i], offspring.Chroms[i], + offspring.Fields[i]) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + population = self.reinsertion(population, offspring, NIND, uniformPoint) # 重插入生成新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/pps/moea_PPS_MOEAD_DE_archive_templet.py b/geatpy/algorithms/moeas/pps/moea_PPS_MOEAD_DE_archive_templet.py new file mode 100644 index 00000000..3b40179b --- /dev/null +++ b/geatpy/algorithms/moeas/pps/moea_PPS_MOEAD_DE_archive_templet.py @@ -0,0 +1,219 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_PPS_MOEAD_DE_archive_templet(ea.MoeaAlgorithm): + """ +moea_PPS_MOEAD_DE_archive_templet : class - 基于pps策略的带全局存档的多目标进化MOEA/D-DE算法类 + +算法描述: + 采用PPS-MOEA/D-DE进行多目标优化,PPS策略详见参考文献[1], + 注:MOEA/D不适合在Python上实现,在Python上,MOEA/D的性能会大幅度降低。 + +参考文献: + [1] Zhun Fan, Wenji Li, Xinye Cai*, Hui Li, Caimin Wei, Qingfu Zhang, + Kalyanmoy Deb, and Erik Goodman. Push and Pull Search for Solving + Constrained Multi-objective Optimization Problems, Swarm and Evolutionary + Computation, vol. 44, no. 2, pp. 665-679, 2019. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'PPS-MOEA/D-DE-archive' + if population.Encoding == 'RI': + self.F = 0.5 # DE的F + self.Cr = 1.0 # DE的Cr + self.mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''RI''.') + self.neighborSize = None # 邻域大小,当设置为None时,将会自动设置为等于种群规模的十分之一 + if self.problem.M <= 2: + self.decomposition = ea.tcheby # 采用切比雪夫权重聚合法 + else: + self.decomposition = ea.pbi # 采用pbi权重聚合法 + self.Ps = 0.9 # (Probability of Selection)表示进化时有多大的概率只从邻域中选择个体参与进化 + self.Nr = 2 # MOEAD-DE中的参数nr,默认为2 + self.MAXSIZE = population.sizes # 全局非支配解存档的大小限制,这里设为等于初始设定的种群个体数 + # PPS策略的一些需要设置的参数 + self.Tc = 0.8 # 论文中的Tc,这里暂设为0.8,在run()函数中它将乘上MAXGEN + self.LastLGen = 20 # 论文中的参数l + self.varient_epsilon = 1e-3 # 论文中的参数varient_epsilon + self.alpha = 0.95 # 论文中的α + self.tao = 0.1 # 论文中的𝜏 + self.cp = 2 # 论文中的cp + + def create_offspring(self, population, Xr0, select_rand, Mask, neighbor_index, idealPoint): + + """ + 描述: + 该函数用于产生子代个体以及更新理想点,它实际上是下面的主代码里抽取出来的, + 若有理解困难,可以把该函数的代码重新放入主代码中。 + + """ + if select_rand < self.Ps: + indices = neighbor_index + else: + indices = np.arange(population.sizes) + offspring = ea.Population(population.Encoding, population.Field, 1) # 实例化一个种群对象用于存储进化的后代(这里只进化生成一个后代) + r = indices[ea.rps(len(indices), 2)] # 随机选择两个索引作为差分向量的索引 + r1, r2 = r[0], r[1] # 得到差分向量索引 + offspring.Chrom = Xr0 + offspring.Chrom[0][Mask] = offspring.Chrom[0][Mask] + self.F * ( + population.Chrom[r1][Mask] - population.Chrom[r2][Mask]) + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 多项式变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + # 更新理想点 + idealPoint = ea.crtidp(offspring.ObjV, maxormins=self.problem.maxormins, old_idealPoint=idealPoint) + return offspring, indices, idealPoint + + def push_stage_reinsertion(self, indices, population, offspring, idealPoint, referPoint): + + """ + 描述: + 适用于push stage的重插入更新种群个体。 + + """ + + weights = referPoint[indices, :] + pop_ObjV = population.ObjV[indices, :] # 获取邻居个体的目标函数值 + CombinObjV = self.decomposition(pop_ObjV, weights, idealPoint, maxormins=self.problem.maxormins) + off_CombinObjV = self.decomposition(offspring.ObjV, weights, idealPoint, maxormins=self.problem.maxormins) + population[indices[np.where(off_CombinObjV <= CombinObjV)[0][:self.Nr]]] = offspring + + def pull_stage_reinsertion(self, indices, population, offspring, idealPoint, referPoint, epsilon_k): + + """ + 描述: + 适用于pull stage的重插入更新种群个体。 + + """ + + weights = referPoint[indices, :] + pop_ObjV = population.ObjV[indices, :] # 获取邻居个体的目标函数值 + CombinObjV = self.decomposition(pop_ObjV, weights, idealPoint, maxormins=self.problem.maxormins) + off_CombinObjV = self.decomposition(offspring.ObjV, weights, idealPoint, maxormins=self.problem.maxormins) + Violation = ea.mergecv(population.CV[indices, :] if population.CV is not None else np.zeros((len(indices), 1))) + off_Violation = ea.mergecv(offspring.CV if population.CV is not None else np.zeros((offspring.sizes, 1))) + population[(indices[np.where((off_CombinObjV <= CombinObjV) & + ((Violation <= epsilon_k) & (off_Violation <= epsilon_k) | ( + Violation == off_Violation)) | + (off_Violation < Violation))[0]])[:self.Nr]] = offspring + + def updateNDSet(self, population, globalNDSet=None): + + """ + 描述: + 更新globalNDSet。 + + """ + + if globalNDSet is None: + globalNDSet = population + else: + globalNDSet = population + globalNDSet # 将population与全局归档集合并 + if globalNDSet.CV is not None: # CV不为None说明有设置约束条件 + globalNDSet = globalNDSet[np.where(np.all(globalNDSet.CV <= 0, 1))[0]] # 排除非可行解 + if globalNDSet.sizes != 0: + [levels, criLevel] = ea.ndsortDED(globalNDSet.ObjV, None, None, globalNDSet.CV, + self.problem.maxormins) # 非支配排序 + globalNDSet = globalNDSet[np.where(levels == 1)[0]] + if globalNDSet.sizes > self.MAXSIZE: + dis = ea.crowdis(globalNDSet.ObjV, np.ones(globalNDSet.sizes)) # 计算拥挤距离 + globalNDSet = globalNDSet[np.argsort(-dis)[:self.MAXSIZE]] # 根据拥挤距离选择符合个数限制的解保留在存档中 + return globalNDSet + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + self.initialization() # 初始化算法类的一些动态参数 + pushStage = True # 一开始是push stage + rk = 1.0 # 论文中的rk,k的含义在论文中是代数,这里保留名称不作变化,下同 + epsilon_k = 0 # 论文中的𝜀(k) + epsilon_0 = 0 # 论文中的𝜀(0) + idealPoints = [] # 存储历代的理想点的列表 + nadirPoints = [] # 存储历代的反理想点的列表 + delta = np.array([1e-6] * self.problem.M) # 论文中为了避免分母为0而设的delta + self.Tc *= self.MAXGEN + self.LastLGen = min(self.LastLGen, self.MAXGEN) + # ===========================准备进化============================ + uniformPoint, NIND = ea.crtup(self.problem.M, population.sizes) # 生成在单位目标维度上均匀分布的参考点集 + population.initChrom(NIND) # 初始化种群染色体矩阵,此时种群规模将调整为uniformPoint点集的大小,initChrom函数会把种群规模给重置 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + # 确定邻域大小 + if self.neighborSize is None: + self.neighborSize = population.sizes // 10 + self.neighborSize = max(self.neighborSize, 2) # 确保不小于2 + # 生成由所有邻居索引组成的矩阵 + neighborIdx = np.argsort(ea.cdist(uniformPoint, uniformPoint), axis=1, kind='mergesort')[:, :self.neighborSize] + # 计算理想点 + idealPoint = ea.crtidp(population.ObjV, maxormins=self.problem.maxormins) + # 创建全局存档 + globalNDSet = self.updateNDSet(population) + # ===========================开始进化============================ + while not self.terminated(population): + idealPoints.append(idealPoint) + nadirPoints.append(ea.crtidp(population.ObjV, maxormins=self.problem.maxormins, reverse=True)) + # 更新epsilon_k + if self.currentGen < self.Tc: + # 更新rk + if self.currentGen >= self.LastLGen: + past_gen = self.currentGen - self.LastLGen + rk = np.max( + [np.abs((idealPoints[-1] - idealPoints[past_gen]) / np.max([idealPoints[past_gen], delta], 0)), + np.abs((nadirPoints[-1] - nadirPoints[past_gen]) / np.max([nadirPoints[past_gen], delta], 0))]) + violation, count = ea.mergecv( + population.CV if population.CV is not None else np.zeros((population.sizes, 1)), return_count=True) + if rk <= self.varient_epsilon and pushStage: + epsilon_0 = np.max(violation) + epsilon_k = epsilon_0 + pushStage = False + if not pushStage: + rf = count / population.sizes + if rf < self.alpha: + epsilon_k *= (1 - self.tao) + else: + epsilon_k = (1 - self.currentGen / self.Tc) ** self.cp * epsilon_0 + else: + epsilon_k = 0 + # 分开push stage和pull stage进行进化 + select_rands = np.random.rand(population.sizes) + Masks = np.random.rand(population.sizes, population.Lind) < self.Cr + if pushStage: + for i in range(population.sizes): + # 产生后代 + offspring, indices, idealPoint = self.create_offspring(population, population.Chrom[[i], :], + select_rands[i], Masks[i], neighborIdx[i, :], + idealPoint) + # 重插入 + self.push_stage_reinsertion(indices, population, offspring, idealPoint, uniformPoint) # 重插入更新种群个体 + else: + for i in range(population.sizes): + # 产生后代 + offspring, indices, idealPoint = self.create_offspring(population, population.Chrom[[i], :], + select_rands[i], Masks[i], neighborIdx[i, :], + idealPoint) + # 重插入 + self.pull_stage_reinsertion(indices, population, offspring, idealPoint, uniformPoint, epsilon_k) + # 完成当代的进化后,更新全局存档 + globalNDSet = self.updateNDSet(population, globalNDSet) + return self.finishing(population, globalNDSet) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/rvea/moea_RVEA_RES_templet.py b/geatpy/algorithms/moeas/rvea/moea_RVEA_RES_templet.py new file mode 100644 index 00000000..a97e94d6 --- /dev/null +++ b/geatpy/algorithms/moeas/rvea/moea_RVEA_RES_templet.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_RVEA_RES_templet(ea.MoeaAlgorithm): + """ +moea_RVEA_RES_templet : class - 带参考点再生策略的多目标进化优化RVEA算法类(RVEA With the Reference Vector Regeneration Strategy) + +算法描述: + 采用带参考点再生策略的RVEA进行多目标优化,即参考文献[1]中的RVEA*算法。 + 该算法与RVEA算法类似,不过可以更好地解决具有复杂帕累托前沿面的多目标优化问题。 + +参考文献: + [1] Cheng R , Jin Y , Olhofer M , et al. A Reference Vector Guided + Evolutionary Algorithm for Many-Objective Optimization[J]. IEEE + Transactions on Evolutionary Computation, 2016:1-1. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'RVEA-RES' + self.ndSort = ea.ndsortESS # 设置非支配排序算子 + self.selFunc = 'urs' # 选择方式,采用无约束随机选择 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encoding == 'BG': + self.recOper = ea.Xovud(XOVR=1) # 生成均匀交叉算子对象 + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.recOper = ea.Recsbx(XOVR=1, n=20) # 生成模拟二进制交叉算子对象 + self.mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.a = 2 # RVEA算法中的参数alpha + self.fr = 0.1 # RVEA算法中的参数fr + + def reinsertion(self, population, offspring, refPoint): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + """ + + # 父子两代合并 + population = population + offspring + # 得到非支配个体 + [levels, criLevel] = self.ndSort(population.ObjV, None, 1, population.CV, + self.problem.maxormins) # 非支配排序,1表示只排序到第一层即非支配个体所在的层级 + population = population[np.where(levels == 1)[0]] + # 选择个体保留到下一代 + [chooseFlag, ans] = ea.refgselect(population.ObjV, refPoint, + self.problem.M * ((self.currentGen + 1) / self.MAXGEN) ** self.a, + population.CV, maxormins=self.problem.maxormins) # ans表示不使用该返回结果 + return population[chooseFlag] + + def renewRefPoint(self, ObjV, refPoint): # 更新参考点 + _ObjV = ObjV - np.min(ObjV, 0) + linkIdx = np.argmax(ea.cdist(_ObjV, refPoint, 'cosine_similarity'), 1) # 找到与参考点关联的点的索引 + noLinkIdx = list(set(range(refPoint.shape[0])) - set(linkIdx)) # 找到不与参考点关联的点的索引 + refPoint[noLinkIdx, :] = np.random.rand(len(noLinkIdx), refPoint.shape[1]) * np.max(_ObjV, 0) + return refPoint + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + uniformPoint, NIND = ea.crtup(self.problem.M, population.sizes) # 生成在单位目标维度上均匀分布的参考点集 + refPoint = np.vstack([uniformPoint, np.random.rand(NIND, self.problem.M)]) # 初始化参考点(详见注释中的参考文献) + population.initChrom(NIND) # 初始化种群染色体矩阵,此时种群规模将调整为uniformPoint点集的大小,initChrom函数会把种群规模给重置 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + print('本算法需谨慎使用先验知识,有可能会导致结果比先验知识差。') + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择个体参与进化 + offspring = population[ea.selecting(self.selFunc, population.sizes, NIND)] + # 对选出的个体进行进化操作 + offspring.Chrom = self.recOper.do(offspring.Chrom) # 重组 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + population = self.reinsertion(population, offspring, refPoint) # 重插入生成新一代种群 + # 修改refPoint + refPoint[NIND:, :] = self.renewRefPoint(population.ObjV, refPoint[NIND:, :]) + if (self.currentGen) % np.ceil(self.fr * self.MAXGEN) == 0: + refPoint[:NIND, :] = uniformPoint * (np.max(population.ObjV, 0) - np.min(population.ObjV, 0)) + # 后续处理,限制种群规模(因为此时种群规模有可能大于NIND) + [levels, criLevel] = self.ndSort(population.ObjV, NIND, None, population.CV, + self.problem.maxormins) # 对NIND个个体进行非支配分层 + population = population[ + ea.refselect(population.ObjV, levels, criLevel, NIND, uniformPoint, self.problem.maxormins)] # 根据参考点选择个体 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/rvea/moea_RVEA_templet.py b/geatpy/algorithms/moeas/rvea/moea_RVEA_templet.py new file mode 100644 index 00000000..4324e467 --- /dev/null +++ b/geatpy/algorithms/moeas/rvea/moea_RVEA_templet.py @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_RVEA_templet(ea.MoeaAlgorithm): + """ +moea_RVEA_templet : class - 多目标进化优化RVEA算法类 + +算法描述: + 采用RVEA进行多目标优化。 + +参考文献: + [1] Cheng R , Jin Y , Olhofer M , et al. A Reference Vector Guided + Evolutionary Algorithm for Many-Objective Optimization[J]. IEEE + Transactions on Evolutionary Computation, 2016:1-1. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'RVEA' + self.selFunc = 'urs' # 选择方式,采用无约束随机选择 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encoding == 'BG': + self.recOper = ea.Xovud(XOVR=1) # 生成均匀交叉算子对象 + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.recOper = ea.Recsbx(XOVR=1, n=20) # 生成模拟二进制交叉算子对象 + self.mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.a = 2 # RVEA算法中的参数alpha + self.fr = 0.1 # RVEA算法中的参数fr + self.Gamma = None # RVEA算法中的Gamma(详见参考文献的公式10),在每次更新参考点后Gamma要重置为None以便重新计算 + + def reinsertion(self, population, offspring, refPoint): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + """ + + # 父子两代合并 + population = population + offspring + # 选择个体保留到下一代 + chooseFlag, self.Gamma = ea.refgselect(population.ObjV, refPoint, + self.problem.M * ((self.currentGen + 1) / self.MAXGEN) ** self.a, + population.CV, self.Gamma, self.problem.maxormins) + return population[chooseFlag] + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + uniformPoint, NIND = ea.crtup(self.problem.M, population.sizes) # 生成在单位目标维度上均匀分布的参考点集 + refPoint = uniformPoint.copy() # 初始化参考点为uniformPoint + population.initChrom(NIND) # 初始化种群染色体矩阵,此时种群规模将调整为uniformPoint点集的大小,initChrom函数会把种群规模给重置 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + print('本算法需谨慎使用先验知识,有可能会导致结果比先验知识差。') + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择个体参与进化 + offspring = population[ea.selecting(self.selFunc, population.sizes, NIND)] + # 对选出的个体进行进化操作 + offspring.Chrom = self.recOper.do(offspring.Chrom) # 重组 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + population = self.reinsertion(population, offspring, refPoint) # 重插入生成新一代种群 + # 修改refPoint + if (self.currentGen) % np.ceil(self.fr * self.MAXGEN) == 0: + refPoint = uniformPoint * (np.max(population.ObjV, 0) - np.min(population.ObjV, 0)) + self.Gamma = None # 重置Gamma为None + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/rvea/moea_psy_RVEA_RES_templet.py b/geatpy/algorithms/moeas/rvea/moea_psy_RVEA_RES_templet.py new file mode 100644 index 00000000..1731f6cf --- /dev/null +++ b/geatpy/algorithms/moeas/rvea/moea_psy_RVEA_RES_templet.py @@ -0,0 +1,122 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_psy_RVEA_RES_templet(ea.MoeaAlgorithm): + """ +moea_psy_RVEA_RES_templet : class - 带参考点再生策略的多染色体多目标进化优化RVEA算法类(RVEA With the Reference Vector Regeneration Strategy) + +描述: + 采用带参考点再生策略的RVEA进行多目标优化,即参考文献[1]中的RVEA*算法。 + 该算法与RVEA算法类似,不过可以更好地解决具有复杂帕累托前沿面的多目标优化问题。 + 该算法类是内置算法类moea_RVEA_RES_templet的多染色体版本。 + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + +参考文献: + [1] Cheng R , Jin Y , Olhofer M , et al. A Reference Vector Guided + Evolutionary Algorithm for Many-Objective Optimization[J]. IEEE + Transactions on Evolutionary Computation, 2016:1-1. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'psy-RVEA-RES' + self.ndSort = ea.ndsortESS # 设置非支配排序算子 + self.selFunc = 'urs' # 选择方式,采用无约束随机选择 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encodings[i] == 'BG': + recOper = ea.Xovud(XOVR=1) # 生成均匀交叉算子对象 + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + recOper = ea.Recsbx(XOVR=1, n=20) # 生成模拟二进制交叉算子对象 + mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + self.a = 2 # RVEA算法中的参数alpha + self.fr = 0.1 # RVEA算法中的参数fr + + def reinsertion(self, population, offspring, refPoint): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + """ + + # 父子两代合并 + population = population + offspring + # 得到非支配个体 + [levels, criLevel] = self.ndSort(population.ObjV, None, 1, population.CV, + self.problem.maxormins) # 非支配排序,1表示只排序到第一层即非支配个体所在的层级 + population = population[np.where(levels == 1)[0]] + # 选择个体保留到下一代 + [chooseFlag, ans] = ea.refgselect(population.ObjV, refPoint, + self.problem.M * ((self.currentGen + 1) / self.MAXGEN) ** self.a, + population.CV, maxormins=self.problem.maxormins) # ans表示不使用该返回结果 + return population[chooseFlag] + + def renewRefPoint(self, ObjV, refPoint): # 更新参考点 + _ObjV = ObjV - np.min(ObjV, 0) + linkIdx = np.argmax(ea.cdist(_ObjV, refPoint, 'cosine_similarity'), 1) # 找到与参考点关联的点的索引 + noLinkIdx = list(set(range(refPoint.shape[0])) - set(linkIdx)) # 找到不与参考点关联的点的索引 + refPoint[noLinkIdx, :] = np.random.rand(len(noLinkIdx), refPoint.shape[1]) * np.max(_ObjV, 0) + return refPoint + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + uniformPoint, NIND = ea.crtup(self.problem.M, population.sizes) # 生成在单位目标维度上均匀分布的参考点集 + refPoint = np.vstack([uniformPoint, np.random.rand(NIND, self.problem.M)]) # 初始化参考点(详见注释中的参考文献) + population.initChrom(NIND) # 初始化种群染色体矩阵,此时种群规模将调整为uniformPoint点集的大小,initChrom函数会把种群规模给重置 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + print('本算法需谨慎使用先验知识,有可能会导致结果比先验知识差。') + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择个体参与进化 + offspring = population[ea.selecting(self.selFunc, population.sizes, NIND)] + # 进行进化操作,分别对各个种群染色体矩阵进行重组和变异 + for i in range(population.ChromNum): + offspring.Chroms[i] = self.recOpers[i].do(offspring.Chroms[i]) # 重组 + offspring.Chroms[i] = self.mutOpers[i].do(offspring.Encodings[i], offspring.Chroms[i], + offspring.Fields[i]) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + population = self.reinsertion(population, offspring, refPoint) # 重插入生成新一代种群 + # 修改refPoint + refPoint[NIND:, :] = self.renewRefPoint(population.ObjV, refPoint[NIND:, :]) + if (self.currentGen) % np.ceil(self.fr * self.MAXGEN) == 0: + refPoint[:NIND, :] = uniformPoint * (np.max(population.ObjV, 0) - np.min(population.ObjV, 0)) + # 后续处理,限制种群规模(因为此时种群规模有可能大于NIND) + [levels, criLevel] = self.ndSort(population.ObjV, NIND, None, population.CV, + self.problem.maxormins) # 对NIND个个体进行非支配分层 + population = population[ + ea.refselect(population.ObjV, levels, criLevel, NIND, uniformPoint, self.problem.maxormins)] # 根据参考点选择个体 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/moeas/rvea/moea_psy_RVEA_templet.py b/geatpy/algorithms/moeas/rvea/moea_psy_RVEA_templet.py new file mode 100644 index 00000000..661c4e15 --- /dev/null +++ b/geatpy/algorithms/moeas/rvea/moea_psy_RVEA_templet.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class moea_psy_RVEA_templet(ea.MoeaAlgorithm): + """ +moea_psy_RVEA_templet : class - 多染色体多目标进化优化RVEA算法类 + +描述: + 采用RVEA进行多目标优化。 + 该算法类是内置算法类moea_RVEA_templet的多染色体版本。 + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + +参考文献: + [1] Cheng R , Jin Y , Olhofer M , et al. A Reference Vector Guided + Evolutionary Algorithm for Many-Objective Optimization[J]. IEEE + Transactions on Evolutionary Computation, 2016:1-1. + + """ + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'psy-RVEA' + self.selFunc = 'urs' # 选择方式,采用无约束随机选择 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=1) # 生成逆转变异算子对象 + elif population.Encodings[i] == 'BG': + recOper = ea.Xovud(XOVR=1) # 生成均匀交叉算子对象 + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + recOper = ea.Recsbx(XOVR=1, n=20) # 生成模拟二进制交叉算子对象 + mutOper = ea.Mutpolyn(Pm=1 / self.problem.Dim, DisI=20) # 生成多项式变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + self.a = 2 # RVEA算法中的参数alpha + self.fr = 0.1 # RVEA算法中的参数fr + self.Gamma = None # RVEA算法中的Gamma(详见参考文献的公式10),在每次更新参考点后Gamma要重置为None以便重新计算 + + def reinsertion(self, population, offspring, refPoint): + + """ + 描述: + 重插入个体产生新一代种群(采用父子合并选择的策略)。 + """ + + # 父子两代合并 + population = population + offspring + # 选择个体保留到下一代 + chooseFlag, self.Gamma = ea.refgselect(population.ObjV, refPoint, + self.problem.M * ((self.currentGen + 1) / self.MAXGEN) ** self.a, + population.CV, self.Gamma, self.problem.maxormins) + return population[chooseFlag] + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + uniformPoint, NIND = ea.crtup(self.problem.M, population.sizes) # 生成在单位目标维度上均匀分布的参考点集 + refPoint = uniformPoint.copy() # 初始化参考点为uniformPoint + population.initChrom(NIND) # 初始化种群染色体矩阵,此时种群规模将调整为uniformPoint点集的大小,initChrom函数会把种群规模给重置 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + print('本算法需谨慎使用先验知识,有可能会导致结果比先验知识差。') + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择个体参与进化 + offspring = population[ea.selecting(self.selFunc, population.sizes, NIND)] + # 进行进化操作,分别对各个种群染色体矩阵进行重组和变异 + for i in range(population.ChromNum): + offspring.Chroms[i] = self.recOpers[i].do(offspring.Chroms[i]) # 重组 + offspring.Chroms[i] = self.mutOpers[i].do(offspring.Encodings[i], offspring.Chroms[i], + offspring.Fields[i]) # 变异 + self.call_aimFunc(offspring) # 求进化后个体的目标函数值 + population = self.reinsertion(population, offspring, refPoint) # 重插入生成新一代种群 + # 修改refPoint + if (self.currentGen) % np.ceil(self.fr * self.MAXGEN) == 0: + refPoint = uniformPoint * (np.max(population.ObjV, 0) - np.min(population.ObjV, 0)) + self.Gamma = None # 重置Gamma为None + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/DE/DE_best_1_L/soea_DE_best_1_L_templet.py b/geatpy/algorithms/soeas/DE/DE_best_1_L/soea_DE_best_1_L_templet.py new file mode 100644 index 00000000..df4fb41d --- /dev/null +++ b/geatpy/algorithms/soeas/DE/DE_best_1_L/soea_DE_best_1_L_templet.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class soea_DE_best_1_L_templet(ea.SoeaAlgorithm): + """ +soea_DE_best_1_L_templet : class - 差分进化DE/best/1/L算法类 + +算法描述: + 本算法类实现的是经典的DE/best/1/L单目标差分进化算法。算法流程如下: + 1) 初始化候选解种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 选择变异的基向量,对当前种群进行差分变异,得到变异个体。 + 5) 将当前种群和变异个体合并,采用指数交叉方法得到试验种群。 + 6) 在当前种群和实验种群之间采用一对一生存者选择方法得到新一代种群。 + 7) 回到第2步。 + +参考文献: + [1] Karol R. Opara and Jarosław Arabas. 2019. Differential Evolution: A + survey of theoretical analyses. Swarm and Evolutionary Computation 44, June + 2017 (2019), 546–558. https://doi.org/10.1016/j.swevo.2018.06.010 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'DE/best/1/L' + self.selFunc = 'ecs' # 基向量的选择方式,采用精英复制选择 + if population.Encoding == 'RI': + self.mutOper = ea.Mutde(F=0.5) # 生成差分变异算子对象 + self.recOper = ea.Xovexp(XOVR=0.5, Half_N=True) # 生成指数交叉算子对象,这里的XOVR即为DE中的Cr + else: + raise RuntimeError('编码方式必须为''RI''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行差分进化操作 + r0 = ea.selecting(self.selFunc, population.FitnV, NIND) # 得到基向量索引 + experimentPop = ea.Population(population.Encoding, population.Field, NIND) # 存储试验个体 + experimentPop.Chrom = self.mutOper.do(population.Encoding, population.Chrom, population.Field, [r0]) # 变异 + experimentPop.Chrom = self.recOper.do(np.vstack([population.Chrom, experimentPop.Chrom])) # 重组 + self.call_aimFunc(experimentPop) # 计算目标函数值 + tempPop = population + experimentPop # 临时合并,以调用otos进行一对一生存者选择 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + population = tempPop[ea.selecting('otos', tempPop.FitnV, NIND)] # 采用One-to-One Survivor选择,产生新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/DE/DE_best_1_bin/soea_DE_best_1_bin_templet.py b/geatpy/algorithms/soeas/DE/DE_best_1_bin/soea_DE_best_1_bin_templet.py new file mode 100644 index 00000000..b049315a --- /dev/null +++ b/geatpy/algorithms/soeas/DE/DE_best_1_bin/soea_DE_best_1_bin_templet.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class soea_DE_best_1_bin_templet(ea.SoeaAlgorithm): + """ +soea_DE_best_1_bin_templet : class - 差分进化DE/best/1/bin算法类 + +算法描述: + 本算法类实现的是DE/best/1/bin单目标差分进化算法。算法流程如下: + 1) 初始化候选解种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 选择变异的基向量,对当前种群进行差分变异,得到变异个体。 + 5) 将当前种群和变异个体合并,采用二项式分布交叉方法得到试验种群。 + 6) 在当前种群和实验种群之间采用一对一生存者选择方法得到新一代种群。 + 7) 回到第2步。 + +参考文献: + [1] Rainer Storn, Siemens Ag, Z F E T Sn, Otto-hahn Ring, and D Muenchen. + 1996.On the Usage of Differential Evolution for Function Optimization. + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'DE/best/1/bin' + self.selFunc = 'ecs' # 基向量的选择方式,采用精英复制选择 + if population.Encoding == 'RI': + self.mutOper = ea.Mutde(F=0.5) # 生成差分变异算子对象 + self.recOper = ea.Xovbd(XOVR=0.5, Half_N=True) # 生成二项式分布交叉算子对象,这里的XOVR即为DE中的Cr + else: + raise RuntimeError('编码方式必须为''RI''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行差分进化操作 + r0 = ea.selecting(self.selFunc, population.FitnV, NIND) # 得到基向量索引 + experimentPop = ea.Population(population.Encoding, population.Field, NIND) # 存储试验个体 + experimentPop.Chrom = self.mutOper.do(population.Encoding, population.Chrom, population.Field, [r0]) # 变异 + experimentPop.Chrom = self.recOper.do(np.vstack([population.Chrom, experimentPop.Chrom])) # 重组 + self.call_aimFunc(experimentPop) # 计算目标函数值 + tempPop = population + experimentPop # 临时合并,以调用otos进行一对一生存者选择 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + population = tempPop[ea.selecting('otos', tempPop.FitnV, NIND)] # 采用One-to-One Survivor选择,产生新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/DE/DE_currentToBest_1_L/soea_DE_currentToBest_1_L_templet.py b/geatpy/algorithms/soeas/DE/DE_currentToBest_1_L/soea_DE_currentToBest_1_L_templet.py new file mode 100644 index 00000000..bfa15cd1 --- /dev/null +++ b/geatpy/algorithms/soeas/DE/DE_currentToBest_1_L/soea_DE_currentToBest_1_L_templet.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class soea_DE_currentToBest_1_L_templet(ea.SoeaAlgorithm): + """ +soea_DE_currentToBest_1_L_templet : class - 差分进化DE/current-to-best/1/bin算法类 + +算法描述: + 为了实现矩阵化计算,本算法类采用打乱个体顺序来代替随机选择差分向量。算法流程如下: + 1) 初始化候选解种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 采用current-to-best的方法选择差分变异的各个向量,对当前种群进行差分变异,得到变异个体。 + 5) 将当前种群和变异个体合并,采用指数交叉方法得到试验种群。 + 6) 在当前种群和实验种群之间采用一对一生存者选择方法得到新一代种群。 + 7) 回到第2步。 + +参考文献: + [1] Das, Swagatam & Suganthan, Ponnuthurai. (2011). Differential Evolution: + A Survey of the State-of-the-Art.. IEEE Trans. Evolutionary Computation. 15. 4-31. + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'DE/current-to-best/1/L' + if population.Encoding == 'RI': + self.mutOper = ea.Mutde(F=0.5) # 生成差分变异算子对象 + self.recOper = ea.Xovexp(XOVR=0.5, Half_N=True) # 生成指数交叉算子对象,这里的XOVR即为DE中的Cr + else: + raise RuntimeError('编码方式必须为''RI''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行差分进化操作 + r0 = np.arange(NIND) + r_best = ea.selecting('ecs', population.FitnV, NIND) # 执行'ecs'精英复制选择 + experimentPop = ea.Population(population.Encoding, population.Field, NIND) # 存储试验个体 + experimentPop.Chrom = self.mutOper.do(population.Encoding, population.Chrom, population.Field, + [r0, None, None, r_best, r0]) # 变异 + experimentPop.Chrom = self.recOper.do(np.vstack([population.Chrom, experimentPop.Chrom])) # 重组 + self.call_aimFunc(experimentPop) # 计算目标函数值 + tempPop = population + experimentPop # 临时合并,以调用otos进行一对一生存者选择 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + population = tempPop[ea.selecting('otos', tempPop.FitnV, NIND)] # 采用One-to-One Survivor选择,产生新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/DE/DE_currentToBest_1_bin/soea_DE_currentToBest_1_bin_templet.py b/geatpy/algorithms/soeas/DE/DE_currentToBest_1_bin/soea_DE_currentToBest_1_bin_templet.py new file mode 100644 index 00000000..792aa185 --- /dev/null +++ b/geatpy/algorithms/soeas/DE/DE_currentToBest_1_bin/soea_DE_currentToBest_1_bin_templet.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class soea_DE_currentToBest_1_bin_templet(ea.SoeaAlgorithm): + """ +soea_DE_currentToBest_1_bin_templet : class - 差分进化DE/current-to-best/1/bin算法算法类 + +算法描述: + 本算法类实现的是经典的DE/current-to-best/1/bin单目标差分进化算法。算法流程如下: + 1) 初始化候选解种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 采用current-to-best的方法选择差分变异的各个向量,对当前种群进行差分变异,得到变异个体。 + 5) 将当前种群和变异个体合并,采用二项式分布交叉方法得到试验种群。 + 6) 在当前种群和实验种群之间采用一对一生存者选择方法得到新一代种群。 + 7) 回到第2步。 + +参考文献: + [1] Das, Swagatam & Suganthan, Ponnuthurai. (2011). Differential Evolution: + A Survey of the State-of-the-Art.. IEEE Trans. Evolutionary Computation. 15. 4-31. + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'DE/current-to-best/1/bin' + if population.Encoding == 'RI': + self.mutOper = ea.Mutde(F=0.5) # 生成差分变异算子对象 + self.recOper = ea.Xovbd(XOVR=0.5, Half_N=True) # 生成二项式分布交叉算子对象,这里的XOVR即为DE中的Cr + else: + raise RuntimeError('编码方式必须为''RI''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行差分进化操作 + r0 = np.arange(NIND) + r_best = ea.selecting('ecs', population.FitnV, NIND) # 执行'ecs'精英复制选择 + experimentPop = ea.Population(population.Encoding, population.Field, NIND) # 存储试验个体 + experimentPop.Chrom = self.mutOper.do(population.Encoding, population.Chrom, population.Field, + [r0, None, None, r_best, r0]) # 变异 + experimentPop.Chrom = self.recOper.do(np.vstack([population.Chrom, experimentPop.Chrom])) # 重组 + self.call_aimFunc(experimentPop) # 计算目标函数值 + tempPop = population + experimentPop # 临时合并,以调用otos进行一对一生存者选择 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + population = tempPop[ea.selecting('otos', tempPop.FitnV, NIND)] # 采用One-to-One Survivor选择,产生新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/DE/DE_currentToRand_1/soea_DE_currentToRand_1_templet.py b/geatpy/algorithms/soeas/DE/DE_currentToRand_1/soea_DE_currentToRand_1_templet.py new file mode 100644 index 00000000..385cc3f5 --- /dev/null +++ b/geatpy/algorithms/soeas/DE/DE_currentToRand_1/soea_DE_currentToRand_1_templet.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class soea_DE_currentToRand_1_templet(ea.SoeaAlgorithm): + """ +soea_DE_currentToRand_1_templet : class - 差分进化DE/current-to-rand/1算法类 + +算法描述: + 本算法类实现的是经典的DE/current-to-rand/1单目标差分进化算法。算法流程如下: + 1) 初始化候选解种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 采用current-to-rand/1的重组方法对当前种群进行差分变异和重组(它等价于将DE/rand/1的变异算法和旋转不变的线性重组算法的结合),得到实验个体。 + 5) 在当前种群和实验种群之间采用一对一生存者选择方法得到新一代种群。 + 6) 回到第2步。 + +参考文献: + [1] Das, Swagatam & Suganthan, Ponnuthurai. (2011). Differential Evolution: + A Survey of the State-of-the-Art.. IEEE Trans. Evolutionary Computation. 15. 4-31. + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'DE/current-to-rand/1' + if population.Encoding == 'RI': + self.mutOper = ea.Mutde(F=[0.5, None]) # 生成差分变异算子对象,这里F=[0.5, None]表示F1 = 0.5, F2 = [0, 1)之间的随机数 + else: + raise RuntimeError('编码方式必须为''RI''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行差分进化操作 + r0 = np.arange(NIND) + experimentPop = ea.Population(population.Encoding, population.Field, NIND) # 存储试验个体 + experimentPop.Chrom = self.mutOper.do(population.Encoding, population.Chrom, population.Field, + [r0, None, None, None, r0]) # 变异 + self.call_aimFunc(experimentPop) # 计算目标函数值 + tempPop = population + experimentPop # 临时合并,以调用otos进行一对一生存者选择 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + population = tempPop[ea.selecting('otos', tempPop.FitnV, NIND)] # 采用One-to-One Survivor选择,产生新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/DE/DE_rand_1_L/soea_DE_rand_1_L_templet.py b/geatpy/algorithms/soeas/DE/DE_rand_1_L/soea_DE_rand_1_L_templet.py new file mode 100644 index 00000000..f2d8beb4 --- /dev/null +++ b/geatpy/algorithms/soeas/DE/DE_rand_1_L/soea_DE_rand_1_L_templet.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class soea_DE_rand_1_L_templet(ea.SoeaAlgorithm): + """ +soea_DE_rand_1_L_templet : class - 差分进化DE/rand/1/L算法类 + +算法描述: + 本算法类实现的是经典的DE/rand/1/L单目标差分进化算法。算法流程如下: + 1) 初始化候选解种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 选择差分变异的基向量,对当前种群进行差分变异,得到变异个体。 + 5) 将当前种群和变异个体合并,采用指数交叉方法得到试验种群。 + 6) 在当前种群和实验种群之间采用一对一生存者选择方法得到新一代种群。 + 7) 回到第2步。 + +参考文献: + [1] Karol R. Opara and Jarosław Arabas. 2019. Differential Evolution: A + survey of theoretical analyses. Swarm and Evolutionary Computation 44, June + 2017 (2019), 546–558. https://doi.org/10.1016/j.swevo.2018.06.010 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'DE/rand/1/L' + self.selFunc = 'rcs' # 基向量的选择方式,采用随机补偿选择 + if population.Encoding == 'RI': + self.mutOper = ea.Mutde(F=0.5) # 生成差分变异算子对象 + self.recOper = ea.Xovexp(XOVR=0.5, Half_N=True) # 生成指数交叉算子对象,这里的XOVR即为DE中的Cr + else: + raise RuntimeError('编码方式必须为''RI''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行差分进化操作 + r0 = ea.selecting(self.selFunc, population.FitnV, NIND) # 得到基向量索引 + experimentPop = ea.Population(population.Encoding, population.Field, NIND) # 存储试验个体 + experimentPop.Chrom = self.mutOper.do(population.Encoding, population.Chrom, population.Field, [r0]) # 变异 + experimentPop.Chrom = self.recOper.do(np.vstack([population.Chrom, experimentPop.Chrom])) # 重组 + self.call_aimFunc(experimentPop) # 计算目标函数值 + tempPop = population + experimentPop # 临时合并,以调用otos进行一对一生存者选择 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + population = tempPop[ea.selecting('otos', tempPop.FitnV, NIND)] # 采用One-to-One Survivor选择,产生新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/DE/DE_rand_1_bin/soea_DE_rand_1_bin_templet.py b/geatpy/algorithms/soeas/DE/DE_rand_1_bin/soea_DE_rand_1_bin_templet.py new file mode 100644 index 00000000..a2b76781 --- /dev/null +++ b/geatpy/algorithms/soeas/DE/DE_rand_1_bin/soea_DE_rand_1_bin_templet.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class soea_DE_rand_1_bin_templet(ea.SoeaAlgorithm): + """ +soea_DE_rand_1_bin_templet : class - 差分进化DE/rand/1/bin算法类 + +算法描述: + 本算法类实现的是经典的DE/rand/1/bin单目标差分进化算法。算法流程如下: + 1) 初始化候选解种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 选择差分变异的基向量,对当前种群进行差分变异,得到变异个体。 + 5) 将当前种群和变异个体合并,采用二项式分布交叉方法得到试验种群。 + 6) 在当前种群和实验种群之间采用一对一生存者选择方法得到新一代种群。 + 7) 回到第2步。 + +参考文献: + [1] Rainer Storn, Siemens Ag, Z F E T Sn, Otto-hahn Ring, and D Muenchen. + 1996.On the Usage of Differential Evolution for Function Optimization. + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'DE/rand/1/bin' + self.selFunc = 'rcs' # 基向量的选择方式,采用随机补偿选择 + if population.Encoding == 'RI': + self.mutOper = ea.Mutde(F=0.5) # 生成差分变异算子对象 + self.recOper = ea.Xovbd(XOVR=0.5, Half_N=True) # 生成二项式分布交叉算子对象,这里的XOVR即为DE中的Cr + else: + raise RuntimeError('编码方式必须为''RI''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行差分进化操作 + r0 = ea.selecting(self.selFunc, population.FitnV, NIND) # 得到基向量索引 + experimentPop = ea.Population(population.Encoding, population.Field, NIND) # 存储试验个体 + experimentPop.Chrom = self.mutOper.do(population.Encoding, population.Chrom, population.Field, [r0]) # 变异 + experimentPop.Chrom = self.recOper.do(np.vstack([population.Chrom, experimentPop.Chrom])) # 重组 + self.call_aimFunc(experimentPop) # 计算目标函数值 + tempPop = population + experimentPop # 临时合并,以调用otos进行一对一生存者选择 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + population = tempPop[ea.selecting('otos', tempPop.FitnV, NIND)] # 采用One-to-One Survivor选择,产生新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/DE/DE_targetToBest_1_L/soea_DE_targetToBest_1_L_templet.py b/geatpy/algorithms/soeas/DE/DE_targetToBest_1_L/soea_DE_targetToBest_1_L_templet.py new file mode 100644 index 00000000..3b976153 --- /dev/null +++ b/geatpy/algorithms/soeas/DE/DE_targetToBest_1_L/soea_DE_targetToBest_1_L_templet.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class soea_DE_targetToBest_1_L_templet(ea.SoeaAlgorithm): + """ +soea_DE_targetToBest_1_L_templet : class - 差分进化DE/target-to-best/1/L算法类 + +算法描述: + 本算法类实现的是经典的DE/target-to-best/1/L单目标差分进化算法。算法流程如下: + 1) 初始化候选解种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 采用target-to-best的方法选择差分变异的基向量,对当前种群进行差分变异,得到变异个体。 + 5) 将当前种群和变异个体合并,采用指数交叉方法得到试验种群。 + 6) 在当前种群和实验种群之间采用一对一生存者选择方法得到新一代种群。 + 7) 回到第2步。 + +参考文献: + [1] Price, K.V., Storn, R.N. and Lampinen, J.A.. Differential Evolution: + A Practical Approach to Global Optimization. : Springer, 2005. + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'DE/target-to-best/1/bin' + self.k = 0.5 # target-to-best中的参数k + if population.Encoding == 'RI': + self.mutOper = ea.Mutde(F=[self.k, 0.5]) # 生成差分变异算子对象 + self.recOper = ea.Xovexp(XOVR=0.5, Half_N=True) # 生成指数交叉算子对象,这里的XOVR即为DE中的Cr + else: + raise RuntimeError('编码方式必须为''RI''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行差分进化操作 + r_best = ea.selecting('ecs', population.FitnV, NIND) # 执行'ecs'精英复制选择 + i = np.arange(NIND) + experimentPop = ea.Population(population.Encoding, population.Field, NIND) # 存储试验个体 + experimentPop.Chrom = self.mutOper.do(population.Encoding, population.Chrom, experimentPop.Field, + [i, r_best, i, None, None]) # 变异 + tempPop = population + experimentPop # 当代种群个体与变异个体进行合并(为的是后面用于重组) + experimentPop.Chrom = self.recOper.do(tempPop.Chrom) # 重组 + self.call_aimFunc(experimentPop) # 计算目标函数值 + tempPop = population + experimentPop # 临时合并,以调用otos进行一对一生存者选择 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + population = tempPop[ea.selecting('otos', tempPop.FitnV, NIND)] # 采用One-to-One Survivor选择,产生新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/DE/DE_targetToBest_1_bin/soea_DE_targetToBest_1_bin_templet.py b/geatpy/algorithms/soeas/DE/DE_targetToBest_1_bin/soea_DE_targetToBest_1_bin_templet.py new file mode 100644 index 00000000..9e172cb8 --- /dev/null +++ b/geatpy/algorithms/soeas/DE/DE_targetToBest_1_bin/soea_DE_targetToBest_1_bin_templet.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class soea_DE_targetToBest_1_bin_templet(ea.SoeaAlgorithm): + """ +soea_DE_targetToBest_1_bin_templet : class - 差分进化DE/target-to-best/1/bin算法类 + +算法描述: + 本算法类实现的是经典的DE/target-to-best/1/bin单目标差分进化算法。算法流程如下: + 1) 初始化候选解种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 采用target-to-best的方法选择差分变异的基向量,对当前种群进行差分变异,得到变异个体。 + 5) 将当前种群和变异个体合并,采用二项式分布交叉方法得到试验种群。 + 6) 在当前种群和实验种群之间采用一对一生存者选择方法得到新一代种群。 + 7) 回到第2步。 + +参考文献: + [1] Price, K.V., Storn, R.N. and Lampinen, J.A.. Differential Evolution: + A Practical Approach to Global Optimization. : Springer, 2005. + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'DE/target-to-best/1/bin' + self.k = 0.5 # target-to-best中的参数k + if population.Encoding == 'RI': + self.mutOper = ea.Mutde(F=[self.k, 0.5]) # 生成差分变异算子对象 + self.recOper = ea.Xovbd(XOVR=0.5, Half_N=True) # 生成二项式分布交叉算子对象,这里的XOVR即为DE中的Cr + else: + raise RuntimeError('编码方式必须为''RI''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行差分进化操作 + r_best = ea.selecting('ecs', population.FitnV, NIND) # 执行'ecs'精英复制选择 + i = np.arange(NIND) + experimentPop = ea.Population(population.Encoding, population.Field, NIND) # 存储试验个体 + experimentPop.Chrom = self.mutOper.do(population.Encoding, population.Chrom, experimentPop.Field, + [i, r_best, i, None, None]) # 变异 + tempPop = population + experimentPop # 当代种群个体与变异个体进行合并(为的是后面用于重组) + experimentPop.Chrom = self.recOper.do(tempPop.Chrom) # 重组 + self.call_aimFunc(experimentPop) # 计算目标函数值 + tempPop = population + experimentPop # 临时合并,以调用otos进行一对一生存者选择 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + population = tempPop[ea.selecting('otos', tempPop.FitnV, NIND)] # 采用One-to-One Survivor选择,产生新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/ES/ES_1_plus_1/soea_ES_1_plus_1_templet.py b/geatpy/algorithms/soeas/ES/ES_1_plus_1/soea_ES_1_plus_1_templet.py new file mode 100644 index 00000000..76d4847f --- /dev/null +++ b/geatpy/algorithms/soeas/ES/ES_1_plus_1/soea_ES_1_plus_1_templet.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class soea_ES_1_plus_1_templet(ea.SoeaAlgorithm): + """ +soea_ES_1_plus_1_templet : class - (1+1)进化策略算法类 + +算法描述: + 本算法类实现的是(1+1)进化策略。算法流程如下: + 1) 根据编码规则初始化N个个体的种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 初始化控制高斯变异中的标准差Sigma(Geatpy中的高斯变异算子传入的是3倍的标准差即Sigma3)。 + 5) 独立地对这种群个体进行高斯变异,得到试验种群。 + 6) 在当前种群和实验种群之间采用一对一生存者选择方法得到新一代种群, + 同时统计新一代种群中有多少个个体继承自实验种群(即变异成功率)。 + 7) 根据变异成功率修改Sigma3。 + 8) 回到第2步。 + +参考文献: + [1] Beyer H G , Schwefel H P . Evolution strategies – A comprehensive + introduction[J]. Natural Computing, 2002, 1(1):3-52. + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = '(1+1)ES' + if population.Encoding != 'RI': + raise RuntimeError('编码方式必须为''RI''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + Sigma3 = 0.5 * (population.Field[1, :] - population.Field[0, :]) # 初始化高斯变异算子的Sigma3 + # ===========================开始进化============================ + while not self.terminated(population): + # 进行进化操作 + experimentPop = ea.Population(population.Encoding, population.Field, NIND) # 存储试验种群 + experimentPop.Chrom = ea.mutgau(population.Encoding, population.Chrom, population.Field, 1, Sigma3) # 高斯变异 + self.call_aimFunc(experimentPop) # 计算目标函数值 + tempPop = population + experimentPop # 临时合并,以调用otos进行一对一生存者选择 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + chooseIdx = ea.selecting('otos', tempPop.FitnV, NIND) # 采用One-to-One Survivor选择 + population = tempPop[chooseIdx] # 产生新一代种群 + # 利用1/5规则调整变异压缩概率 + successfulRate = len(np.where(chooseIdx >= NIND)[0]) / (2 * NIND) + if successfulRate < 1 / 5: + Sigma3 *= 0.817 + elif successfulRate > 1 / 5: + Sigma3 /= 0.817 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/ES/ES_miu_plus_lambda/soea_ES_miu_plus_lambda_templet.py b/geatpy/algorithms/soeas/ES/ES_miu_plus_lambda/soea_ES_miu_plus_lambda_templet.py new file mode 100644 index 00000000..c629a36f --- /dev/null +++ b/geatpy/algorithms/soeas/ES/ES_miu_plus_lambda/soea_ES_miu_plus_lambda_templet.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # 导入geatpy库 + + +class soea_ES_miu_plus_lambda_templet(ea.SoeaAlgorithm): + """ +soea_ES_miu_plus_lambda_templet : class - (μ+λ)进化策略算法类 + +算法描述: + 本算法类实现的是(μ+λ)进化策略[1]。 + +参考文献: + [1] Beyer H G , Schwefel H P . Evolution strategies – A comprehensive + introduction[J]. Natural Computing, 2002, 1(1):3-52. + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = '(μ+λ)ES' + if population.Encoding != 'RI': + raise RuntimeError('编码方式必须为''RI''.') + self.selFunc = 'urs' # 无约束的随机选择算子 + self.NSel = int(0.5 * population.sizes) # 这里用NSel代指算法中的lambda,默认设为种群规模的0.5倍 + self.recOper = ea.Recint(RecOpt=None, Half_N=self.NSel, Alpha=0.5) # 默认采用全局重组方式的中间重组 + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + Sigma3 = np.random.rand(population.sizes, population.Lind) * ( + population.Field[1, :] - population.Field[0, :]) * 0.5 # 初始化高斯变异算子的Sigma3 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择 + choose_index = ea.selecting(self.selFunc, population.FitnV, self.NSel) + offspring = population[choose_index] + offspring_Sigma3 = Sigma3[choose_index] + # 进行进化操作 + offspring.Chrom = self.recOper.do(offspring.Chrom) # 重组 + offspring_Sigma3 = self.recOper.do(offspring_Sigma3) # 对offspring_Sigma3进行重组 + for i in range(len(choose_index)): + offspring.Chrom[i, :] = ea.mutgau(offspring.Encoding, offspring.Chrom[i, :].reshape(1, -1), + offspring.Field, 1, offspring_Sigma3[i]).reshape(-1) # 高斯变异 + self.call_aimFunc(offspring) # 计算目标函数值 + population = population + offspring # 父子合并 + Sigma3 = np.vstack([Sigma3, offspring_Sigma3]) + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # 得到新一代种群 + choose_index = ea.selecting('dup', population.FitnV, NIND) # 采用基于适应度排序的直接复制选择 + population = population[choose_index] + Sigma3 = Sigma3[choose_index] + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/EGA/soea_EGA_templet.py b/geatpy/algorithms/soeas/GA/EGA/soea_EGA_templet.py new file mode 100644 index 00000000..81431189 --- /dev/null +++ b/geatpy/algorithms/soeas/GA/EGA/soea_EGA_templet.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea # 导入geatpy库 + + +class soea_EGA_templet(ea.SoeaAlgorithm): + """ +soea_EGA_templet.py - Elitist Reservation GA Algorithm (精英保留的遗传算法类) + +算法描述: + 本算法类实现的是基于杰出保留的单目标遗传算法。算法流程如下: + 1) 根据编码规则初始化N个个体的种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 独立地从当前种群中选取N-1个母体。 + 5) 独立地对这N-1个母体进行交叉操作。 + 6) 独立地对这N-1个交叉后的个体进行变异。 + 7) 计算当代种群的最优个体,并把它插入到这N-1个交叉后的个体的第一位,得到新一代种群。 + 8) 回到第2步。 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'EGA' + self.selFunc = 'tour' # 锦标赛选择算子 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=0.7) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=0.5) # 生成逆转变异算子对象 + else: + self.recOper = ea.Xovdp(XOVR=0.7) # 生成两点交叉算子对象 + if population.Encoding == 'BG': + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + bestIndi = population[np.argmax(population.FitnV, 0)] # 得到当代的最优个体 + # 选择 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND - 1)] + # 进行进化操作 + offspring.Chrom = self.recOper.do(offspring.Chrom) # 重组 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 计算目标函数值 + population = bestIndi + offspring # 更新种群 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/EGA/soea_psy_EGA_templet.py b/geatpy/algorithms/soeas/GA/EGA/soea_psy_EGA_templet.py new file mode 100644 index 00000000..45dceeb0 --- /dev/null +++ b/geatpy/algorithms/soeas/GA/EGA/soea_psy_EGA_templet.py @@ -0,0 +1,92 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea # 导入geatpy库 + + +class soea_psy_EGA_templet(ea.SoeaAlgorithm): + """ +soea_psy_EGA_templet.py - Polysomy Elitist Reservation GA Algorithm(精英保留的多染色体遗传算法类) + +算法类说明: + 该算法类是内置算法类soea_EGA_templet的多染色体版本, + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + +算法描述: + 本算法类实现的是基于杰出保留的单目标遗传算法。算法流程如下: + 1) 根据编码规则初始化N个个体的种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 独立地从当前种群中选取N-1个母体。 + 5) 独立地对这N-1个母体进行交叉操作。 + 6) 独立地对这N-1个交叉后的个体进行变异。 + 7) 计算当代种群的最优个体,并把它插入到这N-1个交叉后的个体的第一位,得到新一代种群。 + 8) 回到第2步。 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'psy-EGA' + self.selFunc = 'tour' # 锦标赛选择算子 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=0.7) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=0.5) # 生成逆转变异算子对象 + else: + recOper = ea.Xovdp(XOVR=0.7) # 生成两点交叉算子对象 + if population.Encodings[i] == 'BG': + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + self.call_aimFunc(population) # 计算种群的目标函数值 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查,故应确保prophetPop是一个种群类且拥有合法的Chrom、ObjV、Phen等属性) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + bestIndi = population[np.argmax(population.FitnV, 0)] # 得到当代的最优个体 + # 选择 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND - 1)] + # 进行进化操作,分别对各种编码的染色体进行重组和变异 + for i in range(population.ChromNum): + offspring.Chroms[i] = self.recOpers[i].do(offspring.Chroms[i]) # 重组 + offspring.Chroms[i] = self.mutOpers[i].do(offspring.Encodings[i], offspring.Chroms[i], + offspring.Fields[i]) # 变异 + self.call_aimFunc(offspring) # 计算目标函数值 + population = bestIndi + offspring # 更新种群 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/SEGA/soea_SEGA_templet.py b/geatpy/algorithms/soeas/GA/SEGA/soea_SEGA_templet.py new file mode 100644 index 00000000..5d991ca4 --- /dev/null +++ b/geatpy/algorithms/soeas/GA/SEGA/soea_SEGA_templet.py @@ -0,0 +1,81 @@ +# -*- coding: utf-8 -*- +import geatpy as ea # 导入geatpy库 + + +class soea_SEGA_templet(ea.SoeaAlgorithm): + """ +soea_SEGA_templet : class - Strengthen Elitist GA Algorithm(增强精英保留的遗传算法类) + +算法描述: + 本算法类实现的是增强精英保留的遗传算法。算法流程如下: + 1) 根据编码规则初始化N个个体的种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 独立地从当前种群中选取N个母体。 + 5) 独立地对这N个母体进行交叉操作。 + 6) 独立地对这N个交叉后的个体进行变异。 + 7) 将父代种群和交叉变异得到的种群进行合并,得到规模为2N的种群。 + 8) 从合并的种群中根据选择算法选择出N个个体,得到新一代种群。 + 9) 回到第2步。 + 该算法宜设置较大的交叉和变异概率,否则生成的新一代种群中会有越来越多的重复个体。 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'SEGA' + self.selFunc = 'tour' # 锦标赛选择算子 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=0.7) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=0.5) # 生成逆转变异算子对象 + else: + self.recOper = ea.Xovdp(XOVR=0.7) # 生成两点交叉算子对象 + if population.Encoding == 'BG': + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + # 进行进化操作 + offspring.Chrom = self.recOper.do(offspring.Chrom) # 重组 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 计算目标函数值 + population = population + offspring # 父子合并 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # 得到新一代种群 + population = population[ea.selecting('dup', population.FitnV, NIND)] # 采用基于适应度排序的直接复制选择生成新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/SEGA/soea_multi_SEGA_templet.py b/geatpy/algorithms/soeas/GA/SEGA/soea_multi_SEGA_templet.py new file mode 100644 index 00000000..861237ea --- /dev/null +++ b/geatpy/algorithms/soeas/GA/SEGA/soea_multi_SEGA_templet.py @@ -0,0 +1,139 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea # 导入geatpy库 + + +class soea_multi_SEGA_templet(ea.SoeaAlgorithm): + """ +soea_multi_SEGA_templet : class - Multi-population Strengthen Elitist GA Algorithm(增强精英保留的多种群协同遗传算法类) + +算法类说明: + 该算法类是内置算法类soea_SEGA_templet的多种群协同版本,为不同的种群设置不同的重组和变异概率。 + 注意:本算法类中的population为一个存储种群类对象的列表,而不是单个种群类对象。 + +算法描述: + 本算法类实现的是增强精英保留的多种群协同遗传算法。算法流程如下: + 1) 循环population列表,初始化列表中的各个种群的染色体,并将所有种群所有个体的数目记录为NindAll。 + 2) 若满足进化算法停止条件则停止,否则继续执行。 + 3) 循环对各个种群独立进行选择、重组、变异,得到各个种群的子代,并将父代和子代个体合并。 + 4) 对所有种群的所有个体进行统一的适应度评价。 + 5) 根据适应度调用选择算子进行环境选择,选择出NindAll个个体形成新一代种群。 + 6) 根据概率进行种群间个体迁移。 + 7) 回到第2步。 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if type(population) != list: + raise RuntimeError('传入的种群对象列表必须为list类型') + self.name = 'multi-SEGA' + self.PopNum = len(population) # 种群数目 + self.selFunc = 'tour' # 锦标赛选择算子 + self.migFr = 5 # 发生种群迁移的间隔代数 + self.migOpers = ea.Migrate(MIGR=0.2, Structure=2, Select=1, Replacement=2) # 生成种群迁移算子对象 + # 为不同的种群设置不同的重组、变异算子 + self.recOpers = [] + self.mutOpers = [] + Pms = np.linspace(1 / self.problem.Dim, 1, self.PopNum) # 生成变异概率列表,为不同的种群分配不同的变异概率 + Pcs = np.linspace(0.7, 1, self.PopNum) # 生成重组概率列表,为不同的种群分配不同的重组概率 + for i in range(self.PopNum): # 遍历种群列表 + pop = population[i] # 得到当前种群对象 + if pop.Encoding == 'P': + recOper = ea.Xovpmx(XOVR=Pcs[i]) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=float(Pms[i])) # 生成逆转变异算子对象 + else: + recOper = ea.Xovdp(XOVR=Pcs[i]) # 生成两点交叉算子对象 + if pop.Encoding == 'BG': + mutOper = ea.Mutbin(Pm=float(Pms[i])) # 生成二进制变异算子对象 + elif pop.Encoding == 'RI': + mutOper = ea.Mutbga(Pm=float(Pms[i]), MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + + def unite(self, population): + """ + 合并种群,生成联合种群。 + 注:返回的unitePop不携带Field和Chrom的信息,因为其Encoding=None。 + """ + # 遍历种群列表,构造联合种群 + unitePop = ea.Population(None, None, population[0].sizes, None, # 第一个输入参数传入None,设置Encoding为None + ObjV=population[0].ObjV, + FitnV=population[0].FitnV, + CV=population[0].CV, + Phen=population[0].Phen) + for i in range(1, self.PopNum): + unitePop += population[i] + return unitePop + + def calFitness(self, population): + """ + 计算种群个体适应度,population为种群列表 + 该函数直接对输入参数population中的适应度信息进行修改,因此函数不用返回任何参数。 + """ + ObjV = np.vstack(list(pop.ObjV for pop in population)) + CV = np.vstack(list(pop.CV for pop in population)) if population[0].CV is not None else population[0].CV + FitnV = ea.scaling(ObjV, CV, self.problem.maxormins) # 统一计算适应度 + # 为各个种群分配适应度 + idx = 0 + for i in range(self.PopNum): + population[i].FitnV = FitnV[idx: idx + population[i].sizes] + idx += population[i].sizes + + def EnvSelection(self, population, NUM): # 环境选择,选择个体保留到下一代 + FitnVs = list(pop.FitnV for pop in population) + NewChrIxs = ea.mselecting('dup', FitnVs, NUM) # 采用基于适应度排序的直接复制选择 + for i in range(self.PopNum): + population[i] = (population[i])[NewChrIxs[i]] + return population + + def run(self, prophetPops=None): # prophetPops为先知种群列表(即包含先验知识的种群列表) + # ==========================初始化配置=========================== + self.initialization() # 初始化算法类的一些动态参数 + population = self.population # 密切注意本算法类的population是一个存储种群类对象的列表 + NindAll = 0 # 记录所有种群个体总数 + # ===========================准备进化============================ + for i in range(self.PopNum): # 遍历每个种群,初始化每个种群的染色体矩阵 + NindAll += population[i].sizes + population[i].initChrom(population[i].sizes) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群列表prophetPops的合法性进行检查) + if prophetPops is not None: + population[i] = (prophetPops[i] + population[i])[:population[i].sizes] # 插入先知种群 + self.call_aimFunc(population[i]) # 计算种群的目标函数值 + self.calFitness(population) # 统一计算适应度 + unitePop = self.unite(population) # 得到联合种群unitePop + # ===========================开始进化============================ + while self.terminated(unitePop) == False: + for i in range(self.PopNum): # 遍历种群列表,分别对各个种群进行重组和变异 + pop = population[i] # 得到当前种群 + # 选择 + offspring = pop[ea.selecting(self.selFunc, pop.FitnV, pop.sizes)] + # 进行进化操作 + offspring.Chrom = self.recOpers[i].do(offspring.Chrom) # 重组 + offspring.Chrom = self.mutOpers[i].do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 计算目标函数值 + population[i] = population[i] + offspring # 父子合并 + self.calFitness(population) # 统一计算适应度 + population = self.EnvSelection(population, NUM=NindAll) # 选择个体得到新一代种群 + if self.currentGen % self.migFr == 0: + population = self.migOpers.do(population) # 进行种群迁移 + unitePop = self.unite(population) # 更新联合种群 + return self.finishing(unitePop) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/SEGA/soea_psy_SEGA_templet.py b/geatpy/algorithms/soeas/GA/SEGA/soea_psy_SEGA_templet.py new file mode 100644 index 00000000..9ba44dcb --- /dev/null +++ b/geatpy/algorithms/soeas/GA/SEGA/soea_psy_SEGA_templet.py @@ -0,0 +1,93 @@ +# -*- coding: utf-8 -*- +import geatpy as ea # 导入geatpy库 + + +class soea_psy_SEGA_templet(ea.SoeaAlgorithm): + """ +soea_psy_SEGA_templet : class - Polysomy Strengthen Elitist GA Algorithm(增强精英保留的多染色体遗传算法类) + +算法类说明: + 该算法类是内置算法类soea_SEGA_templet的多染色体版本, + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + +算法描述: + 本算法类实现的是增强精英保留的遗传算法。算法流程如下: + 1) 根据编码规则初始化N个个体的种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 独立地从当前种群中选取N个母体。 + 5) 独立地对这N个母体进行交叉操作。 + 6) 独立地对这N个交叉后的个体进行变异。 + 7) 将父代种群和交叉变异得到的种群进行合并,得到规模为2N的种群。 + 8) 从合并的种群中根据选择算法选择出N个个体,得到新一代种群。 + 9) 回到第2步。 + 该算法宜设置较大的交叉和变异概率,否则生成的新一代种群中会有越来越多的重复个体。 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'psy-SEGA' + self.selFunc = 'tour' # 锦标赛选择算子 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=0.7) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=0.5) # 生成逆转变异算子对象 + else: + recOper = ea.Xovdp(XOVR=0.7) # 生成两点交叉算子对象 + if population.Encodings[i] == 'BG': + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + # 进行进化操作,分别对各种编码的染色体进行重组和变异 + for i in range(population.ChromNum): + offspring.Chroms[i] = self.recOpers[i].do(offspring.Chroms[i]) # 重组 + offspring.Chroms[i] = self.mutOpers[i].do(offspring.Encodings[i], offspring.Chroms[i], + offspring.Fields[i]) # 变异 + self.call_aimFunc(offspring) # 计算目标函数值 + population = population + offspring # 父子合并 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # 得到新一代种群 + population = population[ea.selecting('dup', population.FitnV, NIND)] # 采用基于适应度排序的直接复制选择生成新一代种群 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/SGA/soea_GGAP_SGA_templet.py b/geatpy/algorithms/soeas/GA/SGA/soea_GGAP_SGA_templet.py new file mode 100644 index 00000000..52b1b1e4 --- /dev/null +++ b/geatpy/algorithms/soeas/GA/SGA/soea_GGAP_SGA_templet.py @@ -0,0 +1,91 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea # 导入geatpy库 + + +class soea_GGAP_SGA_templet(ea.SoeaAlgorithm): + """ +soea_GGAP_SGA_templet : class - Generational Gap Simple GA Algorithm(带代沟的简单遗传算法类) + +算法描述: + 本算法类实现的是带代沟的简单遗传算法, + 它在SGA算法类的基础上增加“代沟”,用于控制使用多少个子代替换父代来形成新一代种群,算法流程如下: + 1) 根据编码规则初始化N个个体的种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 独立地从当前种群中选取N个母体。 + 5) 独立地对这N个母体进行交叉操作。 + 6) 独立地对这N个交叉后的个体进行变异,并根据代沟从中选择N'个个体替换父代最差的N'个个体,得到下一代种群。 + 7) 回到第2步。 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'GGAP-SGA' + self.selFunc = 'rws' # 轮盘赌选择算子 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=0.7) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=0.5) # 生成逆转变异算子对象 + else: + self.recOper = ea.Xovdp(XOVR=0.7) # 生成两点交叉算子对象 + if population.Encoding == 'BG': + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.GGAP = 0.9 # 代沟,表示使用多少比例的子代替换父代来形成新一代种群 + + def reinsertion(self, population, offspring, GGAP_NUM): + + """ 重插入 """ + replaceIdx = np.argsort(population.FitnV.T[0])[:GGAP_NUM].astype(int) # 计算父代中要被替换的个体索引 + insertIdx = np.argsort(-offspring.FitnV.T[0])[:GGAP_NUM].astype(int) # 计算子代中需要选择进行重插入的个体索引 + population[replaceIdx] = offspring[insertIdx] + return population + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + GGAP_NUM = int(np.ceil(NIND * self.GGAP)) # 计算每一代替换个体的个数 + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + # 进行进化操作 + offspring.Chrom = self.recOper.do(offspring.Chrom) # 重组 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 计算目标函数值 + offspring.FitnV = ea.scaling(offspring.ObjV, offspring.CV, self.problem.maxormins) # 计算适应度 + # 根据代沟把子代重插入到父代生成新一代种群 + population = self.reinsertion(population, offspring, GGAP_NUM) + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/SGA/soea_SGA_templet.py b/geatpy/algorithms/soeas/GA/SGA/soea_SGA_templet.py new file mode 100644 index 00000000..a09c8d95 --- /dev/null +++ b/geatpy/algorithms/soeas/GA/SGA/soea_SGA_templet.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- +import geatpy as ea # 导入geatpy库 + + +class soea_SGA_templet(ea.SoeaAlgorithm): + """ +soea_SGA_templet : class - Simple GA Algorithm(最简单、最经典的遗传算法类) + +算法描述: + 本算法类实现的是最经典的单目标遗传算法。算法流程如下: + 1) 根据编码规则初始化N个个体的种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 独立地从当前种群中选取N个母体。 + 5) 独立地对这N个母体进行交叉操作。 + 6) 独立地对这N个交叉后的个体进行变异,得到下一代种群。 + 7) 回到第2步。 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'SGA' + self.selFunc = 'rws' # 轮盘赌选择算子 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=0.7) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=0.01) # 生成逆转变异算子对象 + else: + self.recOper = ea.Xovdp(XOVR=0.7) # 生成两点交叉算子对象 + if population.Encoding == 'BG': + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择 + population = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + # 进行进化操作 + population.Chrom = self.recOper.do(population.Chrom) # 重组 + population.Chrom = self.mutOper.do(population.Encoding, population.Chrom, population.Field) # 变异 + self.call_aimFunc(population) # 计算目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/SGA/soea_psy_GGAP_SGA_templet.py b/geatpy/algorithms/soeas/GA/SGA/soea_psy_GGAP_SGA_templet.py new file mode 100644 index 00000000..17cbbda6 --- /dev/null +++ b/geatpy/algorithms/soeas/GA/SGA/soea_psy_GGAP_SGA_templet.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea # 导入geatpy库 + + +class soea_psy_GGAP_SGA_templet(ea.SoeaAlgorithm): + """ +soea_psy_GGAP_SGA_templet : class - Polysomy Generational Gap Simple GA Algorithm(带代沟的简单遗传算法类) + +算法类说明: + 该算法类是内置算法类soea_GGAP_SGA_templet的多染色体版本, + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + +算法描述: + 本算法类实现的是带代沟的简单遗传算法, + 它在SGA算法类的基础上增加“代沟”,用于控制使用多少个子代替换父代来形成新一代种群,算法流程如下: + 1) 根据编码规则初始化N个个体的种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 独立地从当前种群中选取N个母体。 + 5) 独立地对这N个母体进行交叉操作。 + 6) 独立地对这N个交叉后的个体进行变异,并根据代沟从中选择N'个个体替换父代最差的N'个个体,得到下一代种群。 + 7) 回到第2步。 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'GGAP-SGA' + self.selFunc = 'rws' # 轮盘赌选择算子 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=0.7) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=0.5) # 生成逆转变异算子对象 + else: + recOper = ea.Xovdp(XOVR=0.7) # 生成两点交叉算子对象 + if population.Encodings[i] == 'BG': + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + self.GGAP = 0.9 # 代沟,表示使用多少个子代替换父代来形成新一代种群 + + def reinsertion(self, population, offspring, GGAP_NUM): + + """ 重插入 """ + replaceIdx = np.argsort(population.FitnV.T[0])[:GGAP_NUM].astype(int) # 计算父代中要被替换的个体索引 + insertIdx = np.argsort(-offspring.FitnV.T[0])[:GGAP_NUM].astype(int) # 计算子代中需要选择进行重插入的个体索引 + population[replaceIdx] = offspring[insertIdx] + return population + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + GGAP_NUM = int(np.ceil(NIND * self.GGAP)) # 计算每一代替换个体的个数 + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择 + offspring = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + # 进行进化操作,分别对各种编码的染色体进行重组和变异 + for i in range(offspring.ChromNum): + offspring.Chroms[i] = self.recOpers[i].do(offspring.Chroms[i]) # 重组 + offspring.Chroms[i] = self.mutOpers[i].do(offspring.Encodings[i], offspring.Chroms[i], + offspring.Fields[i]) # 变异 + self.call_aimFunc(offspring) # 计算目标函数值 + offspring.FitnV = ea.scaling(offspring.ObjV, offspring.CV, self.problem.maxormins) # 计算适应度 + # 根据代沟把子代重插入到父代生成新一代种群 + population = self.reinsertion(population, offspring, GGAP_NUM) + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/SGA/soea_psy_SGA_templet.py b/geatpy/algorithms/soeas/GA/SGA/soea_psy_SGA_templet.py new file mode 100644 index 00000000..bd87bcb9 --- /dev/null +++ b/geatpy/algorithms/soeas/GA/SGA/soea_psy_SGA_templet.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- +import geatpy as ea # 导入geatpy库 + + +class soea_psy_SGA_templet(ea.SoeaAlgorithm): + """ +soea_psy_SGA_templet : class - Polysomy Simple GA Algorithm(最简单、最经典的遗传算法类) + +算法类说明: + 该算法类是内置算法类soea_SGA_templet的多染色体版本, + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + +算法描述: + 本算法类实现的是最经典的单目标遗传算法。算法流程如下: + 1) 根据编码规则初始化N个个体的种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 独立地从当前种群中选取N个母体。 + 5) 独立地对这N个母体进行交叉操作。 + 6) 独立地对这N个交叉后的个体进行变异,得到下一代种群。 + 7) 回到第2步。 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'psy-SGA' + self.selFunc = 'rws' # 轮盘赌选择算子 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=0.7) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=0.5) # 生成逆转变异算子对象 + else: + recOper = ea.Xovdp(XOVR=0.7) # 生成两点交叉算子对象 + if population.Encodings[i] == 'BG': + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择 + population = population[ea.selecting(self.selFunc, population.FitnV, NIND)] + # 进行进化操作,分别对各种编码的染色体进行重组和变异 + for i in range(population.ChromNum): + population.Chroms[i] = self.recOpers[i].do(population.Chroms[i]) # 重组 + population.Chroms[i] = self.mutOpers[i].do(population.Encodings[i], population.Chroms[i], + population.Fields[i]) # 变异 + self.call_aimFunc(population) # 计算目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/steadyGA/soea_psy_steadyGA_templet.py b/geatpy/algorithms/soeas/GA/steadyGA/soea_psy_steadyGA_templet.py new file mode 100644 index 00000000..57462620 --- /dev/null +++ b/geatpy/algorithms/soeas/GA/steadyGA/soea_psy_steadyGA_templet.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +import geatpy as ea # 导入geatpy库 + + +class soea_psy_steadyGA_templet(ea.SoeaAlgorithm): + """ +soea_psy_steadyGA_templet : class - Polysomy Steady State GA Algorithm(多染色体稳态遗传算法类) + +算法类说明: + 该算法类是内置算法类soea_steadyGA_templet的多染色体版本, + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + +算法描述: + 本算法类实现的是稳态遗传算法,算法流程如下: + 1) 根据编码规则初始化N个个体的种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 独立地从当前种群中选取2个母体。 + 5) 独立地对这2个母体进行交叉操作。 + 6) 独立地对这2个交叉后的个体进行变异。 + 7) 将这2个母体和由交叉变异得到的个体进行一对一生存者竞争选择。 + 8) 将第7步得到的个体替换父代中原母体所在位置的个体,形成新一代种群。 + 9) 回到第2步。 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'psy-steadyGA' + self.selFunc = 'etour' # 锦标赛选择算子 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=0.5) # 生成逆转变异算子对象 + else: + recOper = ea.Xovdp(XOVR=1) # 生成两点交叉算子对象 + if population.Encodings[i] == 'BG': + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + if NIND < 2: + raise RuntimeError('error: Population'' size is too small. (种群规模不能小于2。)') + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择 + chooseIdx = ea.selecting(self.selFunc, population.FitnV, 2) + offspring = population[chooseIdx] + # 进行进化操作,分别对各种编码的染色体进行重组和变异 + for i in range(population.ChromNum): + offspring.Chroms[i] = self.recOpers[i].do(offspring.Chroms[i]) # 重组 + offspring.Chroms[i] = self.mutOpers[i].do(offspring.Encodings[i], offspring.Chroms[i], + offspring.Fields[i]) # 变异 + self.call_aimFunc(offspring) # 计算目标函数值 + tempPop = population + offspring # 父子合并 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + # 得到新一代种群 + tempPop = tempPop[ea.selecting('otos', tempPop.FitnV, 2)] # 采用One-to-One Survivor选择 + population[chooseIdx] = tempPop + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/steadyGA/soea_steadyGA_templet.py b/geatpy/algorithms/soeas/GA/steadyGA/soea_steadyGA_templet.py new file mode 100644 index 00000000..8abb5c80 --- /dev/null +++ b/geatpy/algorithms/soeas/GA/steadyGA/soea_steadyGA_templet.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- +import geatpy as ea # 导入geatpy库 + + +class soea_steadyGA_templet(ea.SoeaAlgorithm): + """ +soea_steadyGA_templet : class - Steady State GA Algorithm(稳态遗传算法类) + +算法描述: + 本算法类实现的是稳态遗传算法,算法流程如下: + 1) 根据编码规则初始化N个个体的种群。 + 2) 若满足停止条件则停止,否则继续执行。 + 3) 对当前种群进行统计分析,比如记录其最优个体、平均适应度等等。 + 4) 独立地从当前种群中选取2个母体。 + 5) 独立地对这2个母体进行交叉操作。 + 6) 独立地对这2个交叉后的个体进行变异。 + 7) 将这2个母体和由交叉变异得到的个体进行一对一生存者竞争选择。 + 8) 将第7步得到的个体替换父代中原母体所在位置的个体,形成新一代种群。 + 9) 回到第2步。 + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'steadyGA' + self.selFunc = 'etour' # 锦标赛选择算子 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=1) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=0.5) # 生成逆转变异算子对象 + else: + self.recOper = ea.Xovdp(XOVR=1) # 生成两点交叉算子对象 + if population.Encoding == 'BG': + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + if NIND < 2: + raise RuntimeError('error: Population'' size is too small. (种群规模不能小于2。)') + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + # 选择 + chooseIdx = ea.selecting(self.selFunc, population.FitnV, 2) + offspring = population[chooseIdx] + # 进行进化操作 + offspring.Chrom = self.recOper.do(offspring.Chrom) # 重组 + offspring.Chrom = self.mutOper.do(offspring.Encoding, offspring.Chrom, offspring.Field) # 变异 + self.call_aimFunc(offspring) # 计算目标函数值 + tempPop = population[chooseIdx] + offspring # 父子合并 + tempPop.FitnV = ea.scaling(tempPop.ObjV, tempPop.CV, self.problem.maxormins) # 计算适应度 + # 得到新一代种群 + tempPop = tempPop[ea.selecting('otos', tempPop.FitnV, 2)] # 采用One-to-One Survivor选择 + population[chooseIdx] = tempPop + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/studGA/soea_psy_studGA_templet.py b/geatpy/algorithms/soeas/GA/studGA/soea_psy_studGA_templet.py new file mode 100644 index 00000000..e3642da8 --- /dev/null +++ b/geatpy/algorithms/soeas/GA/studGA/soea_psy_studGA_templet.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea # 导入geatpy库 + + +class soea_psy_studGA_templet(ea.SoeaAlgorithm): + """ +soea_psy_studGA_templet.py - Polysomy Stud GA Algorithm(多染色体种马遗传算法类) + +算法类说明: + 该算法类是内置算法类soea_studGA_templet的多染色体版本, + 因此里面的种群对象为支持混合编码的多染色体种群类PsyPopulation类的对象。 + +算法描述: + 本算法类实现的是种马遗传算法。算法流程详见参考文献[1]。 + +算法类使用注意: + 本算法类调用的目标函数形如:aimFunc(pop), + 其中pop为种群类的对象,代表一个种群, + pop对象的Phen属性(即种群染色体的表现型)等价于种群所有个体的决策变量组成的矩阵, + 该函数根据该Phen计算得到种群所有个体的目标函数值组成的矩阵,并将其赋值给pop对象的ObjV属性。 + 若有约束条件,则在计算违反约束程度矩阵CV后赋值给pop对象的CV属性(详见Geatpy数据结构)。 + 该函数不返回任何的返回值,求得的目标函数值保存在种群对象的ObjV属性中, + 违反约束程度矩阵保存在种群对象的CV属性中。 + 例如:population为一个种群对象,则调用aimFunc(population)即可完成目标函数值的计算, + 此时可通过population.ObjV得到求得的目标函数值,population.CV得到违反约束程度矩阵。 + 若不符合上述规范,则请修改算法类或自定义新算法类。 + +参考文献: + [1] Khatib W , Fleming P J . The stud GA: A mini revolution?[C]// International + Conference on Parallel Problem Solving from Nature. Springer, Berlin, Heidelberg, 1998. + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum == 1: + raise RuntimeError('传入的种群对象必须是多染色体的种群类型。') + self.name = 'psy-studGA' + self.problem = problem + self.population = population + self.selFunc = 'tour' # 锦标赛选择算子 + # 由于有多个染色体,因此需要用多个重组和变异算子 + self.recOpers = [] + self.mutOpers = [] + for i in range(population.ChromNum): + if population.Encodings[i] == 'P': + recOper = ea.Xovpmx(XOVR=0.7) # 生成部分匹配交叉算子对象 + mutOper = ea.Mutinv(Pm=0.5) # 生成逆转变异算子对象 + else: + recOper = ea.Xovdp(XOVR=0.7) # 生成两点交叉算子对象 + if population.Encodings[i] == 'BG': + mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encodings[i] == 'RI': + mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + self.recOpers.append(recOper) + self.mutOpers.append(mutOper) + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + bestIdx = np.argmax(population.FitnV, axis=0) # 得到当代的最优个体的索引, 设置axis=0可使得返回一个向量 + studPop = population[np.tile(bestIdx, (NIND // 2))] # 复制最优个体NIND//2份,组成一个“种马种群” + restPop = population[np.where(np.arange(NIND) != bestIdx)[0]] # 得到除去精英个体外其它个体组成的种群 + # 选择个体,以便后面与种马种群进行交配 + tempPop = restPop[ea.selecting(self.selFunc, restPop.FitnV, (NIND - studPop.sizes))] + # 将种马种群与选择出来的个体进行合并 + population = studPop + tempPop + # 进行进化操作,分别对各种编码的染色体进行重组和变异 + for i in range(population.ChromNum): + population.Chroms[i] = self.recOpers[i].do(population.Chroms[i]) # 重组 + population.Chroms[i] = self.mutOpers[i].do(population.Encodings[i], population.Chroms[i], + population.Fields[i]) # 变异 + self.call_aimFunc(population) + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/algorithms/soeas/GA/studGA/soea_studGA_templet.py b/geatpy/algorithms/soeas/GA/studGA/soea_studGA_templet.py new file mode 100644 index 00000000..4603b1ac --- /dev/null +++ b/geatpy/algorithms/soeas/GA/studGA/soea_studGA_templet.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea # 导入geatpy库 + + +class soea_studGA_templet(ea.SoeaAlgorithm): + """ +soea_studGA_templet.py - Stud GA Algorithm(种马遗传算法类) + +算法描述: + 本算法类实现的是种马遗传算法。算法流程详见参考文献[1]。 + +参考文献: + [1] Khatib W , Fleming P J . The stud GA: A mini revolution?[C]// International + Conference on Parallel Problem Solving from Nature. Springer, Berlin, Heidelberg, 1998. + +""" + + def __init__(self, + problem, + population, + MAXGEN=None, + MAXTIME=None, + MAXEVALS=None, + MAXSIZE=None, + logTras=None, + verbose=None, + outFunc=None, + drawing=None, + trappedValue=None, + maxTrappedCount=None, + dirName=None, + **kwargs): + # 先调用父类构造方法 + super().__init__(problem, population, MAXGEN, MAXTIME, MAXEVALS, MAXSIZE, logTras, verbose, outFunc, drawing, trappedValue, maxTrappedCount, dirName) + if population.ChromNum != 1: + raise RuntimeError('传入的种群对象必须是单染色体的种群类型。') + self.name = 'studGA' + self.selFunc = 'tour' # 锦标赛选择算子 + if population.Encoding == 'P': + self.recOper = ea.Xovpmx(XOVR=0.7) # 生成部分匹配交叉算子对象 + self.mutOper = ea.Mutinv(Pm=0.5) # 生成逆转变异算子对象 + else: + self.recOper = ea.Xovdp(XOVR=0.7) # 生成两点交叉算子对象 + if population.Encoding == 'BG': + self.mutOper = ea.Mutbin(Pm=None) # 生成二进制变异算子对象,Pm设置为None时,具体数值取变异算子中Pm的默认值 + elif population.Encoding == 'RI': + self.mutOper = ea.Mutbga(Pm=1 / self.problem.Dim, MutShrink=0.5, Gradient=20) # 生成breeder GA变异算子对象 + else: + raise RuntimeError('编码方式必须为''BG''、''RI''或''P''.') + + def run(self, prophetPop=None): # prophetPop为先知种群(即包含先验知识的种群) + # ==========================初始化配置=========================== + population = self.population + NIND = population.sizes + self.initialization() # 初始化算法类的一些动态参数 + # ===========================准备进化============================ + population.initChrom(NIND) # 初始化种群染色体矩阵 + # 插入先验知识(注意:这里不会对先知种群prophetPop的合法性进行检查) + if prophetPop is not None: + population = (prophetPop + population)[:NIND] # 插入先知种群 + self.call_aimFunc(population) # 计算种群的目标函数值 + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + # ===========================开始进化============================ + while not self.terminated(population): + bestIdx = np.argmax(population.FitnV, axis=0) # 得到当代的最优个体的索引, 设置axis=0可使得返回一个向量 + studPop = population[np.tile(bestIdx, (NIND // 2))] # 复制最优个体NIND//2份,组成一个“种马种群” + restPop = population[np.where(np.arange(NIND) != bestIdx)[0]] # 得到除去精英个体外其它个体组成的种群 + # 选择个体,以便后面与种马种群进行交配 + tempPop = restPop[ea.selecting(self.selFunc, restPop.FitnV, (NIND - studPop.sizes))] + # 将种马种群与选择出来的个体进行合并 + population = studPop + tempPop + # 进行进化操作 + population.Chrom = self.recOper.do(population.Chrom) # 重组 + population.Chrom = self.mutOper.do(population.Encoding, population.Chrom, population.Field) # 变异 + self.call_aimFunc(population) + population.FitnV = ea.scaling(population.ObjV, population.CV, self.problem.maxormins) # 计算适应度 + return self.finishing(population) # 调用finishing完成后续工作并返回结果 diff --git a/geatpy/benchmarks/__init__.py b/geatpy/benchmarks/__init__.py new file mode 100644 index 00000000..908f9843 --- /dev/null +++ b/geatpy/benchmarks/__init__.py @@ -0,0 +1,48 @@ +from geatpy.benchmarks.mops.bnh.BNH import BNH +from geatpy.benchmarks.mops.c_dtlz.C1_DTLZ1 import C1_DTLZ1 +from geatpy.benchmarks.mops.c_dtlz.C2_DTLZ2 import C2_DTLZ2 +from geatpy.benchmarks.mops.c_dtlz.C3_DTLZ1 import C3_DTLZ1 +from geatpy.benchmarks.mops.c_dtlz.C3_DTLZ4 import C3_DTLZ4 +from geatpy.benchmarks.mops.cf.CF1 import CF1 +from geatpy.benchmarks.mops.cf.CF2 import CF2 +from geatpy.benchmarks.mops.conp.Conp import CON +from geatpy.benchmarks.mops.dtlz.DTLZ1 import DTLZ1 +from geatpy.benchmarks.mops.dtlz.DTLZ2 import DTLZ2 +from geatpy.benchmarks.mops.dtlz.DTLZ3 import DTLZ3 +from geatpy.benchmarks.mops.dtlz.DTLZ4 import DTLZ4 +from geatpy.benchmarks.mops.dtlz.DTLZ5 import DTLZ5 +from geatpy.benchmarks.mops.dtlz.DTLZ6 import DTLZ6 +from geatpy.benchmarks.mops.dtlz.DTLZ7 import DTLZ7 +from geatpy.benchmarks.mops.fonseca.Fonseca import Fonseca +from geatpy.benchmarks.mops.imop.IMOP1 import IMOP1 +from geatpy.benchmarks.mops.imop.IMOP2 import IMOP2 +from geatpy.benchmarks.mops.imop.IMOP3 import IMOP3 +from geatpy.benchmarks.mops.imop.IMOP4 import IMOP4 +from geatpy.benchmarks.mops.osy.OSY import OSY +from geatpy.benchmarks.mops.srn.SRN import SRN +from geatpy.benchmarks.mops.tnk.TNK import TNK +from geatpy.benchmarks.mops.uf.UF1 import UF1 +from geatpy.benchmarks.mops.uf.UF2 import UF2 +from geatpy.benchmarks.mops.wfg.WFG1 import WFG1 +from geatpy.benchmarks.mops.wfg.WFG2 import WFG2 +from geatpy.benchmarks.mops.wfg.WFG3 import WFG3 +from geatpy.benchmarks.mops.wfg.WFG4 import WFG4 +from geatpy.benchmarks.mops.wfg.WFG5 import WFG5 +from geatpy.benchmarks.mops.zdt.ZDT1 import ZDT1 +from geatpy.benchmarks.mops.zdt.ZDT2 import ZDT2 +from geatpy.benchmarks.mops.zdt.ZDT3 import ZDT3 +from geatpy.benchmarks.mops.zdt.ZDT4 import ZDT4 +from geatpy.benchmarks.mops.zdt.ZDT5 import ZDT5 +from geatpy.benchmarks.mops.zdt.ZDT6 import ZDT6 +from geatpy.benchmarks.sops.ackley.Ackley import Ackley +from geatpy.benchmarks.sops.beale.Beale import Beale +from geatpy.benchmarks.sops.goldstein.Goldstein import Goldstein +from geatpy.benchmarks.sops.griewangk.Griewangk import Griewangk +from geatpy.benchmarks.sops.pathological.Pathological import Pathological +from geatpy.benchmarks.sops.rastrigrin.Rastrigrin import Rastrigrin +from geatpy.benchmarks.sops.rosenbrock.Rosenbrock import Rosenbrock +from geatpy.benchmarks.sops.schwefel.Schwefel import Schwefel +from geatpy.benchmarks.sops.shubert.Shubert import Shubert +from geatpy.benchmarks.sops.sphere.Sphere import Sphere +# import tsps +from geatpy.benchmarks.tsps.TSP import TSP diff --git a/geatpy/benchmarks/mops/bnh/BNH.py b/geatpy/benchmarks/mops/bnh/BNH.py new file mode 100644 index 00000000..690c0c14 --- /dev/null +++ b/geatpy/benchmarks/mops/bnh/BNH.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class BNH(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'BNH' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 2 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [5, 3] # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + x2 = Vars[:, [1]] + f1 = 4 * x1 ** 2 + 4 * x2 ** 2 + f2 = (x1 - 5) ** 2 + (x2 - 5) ** 2 + # # 采用罚函数法处理约束 + # exIdx1 = np.where((x1 - 5)**2 + x2**2 - 25 > 0)[0] + # exIdx2 = np.where(-(x1 - 8)**2 - (x2 + 3)**2 + 7.7 > 0)[0] + # exIdx = np.unique(np.hstack([exIdx1, exIdx2])) + # alpha = 2 # 惩罚缩放因子 + # beta = 1 # 惩罚最小偏移量 + # f1[exIdx] = f1[exIdx] + self.maxormins[0] * alpha * (np.max(f1)-np.min(f1)+beta) + # f2[exIdx] = f2[exIdx] + self.maxormins[1] * alpha * (np.max(f2)-np.min(f2)+beta) + # 采用可行性法则处理约束 + CV = np.hstack([(x1 - 5) ** 2 + x2 ** 2 - 25, + -(x1 - 8) ** 2 - (x2 + 3) ** 2 + 7.7]) + f = np.hstack([f1, f2]) + return f, CV + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 欲得到10000个真实前沿点 + x1 = np.linspace(0, 5, N) + x2 = x1.copy() + x2[x1 >= 3] = 3 + return np.vstack((4 * x1 ** 2 + 4 * x2 ** 2, (x1 - 5) ** 2 + (x2 - 5) ** 2)).T diff --git a/geatpy/benchmarks/mops/c_dtlz/C1_DTLZ1.py b/geatpy/benchmarks/mops/c_dtlz/C1_DTLZ1.py new file mode 100644 index 00000000..ccf3eae2 --- /dev/null +++ b/geatpy/benchmarks/mops/c_dtlz/C1_DTLZ1.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class C1_DTLZ1(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'C1-DTLZ1' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = M + 4 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + XM = Vars[:, (self.M - 1):] + g = 100 * (self.Dim - self.M + 1 + np.sum(((XM - 0.5) ** 2 - np.cos(20 * np.pi * (XM - 0.5))), 1, + keepdims=True)) + ones_metrix = np.ones((Vars.shape[0], 1)) + f = 0.5 * np.hstack([np.fliplr(np.cumprod(Vars[:, :self.M - 1], 1)), ones_metrix]) * np.hstack( + [ones_metrix, 1 - Vars[:, range(self.M - 2, -1, -1)]]) * (1 + g) + # 计算违反约束程度矩阵的值 + CV = f[:, [-1]] / 0.6 + np.sum(f[:, :-1] / 0.5, 1, keepdims=True) - 1 + return f, CV + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + uniformPoint, ans = ea.crtup(self.M, 10000) # 生成10000个在各目标的单位维度上均匀分布的参考点 + referenceObjV = uniformPoint / 2 + + return referenceObjV diff --git a/geatpy/benchmarks/mops/c_dtlz/C2_DTLZ2.py b/geatpy/benchmarks/mops/c_dtlz/C2_DTLZ2.py new file mode 100644 index 00000000..dbb4ee78 --- /dev/null +++ b/geatpy/benchmarks/mops/c_dtlz/C2_DTLZ2.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class C2_DTLZ2(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'C2-DTLZ2' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + # 额外数据 + if M == 2: + self.r = 0.2 + elif M == 3: + self.r = 0.4 + else: + self.r = 0.5 + + def evalVars(self, Vars): # 目标函数 + XM = Vars[:, (self.M - 1):] + g = np.sum((XM - 0.5) ** 2, 1, keepdims=True) + ones_metrix = np.ones((g.shape[0], 1)) + f = np.hstack([np.fliplr(np.cumprod(np.cos(Vars[:, :self.M - 1] * np.pi / 2), 1)), ones_metrix]) * np.hstack( + [ones_metrix, np.sin(Vars[:, range(self.M - 2, -1, -1)] * np.pi / 2)]) * (1 + g) + # 计算违反约束程度矩阵的值 + CV = np.min([np.min((f - 1) ** 2 + np.sum(f ** 2, 1, keepdims=True) - f ** 2 - self.r ** 2, 1, keepdims=True), + np.sum((f - 1 / np.sqrt(self.M)) ** 2, 1, keepdims=True) - self.r ** 2], 0) + return f, CV + + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + Point, ans = ea.crtup(self.M, 10000) # 生成10000个在各目标的单位维度上均匀分布的参考点 + Point /= np.tile(np.sqrt(np.sum(Point ** 2, 1, keepdims=True)), (1, self.M)) + r = 0.4 if self.M == 3 else 0.5 + referenceObjV = Point[np.where(np.min( + [np.min((Point - 1) ** 2 + np.sum(Point ** 2, 1, keepdims=True) - Point ** 2 - r ** 2, 1, keepdims=True), + np.sum((Point - 1 / np.sqrt(self.M)) ** 2, 1, keepdims=True) - r ** 2], 0) <= 0)[0], :] + return referenceObjV diff --git a/geatpy/benchmarks/mops/c_dtlz/C3_DTLZ1.py b/geatpy/benchmarks/mops/c_dtlz/C3_DTLZ1.py new file mode 100644 index 00000000..a06dd2c3 --- /dev/null +++ b/geatpy/benchmarks/mops/c_dtlz/C3_DTLZ1.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class C3_DTLZ1(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'C3-DTLZ1' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + XM = Vars[:, (self.M - 1):] + g = 100 * (self.Dim - self.M + 1 + np.sum(((XM - 0.5) ** 2 - np.cos(20 * np.pi * (XM - 0.5))), 1, + keepdims=True)) + ones_metrix = np.ones((Vars.shape[0], 1)) + f = 0.5 * np.hstack([np.fliplr(np.cumprod(Vars[:, :self.M - 1], 1)), ones_metrix]) * np.hstack( + [ones_metrix, 1 - Vars[:, range(self.M - 2, -1, -1)]]) * (1 + g) + # 计算违反约束程度矩阵的值 + CV = 1 - 2 * f - (np.sum(f, axis=1, keepdims=True) - f) + return f, CV \ No newline at end of file diff --git a/geatpy/benchmarks/mops/c_dtlz/C3_DTLZ4.py b/geatpy/benchmarks/mops/c_dtlz/C3_DTLZ4.py new file mode 100644 index 00000000..c91013a7 --- /dev/null +++ b/geatpy/benchmarks/mops/c_dtlz/C3_DTLZ4.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class C3_DTLZ4(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'C3-DTLZ4' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + alpha = 100 + XM = Vars[:, (self.M - 1):] + g = np.sum((XM - 0.5) ** 2, 1, keepdims=True) + ones_metrix = np.ones((g.shape[0], 1)) + f = np.hstack( + [np.fliplr(np.cumprod(np.cos(Vars[:, :self.M - 1] ** alpha * np.pi / 2), 1)), ones_metrix]) * np.hstack( + [ones_metrix, np.sin(Vars[:, range(self.M - 2, -1, -1)] ** alpha * np.pi / 2)]) * (1 + g) + # 计算违反约束程度矩阵的值 + CV = 1 - f**2 / 4 - (np.sum(f**2, axis=1, keepdims=True) - f**2) + return f, CV + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + referenceObjV, ans = ea.crtup(self.M, 10000) # 生成10000个在各目标的单位维度上均匀分布的参考点 + referenceObjV /= np.sqrt( + np.sum(referenceObjV ** 2, 1, keepdims=True) - 3 / 4 * np.max(referenceObjV ** 2, 1, keepdims=True)) + return referenceObjV diff --git a/geatpy/benchmarks/mops/cf/CF1.py b/geatpy/benchmarks/mops/cf/CF1.py new file mode 100644 index 00000000..9275b39c --- /dev/null +++ b/geatpy/benchmarks/mops/cf/CF1.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class CF1(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=10): # M : 目标维数;Dim : 决策变量维数 + name = 'CF1' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + J1 = np.arange(2, self.Dim, 2) + J2 = np.arange(1, self.Dim, 2) + f1 = x1 + 2 * np.mean((Vars[:, J1] - np.abs(x1) ** (0.5 * (1 + 3 * (J1 + 1 - 2) / (self.Dim - 2)))) ** 2, 1, + keepdims=True) + f2 = 1 - x1 + 2 * np.mean((Vars[:, J2] - np.abs(x1) ** (0.5 * (1 + 3 * (J2 + 1 - 2) / (self.Dim - 2)))) ** 2, 1, + keepdims=True) + ObjV = np.hstack([f1, f2]) + CV = 1 - f1 - f2 + np.abs(np.sin(10 * np.pi * (f1 - f2 + 1))) + return ObjV, CV + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + ObjV1 = np.linspace(0, 1, 21) + ObjV2 = 1 - ObjV1 + referenceObjV = np.array([ObjV1, ObjV2]).T + return referenceObjV diff --git a/geatpy/benchmarks/mops/cf/CF2.py b/geatpy/benchmarks/mops/cf/CF2.py new file mode 100644 index 00000000..f7903d88 --- /dev/null +++ b/geatpy/benchmarks/mops/cf/CF2.py @@ -0,0 +1,40 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class CF2(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=10): # M : 目标维数;Dim : 决策变量维数 + name = 'CF2' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] + [-1] * (Dim - 1) # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + J1 = np.arange(2, self.Dim, 2) + J2 = np.arange(1, self.Dim, 2) + tmp = 6 * np.pi * x1 + f1 = x1 + 2 * np.mean((Vars[:, J1] - np.sin(tmp + np.pi / self.Dim * (J1 + 1))) ** 2, 1, + keepdims=True) + f2 = 1 - np.sqrt(np.abs(x1)) + 2 * np.mean( + (Vars[:, J2] - np.cos(tmp + np.pi / self.Dim * (J2 + 1))) ** 2, 1, keepdims=True) + ObjV = np.hstack([f1, f2]) + tmp = np.sqrt(np.abs(f1)) + tmp = f2 + tmp - np.sin(2 * np.pi * (tmp - f2 + 1)) - 1 + CV = -tmp / (1 + np.exp(4 * np.abs(tmp))) + return ObjV, CV + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 生成10000个参考点 + ObjV1 = np.linspace(0, 1, N) + ObjV2 = 1 - np.sqrt(ObjV1) + referenceObjV = np.array([ObjV1, ObjV2]).T + deleteIdx = np.where((0 < ObjV1) & (ObjV1 < 1 / 16) | (1 / 4 < ObjV1) & (ObjV1 < 9 / 16))[0] + return np.delete(referenceObjV, deleteIdx, 0) diff --git a/geatpy/benchmarks/mops/conp/Conp.py b/geatpy/benchmarks/mops/conp/Conp.py new file mode 100644 index 00000000..6bfa9fc9 --- /dev/null +++ b/geatpy/benchmarks/mops/conp/Conp.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class CON(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'CON' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 2 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0.1, 0] # 决策变量下界 + ub = [1, 5] # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + x2 = Vars[:, [1]] + f1 = x1 + f2 = (1 + x2) / x1 + # # 采用罚函数法处理约束 + # exIdx1 = np.where(x2 + 9*x1 < 6)[0] + # exIdx2 = np.where(-x2 + 9 * x1 < 1)[0] + # exIdx = np.unique(np.hstack([exIdx1, exIdx2])) + # alpha = 2 # 惩罚缩放因子 + # beta = 1 # 惩罚最小偏移量 + # f1[exIdx] = f1[exIdx] + self.maxormins[0] * alpha * (np.max(f1)-np.min(f1)+beta) + # f2[exIdx] = f2[exIdx] + self.maxormins[1] * alpha * (np.max(f2)-np.min(f2)+beta) + # 采用可行性法则处理约束 + CV = np.hstack([6 - x2 - 9 * x1, + 1 + x2 - 9 * x1]) + f = np.hstack([f1, f2]) + return f, CV diff --git a/geatpy/benchmarks/mops/dtlz/DTLZ1.py b/geatpy/benchmarks/mops/dtlz/DTLZ1.py new file mode 100644 index 00000000..07a05661 --- /dev/null +++ b/geatpy/benchmarks/mops/dtlz/DTLZ1.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class DTLZ1(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'DTLZ1' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 4 # 初始化Dim(决策变量维数) + varTypes = np.array([0] * Dim) # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + XM = Vars[:, (self.M - 1):] + g = 100 * (self.Dim - self.M + 1 + np.sum(((XM - 0.5) ** 2 - np.cos(20 * np.pi * (XM - 0.5))), 1, + keepdims=True)) + ones_metrix = np.ones((Vars.shape[0], 1)) + f = 0.5 * np.hstack([np.fliplr(np.cumprod(Vars[:, :self.M - 1], 1)), ones_metrix]) * np.hstack( + [ones_metrix, 1 - Vars[:, range(self.M - 2, -1, -1)]]) * (1 + g) + return f + + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + uniformPoint, ans = ea.crtup(self.M, 10000) # 生成10000个在各目标的单位维度上均匀分布的参考点 + referenceObjV = uniformPoint / 2 + return referenceObjV diff --git a/geatpy/benchmarks/mops/dtlz/DTLZ2.py b/geatpy/benchmarks/mops/dtlz/DTLZ2.py new file mode 100644 index 00000000..4386ca6c --- /dev/null +++ b/geatpy/benchmarks/mops/dtlz/DTLZ2.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class DTLZ2(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'DTLZ2' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + XM = Vars[:, (self.M - 1):] + g = np.sum((XM - 0.5) ** 2, 1, keepdims=True) + ones_metrix = np.ones((g.shape[0], 1)) + f = np.hstack([np.fliplr(np.cumprod(np.cos(Vars[:, :self.M - 1] * np.pi / 2), 1)), ones_metrix]) * np.hstack( + [ones_metrix, np.sin(Vars[:, range(self.M - 2, -1, -1)] * np.pi / 2)]) * (1 + g) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + uniformPoint, ans = ea.crtup(self.M, 10000) # 生成10000个在各目标的单位维度上均匀分布的参考点 + referenceObjV = uniformPoint / np.tile(np.sqrt(np.sum(uniformPoint ** 2, 1, keepdims=True)), (1, self.M)) + return referenceObjV diff --git a/geatpy/benchmarks/mops/dtlz/DTLZ3.py b/geatpy/benchmarks/mops/dtlz/DTLZ3.py new file mode 100644 index 00000000..1f04e1e1 --- /dev/null +++ b/geatpy/benchmarks/mops/dtlz/DTLZ3.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class DTLZ3(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'DTLZ3' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + XM = Vars[:, (self.M - 1):] + g = 100 * (self.Dim - self.M + 1 + np.sum(((XM - 0.5) ** 2 - np.cos(20 * np.pi * (XM - 0.5))), 1, + keepdims=True)) + ones_metrix = np.ones((Vars.shape[0], 1)) + f = np.hstack([np.fliplr(np.cumprod(np.cos(Vars[:, :self.M - 1] * np.pi / 2), 1)), ones_metrix]) * np.hstack( + [ones_metrix, np.sin(Vars[:, range(self.M - 2, -1, -1)] * np.pi / 2)]) * (1 + g) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + uniformPoint, ans = ea.crtup(self.M, 10000) # 生成10000个在各目标的单位维度上均匀分布的参考点 + referenceObjV = uniformPoint / np.tile(np.sqrt(np.sum(uniformPoint ** 2, 1, keepdims=True)), (1, self.M)) + return referenceObjV diff --git a/geatpy/benchmarks/mops/dtlz/DTLZ4.py b/geatpy/benchmarks/mops/dtlz/DTLZ4.py new file mode 100644 index 00000000..faed26a9 --- /dev/null +++ b/geatpy/benchmarks/mops/dtlz/DTLZ4.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class DTLZ4(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'DTLZ4' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + alpha = 100 + XM = Vars[:, (self.M - 1):] + g = np.sum((XM - 0.5) ** 2, 1, keepdims=True) + ones_metrix = np.ones((g.shape[0], 1)) + f = np.hstack( + [np.fliplr(np.cumprod(np.cos(Vars[:, :self.M - 1] ** alpha * np.pi / 2), 1)), ones_metrix]) * np.hstack( + [ones_metrix, np.sin(Vars[:, range(self.M - 2, -1, -1)] ** alpha * np.pi / 2)]) * (1 + g) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + uniformPoint, ans = ea.crtup(self.M, 10000) # 生成10000个在各目标的单位维度上均匀分布的参考点 + referenceObjV = uniformPoint / np.tile(np.sqrt(np.sum(uniformPoint ** 2, 1, keepdims=True)), (1, self.M)) + return referenceObjV diff --git a/geatpy/benchmarks/mops/dtlz/DTLZ5.py b/geatpy/benchmarks/mops/dtlz/DTLZ5.py new file mode 100644 index 00000000..566a27e2 --- /dev/null +++ b/geatpy/benchmarks/mops/dtlz/DTLZ5.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class DTLZ5(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'DTLZ5' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + _Phen = Vars.copy() # 为了后面计算不影响函数外部的值,这里进行矩阵复制 + XM = _Phen[:, (self.M - 1):] + g = np.sum((XM - 0.5) ** 2, 1, keepdims=True) + g_rep = np.tile(g, (1, self.M - 2)) # 复制g,使其维度与后面与之点乘的矩阵一致 + _Phen[:, 1:self.M - 1] = (1 + 2 * g_rep * Vars[:, 1:self.M - 1]) / (2 + 2 * g_rep) + ones_metrix = np.ones((g.shape[0], 1)) + f = np.hstack([np.fliplr(np.cumprod(np.cos(_Phen[:, :self.M - 1] * np.pi / 2), 1)), ones_metrix]) * np.hstack( + [ones_metrix, np.sin(_Phen[:, range(self.M - 2, -1, -1)] * np.pi / 2)]) * (1 + g) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 生成10000个参考点 + P = np.vstack([np.linspace(0, 1, N), np.linspace(1, 0, N)]).T + P = P / np.tile(np.sqrt(np.sum(P ** 2, 1, keepdims=True)), (1, P.shape[1])) + P = np.hstack([P[:, np.zeros(self.M - 2, dtype=np.int)], P]) + referenceObjV = P / np.sqrt(2) ** np.tile(np.hstack([self.M - 2, np.linspace(self.M - 2, 0, self.M - 1)]), + (P.shape[0], 1)) + return referenceObjV diff --git a/geatpy/benchmarks/mops/dtlz/DTLZ6.py b/geatpy/benchmarks/mops/dtlz/DTLZ6.py new file mode 100644 index 00000000..a184fb56 --- /dev/null +++ b/geatpy/benchmarks/mops/dtlz/DTLZ6.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class DTLZ6(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'DTLZ6' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + _Phen = Vars.copy() # 为了后面计算不影响函数外部的值,这里进行矩阵复制 + XM = _Phen[:, (self.M - 1):] + g = np.sum(np.abs(XM) ** 0.1, 1, keepdims=True) + g_rep = np.tile(g, (1, self.M - 2)) # 复制g,使其维度与后面与之点乘的矩阵一致 + _Phen[:, 1:self.M - 1] = (1 + 2 * g_rep * Vars[:, 1:self.M - 1]) / (2 + 2 * g_rep) + ones_metrix = np.ones((g.shape[0], 1)) + f = np.hstack([np.fliplr(np.cumprod(np.cos(_Phen[:, :self.M - 1] * np.pi / 2), 1)), ones_metrix]) * np.hstack( + [ones_metrix, np.sin(_Phen[:, range(self.M - 2, -1, -1)] * np.pi / 2)]) * (1 + g) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 生成10000个参考点 + P = np.vstack([np.linspace(0, 1, N), np.linspace(1, 0, N)]).T + P = P / np.tile(np.sqrt(np.sum(P ** 2, 1, keepdims=True)), (1, P.shape[1])) + P = np.hstack([P[:, np.zeros(self.M - 2, dtype=np.int)], P]) + referenceObjV = P / np.sqrt(2) ** np.tile(np.hstack([self.M - 2, np.linspace(self.M - 2, 0, self.M - 1)]), + (P.shape[0], 1)) + return referenceObjV diff --git a/geatpy/benchmarks/mops/dtlz/DTLZ7.py b/geatpy/benchmarks/mops/dtlz/DTLZ7.py new file mode 100644 index 00000000..62a18829 --- /dev/null +++ b/geatpy/benchmarks/mops/dtlz/DTLZ7.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class DTLZ7(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'DTLZ7' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 19 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + _Phen = Vars.copy() # 为了后面计算不影响函数外部的值,这里进行矩阵复制 + ObjV = np.zeros((Vars.shape[0], self.M)) + XM = _Phen[:, (self.M - 1):] + g = 1 + 9 * np.mean(XM, 1, keepdims=True) + ObjV_tmp = Vars[:, :self.M - 1] + ObjV[:, :self.M - 1] = ObjV_tmp + ObjV[:, [self.M - 1]] = (1 + g) * self.M - np.sum(ObjV_tmp * (1 + np.sin(3 * np.pi * ObjV_tmp)), 1, + keepdims=True) + return ObjV + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 1000 # 欲生成10000个全局帕累托最优解 + # 参数a,b,c为求解方程得到,详见DTLZ7的参考文献 + a = 0.2514118360889171 + b = 0.6316265307000614 + c = 0.8594008566447239 + Vars, Sizes = ea.crtgp(self.M - 1, N) # 生成单位超空间内均匀的网格点集 + middle = 0.5 + left = Vars <= middle + right = Vars > middle + maxs_Left = np.max(Vars[left]) + if maxs_Left > 0: + Vars[left] = Vars[left] / maxs_Left * a + Vars[right] = (Vars[right] - middle) / (np.max(Vars[right]) - middle) * (c - b) + b + P = np.hstack([Vars, (2 * self.M - np.sum(Vars * (1 + np.sin(3 * np.pi * Vars)), 1, keepdims=True))]) + referenceObjV = P + return referenceObjV diff --git a/geatpy/benchmarks/mops/fonseca/Fonseca.py b/geatpy/benchmarks/mops/fonseca/Fonseca.py new file mode 100644 index 00000000..38a9475b --- /dev/null +++ b/geatpy/benchmarks/mops/fonseca/Fonseca.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class Fonseca(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=5): # M : 目标维数;Dim : 决策变量维数 + name = 'Fonseca' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-4] * Dim # 决策变量下界 + ub = [4] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + f1 = 1 - np.exp(-np.sum((Vars - 1 / np.sqrt(self.Dim)) ** 2, 1, keepdims=True)) + f2 = 1 - np.exp(-np.sum((Vars + 1 / np.sqrt(self.Dim)) ** 2, 1, keepdims=True)) + f = np.hstack([f1, f2]) + return f + + def calReferObjV(self): # 设定目标数参考值 + return None diff --git a/geatpy/benchmarks/mops/imop/IMOP1.py b/geatpy/benchmarks/mops/imop/IMOP1.py new file mode 100644 index 00000000..fcbd6aa8 --- /dev/null +++ b/geatpy/benchmarks/mops/imop/IMOP1.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class IMOP1(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=10, Alpha=0.05, K=5): # M : 目标维数;Dim : 决策变量维数 + name = 'IMOP1' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = np.array([0] * Dim) # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + self.Alpha = Alpha + self.K = K + + def evalVars(self, Vars): # 目标函数 + temp = np.abs(np.mean(Vars[:, :self.K], 1)) ** self.Alpha # 取绝对值,避免因浮点数精度而导致的小于0 + g = np.sum((Vars[:, self.K:] - 0.5) ** 2, 1) + ObjV1 = g + np.cos(temp * np.pi / 2) ** 8 + ObjV2 = g + np.sin(temp * np.pi / 2) ** 8 + f = np.array([ObjV1, ObjV2]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + Num = 10000 # 生成10000个参考点 + temp = np.linspace(0.5 ** 4, 1, Num // 2) + ObjV1 = np.hstack([temp, (1 - temp ** 0.25) ** 4]) + ObjV2 = np.hstack([(1 - temp ** 0.25) ** 4, temp]) + return np.array([ObjV1, ObjV2]).T diff --git a/geatpy/benchmarks/mops/imop/IMOP2.py b/geatpy/benchmarks/mops/imop/IMOP2.py new file mode 100644 index 00000000..5a8d5462 --- /dev/null +++ b/geatpy/benchmarks/mops/imop/IMOP2.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class IMOP2(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=10, Alpha=0.05, K=5): # M : 目标维数;Dim : 决策变量维数 + name = 'IMOP2' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = np.array([0] * Dim) # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + self.Alpha = Alpha + self.K = K + + def evalVars(self, Vars): # 目标函数 + temp = np.abs(np.mean(Vars[:, :self.K], 1)) ** self.Alpha # 取绝对值,避免因浮点数精度而导致的小于0 + g = np.sum((Vars[:, self.K:] - 0.5) ** 2, 1) + ObjV1 = g + np.abs(np.cos(temp * np.pi / 2)) ** 0.5 + ObjV2 = g + np.abs(np.sin(temp * np.pi / 2)) ** 0.5 + f = np.array([ObjV1, ObjV2]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + Num = 10000 # 生成10000个参考点 + temp = np.linspace(0, 0.5 ** 0.25, Num // 2) + ObjV1 = np.hstack([temp, (1 - temp ** 4) ** 0.25]) + ObjV2 = np.hstack([(1 - temp ** 4) ** 0.25, temp]) + return np.array([ObjV1, ObjV2]).T diff --git a/geatpy/benchmarks/mops/imop/IMOP3.py b/geatpy/benchmarks/mops/imop/IMOP3.py new file mode 100644 index 00000000..e0868fef --- /dev/null +++ b/geatpy/benchmarks/mops/imop/IMOP3.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class IMOP3(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=10, Alpha=0.05, K=5): # M : 目标维数;Dim : 决策变量维数 + name = 'IMOP3' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = np.array([0] * Dim) # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + self.Alpha = Alpha + self.K = K + + def evalVars(self, Vars): # 目标函数 + temp = np.abs(np.mean(Vars[:, :self.K], 1)) ** self.Alpha # 取绝对值,避免因浮点数精度而导致的小于0 + g = np.sum((Vars[:, self.K:] - 0.5) ** 2, 1) + ObjV1 = g + (1 + np.cos(temp * np.pi * 10) / 5 - temp) + ObjV2 = g + temp + f = np.array([ObjV1, ObjV2]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + Num = 10000 # 生成10000个参考点 + temp = np.linspace(0, 1, Num) + ObjV1 = 1 + np.cos(temp * np.pi * 10) / 5 - temp + ObjV2 = temp + referenceObjV = np.array([ObjV1, ObjV2]).T + [levels, criLevel] = ea.ndsortDED(referenceObjV, None, 1) + referenceObjV = referenceObjV[np.where(levels == 1)[0], :] + return referenceObjV diff --git a/geatpy/benchmarks/mops/imop/IMOP4.py b/geatpy/benchmarks/mops/imop/IMOP4.py new file mode 100644 index 00000000..290fd0a7 --- /dev/null +++ b/geatpy/benchmarks/mops/imop/IMOP4.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class IMOP4(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=3, Alpha=0.05, K=5): # M : 目标维数;Dim : 决策变量维数 + name = 'IMOP4' # 初始化name(函数名称,可以随意设置) + M = 3 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = np.array([0] * Dim) # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + self.Alpha = Alpha + self.K = K + + def evalVars(self, Vars): # 目标函数 + temp = np.abs(np.mean(Vars[:, :self.K], 1)) ** self.Alpha # 取绝对值,避免因浮点数精度而导致的小于0 + g = np.sum((Vars[:, self.K:] - 0.5) ** 2, 1) + ObjV1 = (1 + g) * temp + ObjV2 = (1 + g) * (temp + np.sin(10 * np.pi * temp) / 10) + ObjV3 = (1 + g) * (1 - temp) + f = np.array([ObjV1, ObjV2, ObjV3]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + Num = 10000 # 生成10000个参考点 + ObjV1 = np.linspace(0, 1, Num) + ObjV2 = ObjV1 + np.sin(10 * np.pi * ObjV1) / 10 + ObjV3 = 1 - ObjV1 + return np.array([ObjV1, ObjV2, ObjV3]).T diff --git a/geatpy/benchmarks/mops/osy/OSY.py b/geatpy/benchmarks/mops/osy/OSY.py new file mode 100644 index 00000000..37b3d043 --- /dev/null +++ b/geatpy/benchmarks/mops/osy/OSY.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class OSY(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'OSY' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 6 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0, 0, 1, 0, 1, 0] # 决策变量下界 + ub = [10, 10, 5, 6, 5, 10] # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, X): # 目标函数 + x1 = X[:, [0]] + x2 = X[:, [1]] + x3 = X[:, [2]] + x4 = X[:, [3]] + x5 = X[:, [4]] + x6 = X[:, [5]] + f1 = -(25 * (x1 - 2) ** 2 + (x2 - 2) ** 2 + (x3 - 1) ** 2 + (x4 - 4) ** 2 + (x5 - 1) ** 2) + f2 = np.sum(X ** 2, 1, keepdims=True) + # # 罚函数法处理约束 + # exIdx1 = np.where(x1+x2-2<0)[0] + # exIdx2 = np.where(6-x1-x2<0)[0] + # exIdx3 = np.where(2-x2+x1<0)[0] + # exIdx4 = np.where(2-x1+3*x2<0)[0] + # exIdx5 = np.where(4-(x3-3)**2-x4<0)[0] + # exIdx6 = np.where((x5-3)**2+x6-4<0)[0] + # exIdx = np.unique(np.hstack([exIdx1, exIdx2, exIdx3, exIdx4, exIdx5, exIdx6])) + # alpha = 2 # 惩罚缩放因子 + # beta = 1 # 惩罚最小偏移量 + # f1[exIdx] = f1[exIdx] + self.maxormins[0] * alpha * (np.max(f1)-np.min(f1)+beta) + # f2[exIdx] = f2[exIdx] + self.maxormins[1] * alpha * (np.max(f2)-np.min(f2)+beta) + f = np.hstack([f1, f2]) + return f diff --git a/geatpy/benchmarks/mops/srn/SRN.py b/geatpy/benchmarks/mops/srn/SRN.py new file mode 100644 index 00000000..5f9b35f3 --- /dev/null +++ b/geatpy/benchmarks/mops/srn/SRN.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class SRN(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'SRN' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 2 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-20] * Dim # 决策变量下界 + ub = [20] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + x2 = Vars[:, [1]] + f1 = 2 + (x1 - 2) ** 2 + (x2 - 1) ** 2 + f2 = 9 * x1 - (x2 - 1) ** 2 + # # 采用罚函数法处理约束 + # exIdx1 = np.where(x1**2 + x2**2 > 225)[0] + # exIdx2 = np.where(x1 - 3 * x2 + 10 > 0)[0] + # exIdx = np.unique(np.hstack([exIdx1, exIdx2])) + # alpha = 2 # 惩罚缩放因子 + # beta = 1 # 惩罚最小偏移量 + # f1[exIdx] = f1[exIdx] + self.maxormins[0] * alpha * (np.max(f1)-np.min(f1)+beta) + # f2[exIdx] = f2[exIdx] + self.maxormins[1] * alpha * (np.max(f2)-np.min(f2)+beta) + # 采用可行性法则处理约束 + CV = np.hstack([x1 ** 2 + x2 ** 2 - 225, + x1 - 3 * x2 + 10]) + ObjV = np.hstack([f1, f2]) + return ObjV, CV \ No newline at end of file diff --git a/geatpy/benchmarks/mops/tnk/TNK.py b/geatpy/benchmarks/mops/tnk/TNK.py new file mode 100644 index 00000000..12c3dc03 --- /dev/null +++ b/geatpy/benchmarks/mops/tnk/TNK.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class TNK(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'TNK' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 2 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [np.pi] * Dim # 决策变量上界 + lbin = [1, 0] # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + x2 = Vars[:, [1]] + # 采用可行性法则处理约束 + CV = np.hstack([-(x1 ** 2 + x2 ** 2 - 1 - 0.1 * np.cos(16 * np.arctan(x1 / x2))), + (x1 - 0.5) ** 2 + (x2 - 0.5) ** 2 - 0.5]) + + ObjV = Vars.copy() + return ObjV, CV diff --git a/geatpy/benchmarks/mops/uf/UF1.py b/geatpy/benchmarks/mops/uf/UF1.py new file mode 100644 index 00000000..2f884440 --- /dev/null +++ b/geatpy/benchmarks/mops/uf/UF1.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class UF1(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=30): # M : 目标维数;Dim : 决策变量维数 + name = 'UF1' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] + [-1] * (Dim - 1) # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + J1 = np.arange(2, self.Dim, 2) + J2 = np.arange(1, self.Dim, 2) + tmp = 6 * np.pi * x1 + f1 = x1 + 2 * np.mean((Vars[:, J1] - np.sin(tmp + np.pi / self.Dim * (J1 + 1))) ** 2, 1, keepdims=True) + f2 = 1 - np.sqrt(np.abs(x1)) + 2 * np.mean((Vars[:, J2] - np.sin(tmp + np.pi / self.Dim * (J2 + 1))) ** 2, 1, + keepdims=True) + f = np.hstack([f1, f2]) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 生成10000个参考点 + ObjV1 = np.linspace(0, 1, N) + ObjV2 = 1 - np.sqrt(ObjV1) + referenceObjV = np.array([ObjV1, ObjV2]).T + return referenceObjV diff --git a/geatpy/benchmarks/mops/uf/UF2.py b/geatpy/benchmarks/mops/uf/UF2.py new file mode 100644 index 00000000..d84dfba9 --- /dev/null +++ b/geatpy/benchmarks/mops/uf/UF2.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class UF2(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=30): # M : 目标维数;Dim : 决策变量维数 + name = 'UF2' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] + [-1] * (Dim - 1) # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + J1 = np.array(list(range(2, self.Dim, 2))) + J2 = np.array(list(range(1, self.Dim, 2))) + yJ1 = Vars[:, J1] - ( + 0.3 * x1 ** 2 * np.cos(24 * np.pi * x1 + 4 * (J1 + 1) * np.pi / self.Dim) + 0.6 * x1) * np.cos( + 6 * np.pi * x1 + (J1 + 1) * np.pi / self.Dim) + yJ2 = Vars[:, J2] - ( + 0.3 * x1 ** 2 * np.cos(24 * np.pi * x1 + 4 * (J2 + 1) * np.pi / self.Dim) + 0.6 * x1) * np.sin( + 6 * np.pi * x1 + (J2 + 1) * np.pi / self.Dim) + f1 = x1 + 2 * np.mean((yJ1) ** 2, 1, keepdims=True) + f2 = 1 - np.sqrt(np.abs(x1)) + 2 * np.mean((yJ2) ** 2, 1, keepdims=True) + f = np.hstack([f1, f2]) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 生成10000个参考点 + ObjV1 = np.linspace(0, 1, N) + ObjV2 = 1 - np.sqrt(ObjV1) + referenceObjV = np.array([ObjV1, ObjV2]).T + return referenceObjV diff --git a/geatpy/benchmarks/mops/wfg/WFG1.py b/geatpy/benchmarks/mops/wfg/WFG1.py new file mode 100644 index 00000000..2e0cda68 --- /dev/null +++ b/geatpy/benchmarks/mops/wfg/WFG1.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class WFG1(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'WFG1' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = list(range(2, 2 * Dim + 1, 2)) # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + # 目标函数中用到的一些参数设置 + self.K = self.M - 1 + self.L = self.Dim - self.K + self.S = np.array([list(range(2, 2 * self.M + 1, 2))]) + self.D = 1 + self.A = np.ones((1, self.M - 1)) + + def evalVars(self, Vars): # 目标函数 + N, Lind = Vars.shape + M = self.M + K = self.K + L = self.L + S = self.S + D = self.D + A = np.tile(self.A, (N, 1)) + Z = Vars / np.array([range(2, 2 * Lind + 1, 2)]) + t1 = np.zeros((N, K + L)) + t1[:, :K] = Z[:, :K] + t1[:, K:] = s_linear(Z[:, K:], 0.35) + t2 = np.zeros((N, K + L)) + t2[:, :K] = t1[:, :K] + t2[:, K:] = b_flat(t1[:, K:], 0.8, 0.75, 0.85) + t3 = b_poly(t2, 0.02) + t4 = np.zeros((N, M)) + K_divide_M_sub_1 = int(K / (M - 1)) + for i in range(1, M): + t4[:, i - 1] = r_sum(t3[:, list(range((i - 1) * K_divide_M_sub_1, i * K_divide_M_sub_1))], + list(range(2 * (i - 1) * K_divide_M_sub_1 + 1, 2 * i * K_divide_M_sub_1 + 1, 2))) + t4[:, M - 1] = r_sum(t3[:, K: K + L], list(range(2 * (K + 1), 2 * (K + L) + 1, 2))) + x = np.zeros((N, M)) + for i in range(1, M): + x[:, [i - 1]] = np.max([t4[:, [M - 1]], A[:, [i - 1]]], 0) * (t4[:, [i - 1]] - 0.5) + 0.5 + x[:, [M - 1]] = t4[:, [M - 1]] + h = convex(x) + h[:, [M - 1]] = mixed(x) + f = D * x[:, [M - 1]] + S * h + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 设置所要生成的全局最优解的个数 + Point, num = ea.crtup(self.M, N) # 生成N个在各目标的单位维度上均匀分布的参考点 + M = self.M + c = np.ones((num, M)) + for i in range(num): + for j in range(1, M): + temp = Point[i, j] / Point[i, 0] * np.prod(1 - c[i, M - j: M - 1]) + c[i, M - j - 1] = (temp ** 2 - temp + np.sqrt(2 * temp)) / (temp ** 2 + 1) + x = np.arccos(c) * 2 / np.pi + temp = (1 - np.sin(np.pi / 2 * x[:, [1]])) * Point[:, [M - 1]] / Point[:, [M - 2]] + a = np.linspace(0, 1, 10000 + 1) + for i in range(num): + E = np.abs(temp[i] * (1 - np.cos(np.pi / 2 * a)) - 1 + a + np.cos(10 * np.pi * a + np.pi / 2) / 10 / np.pi) + rank = np.argsort(E, kind='mergesort') + x[i, 0] = a[np.min(rank[0: 10])] + Point = convex(x) + Point[:, [M - 1]] = mixed(x) + referenceObjV = np.array([list(range(2, 2 * self.M + 1, 2))]) * Point + return referenceObjV + + +def convex(x): + return np.fliplr( + np.cumprod(np.hstack([np.ones((x.shape[0], 1)), 1 - np.cos(x[:, :-1] * np.pi / 2)]), 1)) * np.hstack( + [np.ones((x.shape[0], 1)), 1 - np.sin(x[:, list(range(x.shape[1] - 1 - 1, -1, -1))] * np.pi / 2)]) + + +def mixed(x): + return 1 - x[:, [0]] - np.cos(10 * np.pi * x[:, [0]] + np.pi / 2) / 10 / np.pi + + +def s_linear(x, A): + return np.abs(x - A) / np.abs(np.floor(A - x) + A) + + +def b_flat(x, A, B, C): + Output = A + np.min([0 * np.floor(x - B), np.floor(x - B)], 0) * A * (B - x) / B - np.min( + [0 * np.floor(C - x), np.floor(C - x)], 0) * (1 - A) * (x - C) / (1 - C) + return np.round(Output, 6) + + +def b_poly(x, a): + return np.sign(x) * np.abs(x) ** a + + +def r_sum(x, w): + Output = np.sum(x * w, 1) / np.sum(w) + return Output diff --git a/geatpy/benchmarks/mops/wfg/WFG2.py b/geatpy/benchmarks/mops/wfg/WFG2.py new file mode 100644 index 00000000..f8eb8420 --- /dev/null +++ b/geatpy/benchmarks/mops/wfg/WFG2.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class WFG2(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'WFG2' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = list(range(2, 2 * Dim + 1, 2)) # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + # 目标函数中用到的一些参数设置 + self.K = self.M - 1 + self.L = self.Dim - self.K + self.S = np.array([list(range(2, 2 * self.M + 1, 2))]) + self.D = 1 + self.A = np.ones((1, self.M - 1)) + + def evalVars(self, Vars): # 目标函数 + N, Lind = Vars.shape + M = self.M + K = self.K + L = self.L + S = self.S + D = self.D + A = np.tile(self.A, (N, 1)) + Z = Vars / np.array([range(2, Lind * 2 + 1, 2)]) + t1 = np.zeros((N, K + L)) + t1[:, :K] = Z[:, :K] + t1[:, K:] = s_linear(Z[:, K:], 0.35) + t2 = np.zeros((N, int(K + L / 2))) + t2[:, :K] = t1[:, :K] + t2[:, K: int(K + L / 2)] = (t1[:, K:: 2] + t1[:, K + 1:: 2] + 2 * np.abs(t1[:, K:: 2] - t1[:, K + 1:: 2])) / 3 + t3 = np.ones((N, M)) + K_divide_M_sub_1 = int(K / (M - 1)) + for i in range(1, M): + t3[:, i - 1] = r_sum(t2[:, list(range((i - 1) * K_divide_M_sub_1, i * K_divide_M_sub_1))], + np.ones((1, K_divide_M_sub_1))) + t3[:, M - 1] = r_sum(t2[:, K: int(K + L / 2)], np.ones((1, int(L / 2)))) + x = np.zeros((N, M)) + for i in range(1, M): + x[:, [i - 1]] = np.max([t3[:, [M - 1]], A[:, [i - 1]]], 0) * (t3[:, [i - 1]] - 0.5) + 0.5 + x[:, [M - 1]] = t3[:, [M - 1]] + h = convex(x) + h[:, [M - 1]] = disc(x) + f = D * x[:, [M - 1]] + S * h + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 设置所要生成的全局最优解的个数 + Point, num = ea.crtup(self.M, N) # 生成N个在各目标的单位维度上均匀分布的参考点 + M = self.M + c = np.ones((num, M)) + for i in range(num): + for j in range(1, M): + temp = Point[i, j] / Point[i, 0] * np.prod(1 - c[i, M - j: M - 1]) + c[i, M - j - 1] = (temp ** 2 - temp + np.sqrt(2 * temp)) / (temp ** 2 + 1) + x = np.arccos(c) * 2 / np.pi + temp = (1 - np.sin(np.pi / 2 * x[:, [1]])) * Point[:, [M - 1]] / Point[:, [M - 2]] + a = np.linspace(0, 1, 10000 + 1) + for i in range(num): + E = np.abs(temp[i] * (1 - np.cos(np.pi / 2 * a)) - 1 + a * np.cos(5 * np.pi * a) ** 2) + rank = np.argsort(E, kind='mergesort') + x[i, 0] = a[np.min(rank[0: 10])] + Point = convex(x) + Point[:, [M - 1]] = disc(x) + [levels, criLevel] = ea.ndsortESS(Point, None, 1) # 非支配分层,只分出第一层即可 + Point = Point[np.where(levels == 1)[0], :] # 只保留点集中的非支配点 + referenceObjV = np.array([list(range(2, 2 * self.M + 1, 2))]) * Point + return referenceObjV + + +def convex(x): + return np.fliplr( + np.cumprod(np.hstack([np.ones((x.shape[0], 1)), 1 - np.cos(x[:, :-1] * np.pi / 2)]), 1)) * np.hstack( + [np.ones((x.shape[0], 1)), 1 - np.sin(x[:, list(range(x.shape[1] - 1 - 1, -1, -1))] * np.pi / 2)]) + + +def disc(x): + return 1 - x[:, [0]] * (np.cos(5 * np.pi * x[:, [0]])) ** 2 + + +def s_linear(x, A): + return np.abs(x - A) / np.abs(np.floor(A - x) + A) + + +def r_sum(x, w): + Output = np.sum(x * w, 1) / np.sum(w) + return Output diff --git a/geatpy/benchmarks/mops/wfg/WFG3.py b/geatpy/benchmarks/mops/wfg/WFG3.py new file mode 100644 index 00000000..d99a94da --- /dev/null +++ b/geatpy/benchmarks/mops/wfg/WFG3.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class WFG3(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'WFG3' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = list(range(2, 2 * Dim + 1, 2)) # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + # 目标函数中用到的一些参数设置 + self.K = self.M - 1 + self.L = self.Dim - self.K + self.S = np.array([list(range(2, 2 * self.M + 1, 2))]) + self.D = 1 + self.A = [1] + [0] * (self.M - 2) + + def evalVars(self, Vars): # 目标函数 + N, Lind = Vars.shape + M = self.M + K = self.K + L = self.L + S = self.S + D = self.D + A = np.tile(self.A, (N, 1)) + Z = Vars / np.array([range(2, Lind * 2 + 1, 2)]) + t1 = np.zeros((N, K + L)) + t1[:, :K] = Z[:, :K] + t1[:, K:] = s_linear(Z[:, K:], 0.35) + t2 = np.zeros((N, int(K + L / 2))) + t2[:, :K] = t1[:, :K] + t2[:, K: int(K + L / 2)] = (t1[:, K:: 2] + t1[:, K + 1:: 2] + 2 * np.abs(t1[:, K:: 2] - t1[:, K + 1:: 2])) / 3 + t3 = np.ones((N, M)) + K_divide_M_sub_1 = int(K / (M - 1)) + for i in range(1, M): + t3[:, i - 1] = r_sum(t2[:, list(range((i - 1) * K_divide_M_sub_1, i * K_divide_M_sub_1))], + np.ones((1, K_divide_M_sub_1))) + t3[:, M - 1] = r_sum(t2[:, K: int(K + L / 2)], np.ones((1, int(L / 2)))) + x = np.zeros((N, M)) + for i in range(1, M): + x[:, [i - 1]] = np.max([t3[:, [M - 1]], A[:, [i - 1]]], 0) * (t3[:, [i - 1]] - 0.5) + 0.5 + x[:, [M - 1]] = t3[:, [M - 1]] + h = linear(x) + f = D * x[:, [M - 1]] + S * h + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 设置所要生成的全局最优解的个数 + X = np.hstack([np.array([np.linspace(0, 1, N)]).T, np.zeros((N, self.M - 2)) + 0.5, np.zeros((N, 1))]) + Point = linear(X) + referenceObjV = np.array([list(range(2, 2 * self.M + 1, 2))]) * Point + return referenceObjV + + +def linear(x): + return np.fliplr(np.cumprod(np.hstack([np.ones((x.shape[0], 1)), x[:, :-1]]), 1)) * np.hstack( + [np.ones((x.shape[0], 1)), 1 - x[:, list(range(x.shape[1] - 1 - 1, -1, -1))]]) + + +def s_linear(x, A): + return np.abs(x - A) / np.abs(np.floor(A - x) + A) + + +def r_sum(x, w): + Output = np.sum(x * w, 1) / np.sum(w) + return Output diff --git a/geatpy/benchmarks/mops/wfg/WFG4.py b/geatpy/benchmarks/mops/wfg/WFG4.py new file mode 100644 index 00000000..c147f0d4 --- /dev/null +++ b/geatpy/benchmarks/mops/wfg/WFG4.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class WFG4(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'WFG4' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = list(range(2, 2 * Dim + 1, 2)) # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + # 目标函数中用到的一些参数设置 + self.K = self.M - 1 + self.L = self.Dim - self.K + self.S = np.array([list(range(2, 2 * self.M + 1, 2))]) + self.D = 1 + self.A = np.ones((1, self.M - 1)) + + def evalVars(self, Vars): # 目标函数 + N, Lind = Vars.shape + M = self.M + K = self.K + L = self.L + S = self.S + D = self.D + A = np.tile(self.A, (N, 1)) + Z = Vars / np.array([range(2, Lind * 2 + 1, 2)]) + t1 = s_multi(Z, 30, 10, 0.35) + t2 = np.zeros((N, int(K + L / 2))) + t2[:, :K] = t1[:, :K] + t2[:, K: int(K + L / 2)] = (t1[:, K:: 2] + t1[:, K + 1:: 2] + 2 * np.abs(t1[:, K:: 2] - t1[:, K + 1:: 2])) / 3 + t2 = np.ones((N, M)) + K_divide_M_sub_1 = int(K / (M - 1)) + for i in range(1, M): + t2[:, i - 1] = r_sum(t1[:, list(range((i - 1) * K_divide_M_sub_1, i * K_divide_M_sub_1))], + np.ones((1, K_divide_M_sub_1))) + t2[:, M - 1] = r_sum(t1[:, K: K + L], np.ones((1, L))) + x = np.zeros((N, M)) + for i in range(1, M): + x[:, [i - 1]] = np.max([t2[:, [M - 1]], A[:, [i - 1]]], 0) * (t2[:, [i - 1]] - 0.5) + 0.5 + x[:, [M - 1]] = t2[:, [M - 1]] + h = concave(x) + f = D * x[:, [M - 1]] + S * h + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 设置所要生成的全局最优解的个数 + Point, num = ea.crtup(self.M, N) # 生成N个在各目标的单位维度上均匀分布的参考点 + Point = Point / np.sqrt(np.sum(Point ** 2, 1, keepdims=True)) + referenceObjV = np.array([list(range(2, 2 * self.M + 1, 2))]) * Point + return referenceObjV + + +def s_multi(x, A, B, C): + return (1 + np.cos((4 * A + 2) * np.pi * (0.5 - np.abs(x - C) / 2 / (np.floor(C - x) + C))) + 4 * B * ( + np.abs(x - C) / 2 / (np.floor(C - x) + C)) ** 2) / (B + 2) + + +def concave(x): + return np.fliplr(np.cumprod(np.hstack([np.ones((x.shape[0], 1)), np.sin(x[:, :-1] * np.pi / 2)]), 1)) * np.hstack( + [np.ones((x.shape[0], 1)), np.cos(x[:, list(range(x.shape[1] - 1 - 1, -1, -1))] * np.pi / 2)]) + + +def r_sum(x, w): + Output = np.sum(x * w, 1) / np.sum(w) + return Output diff --git a/geatpy/benchmarks/mops/wfg/WFG5.py b/geatpy/benchmarks/mops/wfg/WFG5.py new file mode 100644 index 00000000..6851714f --- /dev/null +++ b/geatpy/benchmarks/mops/wfg/WFG5.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class WFG5(ea.Problem): # 继承Problem父类 + def __init__(self, M=3, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'WFG5' # 初始化name(函数名称,可以随意设置) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + if Dim is None: + Dim = M + 9 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = list(range(2, 2 * Dim + 1, 2)) # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + # 目标函数中用到的一些参数设置 + self.K = self.M - 1 + self.L = self.Dim - self.K + self.S = np.array([list(range(2, 2 * self.M + 1, 2))]) + self.D = 1 + self.A = np.ones((1, self.M - 1)) + + def evalVars(self, Vars): # 目标函数 + N, Lind = Vars.shape + M = self.M + K = self.K + L = self.L + S = self.S + D = self.D + A = np.tile(self.A, (N, 1)) + Z = Vars / np.array([range(2, Lind * 2 + 1, 2)]) + t1 = s_decept(Z, 0.35, 0.001, 0.05) + t2 = np.zeros((N, int(K + L / 2))) + t2[:, :K] = t1[:, :K] + t2[:, K: int(K + L / 2)] = (t1[:, K:: 2] + t1[:, K + 1:: 2] + 2 * np.abs(t1[:, K:: 2] - t1[:, K + 1:: 2])) / 3 + t2 = np.ones((N, M)) + K_divide_M_sub_1 = int(K / (M - 1)) + for i in range(1, M): + t2[:, i - 1] = r_sum(t1[:, list(range((i - 1) * K_divide_M_sub_1, i * K_divide_M_sub_1))], + np.ones((1, K_divide_M_sub_1))) + t2[:, M - 1] = r_sum(t1[:, K: K + L], np.ones((1, L))) + x = np.zeros((N, M)) + for i in range(1, M): + x[:, [i - 1]] = np.max([t2[:, [M - 1]], A[:, [i - 1]]], 0) * (t2[:, [i - 1]] - 0.5) + 0.5 + x[:, [M - 1]] = t2[:, [M - 1]] + h = concave(x) + f = D * x[:, [M - 1]] + S * h + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 设置所要生成的全局最优解的个数 + Point, num = ea.crtup(self.M, N) # 生成N个在各目标的单位维度上均匀分布的参考点 + Point = Point / np.sqrt(np.sum(Point ** 2, 1, keepdims=True)) + referenceObjV = np.array([list(range(2, 2 * self.M + 1, 2))]) * Point + return referenceObjV + + +def s_decept(x, A, B, C): + return 1 + (np.abs(x - A) - B) * (np.floor(x - A + B) * (1 - C + (A - B) / B) / (A - B) + np.floor(A + B - x) * ( + 1 - C + (1 - A - B) / B) / (1 - A - B) + 1 / B) + + +def concave(x): + return np.fliplr(np.cumprod(np.hstack([np.ones((x.shape[0], 1)), np.sin(x[:, :-1] * np.pi / 2)]), 1)) * np.hstack( + [np.ones((x.shape[0], 1)), np.cos(x[:, list(range(x.shape[1] - 1 - 1, -1, -1))] * np.pi / 2)]) + + +def r_sum(x, w): + Output = np.sum(x * w, 1) / np.sum(w) + return Output diff --git a/geatpy/benchmarks/mops/zdt/ZDT1.py b/geatpy/benchmarks/mops/zdt/ZDT1.py new file mode 100644 index 00000000..47ad4828 --- /dev/null +++ b/geatpy/benchmarks/mops/zdt/ZDT1.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class ZDT1(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=30): # M : 目标维数;Dim : 决策变量维数 + name = 'ZDT1' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + ObjV1 = Vars[:, 0] + gx = 1 + 9 * np.sum(Vars[:, 1:], 1) / (self.Dim - 1) + hx = 1 - np.sqrt(np.abs(Vars[:, 0] / gx)) # 取绝对值是为了避免浮点数精度异常带来的影响 + ObjV2 = gx * hx + f = np.array([ObjV1, ObjV2]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 生成10000个参考点 + ObjV1 = np.linspace(0, 1, N) + ObjV2 = 1 - np.sqrt(ObjV1) + referenceObjV = np.array([ObjV1, ObjV2]).T + return referenceObjV diff --git a/geatpy/benchmarks/mops/zdt/ZDT2.py b/geatpy/benchmarks/mops/zdt/ZDT2.py new file mode 100644 index 00000000..7573a5d1 --- /dev/null +++ b/geatpy/benchmarks/mops/zdt/ZDT2.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class ZDT2(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=30): # M : 目标维数;Dim : 决策变量维数 + name = 'ZDT2' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + ObjV1 = Vars[:, 0] + gx = 1 + 9 * np.sum(Vars[:, 1:], 1) / (self.Dim - 1) + hx = 1 - (ObjV1 / gx) ** 2 + ObjV2 = gx * hx + f = np.array([ObjV1, ObjV2]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 生成10000个参考点 + ObjV1 = np.linspace(0, 1, N) + ObjV2 = 1 - ObjV1 ** 2 + referenceObjV = np.array([ObjV1, ObjV2]).T + return referenceObjV diff --git a/geatpy/benchmarks/mops/zdt/ZDT3.py b/geatpy/benchmarks/mops/zdt/ZDT3.py new file mode 100644 index 00000000..3ff6acc1 --- /dev/null +++ b/geatpy/benchmarks/mops/zdt/ZDT3.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class ZDT3(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=30): # M : 目标维数;Dim : 决策变量维数 + name = 'ZDT3' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + ObjV1 = Vars[:, 0] + gx = 1 + 9 * np.sum(Vars[:, 1:], 1) / (self.Dim - 1) + hx = 1 - np.sqrt(np.abs(ObjV1 / gx)) - (ObjV1 / gx) * np.sin(10 * np.pi * ObjV1) # 取绝对值是为了避免浮点数精度异常带来的影响 + ObjV2 = gx * hx + f = np.array([ObjV1, ObjV2]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 生成10000个参考点 + ObjV1 = np.linspace(0, 1, N) + ObjV2 = 1 - ObjV1 ** 0.5 - ObjV1 * np.sin(10 * np.pi * ObjV1) + f = np.array([ObjV1, ObjV2]).T + levels, criLevel = ea.ndsortESS(f, None, 1) + referenceObjV = f[np.where(levels == 1)[0]] + return referenceObjV diff --git a/geatpy/benchmarks/mops/zdt/ZDT4.py b/geatpy/benchmarks/mops/zdt/ZDT4.py new file mode 100644 index 00000000..98e3426e --- /dev/null +++ b/geatpy/benchmarks/mops/zdt/ZDT4.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +class ZDT4(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=10): # M : 目标维数;Dim : 决策变量维数 + name = 'ZDT4' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] + [-5] * (Dim - 1) # 决策变量下界 + ub = [1] + [5] * (Dim - 1) # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + ObjV1 = Vars[:, 0] + Vars1_10 = Vars[:, 1:Vars.shape[1]] + gx = 1 + 10 * (self.Dim - 1) + np.sum(Vars1_10 ** 2 - 10 * np.cos(4 * np.pi * Vars1_10), 1) + hx = 1 - np.sqrt(np.abs(ObjV1) / gx) # 取绝对值是为了避免浮点数精度异常带来的影响 + ObjV2 = gx * hx + f = np.array([ObjV1, ObjV2]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 生成10000个参考点 + ObjV1 = np.linspace(0, 1, N) + ObjV2 = 1 - np.sqrt(ObjV1) + referenceObjV = np.array([ObjV1, ObjV2]).T + return referenceObjV diff --git a/geatpy/benchmarks/mops/zdt/ZDT5.py b/geatpy/benchmarks/mops/zdt/ZDT5.py new file mode 100644 index 00000000..87d8d678 --- /dev/null +++ b/geatpy/benchmarks/mops/zdt/ZDT5.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class ZDT5(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=None): # M : 目标维数;Dim : 决策变量维数 + name = 'ZDT5' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 11 # 初始化Dim(决策变量维数) + varTypes = [1] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [30] + [5] * (Dim - 1) # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + v = np.zeros(Vars.shape) + v[np.where(Vars < 5)] += 2 + v[np.where(Vars == 5)] = 1 + ObjV1 = 1 + Vars[:, 0] + g = np.sum(v[:, 1:], 1) + h = 1 / ObjV1 + ObjV2 = g * h + f = np.array([ObjV1, ObjV2]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + ObjV1 = np.arange(1, 32) + ObjV2 = (self.Dim + 39) / 5 / ObjV1 + referenceObjV = np.array([ObjV1, ObjV2]).T + return referenceObjV diff --git a/geatpy/benchmarks/mops/zdt/ZDT6.py b/geatpy/benchmarks/mops/zdt/ZDT6.py new file mode 100644 index 00000000..2d457fb3 --- /dev/null +++ b/geatpy/benchmarks/mops/zdt/ZDT6.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + + +class ZDT6(ea.Problem): # 继承Problem父类 + def __init__(self, M=None, Dim=10): # M : 目标维数;Dim : 决策变量维数 + name = 'ZDT6' # 初始化name(函数名称,可以随意设置) + M = 2 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + ObjV1 = 1 - np.exp(-4 * Vars[:, 0]) * (np.sin(6 * np.pi * Vars[:, 0])) ** 6 + gx = 1 + 9 * np.abs(np.sum(Vars[:, 1:10], 1) / (self.Dim - 1)) ** 0.25 + hx = 1 - (ObjV1 / gx) ** 2 + ObjV2 = gx * hx + f = np.array([ObjV1, ObjV2]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值,即“真实帕累托前沿点”) + N = 10000 # 生成10000个参考点 + ObjV1 = np.linspace(0.280775, 1, N) + ObjV2 = 1 - ObjV1 ** 2; + referenceObjV = np.array([ObjV1, ObjV2]).T + return referenceObjV diff --git a/geatpy/benchmarks/sops/ackley/Ackley.py b/geatpy/benchmarks/sops/ackley/Ackley.py new file mode 100644 index 00000000..dba96552 --- /dev/null +++ b/geatpy/benchmarks/sops/ackley/Ackley.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +class Ackley(ea.Problem): # 继承Problem父类 + def __init__(self, Dim=30): # Dim : 决策变量维数 + name = 'Ackley' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-32.768] * Dim # 决策变量下界 + ub = [32.768] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, x): # 目标函数 + n = self.Dim + f = np.array([-20 * np.exp(-0.2 * np.sqrt(1 / n * np.sum(x ** 2, 1))) - + np.exp(1 / n * np.sum(np.cos(2 * np.pi * x), 1)) + np.e + 20]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[0]]) + return referenceObjV diff --git a/geatpy/benchmarks/sops/beale/Beale.py b/geatpy/benchmarks/sops/beale/Beale.py new file mode 100644 index 00000000..859a50f5 --- /dev/null +++ b/geatpy/benchmarks/sops/beale/Beale.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +class Beale(ea.Problem): # 继承Problem父类 + def __init__(self, Dim=None): # Dim : 决策变量维数 + name = 'Beale' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + Dim = 2 # 初始化Dim(决策变量维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-4.5, -100] # 决策变量下界 + ub = [100, 4.5] # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x = Vars[:, [0]] + y = Vars[:, [1]] + f = (1.5 - x + x * y) ** 2 + (2.25 - x + x * y ** 2) ** 2 + (2.625 - x + x * y ** 3) ** 2 + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[0]]) + return referenceObjV diff --git a/geatpy/benchmarks/sops/goldstein/Goldstein.py b/geatpy/benchmarks/sops/goldstein/Goldstein.py new file mode 100644 index 00000000..58277d7b --- /dev/null +++ b/geatpy/benchmarks/sops/goldstein/Goldstein.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +class Goldstein(ea.Problem): # 继承Problem父类 + def __init__(self, Dim=None): # Dim : 决策变量维数 + name = 'Goldstein' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + Dim = 2 # 初始化Dim(决策变量维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-2, -100] # 决策变量下界 + ub = [100, 2] # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x = Vars[:, [0]] + y = Vars[:, [1]] + f = (1 + (x + y + 1) ** 2 * (19 - 14 * x + 13 * x ** 2 - 14 * y + 6 * x * y + 3 * y ** 2)) * ( + 30 + (2 * x - 3 * y) ** 2 * (18 - 32 * x + 12 * x ** 2 + 48 * y - 36 * x * y + 27 * y ** 2)) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[3]]) + return referenceObjV diff --git a/geatpy/benchmarks/sops/griewangk/Griewangk.py b/geatpy/benchmarks/sops/griewangk/Griewangk.py new file mode 100644 index 00000000..0c8317a9 --- /dev/null +++ b/geatpy/benchmarks/sops/griewangk/Griewangk.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +class Griewangk(ea.Problem): # 继承Problem父类 + def __init__(self, Dim=30): # Dim : 决策变量维数 + name = 'Griewangk' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + # 初始化varTypes(决策变量的类型) + lb = [-600] * Dim # 决策变量下界 + ub = [600] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + Nind = Vars.shape[0] + number = np.tile(np.arange(1, self.Dim + 1), (Nind, 1)) + f = np.array([np.sum(((Vars ** 2) / 4000).T, 0) - np.prod(np.cos(Vars / np.sqrt(number)).T, 0) + 1]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[0]]) + return referenceObjV diff --git a/geatpy/benchmarks/sops/pathological/Pathological.py b/geatpy/benchmarks/sops/pathological/Pathological.py new file mode 100644 index 00000000..67546e06 --- /dev/null +++ b/geatpy/benchmarks/sops/pathological/Pathological.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +class Pathological(ea.Problem): # 继承Problem父类 + def __init__(self, Dim=30): # Dim : 决策变量维数 + name = 'Pathological' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-100] * Dim # 决策变量下界 + ub = [100] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + x2 = Vars[:, [1]] + f = 0.5 + ((np.sin(np.sqrt(np.abs(x1 ** 2 + x2 ** 2)))) ** 2 - 0.5) / ((1 + 0.001 * (x1 ** 2 + x2 ** 2)) ** 2) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[0]]) + return referenceObjV diff --git a/geatpy/benchmarks/sops/rastrigrin/Rastrigrin.py b/geatpy/benchmarks/sops/rastrigrin/Rastrigrin.py new file mode 100644 index 00000000..d61c631a --- /dev/null +++ b/geatpy/benchmarks/sops/rastrigrin/Rastrigrin.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +class Rastrigrin(ea.Problem): # 继承Problem父类 + def __init__(self, Dim=30): # Dim : 决策变量维数 + name = 'Rastrigrin' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-5.12] * Dim # 决策变量下界 + ub = [5.12] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, x): # 目标函数 + f = np.sum((x ** 2 - 10 * np.cos(2 * np.pi * x) + 10), 1, keepdims=True) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[0]]) + return referenceObjV diff --git a/geatpy/benchmarks/sops/rosenbrock/Rosenbrock.py b/geatpy/benchmarks/sops/rosenbrock/Rosenbrock.py new file mode 100644 index 00000000..7ee7c5e1 --- /dev/null +++ b/geatpy/benchmarks/sops/rosenbrock/Rosenbrock.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +class Rosenbrock(ea.Problem): # 继承Problem父类 + def __init__(self, Dim=30): # Dim : 决策变量维数 + name = 'Rosenbrock' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-2.048] * Dim # 决策变量下界 + ub = [2.048] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, x): # 目标函数 + Nvar = self.Dim + Mat1 = x[:, :Nvar - 1] + Mat2 = x[:, 1:Nvar] + f = np.array([np.sum((100 * (Mat2 - Mat1 ** 2) ** 2 + (1 - Mat1) ** 2).T, 0)]).T + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[0]]) + return referenceObjV diff --git a/geatpy/benchmarks/sops/schwefel/Schwefel.py b/geatpy/benchmarks/sops/schwefel/Schwefel.py new file mode 100644 index 00000000..020d9ea1 --- /dev/null +++ b/geatpy/benchmarks/sops/schwefel/Schwefel.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +class Schwefel(ea.Problem): # 继承Problem父类 + def __init__(self, Dim=30): # Dim : 决策变量维数 + name = 'Schwefel' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-500] * Dim # 决策变量下界 + ub = [500] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, x): # 目标函数 + f = np.sum(-x * np.sin(np.sqrt(np.abs(x))), 1, keepdims=True) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[-self.Dim * 418.9829]]) + return referenceObjV diff --git a/geatpy/benchmarks/sops/shubert/Shubert.py b/geatpy/benchmarks/sops/shubert/Shubert.py new file mode 100644 index 00000000..8cc12aa2 --- /dev/null +++ b/geatpy/benchmarks/sops/shubert/Shubert.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +class Shubert(ea.Problem): # 继承Problem父类 + def __init__(self, Dim=None): # Dim : 决策变量维数 + name = 'Shubert' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + Dim = 2 # 初始化Dim(决策变量维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-10] * Dim # 决策变量下界 + ub = [10] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x = Vars[:, [0]] + y = Vars[:, [1]] + f = ((1 * np.cos((1 + 1) * x + 1)) + (2 * np.cos((2 + 1) * x + 2)) + (3 * np.cos((3 + 1) * x + 3)) + + (4 * np.cos((4 + 1) * x + 4)) + (5 * np.cos((5 + 1) * x + 5))) * ((1 * np.cos((1 + 1) * y + 1)) + + (2 * np.cos((2 + 1) * y + 2)) + ( + 3 * np.cos( + (3 + 1) * y + 3)) + ( + 4 * np.cos( + (4 + 1) * y + 4)) + + (5 * np.cos((5 + 1) * y + 5))) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[-186.731]]) + return referenceObjV diff --git a/geatpy/benchmarks/sops/sphere/Sphere.py b/geatpy/benchmarks/sops/sphere/Sphere.py new file mode 100644 index 00000000..ec24c594 --- /dev/null +++ b/geatpy/benchmarks/sops/sphere/Sphere.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + + +class Sphere(ea.Problem): # 继承Problem父类 + def __init__(self, Dim=30): # Dim : 决策变量维数 + name = 'Sphere' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-5.12] * Dim # 决策变量下界 + ub = [5.12] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + f= np.sum(Vars ** 2, 1, keepdims=True) + return f + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[0]]) + return referenceObjV diff --git a/geatpy/benchmarks/tsps/TSP.py b/geatpy/benchmarks/tsps/TSP.py new file mode 100644 index 00000000..23b83efa --- /dev/null +++ b/geatpy/benchmarks/tsps/TSP.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea +import os + + +class TSP(ea.Problem): # 继承Problem父类 + def __init__(self, testName): # testName为测试集名称 + name = testName # 初始化name + # 读取城市坐标数据 + self.places = np.loadtxt(os.path.dirname(os.path.realpath(__file__)) + "/data/" + testName + ".csv", delimiter=",", usecols=(0, 1)) + M = 1 # 初始化M(目标维数) + Dim = self.places.shape[0] # 初始化Dim(决策变量维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [Dim - 1] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, x): # 目标函数 + N = x.shape[0] + # 添加最后回到出发地 + X = np.hstack([x, x[:, [0]]]).astype(int) + ObjV = [] # 存储所有种群个体对应的总路程 + for i in range(N): + journey = self.places[X[i], :] # 按既定顺序到达的地点坐标 + distance = np.sum(np.sqrt(np.sum(np.diff(journey.T) ** 2, 0))) # 计算总路程 + ObjV.append(distance) + f = np.array([ObjV]).T + return f diff --git a/geatpy/benchmarks/tsps/data/a280.csv b/geatpy/benchmarks/tsps/data/a280.csv new file mode 100644 index 00000000..a25b70c1 --- /dev/null +++ b/geatpy/benchmarks/tsps/data/a280.csv @@ -0,0 +1,280 @@ +288,149 +288,129 +270,133 +256,141 +256,157 +246,157 +236,169 +228,169 +228,161 +220,169 +212,169 +204,169 +196,169 +188,169 +196,161 +188,145 +172,145 +164,145 +156,145 +148,145 +140,145 +148,169 +164,169 +172,169 +156,169 +140,169 +132,169 +124,169 +116,161 +104,153 +104,161 +104,169 +90,165 +80,157 +64,157 +64,165 +56,169 +56,161 +56,153 +56,145 +56,137 +56,129 +56,121 +40,121 +40,129 +40,137 +40,145 +40,153 +40,161 +40,169 +32,169 +32,161 +32,153 +32,145 +32,137 +32,129 +32,121 +32,113 +40,113 +56,113 +56,105 +48,99 +40,99 +32,97 +32,89 +24,89 +16,97 +16,109 +8,109 +8,97 +8,89 +8,81 +8,73 +8,65 +8,57 +16,57 +8,49 +8,41 +24,45 +32,41 +32,49 +32,57 +32,65 +32,73 +32,81 +40,83 +40,73 +40,63 +40,51 +44,43 +44,35 +44,27 +32,25 +24,25 +16,25 +16,17 +24,17 +32,17 +44,11 +56,9 +56,17 +56,25 +56,33 +56,41 +64,41 +72,41 +72,49 +56,49 +48,51 +56,57 +56,65 +48,63 +48,73 +56,73 +56,81 +48,83 +56,89 +56,97 +104,97 +104,105 +104,113 +104,121 +104,129 +104,137 +104,145 +116,145 +124,145 +132,145 +132,137 +140,137 +148,137 +156,137 +164,137 +172,125 +172,117 +172,109 +172,101 +172,93 +172,85 +180,85 +180,77 +180,69 +180,61 +180,53 +172,53 +172,61 +172,69 +172,77 +164,81 +148,85 +124,85 +124,93 +124,109 +124,125 +124,117 +124,101 +104,89 +104,81 +104,73 +104,65 +104,49 +104,41 +104,33 +104,25 +104,17 +92,9 +80,9 +72,9 +64,21 +72,25 +80,25 +80,25 +80,41 +88,49 +104,57 +124,69 +124,77 +132,81 +140,65 +132,61 +124,61 +124,53 +124,45 +124,37 +124,29 +132,21 +124,21 +120,9 +128,9 +136,9 +148,9 +162,9 +156,25 +172,21 +180,21 +180,29 +172,29 +172,37 +172,45 +180,45 +180,37 +188,41 +196,49 +204,57 +212,65 +220,73 +228,69 +228,77 +236,77 +236,69 +236,61 +228,61 +228,53 +236,53 +236,45 +228,45 +228,37 +236,37 +236,29 +228,29 +228,21 +236,21 +252,21 +260,29 +260,37 +260,45 +260,53 +260,61 +260,69 +260,77 +276,77 +276,69 +276,61 +276,53 +284,53 +284,61 +284,69 +284,77 +284,85 +284,93 +284,101 +288,109 +280,109 +276,101 +276,93 +276,85 +268,97 +260,109 +252,101 +260,93 +260,85 +236,85 +228,85 +228,93 +236,93 +236,101 +228,101 +228,109 +228,117 +228,125 +220,125 +212,117 +204,109 +196,101 +188,93 +180,93 +180,101 +180,109 +180,117 +180,125 +196,145 +204,145 +212,145 +220,145 +228,145 +236,145 +246,141 +252,125 +260,129 +280,133 diff --git a/geatpy/benchmarks/tsps/data/att48.csv b/geatpy/benchmarks/tsps/data/att48.csv new file mode 100644 index 00000000..3f72d31f --- /dev/null +++ b/geatpy/benchmarks/tsps/data/att48.csv @@ -0,0 +1,48 @@ +6734,1453 +2233,10 +5530,1424 +401,841 +3082,1644 +7608,4458 +7573,3716 +7265,1268 +6898,1885 +1112,2049 +5468,2606 +5989,2873 +4706,2674 +4612,2035 +6347,2683 +6107,669 +7611,5184 +7462,3590 +7732,4723 +5900,3561 +4483,3369 +6101,1110 +5199,2182 +1633,2809 +4307,2322 +675,1006 +7555,4819 +7541,3981 +3177,756 +7352,4506 +7545,2801 +3245,3305 +6426,3173 +4608,1198 +23,2216 +7248,3779 +7762,4595 +7392,2244 +3484,2829 +6271,2135 +4985,140 +1916,1569 +7280,4899 +7509,3239 +10,2676 +6807,2993 +5185,3258 +3023,1942 diff --git a/geatpy/benchmarks/tsps/data/ch130.csv b/geatpy/benchmarks/tsps/data/ch130.csv new file mode 100644 index 00000000..3181f76f --- /dev/null +++ b/geatpy/benchmarks/tsps/data/ch130.csv @@ -0,0 +1,130 @@ +334.5909246,161.7809319 +397.6446634,262.8165331 +503.8741827,172.8741151 +444.0479404,384.649181 +311.6137147,2.009169983 +662.8551011,549.2301264 +40.09790306,187.2375431 +526.8941409,215.7079092 +209.1887938,691.0262292 +683.2674132,414.2096287 +280.7494439,5.920639205 +252.749309,535.7430385 +698.7850452,348.441373 +678.7574678,410.7256424 +220.0041131,409.1225813 +355.1528557,76.39120764 +296.9724228,313.1312792 +504.5154072,240.8866564 +224.1079497,358.4872229 +470.6801297,309.6259188 +554.2530513,279.4242467 +567.6332684,352.7162027 +599.0532671,361.094869 +240.5232959,430.6036008 +32.08259728,345.855101 +91.05387369,148.721327 +248.2179895,343.9528017 +488.8909044,3.612231139 +206.046794,437.7639406 +575.8409416,141.967096 +282.6089948,329.4183806 +27.65814849,424.7684582 +568.573731,287.0975661 +269.4638933,295.9464636 +417.8004857,341.259659 +32.16809387,448.8998721 +561.4775136,357.354393 +342.9482167,492.3321424 +399.6752075,156.8435036 +571.737105,375.7575351 +370.7559843,151.9060752 +509.7093253,435.7975189 +177.0207,295.6044773 +526.1674199,409.4859418 +316.5725172,65.64001082 +469.29081,281.9891445 +572.7630641,373.3208821 +29.51769943,330.0382309 +454.0082937,537.2178548 +416.1546762,227.6133101 +535.2514331,471.0648644 +265.4455534,684.9987192 +478.054211,509.6452029 +370.4781203,332.5390063 +598.3479202,446.869328 +201.1521139,649.0260269 +193.692536,680.2322841 +448.5792599,532.793406 +603.2853486,134.4006474 +543.0102491,481.5168231 +214.5750793,43.64601175 +426.3501452,61.7285416 +89.04470371,277.1158386 +84.49201002,31.84748164 +220.0468614,623.0778103 +688.4613313,0.470231273 +687.2857532,373.5346236 +75.4934934,312.9175377 +63.41709935,23.70393097 +97.93634959,211.0910931 +399.5255885,170.8221968 +456.3167017,597.1937162 +319.8855102,626.8396605 +295.9250895,664.6291555 +288.4868857,667.7284071 +268.3951859,52.90101816 +140.4709056,513.5566721 +689.8079027,167.5947004 +280.5784507,458.7533547 +453.3884434,282.9082329 +213.5704943,525.8681818 +133.6953005,677.1757808 +521.1658691,132.8617087 +30.26579463,450.0754503 +657.0199585,39.77729083 +6.925224196,23.87492416 +252.4286968,535.1659365 +42.85516825,63.82320818 +145.8999394,399.5255885 +638.4885716,62.62625585 +489.2756391,665.3131282 +361.2231139,564.2347788 +519.9475426,347.9711417 +129.3349741,435.669274 +259.7172815,454.6495181 +676.342189,371.0979707 +84.51338417,183.3260739 +77.71640487,354.3833863 +335.9802443,660.6321897 +264.3554718,377.5743377 +51.68269169,676.0429509 +692.1376849,543.8010926 +169.2191357,547.8194325 +194.0131482,263.4791317 +415.1928395,78.9133572 +415.0432205,479.0801702 +169.838986,245.6103433 +525.0987124,213.5063719 +238.6851191,33.4932911 +116.2112468,363.5742703 +16.92832581,656.5711014 +434.3440768,92.69968314 +40.52538604,424.6829616 +530.4849979,183.8390534 +484.3595849,49.24603873 +263.6501249,426.5852608 +450.2891918,126.3853416 +441.7822806,299.7724363 +24.21691054,500.3474482 +503.7886861,514.689502 +635.538939,200.9811207 +614.5922733,418.8691931 +21.71613513,660.974176 +143.826647,92.69968314 +637.7191022,54.20484124 +566.564561,199.9551616 +196.6849168,221.8209158 +384.9270449,87.4630167 +178.1107816,104.6905806 +403.2874387,205.8971749 diff --git a/geatpy/benchmarks/tsps/data/eil51.csv b/geatpy/benchmarks/tsps/data/eil51.csv new file mode 100644 index 00000000..a5b48d54 --- /dev/null +++ b/geatpy/benchmarks/tsps/data/eil51.csv @@ -0,0 +1,51 @@ +37,52 +49,49 +52,64 +20,26 +40,30 +21,47 +17,63 +31,62 +52,33 +51,21 +42,41 +31,32 +5,25 +12,42 +36,16 +52,41 +27,23 +17,33 +13,13 +57,58 +62,42 +42,57 +16,57 +8,52 +7,38 +27,68 +30,48 +43,67 +58,48 +58,27 +37,69 +38,46 +46,10 +61,33 +62,63 +63,69 +32,22 +45,35 +59,15 +5,6 +10,17 +21,10 +5,64 +30,15 +39,10 +32,39 +25,32 +25,55 +48,28 +56,37 +30,40 diff --git a/geatpy/benchmarks/tsps/data/eil76.csv b/geatpy/benchmarks/tsps/data/eil76.csv new file mode 100644 index 00000000..8eeff524 --- /dev/null +++ b/geatpy/benchmarks/tsps/data/eil76.csv @@ -0,0 +1,76 @@ +22,22 +36,26 +21,45 +45,35 +55,20 +33,34 +50,50 +55,45 +26,59 +40,66 +55,65 +35,51 +62,35 +62,57 +62,24 +21,36 +33,44 +9,56 +62,48 +66,14 +44,13 +26,13 +11,28 +7,43 +17,64 +41,46 +55,34 +35,16 +52,26 +43,26 +31,76 +22,53 +26,29 +50,40 +55,50 +54,10 +60,15 +47,66 +30,60 +30,50 +12,17 +15,14 +16,19 +21,48 +50,30 +51,42 +50,15 +48,21 +12,38 +15,56 +29,39 +54,38 +55,57 +67,41 +10,70 +6,25 +65,27 +40,60 +70,64 +64,4 +36,6 +30,20 +20,30 +15,5 +50,70 +57,72 +45,42 +38,33 +50,4 +66,8 +59,5 +35,60 +27,24 +40,20 +40,37 +40,40 diff --git a/geatpy/benchmarks/tsps/data/kroD100.csv b/geatpy/benchmarks/tsps/data/kroD100.csv new file mode 100644 index 00000000..687a6079 --- /dev/null +++ b/geatpy/benchmarks/tsps/data/kroD100.csv @@ -0,0 +1,100 @@ +2995,264 +202,233 +981,848 +1346,408 +781,670 +1009,1001 +2927,1777 +2982,949 +555,1121 +464,1302 +3452,637 +571,1982 +2656,128 +1623,1723 +2067,694 +1725,927 +3600,459 +1109,1196 +366,339 +778,1282 +386,1616 +3918,1217 +3332,1049 +2597,349 +811,1295 +241,1069 +2658,360 +394,1944 +3786,1862 +264,36 +2050,1833 +3538,125 +1646,1817 +2993,624 +547,25 +3373,1902 +460,267 +3060,781 +1828,456 +1021,962 +2347,388 +3535,1112 +1529,581 +1203,385 +1787,1902 +2740,1101 +555,1753 +47,363 +3935,540 +3062,329 +387,199 +2901,920 +931,512 +1766,692 +401,980 +149,1629 +2214,1977 +3805,1619 +1179,969 +1017,333 +2834,1512 +634,294 +1819,814 +1393,859 +1768,1578 +3023,871 +3248,1906 +1632,1742 +2223,990 +3868,697 +1541,354 +2374,1944 +1962,389 +3007,1524 +3220,1945 +2356,1568 +1604,706 +2028,1736 +2581,121 +2221,1578 +2944,632 +1082,1561 +997,942 +2334,523 +1264,1090 +1699,1294 +235,1059 +2592,248 +3642,699 +3599,514 +1766,678 +240,619 +1272,246 +3503,301 +80,1533 +1677,1238 +3766,154 +3946,459 +1994,1852 +278,165 diff --git a/geatpy/benchmarks/tsps/data/rand400.csv b/geatpy/benchmarks/tsps/data/rand400.csv new file mode 100644 index 00000000..7388bea9 --- /dev/null +++ b/geatpy/benchmarks/tsps/data/rand400.csv @@ -0,0 +1,400 @@ +4.36E+02,5.88E+02 +6.03E+02,8.02E+02 +8.62E+02,9.54E+02 +4.44E+02,5.53E+02 +7.96E+02,7.97E+02 +8.89E+01,8.39E+02 +2.34E+02,8.51E+02 +4.77E+02,2.04E+02 +4.06E+02,6.02E+02 +9.55E+02,7.85E+02 +5.93E+02,9.69E+02 +9.46E+02,4.33E+02 +8.31E+01,6.01E+02 +8.61E+02,7.54E+02 +2.48E+02,6.99E+02 +9.63E+02,9.66E+02 +1.26E+02,5.37E+02 +5.63E+02,2.07E+01 +5.53E+01,6.19E+02 +6.91E+02,5.77E+02 +2.37E+02,7.07E+02 +5.83E+02,6.09E+02 +4.04E+02,9.42E+02 +1.58E+01,6.15E+02 +2.01E+01,6.29E+01 +1.97E+02,6.14E+02 +9.13E+02,4.29E+02 +8.28E+02,5.84E+02 +4.96E+01,4.06E+01 +2.71E+02,7.37E+02 +9.79E+02,7.17E+02 +4.89E+02,9.58E+02 +8.17E+02,2.81E+02 +3.33E+02,4.67E+02 +2.78E+02,9.46E+02 +1.69E+02,9.75E+02 +8.06E+02,5.38E+02 +4.45E+02,3.07E+02 +3.07E+02,5.53E+02 +5.55E+02,3.59E+02 +1.56E+02,1.79E+02 +1.40E+02,7.04E+02 +9.63E+02,4.43E+02 +4.61E+02,2.56E+02 +3.86E+02,4.88E+02 +9.31E+02,1.98E+02 +2.80E+02,8.96E+02 +3.31E+02,9.23E+02 +3.35E+01,8.90E+02 +5.12E+02,6.04E+01 +2.33E+02,3.28E+02 +8.71E+02,7.48E+02 +1.26E+02,2.71E+01 +2.57E+01,3.85E+02 +5.51E+02,3.18E+02 +4.22E+02,6.70E+02 +6.99E+02,6.42E+02 +3.06E+01,8.81E+02 +4.87E+02,9.88E+02 +5.48E+02,8.70E+02 +7.64E+02,2.28E+02 +4.89E+02,8.85E+02 +9.09E+02,4.83E+02 +1.95E+02,8.21E+02 +1.72E+02,1.12E+02 +5.99E+02,5.88E+02 +1.33E+02,5.08E+02 +3.27E+02,8.69E+02 +2.68E+02,7.88E+02 +7.93E+02,1.37E+02 +1.57E+02,1.87E+02 +1.86E+02,9.03E+02 +7.46E+02,8.19E+02 +6.73E+02,1.42E+02 +7.95E+02,4.97E+02 +2.99E+02,7.97E+02 +9.16E+01,3.78E+02 +9.18E+02,1.05E+02 +3.70E+02,2.75E+02 +7.89E+02,7.38E+02 +8.00E+02,1.59E+02 +7.48E+02,5.37E+02 +4.87E+02,8.86E+01 +1.49E+02,9.51E+01 +2.32E+02,1.01E+01 +9.73E+02,2.20E+02 +4.06E+01,2.60E+02 +1.92E+02,2.93E+02 +2.40E+01,5.10E+02 +3.17E+02,3.12E+02 +4.95E+02,1.63E+02 +5.25E+02,6.81E+02 +8.36E+02,8.83E+02 +7.75E+02,1.81E+02 +1.09E+02,2.74E+01 +6.53E+02,6.72E+02 +6.28E+02,1.97E+02 +1.95E+00,7.12E+02 +7.31E+02,4.47E+02 +5.80E+02,9.33E+02 +3.77E+02,8.64E+02 +2.58E+02,2.51E+02 +6.59E+02,6.93E+02 +7.01E+02,4.39E+02 +8.01E+02,3.28E+02 +7.55E+02,5.82E+02 +1.68E+02,7.75E+02 +6.08E+02,6.73E+02 +5.70E+02,3.60E+02 +5.06E+02,7.95E+02 +6.93E+02,4.75E+02 +6.15E+02,4.16E+02 +4.33E+02,8.54E+02 +2.27E+02,1.49E+02 +3.26E+02,6.16E+02 +7.56E+02,9.97E+02 +1.75E+02,5.52E+02 +2.07E+02,7.53E+02 +1.27E+02,9.86E+02 +2.45E+02,5.96E+02 +3.68E+02,3.22E+02 +6.18E+02,8.08E+02 +2.85E+02,9.06E+02 +3.47E+02,9.33E+02 +9.42E+02,7.34E+02 +9.23E+02,4.10E+02 +1.54E+02,2.31E+02 +4.76E+02,2.53E+02 +2.32E+02,5.88E+02 +4.40E+02,8.19E+02 +9.59E+02,3.82E+02 +6.59E+02,9.89E+02 +4.75E+02,4.23E+02 +7.35E+02,7.62E+01 +8.45E+02,8.56E+02 +1.03E+01,8.30E+02 +3.59E+02,6.89E+02 +9.01E+02,2.07E+02 +6.07E+02,7.79E+02 +6.82E+02,8.47E+01 +8.41E+02,7.57E+02 +4.50E+02,8.84E+02 +7.26E+02,4.02E+02 +8.83E+02,1.50E+02 +4.30E+02,2.29E+02 +9.81E+02,8.22E+02 +5.78E+02,5.45E+02 +5.42E+02,8.18E+02 +5.09E+02,1.64E+02 +8.76E+02,2.51E+02 +1.01E+02,8.20E+02 +4.86E+02,5.48E+00 +1.34E+02,2.29E+02 +1.67E+02,9.44E+02 +1.56E+02,4.46E+02 +2.68E+02,6.90E+01 +4.76E+02,7.12E+02 +4.57E+02,8.09E+02 +2.17E+02,2.01E+01 +1.65E+02,8.12E+02 +3.82E+02,4.58E+02 +3.11E+02,2.21E+02 +2.20E+00,2.58E+01 +1.35E+02,5.79E+02 +2.58E+02,3.33E+02 +6.78E+02,5.47E+02 +1.76E+02,6.12E+02 +5.60E+02,3.31E+02 +4.17E+02,5.22E+02 +8.52E+02,4.20E+02 +8.51E+02,3.21E+02 +7.46E+02,5.71E+01 +1.05E+02,5.89E+02 +6.43E+01,8.70E+01 +4.17E+02,1.94E+02 +8.84E+02,5.59E+02 +8.69E+02,1.80E+02 +2.62E+02,4.26E+02 +6.70E+02,6.62E+02 +4.20E+02,3.44E+01 +4.25E+02,2.40E+02 +6.15E+02,4.82E+00 +9.67E+02,2.36E+02 +1.81E+02,9.63E+02 +1.54E+02,2.54E+02 +1.38E+02,5.45E+02 +2.39E+01,2.40E+02 +7.01E+02,4.35E+01 +9.52E+02,7.92E+02 +1.90E+02,9.77E+00 +3.48E+02,9.98E+02 +3.31E+02,8.83E+00 +5.47E+02,2.05E+02 +7.77E+02,2.91E+02 +7.57E+02,9.18E+02 +1.72E+02,7.73E+02 +8.57E+01,3.37E+01 +9.05E+02,1.26E+02 +8.75E+01,3.89E+02 +2.20E+01,1.03E+02 +4.17E+02,5.81E+02 +2.06E+02,4.77E+02 +4.87E+02,6.25E+02 +3.72E+02,7.79E+01 +1.18E+02,4.80E+02 +2.96E+02,9.23E+02 +8.79E+02,9.67E+02 +8.90E+02,1.08E+02 +6.37E+02,8.53E+02 +3.82E+02,9.62E+01 +1.35E+02,4.16E+02 +7.60E+02,8.14E+02 +4.45E+01,9.41E+02 +2.45E+02,4.74E+02 +6.43E+02,5.90E+02 +2.28E+02,5.38E+02 +6.46E+02,3.66E+01 +8.82E+02,4.36E+02 +6.81E+02,1.56E+02 +8.12E+02,4.66E+02 +9.63E+02,5.85E+02 +3.13E+02,6.11E+02 +8.54E+02,6.22E+02 +5.18E+02,9.90E+02 +2.72E+02,2.02E+02 +7.62E+02,7.51E+02 +6.49E+02,6.04E+02 +7.84E+02,7.42E+02 +3.99E+02,1.92E+02 +3.25E+01,9.39E+02 +8.14E+02,4.36E+02 +2.91E+02,2.92E+02 +6.07E+02,1.36E+01 +9.27E+01,4.34E+02 +7.69E+02,1.83E+02 +1.76E+02,4.09E+02 +3.45E+02,3.88E+02 +2.27E+02,3.44E+02 +4.91E+02,3.29E+02 +2.55E+01,6.70E+02 +7.89E+02,1.80E+02 +9.81E+02,7.35E+02 +5.82E+01,2.07E+02 +1.95E+02,3.04E+02 +5.44E+02,9.96E+02 +5.57E+02,3.79E+02 +2.57E+02,6.07E+02 +8.05E+02,3.73E+02 +4.62E+02,4.17E+02 +8.18E+02,6.30E+02 +4.15E+02,8.24E+02 +2.03E+02,2.80E+02 +3.26E+02,9.08E+02 +5.12E+02,9.07E+02 +8.27E+02,8.03E+02 +3.74E+02,4.94E+02 +5.99E+02,6.20E+02 +3.27E+02,3.84E+02 +3.60E+02,1.75E+02 +8.10E+02,7.58E+02 +2.61E+02,2.13E+02 +9.34E+02,6.85E+02 +1.76E+02,3.65E+02 +6.07E+02,3.55E+02 +6.68E+02,8.10E+02 +8.53E+02,8.25E+02 +7.46E+02,5.60E+01 +9.36E+01,5.31E+02 +8.19E+02,6.07E+02 +7.47E+02,4.92E+02 +2.31E+02,9.61E+02 +6.84E+02,9.30E+02 +4.31E+02,6.86E+02 +7.10E+02,5.61E+02 +4.52E+02,6.63E+02 +3.85E+02,8.13E+02 +8.86E+02,4.94E+00 +5.26E+01,2.71E+02 +1.53E+02,9.52E+02 +8.09E+02,7.64E+02 +7.75E+02,7.80E+02 +1.78E+02,5.20E+02 +9.89E+02,2.56E+02 +1.14E+02,3.77E+02 +2.36E+02,4.94E+02 +3.14E+02,4.38E+02 +2.74E+02,1.73E+02 +5.00E+01,7.43E+02 +6.43E+00,3.54E+02 +5.40E+02,5.29E+02 +7.86E+02,4.33E+02 +9.95E+02,7.77E+01 +5.10E+02,8.34E+02 +8.90E+02,3.07E+02 +3.04E+02,5.36E+02 +4.74E+02,2.23E+01 +8.69E+02,4.85E+02 +9.17E+01,6.61E+02 +6.17E+02,7.49E+02 +4.14E+02,7.48E+02 +2.36E+02,6.83E+02 +9.75E+02,1.72E+02 +7.32E+02,3.21E+02 +3.34E+02,5.95E+02 +5.61E+02,1.41E+01 +3.30E+01,5.46E+02 +4.52E+02,7.98E+02 +1.97E+02,1.99E+00 +2.36E+02,4.00E+02 +7.48E+02,3.60E+02 +4.31E+02,8.16E+02 +2.18E+01,2.57E+02 +3.45E+02,2.30E+02 +7.55E+02,9.29E+02 +2.57E+02,1.79E+02 +2.33E+02,7.89E+02 +1.10E+02,5.55E+02 +8.18E+02,3.89E+02 +4.39E+02,1.37E+02 +3.45E+02,8.38E+02 +9.21E+02,4.60E+02 +9.50E+02,3.40E+01 +1.24E+02,9.11E+02 +8.27E+02,2.35E+02 +9.68E+02,1.67E+02 +7.64E+02,5.59E+02 +4.77E+02,8.35E+02 +1.89E+02,6.21E+02 +5.00E+02,8.85E+02 +8.08E+02,8.79E+02 +6.14E+00,1.23E+02 +6.81E+02,9.80E+02 +7.52E+02,1.73E+02 +7.41E+02,3.60E+02 +4.94E+02,2.00E+02 +2.25E+02,5.56E+02 +7.82E+02,6.88E+02 +5.60E+02,1.71E+02 +4.63E+02,7.12E+02 +9.96E+01,1.92E+02 +2.58E+02,8.15E+02 +4.29E+01,9.26E+02 +1.73E+02,1.73E+02 +4.83E+02,8.14E+02 +5.37E+02,8.94E+02 +2.99E+00,9.73E+02 +2.87E+02,4.36E+02 +3.45E+01,2.82E+02 +3.82E+02,2.29E+02 +4.07E+02,8.58E+02 +9.58E+02,2.55E+01 +5.34E+02,4.50E+02 +8.91E+02,7.72E+02 +6.10E+02,7.15E+02 +8.01E+02,3.69E+02 +6.59E+00,1.97E+02 +1.23E+02,4.37E+02 +5.18E+02,6.49E+02 +2.35E+02,4.13E+01 +6.04E+02,7.24E+02 +9.10E+02,9.49E+02 +4.98E+02,9.27E+02 +5.49E+02,9.53E+02 +7.79E+02,9.90E+01 +5.82E+02,7.56E+01 +2.15E+02,8.22E+01 +5.60E+02,6.23E+02 +6.94E+02,5.56E+02 +9.05E+01,1.68E+01 +7.61E+02,4.12E+02 +6.27E+02,5.27E+02 +9.96E+02,2.35E+02 +9.19E+02,8.77E+02 +9.90E+02,4.73E+01 +3.78E+02,3.14E+02 +9.61E+02,4.13E+02 +8.25E+02,7.09E+02 +8.27E+02,5.80E+02 +3.58E+01,9.90E+02 +6.20E+02,2.82E+02 +1.10E+02,1.21E+02 +7.39E+02,8.21E+02 +2.74E+02,2.58E+02 +8.25E+01,6.44E+02 +5.93E+02,7.64E+02 +7.25E+02,4.71E+02 +7.78E+02,9.02E+02 +8.86E+02,6.66E+02 +2.69E+01,1.64E+02 +7.41E+02,9.73E+02 +1.66E+02,7.12E+02 +2.56E+02,1.27E+02 +9.27E+02,9.00E+02 +5.25E+02,5.37E+01 +7.22E+01,4.24E+02 +3.67E+02,8.63E+02 +3.49E+02,7.99E+02 +1.27E+02,4.29E+01 +5.88E+02,1.40E+02 +2.28E+01,3.55E+02 diff --git a/geatpy/benchmarks/tsps/data/rat195.csv b/geatpy/benchmarks/tsps/data/rat195.csv new file mode 100644 index 00000000..219ac3db --- /dev/null +++ b/geatpy/benchmarks/tsps/data/rat195.csv @@ -0,0 +1,195 @@ +3,12 +17,12 +23,9 +34,11 +47,11 +54,12 +66,16 +75,7 +86,6 +94,8 +107,9 +115,14 +123,15 +3,32 +15,32 +26,34 +33,34 +42,34 +53,25 +64,32 +74,32 +85,34 +95,28 +104,25 +113,31 +125,34 +3,48 +15,46 +26,50 +36,54 +48,50 +54,46 +64,54 +75,44 +88,49 +98,50 +103,54 +115,47 +127,49 +6,75 +15,75 +27,73 +36,73 +47,68 +54,72 +66,68 +74,67 +85,65 +94,74 +107,65 +117,65 +125,68 +6,84 +13,95 +25,94 +37,84 +47,87 +53,95 +63,86 +77,93 +83,89 +94,95 +103,92 +115,95 +123,93 +7,114 +15,111 +24,112 +36,108 +43,112 +56,105 +64,112 +73,112 +86,107 +98,108 +104,113 +117,115 +126,109 +6,127 +17,125 +27,134 +35,126 +44,131 +54,132 +63,124 +77,127 +82,134 +96,128 +103,126 +116,130 +126,134 +7,152 +16,147 +24,153 +35,151 +45,154 +55,146 +63,155 +75,151 +87,154 +93,156 +104,151 +117,153 +127,148 +3,164 +16,172 +25,165 +35,175 +44,169 +53,174 +64,168 +76,171 +87,173 +95,174 +106,168 +114,169 +125,169 +3,190 +16,188 +25,195 +37,186 +44,189 +54,194 +66,192 +77,192 +85,188 +93,185 +106,192 +113,193 +125,195 +5,207 +15,213 +24,209 +33,214 +43,206 +53,211 +64,213 +74,212 +84,212 +94,209 +104,215 +115,206 +127,209 +6,229 +13,227 +26,235 +34,225 +43,227 +55,225 +67,229 +75,234 +87,230 +95,235 +105,228 +117,225 +127,230 +6,249 +15,246 +26,255 +33,246 +47,248 +58,252 +65,248 +73,247 +87,249 +94,245 +104,256 +113,246 +125,253 +5,266 +16,274 +24,267 +37,266 +45,267 +54,266 +67,267 +74,265 +87,264 +95,271 +106,264 +116,271 +127,273 +7,287 +17,294 +23,287 +33,284 +43,288 +53,295 +67,288 +73,286 +87,293 +94,284 +104,291 +114,294 +127,290 diff --git a/geatpy/benchmarks/tsps/data/st70.csv b/geatpy/benchmarks/tsps/data/st70.csv new file mode 100644 index 00000000..784f3b92 --- /dev/null +++ b/geatpy/benchmarks/tsps/data/st70.csv @@ -0,0 +1,70 @@ +64,96 +80,39 +69,23 +72,42 +48,67 +58,43 +81,34 +79,17 +30,23 +42,67 +7,76 +29,51 +78,92 +64,8 +95,57 +57,91 +40,35 +68,40 +92,34 +62,1 +28,43 +76,73 +67,88 +93,54 +6,8 +87,18 +30,9 +77,13 +78,94 +55,3 +82,88 +73,28 +20,55 +27,43 +95,86 +67,99 +48,83 +75,81 +8,19 +20,18 +54,38 +63,36 +44,33 +52,18 +12,13 +25,5 +58,85 +5,67 +90,9 +41,76 +25,76 +37,64 +56,63 +10,55 +98,7 +16,74 +89,60 +48,82 +81,76 +29,60 +17,22 +5,45 +79,70 +9,100 +17,82 +74,67 +10,68 +48,19 +83,86 +84,94 diff --git a/geatpy/benchmarks/tsps/data/ts225.csv b/geatpy/benchmarks/tsps/data/ts225.csv new file mode 100644 index 00000000..72a6da9e --- /dev/null +++ b/geatpy/benchmarks/tsps/data/ts225.csv @@ -0,0 +1,225 @@ +4000,4000 +4000,4500 +4000,5000 +4000,5500 +4000,6000 +4000,6500 +4000,7000 +4000,7500 +4000,8000 +4000,8500 +4000,9000 +4000,9500 +4000,10000 +4000,10500 +4000,11000 +4000,11500 +4000,12000 +4000,12500 +4000,13000 +4000,13500 +4000,14000 +4000,14500 +4000,15000 +4000,15500 +4000,16000 +7000,4000 +7000,4500 +7000,5000 +7000,5500 +7000,6000 +7000,6500 +7000,7000 +7000,7500 +7000,8000 +7000,8500 +7000,9000 +7000,9500 +7000,10000 +7000,10500 +7000,11000 +7000,11500 +7000,12000 +7000,12500 +7000,13000 +7000,13500 +7000,14000 +7000,14500 +7000,15000 +7000,15500 +7000,16000 +10000,4000 +10000,4500 +10000,5000 +10000,5500 +10000,6000 +10000,6500 +10000,7000 +10000,7500 +10000,8000 +10000,8500 +10000,9000 +10000,9500 +10000,10000 +10000,10500 +10000,11000 +10000,11500 +10000,12000 +10000,12500 +10000,13000 +10000,13500 +10000,14000 +10000,14500 +10000,15000 +10000,15500 +10000,16000 +13000,4000 +13000,4500 +13000,5000 +13000,5500 +13000,6000 +13000,6500 +13000,7000 +13000,7500 +13000,8000 +13000,8500 +13000,9000 +13000,9500 +13000,10000 +13000,10500 +13000,11000 +13000,11500 +13000,12000 +13000,12500 +13000,13000 +13000,13500 +13000,14000 +13000,14500 +13000,15000 +13000,15500 +13000,16000 +16000,4000 +16000,4500 +16000,5000 +16000,5500 +16000,6000 +16000,6500 +16000,7000 +16000,7500 +16000,8000 +16000,8500 +16000,9000 +16000,9500 +16000,10000 +16000,10500 +16000,11000 +16000,11500 +16000,12000 +16000,12500 +16000,13000 +16000,13500 +16000,14000 +16000,14500 +16000,15000 +16000,15500 +16000,16000 +4500,4000 +5000,4000 +5500,4000 +6000,4000 +6500,4000 +4500,7000 +5000,7000 +5500,7000 +6000,7000 +6500,7000 +4500,10000 +5000,10000 +5500,10000 +6000,10000 +6500,10000 +4500,13000 +5000,13000 +5500,13000 +6000,13000 +6500,13000 +4500,16000 +5000,16000 +5500,16000 +6000,16000 +6500,16000 +7500,4000 +8000,4000 +8500,4000 +9000,4000 +9500,4000 +7500,7000 +8000,7000 +8500,7000 +9000,7000 +9500,7000 +7500,10000 +8000,10000 +8500,10000 +9000,10000 +9500,10000 +7500,13000 +8000,13000 +8500,13000 +9000,13000 +9500,13000 +7500,16000 +8000,16000 +8500,16000 +9000,16000 +9500,16000 +10500,4000 +11000,4000 +11500,4000 +12000,4000 +12500,4000 +10500,7000 +11000,7000 +11500,7000 +12000,7000 +12500,7000 +10500,10000 +11000,10000 +11500,10000 +12000,10000 +12500,10000 +10500,13000 +11000,13000 +11500,13000 +12000,13000 +12500,13000 +10500,16000 +11000,16000 +11500,16000 +12000,16000 +12500,16000 +13500,4000 +14000,4000 +14500,4000 +15000,4000 +15500,4000 +13500,7000 +14000,7000 +14500,7000 +15000,7000 +15500,7000 +13500,10000 +14000,10000 +14500,10000 +15000,10000 +15500,10000 +13500,13000 +14000,13000 +14500,13000 +15000,13000 +15500,13000 +13500,16000 +14000,16000 +14500,16000 +15000,16000 +15500,16000 diff --git a/geatpy/demo/moea_demo/moea_demo1/MyProblem.py b/geatpy/demo/moea_demo/moea_demo1/MyProblem.py new file mode 100644 index 00000000..d96baf41 --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo1/MyProblem.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +""" +min f1 = -25 * (x1 - 2)**2 - (x2 - 2)**2 - (x3 - 1)**2 - (x4 - 4)**2 - (x5 - 1)**2 +min f2 = (x1 - 1)**2 + (x2 - 1)**2 + (x3 - 1)**2 + (x4 - 1)**2 + (x5 - 1)**2 +s.t. +x1 + x2 >= 2 +x1 + x2 <= 6 +x1 - x2 >= -2 +x1 - 3*x2 <= 2 +4 - (x3 - 3)**2 - x4 >= 0 +(x5 - 3)**2 + x4 - 4 >= 0 +x1,x2,x3,x4,x5 ∈ {0,1,2,3,4,5,6,7,8,9,10} +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self, M=2): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + Dim = 5 # 初始化Dim(决策变量维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [1] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [10] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + x2 = Vars[:, [1]] + x3 = Vars[:, [2]] + x4 = Vars[:, [3]] + x5 = Vars[:, [4]] + f1 = -25 * (x1 - 2) ** 2 - (x2 - 2) ** 2 - (x3 - 1) ** 2 - (x4 - 4) ** 2 - (x5 - 1) ** 2 + f2 = (x1 - 1) ** 2 + (x2 - 1) ** 2 + (x3 - 1) ** 2 + (x4 - 1) ** 2 + (x5 - 1) ** 2 + # # 利用罚函数法处理约束条件 + # idx1 = np.where(x1 + x2 < 2)[0] + # idx2 = np.where(x1 + x2 > 6)[0] + # idx3 = np.where(x1 - x2 < -2)[0] + # idx4 = np.where(x1 - 3*x2 > 2)[0] + # idx5 = np.where(4 - (x3 - 3)**2 - x4 < 0)[0] + # idx6 = np.where((x5 - 3)**2 + x4 - 4 < 0)[0] + # exIdx = np.unique(np.hstack([idx1, idx2, idx3, idx4, idx5, idx6])) # 得到非可行解的下标 + # f1[exIdx] = f1[exIdx] + np.max(f1) - np.min(f1) + # f2[exIdx] = f2[exIdx] + np.max(f2) - np.min(f2) + # 利用可行性法则处理约束条件 + CV = np.hstack([2 - x1 - x2, + x1 + x2 - 6, + -2 - x1 + x2, + x1 - 3 * x2 - 2, + (x3 - 3) ** 2 + x4 - 4, + 4 - (x5 - 3) ** 2 - x4]) + f = np.hstack([f1, f2]) + return f, CV diff --git a/geatpy/demo/moea_demo/moea_demo1/main.py b/geatpy/demo/moea_demo/moea_demo1/main.py new file mode 100644 index 00000000..c7505f5e --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo1/main.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" +该案例展示了一个离散决策变量的最小化目标的双目标优化问题的求解。问题的定义详见MyProblem.py。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 构建算法 + algorithm = ea.moea_NSGA2_templet(problem, + ea.Population(Encoding='BG', NIND=50), + MAXGEN=200, # 最大进化代数 + logTras=0) # 表示每隔多少代记录一次日志信息,0表示不记录。 + algorithm.mutOper.Pm = 0.2 # 修改变异算子的变异概率 + algorithm.recOper.XOVR = 0.9 # 修改交叉算子的交叉概率 + # 求解 + res = ea.optimize(algorithm, verbose=False, drawing=1, outputMsg=True, drawLog=False, saveFlag=False) + print(res) diff --git a/geatpy/demo/moea_demo/moea_demo2/MyProblem.py b/geatpy/demo/moea_demo/moea_demo2/MyProblem.py new file mode 100644 index 00000000..9dbbbb1e --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo2/MyProblem.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +""" +min f1 = X**2 +min f2 = (X - 2)**2 +s.t. +X**2 - 2.5 * X + 1.5 >= 0 +10 <= Xi <= 10, (i = 1,2,3,...) +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self, M=2): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + Dim = 1 # 初始化Dim(决策变量维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [-10] * Dim # 决策变量下界 + ub = [10] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + f1 = Vars ** 2 + f2 = (Vars - 2) ** 2 + # # 利用罚函数法处理约束条件 + # exIdx = np.where(Vars**2 - 2.5 * Vars + 1.5 < 0)[0] # 获取不满足约束条件的个体在种群中的下标 + # f1[exIdx] = f1[exIdx] + np.max(f1) - np.min(f1) + # f2[exIdx] = f2[exIdx] + np.max(f2) - np.min(f2) + # 利用可行性法则处理约束条件 + CV = -Vars ** 2 + 2.5 * Vars - 1.5 + ObjV = np.hstack([f1, f2]) + return ObjV, CV diff --git a/geatpy/demo/moea_demo/moea_demo2/main.py b/geatpy/demo/moea_demo/moea_demo2/main.py new file mode 100644 index 00000000..d6280c59 --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo2/main.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" +该案例展示了一个带约束连续决策变量的最小化目标的双目标优化问题的求解。详见MyProblem.py。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 构建算法 + algorithm = ea.moea_NSGA2_templet(problem, + ea.Population(Encoding='RI', NIND=50), + MAXGEN=200, # 最大进化代数 + logTras=0) # 表示每隔多少代记录一次日志信息,0表示不记录。 + # 求解 + res = ea.optimize(algorithm, verbose=False, drawing=1, outputMsg=True, drawLog=False, saveFlag=False) + print(res) diff --git a/geatpy/demo/moea_demo/moea_demo3/MyProblem.py b/geatpy/demo/moea_demo/moea_demo3/MyProblem.py new file mode 100644 index 00000000..4d11d2b1 --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo3/MyProblem.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +""" +一个带约束的多目标背包问题: + 假设有5类物品,每类物品中包含着四个具体的物品,要求从这五种类别的物品中分别选择一个物品放进背包, +使背包内的物品总价最高,总体积最小,且背包的总质量不能超过92kg。用矩阵P代表背包中物品的价值; +矩阵R代表背包中物品的体积;矩阵C代表物品的质量。P,R,C的取值如下: +P=[[3,4,9,15,2], R=[[0.2, 0.3, 0.4, 0.6, 0.1], C=[[10,13,24,32,4], + [4,6,8,10,2.5], [0.25,0.35,0.38,0.45,0.15], [12,15,22,26,5.2], + [5,7,10,12,3], [0.3, 0.37,0.5, 0.5, 0.2], [14,18,25,28,6.8], + [3,5,10,10,2]] [0.3, 0.32,0.45,0.6, 0.2]] [14,14,28,32,6.8]] +分析: + 这是一个0-1背包问题,但如果用一个元素为0或1的矩阵来表示哪些物品被选中,则不利于后面采用进 +化算法进行求解。可以从另一种角度对背包问题进行编码:由于问题要求在每类物品均要选出一件,这里我 +们可以用0, 1, 2, 3来表示具体选择哪件物品。因此染色体可以编码为一个元素属于{0, 1, 2, 3}的1x5Numpy ndarray一维数组, +比如:[0,0,0,0,0]表示从这五类物品中各选取第一个物品。 +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self, M=2): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + maxormins = [-1, 1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 5 # 初始化Dim(决策变量维数) + varTypes = [1] * Dim # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [0] * Dim # 决策变量下界 + ub = [3] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + # 添加几个属性来存储P、R、C + self.P = np.array([[3, 4, 9, 15, 2], + [4, 6, 8, 10, 2.5], + [5, 7, 10, 12, 3], + [3, 5, 10, 10, 2]]) + self.R = np.array([[0.2, 0.3, 0.4, 0.6, 0.1], + [0.25, 0.35, 0.38, 0.45, 0.15], + [0.3, 0.37, 0.5, 0.5, 0.2], + [0.3, 0.32, 0.45, 0.6, 0.2]]) + self.C = np.array([[10, 13, 24, 32, 4], + [12, 15, 22, 26, 5.2], + [14, 18, 25, 28, 6.8], + [14, 14, 28, 32, 6.8]]) + + def evalVars(self, Vars): # 目标函数 + x = Vars.astype(int) + f1 = np.sum(self.P[x, [0, 1, 2, 3, 4]], 1) + f2 = np.sum(self.R[x, [0, 1, 2, 3, 4]], 1) + # 采用可行性法则处理约束 + CV = np.array([np.sum(self.C[x, [0, 1, 2, 3, 4]], 1)]).T - 92 + ObjV = np.vstack([f1, f2]).T + return ObjV, CV diff --git a/geatpy/demo/moea_demo/moea_demo3/main.py b/geatpy/demo/moea_demo/moea_demo3/main.py new file mode 100644 index 00000000..02c954b4 --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo3/main.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" +该案例展示了一个带约束的多目标背包问题的求解。详见MyProblem.py。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 构建算法 + algorithm = ea.moea_NSGA2_templet(problem, + ea.Population(Encoding='BG', NIND=30), + MAXGEN=300, # 最大进化代数 + logTras=0) # 表示每隔多少代记录一次日志信息,0表示不记录。 + # 求解 + res = ea.optimize(algorithm, verbose=False, drawing=1, outputMsg=True, drawLog=False, saveFlag=False) + print(res) diff --git a/geatpy/demo/moea_demo/moea_demo4/MyProblem.py b/geatpy/demo/moea_demo/moea_demo4/MyProblem.py new file mode 100644 index 00000000..3fb1e8da --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo4/MyProblem.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +""" +一个带约束的多目标背包问题: + 假设有5类物品,每类物品中包含着四个具体的物品(序号记作0,1,2,3),现要求从这五种类别的物品 +中分别选择一个物品放进背包,要求使背包内的物品总价最高,总体积最小,且背包的总质量不能超过92kg。 +不同于moea_demo3的案例的是:这里额外要求选出的五个物品的序号最多只能有2个重复。 + 若用矩阵P代表背包中物品的价值;矩阵R代表背包中物品的体积;矩阵C代表物品的质量,则P,R,C的取值如下: +P=[[3,4,9,15,2], R=[[0.2, 0.3, 0.4, 0.6, 0.1], C=[[10,13,24,32,4], + [4,6,8,10,2.5], [0.25,0.35,0.38,0.45,0.15], [12,15,22,26,5.2], + [5,7,10,12,3], [0.3, 0.37,0.5, 0.5, 0.2], [14,18,25,28,6.8], + [3,5,10,10,2]] [0.3, 0.32,0.45,0.6, 0.2]] [14,14,28,32,6.8]] +分析: + 这是一个0-1背包问题,但如果用一个元素为0或1的矩阵来表示哪些物品被选中,则不利于后面采用进 +化算法进行求解。可以从另一种角度对背包问题进行编码:由于问题要求在每类物品均要选出一件,这里我 +们可以用每类物品的序号0, 1, 2, 3来表示从每类物品中具体选择哪件物品。因此染色体可以编码为一个 +元素属于{0, 1, 2, 3}的1x5Numpy ndarray一维数组,比如:[0,1,2,3,0]。 + 该问题可以像moea_demo3那样单纯用实整数编码'RI'来实现,但由于有一个”要求选出的五个物品的 +序号最多只能有2个重复“的约束,因此把后面四个决策变量用排列编码'P',第一个决策变量采用实整数编码'RI'来求解会更好。 +MyProblem是问题类,本质上是不需要管具体使用什么编码的,因此混合编码的设置在执行脚本main.py中进行而不是在此处。 +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self, M=2): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + maxormins = [-1, 1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 5 # 初始化Dim(决策变量维数) + varTypes = [1] * Dim # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [0] * Dim # 决策变量下界 + ub = [3] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + # 添加几个属性来存储P、R、C + self.P = np.array([[3, 4, 9, 15, 2], + [4, 6, 8, 10, 2.5], + [5, 7, 10, 12, 3], + [3, 5, 10, 10, 2]]) + self.R = np.array([[0.2, 0.3, 0.4, 0.6, 0.1], + [0.25, 0.35, 0.38, 0.45, 0.15], + [0.3, 0.37, 0.5, 0.5, 0.2], + [0.3, 0.32, 0.45, 0.6, 0.2]]) + self.C = np.array([[10, 13, 24, 32, 4], + [12, 15, 22, 26, 5.2], + [14, 18, 25, 28, 6.8], + [14, 14, 28, 32, 6.8]]) + + def evalVars(self, Vars): # 目标函数 + x = Vars.astype(int) # 得到决策变量矩阵 + f1 = np.sum(self.P[x, [0, 1, 2, 3, 4]], 1) + f2 = np.sum(self.R[x, [0, 1, 2, 3, 4]], 1) + # 采用可行性法则处理约束 + CV = np.array([np.sum(self.C[x, [0, 1, 2, 3, 4]], 1)]).T - 92 + ObjV = np.vstack([f1, f2]).T + return ObjV, CV diff --git a/geatpy/demo/moea_demo/moea_demo4/main.py b/geatpy/demo/moea_demo/moea_demo4/main.py new file mode 100644 index 00000000..4e8375f5 --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo4/main.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 构建算法 + algorithm = ea.moea_psy_NSGA2_templet(problem, + ea.PsyPopulation(Encodings=['RI', 'P'], NIND=30, EncoIdxs=[[0], [1,2,3,4]]), + MAXGEN=200, # 最大进化代数 + logTras=0) # 表示每隔多少代记录一次日志信息,0表示不记录。 + # 求解 + res = ea.optimize(algorithm, verbose=False, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + print(res) diff --git a/geatpy/demo/moea_demo/moea_demo5/MyProblem.py b/geatpy/demo/moea_demo/moea_demo5/MyProblem.py new file mode 100644 index 00000000..7d919d64 --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo5/MyProblem.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +""" +该案例是moea_demo1的拓展,在main.py中通过两次运行算法类来展示如何通过先验知识来帮助进化。 +待优化模型如下: +min f1 = -25 * (x1 - 2)**2 - (x2 - 2)**2 - (x3 - 1)**2 - (x4 - 4)**2 - (x5 - 1)**2 +min f2 = (x1 - 1)**2 + (x2 - 1)**2 + (x3 - 1)**2 + (x4 - 1)**2 + (x5 - 1)**2 +s.t. +x1 + x2 >= 2 +x1 + x2 <= 6 +x1 - x2 >= -2 +x1 - 3*x2 <= 2 +4 - (x3 - 3)**2 - x4 >= 0 +(x5 - 3)**2 + x4 - 4 >= 0 +x1,x2,x3,x4,x5 ∈ {0,1,2,3,4,5,6,7,8,9,10} +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self, M=2): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + Dim = 5 # 初始化Dim(决策变量维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [1] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [10] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + x2 = Vars[:, [1]] + x3 = Vars[:, [2]] + x4 = Vars[:, [3]] + x5 = Vars[:, [4]] + f1 = -25 * (x1 - 2) ** 2 - (x2 - 2) ** 2 - (x3 - 1) ** 2 - (x4 - 4) ** 2 - (x5 - 1) ** 2 + f2 = (x1 - 1) ** 2 + (x2 - 1) ** 2 + (x3 - 1) ** 2 + (x4 - 1) ** 2 + (x5 - 1) ** 2 + # # 利用罚函数法处理约束条件 + # idx1 = np.where(x1 + x2 < 2)[0] + # idx2 = np.where(x1 + x2 > 6)[0] + # idx3 = np.where(x1 - x2 < -2)[0] + # idx4 = np.where(x1 - 3*x2 > 2)[0] + # idx5 = np.where(4 - (x3 - 3)**2 - x4 < 0)[0] + # idx6 = np.where((x5 - 3)**2 + x4 - 4 < 0)[0] + # exIdx = np.unique(np.hstack([idx1, idx2, idx3, idx4, idx5, idx6])) # 得到非可行解的下标 + # f1[exIdx] = f1[exIdx] + np.max(f1) - np.min(f1) + # f2[exIdx] = f2[exIdx] + np.max(f2) - np.min(f2) + # 利用可行性法则处理约束条件 + CV = np.hstack([2 - x1 - x2, + x1 + x2 - 6, + -2 - x1 + x2, + x1 - 3 * x2 - 2, + (x3 - 3) ** 2 + x4 - 4, + 4 - (x5 - 3) ** 2 - x4]) + ObjV = np.hstack([f1, f2]) + return ObjV, CV diff --git a/geatpy/demo/moea_demo/moea_demo5/main.py b/geatpy/demo/moea_demo/moea_demo5/main.py new file mode 100644 index 00000000..03448e40 --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo5/main.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 构建算法 + algorithm = ea.moea_awGA_templet(problem, + ea.Population(Encoding='RI', NIND=50), + MAXGEN=20, # 最大进化代数 + logTras=0) # 表示每隔多少代记录一次日志信息 + # 求解 + res = ea.optimize(algorithm, verbose=False, drawing=0, outputMsg=False, drawLog=False, saveFlag=False) + prophetPop = res['optPop'] + algorithm = ea.moea_NSGA2_templet(problem, + ea.Population(Encoding='RI', NIND=50), + prophetPop=prophetPop, # 传入先验知识 + MAXGEN=50, # 最大进化代数 + logTras=0) # 表示每隔多少代记录一次日志信息,0表示不记录。 + # 求解 + res = ea.optimize(algorithm, verbose=False, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + print(res) \ No newline at end of file diff --git a/geatpy/demo/moea_demo/moea_demo6/MyProblem.py b/geatpy/demo/moea_demo/moea_demo6/MyProblem.py new file mode 100644 index 00000000..cc87838c --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo6/MyProblem.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +""" +这是一个离散决策变量的最小化目标的双目标优化问题。 +min f1 = -25 * (x1 - 2)**2 - (x2 - 2)**2 - (x3 - 1)**2 - (x4 - 4)**2 - (x5 - 1)**2 +min f2 = (x1 - 1)**2 + (x2 - 1)**2 + (x3 - 1)**2 + (x4 - 1)**2 + (x5 - 1)**2 +s.t. +x1 + x2 >= 2 +x1 + x2 <= 6 +x1 - x2 >= -2 +x1 - 3*x2 <= 2 +4 - (x3 - 3)**2 - x4 >= 0 +(x5 - 3)**2 + x4 - 4 >= 0 +x1,x2,x3,x4,x5 ∈ {0,1,2,3,4,5,6,7,8,9,10} +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self, M=2): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + Dim = 5 # 初始化Dim(决策变量维数) + maxormins = [1] * M # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + varTypes = [1] * Dim # 初始化varTypes(决策变量的类型,0:实数;1:整数) + lb = [0] * Dim # 决策变量下界 + ub = [10] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def aimFunc(self, pop): # 目标函数 + Vars = pop.Phen # 得到决策变量矩阵 + x1 = Vars[:, [0]] + x2 = Vars[:, [1]] + x3 = Vars[:, [2]] + x4 = Vars[:, [3]] + x5 = Vars[:, [4]] + f1 = -25 * (x1 - 2) ** 2 - (x2 - 2) ** 2 - (x3 - 1) ** 2 - (x4 - 4) ** 2 - (x5 - 1) ** 2 + f2 = (x1 - 1) ** 2 + (x2 - 1) ** 2 + (x3 - 1) ** 2 + (x4 - 1) ** 2 + (x5 - 1) ** 2 + # 利用可行性法则处理约束条件 + pop.CV = np.hstack([2 - x1 - x2, + x1 + x2 - 6, + -2 - x1 + x2, + x1 - 3 * x2 - 2, + (x3 - 3) ** 2 + x4 - 4, + 4 - (x5 - 3) ** 2 - x4]) + pop.ObjV = np.hstack([f1, f2]) # 把求得的目标函数值赋值给种群pop的ObjV diff --git a/geatpy/demo/moea_demo/moea_demo6/main.py b/geatpy/demo/moea_demo/moea_demo6/main.py new file mode 100644 index 00000000..0f914927 --- /dev/null +++ b/geatpy/demo/moea_demo/moea_demo6/main.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" +描述: + 该案例是moea_demo1的另一个版本,展示了如何定义aimFunc()而不是evalVars()来计算目标函数和违反约束程度值。【见MyProblem.py】 + 同时展示如何定义outFunc(),用于让算法在每一次进化时调用该outFunc()函数。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 定义outFunc()函数 + def outFunc(alg, pop): # alg 和 pop为outFunc的固定输入参数,分别为算法对象和每次迭代的种群对象。 + print('第 %d 代' % alg.currentGen) + # 构建算法 + algorithm = ea.moea_NSGA2_templet(problem, + ea.Population(Encoding='RI', NIND=50), + MAXGEN=200, # 最大进化代数 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + outFunc=outFunc) + # 求解 + res = ea.optimize(algorithm, verbose=False, drawing=1, outputMsg=True, drawLog=True, saveFlag=False) + print(res) diff --git a/geatpy/demo/moea_demo/moea_quick_start/main.py b/geatpy/demo/moea_demo/moea_quick_start/main.py new file mode 100644 index 00000000..28d7df17 --- /dev/null +++ b/geatpy/demo/moea_demo/moea_quick_start/main.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- + +import geatpy as ea +import numpy as np + +""" + +本案例展示了如何快速创建多目标优化问题对象、快速调用算法求解。 + +""" + +if __name__ == '__main__': + # 构建问题 + def evalVars(Vars): # 定义目标函数(含约束) + f1 = Vars ** 2 + f2 = (Vars - 2) ** 2 + ObjV = np.hstack([f1, f2]) + CV = -Vars ** 2 + 2.5 * Vars - 1.5 + return ObjV, CV + + + problem = ea.Problem(name='moea quick start', + M=2, + maxormins=[1, 1], + Dim=1, + varTypes=[0], + lb=[-10], + ub=[10], + evalVars=evalVars) + # 构建算法 + algorithm = ea.moea_NSGA2_templet(problem, + ea.Population(Encoding='RI', NIND=20), + MAXGEN=50, # 最大进化代数 + logTras=1) # 表示每隔多少代记录一次日志信息,0表示不记录。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=True, saveFlag=True) + print(res) diff --git a/geatpy/demo/soea_demo/soea_demo1/MyProblem.py b/geatpy/demo/soea_demo/soea_demo1/MyProblem.py new file mode 100644 index 00000000..33ec8935 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo1/MyProblem.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +""" +max f = x * np.sin(10 * np.pi * x) + 2.0 +s.t. +-1 <= x <= 2 +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [-1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 1 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [-1] # 决策变量下界 + ub = [2] # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, x): # 目标函数 + f = x * np.sin(10 * np.pi * x) + 2.0 + return f diff --git a/geatpy/demo/soea_demo/soea_demo1/main.py b/geatpy/demo/soea_demo/soea_demo1/main.py new file mode 100644 index 00000000..d8f91ce0 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo1/main.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" +该案例展示了一个简单的连续型决策变量最大化目标的单目标优化问题的求解。问题的定义详见MyProblem.py。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 构建算法 + algorithm = ea.soea_SEGA_templet(problem, + ea.Population(Encoding='RI', NIND=40), + MAXGEN=25, # 最大进化代数。 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + trappedValue=1e-6, # 单目标优化陷入停滞的判断阈值。 + maxTrappedCount=10) # 进化停滞计数器最大上限值。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + print(res) diff --git a/geatpy/demo/soea_demo/soea_demo10/MyProblem.py b/geatpy/demo/soea_demo/soea_demo10/MyProblem.py new file mode 100644 index 00000000..aa51ffda --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo10/MyProblem.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +""" + 这是一个带等式约束的连续型决策变量最大化目标的单目标优化问题, + 该函数存在多个欺骗性很强的局部最优点。 + max f = 4*x1 + 2*x2 + x3 + s.t. + 2*x1 + x2 - 1 <= 0 + x1 + 2*x3 - 2 <= 0 + x1 + x2 + x3 - 1 == 0 + 0 <= x1,x2 <= 1 + 0 < x3 < 2 +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [-1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 3 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [0, 0, 0] # 决策变量下界 + ub = [1, 1, 2] # 决策变量上界 + lbin = [1, 1, 0] # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1, 1, 0] # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + x2 = Vars[:, [1]] + x3 = Vars[:, [2]] + f = 4 * x1 + 2 * x2 + x3 + # 采用可行性法则处理约束 + CV = np.hstack([2 * x1 + x2 - 1, + x1 + 2 * x3 - 2, + np.abs(x1 + x2 + x3 - 1)]) + return f, CV + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[2.5]]) + return referenceObjV diff --git a/geatpy/demo/soea_demo/soea_demo10/main.py b/geatpy/demo/soea_demo/soea_demo10/main.py new file mode 100644 index 00000000..21254702 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo10/main.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +import numpy as np +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" + 该案例展示了一个带等式约束的连续型决策变量最大化目标的单目标优化问题。问题的定义详见MyProblem.py。 + 与soea_demo2不同之处是采用先验知识帮助进化优化。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() # 生成问题对象 + # 快速构建算法 + algorithm = ea.soea_DE_currentToBest_1_bin_templet(problem, + ea.Population(Encoding='RI', NIND=20), + MAXGEN=400, # 最大进化代数。 + logTras=0) # 表示每隔多少代记录一次日志信息,0表示不记录。 + algorithm.mutOper.F = 0.7 # 差分进化中的参数F。 + algorithm.recOper.XOVR = 0.7 # 交叉概率。 + # 先验知识 + prophetVars = np.array([[0.4, 0.2, 0.4]]) # 假设已知[0.4, 0.2, 0.4]为一组比较优秀的变量。 + # 求解 + res = ea.optimize(algorithm, prophet=prophetVars, verbose=True, drawing=1, outputMsg=True, drawLog=True, saveFlag=True) + print(res) diff --git a/geatpy/demo/soea_demo/soea_demo11/MyProblem.py b/geatpy/demo/soea_demo/soea_demo11/MyProblem.py new file mode 100644 index 00000000..7c2feb71 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo11/MyProblem.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +import numpy as np + +import geatpy as ea + +""" +max f = (-1+x1+((6-x2)*x2-2)*x2)**2+(-1+x1+((x2+2)*x2-10)*x2)**2 +s.t. x∈{1.1, 1, 0, 3, 5.5, 7.2, 9} +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + self.var_set = np.array([1.1, 1, 0, 3, 5.5, 7.2, 9]) # 设定一个集合,要求决策变量的值取自于该集合 + Dim = 2 # 初始化Dim(决策变量维数) + varTypes = [1] * Dim # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [0, 0] # 决策变量下界 + ub = [6, 6] # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + Vars = Vars.astype(np.int32) # 强制类型转换确保元素是整数 + x1 = self.var_set[Vars[:, [0]]] # 得到所有的x1组成的列向量 + x2 = self.var_set[Vars[:, [1]]] # 得到所有的x2组成的列向量 + f = (-1 + x1 + ((6 - x2) * x2 - 2) * x2) ** 2 + (-1 + x1 + ((x2 + 2) * x2 - 10) * x2) ** 2 + return f diff --git a/geatpy/demo/soea_demo/soea_demo11/main.py b/geatpy/demo/soea_demo/soea_demo11/main.py new file mode 100644 index 00000000..016a9b17 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo11/main.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 + +import geatpy as ea # import geatpy + +""" +该案例展示2个决策变量的单目标优化,决策变量的值将取自于一个设定好的变量集合。问题的定义详见MyProblem.py。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 构建算法 + algorithm = ea.soea_DE_rand_1_bin_templet(problem, + ea.Population(Encoding='RI', NIND=20), + MAXGEN=25, # 最大进化代数。 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + trappedValue=1e-6, # 单目标优化陷入停滞的判断阈值。 + maxTrappedCount=10) # 进化停滞计数器最大上限值。 + algorithm.mutOper.F = 0.5 # 差分进化中的参数F。 + algorithm.recOper.XOVR = 0.2 # 差分进化中的参数Cr。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + print(res) diff --git a/geatpy/demo/soea_demo/soea_demo2/MyProblem.py b/geatpy/demo/soea_demo/soea_demo2/MyProblem.py new file mode 100644 index 00000000..dd22ba0a --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo2/MyProblem.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +"""MyProblem.py""" +import numpy as np +import geatpy as ea + +""" + 该目标函数存在多个欺骗性很强的局部最优点。 + max f = 4*x1 + 2*x2 + x3 + s.t. + 2*x1 + x2 - 1 <= 0 + x1 + 2*x3 - 2 <= 0 + x1 + x2 + x3 - 1 == 0 + 0 <= x1,x2 <= 1 + 0 < x3 < 2 +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [-1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 3 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [0, 0, 0] # 决策变量下界 + ub = [1, 1, 2] # 决策变量上界 + lbin = [1, 1, 0] # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1, 1, 0] # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, Vars): # 目标函数 + x1 = Vars[:, [0]] + x2 = Vars[:, [1]] + x3 = Vars[:, [2]] + f = 4 * x1 + 2 * x2 + x3 + # 采用可行性法则处理约束 + CV = np.hstack([2 * x1 + x2 - 1, + x1 + 2 * x3 - 2, + np.abs(x1 + x2 + x3 - 1)]) + return f, CV + + def calReferObjV(self): # 设定目标数参考值(本问题目标函数参考值设定为理论最优值) + referenceObjV = np.array([[2.5]]) + return referenceObjV diff --git a/geatpy/demo/soea_demo/soea_demo2/main.py b/geatpy/demo/soea_demo/soea_demo2/main.py new file mode 100644 index 00000000..5dd30c10 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo2/main.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" + 该案例展示了一个带等式约束的连续型决策变量最大化目标的单目标优化问题的求解。问题的定义详见MyProblem.py。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 构建算法 + algorithm = ea.soea_DE_rand_1_bin_templet(problem, + ea.Population(Encoding='RI', NIND=100), + MAXGEN=500, # 最大进化代数。 + logTras=1) # 表示每隔多少代记录一次日志信息,0表示不记录。 + algorithm.mutOper.F = 0.5 # 差分进化中的参数F + algorithm.recOper.XOVR = 0.7 # 重组概率 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + print(res) diff --git a/geatpy/demo/soea_demo/soea_demo3/MyProblem.py b/geatpy/demo/soea_demo/soea_demo3/MyProblem.py new file mode 100644 index 00000000..451ef04f --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo3/MyProblem.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +""" + 有十座城市:A, B, C, D, E, F, G, H, I, J,坐标如下: + X Y + [[0.4, 0.4439], + [0.2439,0.1463], + [0.1707,0.2293], + [0.2293,0.761], + [0.5171,0.9414], + [0.8732,0.6536], + [0.6878,0.5219], + [0.8488,0.3609], + [0.6683,0.2536], + [0.6195,0.2634]] + 某旅行者从A城市出发,想逛遍所有城市,并且每座城市去且只去一次,最后要返回出发地, +而且需要从G地拿重要文件到D地,另外要从F地把公司的车开到E地,那么他应该如何设计行程方案,才能用 +最短的路程来满足他的旅行需求? + 分析:在这个案例中,旅行者从A地出发,把其他城市走遍一次后回到A地,因此我们只需要考虑中间途 +径的9个城市的访问顺序即可。这9个城市需要排列组合选出满足约束条件的最优的排列顺序作为最终的路线方案。 +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 9 # 初始化Dim(决策变量维数) + varTypes = [1] * Dim # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [1] * Dim # 决策变量下界 + ub = [9] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + # 新增一个属性存储旅行地坐标 + self.places = np.array([[0.4, 0.4439], + [0.2439, 0.1463], + [0.1707, 0.2293], + [0.2293, 0.761], + [0.5171, 0.9414], + [0.8732, 0.6536], + [0.6878, 0.5219], + [0.8488, 0.3609], + [0.6683, 0.2536], + [0.6195, 0.2634]]) + + def evalVars(self, x): # 目标函数 + # 添加从0地出发且最后回到出发地 + X = np.hstack([np.zeros((x.shape[0], 1)), x, np.zeros((x.shape[0], 1))]).astype(int) + ObjV = [] # 存储所有种群个体对应的总路程 + for i in range(X.shape[0]): + journey = self.places[X[i], :] # 按既定顺序到达的地点坐标 + distance = np.sum(np.sqrt(np.sum(np.diff(journey.T) ** 2, 0))) # 计算总路程 + ObjV.append(distance) + f = np.array([ObjV]).T + # 找到违反约束条件的个体在种群中的索引,保存在向量exIdx中(如:若0、2、4号个体违反约束条件,则编程找出他们来) + exIdx1 = np.where(np.where(x == 3)[1] - np.where(x == 6)[1] < 0)[0] + exIdx2 = np.where(np.where(x == 4)[1] - np.where(x == 5)[1] < 0)[0] + exIdx = np.unique(np.hstack([exIdx1, exIdx2])) + CV = np.zeros((x.shape[0], 1)) + CV[exIdx] = 1 # 把求得的违反约束程度矩阵赋值给种群pop的CV + return f, CV diff --git a/geatpy/demo/soea_demo/soea_demo3/main.py b/geatpy/demo/soea_demo/soea_demo3/main.py new file mode 100644 index 00000000..3990cdd4 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo3/main.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +import matplotlib.pyplot as plt +import numpy as np +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" + 该案例展示了一个带约束的单目标旅行商问题的求解。问题的定义详见MyProblem.py。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 构建算法 + algorithm = ea.soea_SEGA_templet(problem, + ea.Population(Encoding='P', NIND=50), + MAXGEN=200, # 最大进化代数 + logTras=1) # 表示每隔多少代记录一次日志信息,0表示不记录。 + algorithm.mutOper.Pm = 0.5 # 变异概率 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + # 绘制路线图 + if res['success']: + print('最短路程为:%s' % res['ObjV'][0][0]) + print('最佳路线为:') + best_journey = np.hstack([0, res['Vars'][0, :], 0]) + for i in range(len(best_journey)): + print(int(best_journey[i]), end=' ') + print() + # 绘图 + plt.figure() + plt.plot(problem.places[best_journey.astype(int), 0], problem.places[best_journey.astype(int), 1], c='black') + plt.plot(problem.places[best_journey.astype(int), 0], problem.places[best_journey.astype(int), 1], 'o', + c='black') + for i in range(len(best_journey)): + plt.text(problem.places[int(best_journey[i]), 0], problem.places[int(best_journey[i]), 1], + chr(int(best_journey[i]) + 65), fontsize=20) + plt.grid(True) + plt.xlabel('x') + plt.ylabel('y') + plt.savefig('roadmap.svg', dpi=600, bbox_inches='tight') + plt.show() + else: + print('没找到可行解。') diff --git a/geatpy/demo/soea_demo/soea_demo4/MyProblem.py b/geatpy/demo/soea_demo/soea_demo4/MyProblem.py new file mode 100644 index 00000000..062345e9 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo4/MyProblem.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + # 定义需要匹配的句子 + strs = 'Tom is a little boy, isn\'t he? Yes he is, he is a good and smart child and he is always ready to ' \ + 'help others, all in all we all love him very much.' + self.words = [] + for c in strs: + self.words.append(ord(c)) # 把字符串转成ASCII码 + M = 1 # 初始化M(目标维数) + maxormins = [1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = len(self.words) # 初始化Dim(决策变量维数) + varTypes = [1] * Dim # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [32] * Dim # 决策变量下界 + ub = [122] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + print('句子长度: ', len(self.words)) + + def evalVars(self, Vars): # 目标函数 + diff = np.sum((Vars - self.words) ** 2, 1) + f = np.array([diff]).T + return f diff --git a/geatpy/demo/soea_demo/soea_demo4/main.py b/geatpy/demo/soea_demo/soea_demo4/main.py new file mode 100644 index 00000000..7ca64b39 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo4/main.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" +该案例展示了一个利用单目标进化算法实现句子匹配的应用实例。问题的定义详见MyProblem.py。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 快速构建算法 + algorithm = ea.soea_DE_rand_1_L_templet(problem, + ea.Population(Encoding='RI', NIND=50), + MAXGEN=2000, # 最大进化代数 + logTras=1) # 表示每隔多少代记录一次日志信息,0表示不记录。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=False, drawLog=False, saveFlag=True) + print('最佳目标函数值:%s' % res['ObjV'][0][0]) + print('搜索到的句子为:') + for num in res['Vars'][0, :]: + print(chr(int(num)), end='') diff --git a/geatpy/demo/soea_demo/soea_demo5/MyProblem.py b/geatpy/demo/soea_demo/soea_demo5/MyProblem.py new file mode 100644 index 00000000..e9f4087c --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo5/MyProblem.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +""" +该案例展示了一个需要混合编码种群来进化的最大化目标的单目标优化问题。 +模型: +max f = sin(2x1) - cos(x2) + 2x3^2 -3x4 + (x5-3)^2 + 7x6 +s.t. +-1.5 <= x1,x2 <= 2.5, +1 <= x3,x4,x5,x6 <= 7,且x3,x4,x5,x6为互不相等的整数。 +分析: +该问题可以单纯用实整数编码'RI'来实现,但由于有一个”x3,x4,x5,x6互不相等“的约束, +因此把x3,x4,x5,x6用排列编码'P',x1和x2采用实整数编码'RI'来求解会更好。 +MyProblem是问题类,本质上是不需要管具体使用什么编码的,因此混合编码的设置在执行脚本main.py中进行而不是在此处。 +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [-1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 6 # 初始化Dim(决策变量维数) + varTypes = [0, 0, 1, 1, 1, 1] # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [-1.5, -1.5, 1, 1, 1, 1] # 决策变量下界 + ub = [2.5, 2.5, 7, 7, 7, 7] # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, X): # 目标函数 + x1 = X[:, [0]] + x2 = X[:, [1]] + x3 = X[:, [2]] + x4 = X[:, [3]] + x5 = X[:, [4]] + x6 = X[:, [5]] + f = np.sin(2 * x1) - np.cos(x2) + 2 * x3 ** 2 - 3 * x4 + ( + x5 - 3) ** 2 + 7 * x6 + return f diff --git a/geatpy/demo/soea_demo/soea_demo5/main.py b/geatpy/demo/soea_demo/soea_demo5/main.py new file mode 100644 index 00000000..134adb7c --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo5/main.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" +该案例展示了一个需要混合编码种群来进化的最大化目标的单目标优化问题。问题的定义详见MyProblem.py。 +分析: +该问题可以单纯用实整数编码'RI'来实现,但由于有一个”x3,x4,x5,x6互不相等“的约束, +因此把x3,x4,x5,x6用排列编码'P',x1和x2采用实整数编码'RI'来求解会更好。 +MyProblem是问题类,本质上是不需要管具体使用什么编码的,因此混合编码的设置在执行脚本main.py中进行而不是在此处。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 快速构建算法 + algorithm = ea.soea_psy_EGA_templet(problem, + ea.PsyPopulation(Encodings=['RI', 'P'], NIND=40, EncoIdxs=[[0, 1], [2, 3, 4, 5]]), + MAXGEN=25, # 最大进化代数 + logTras=1) # 表示每隔多少代记录一次日志信息,0表示不记录。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + print(res) diff --git a/geatpy/demo/soea_demo/soea_demo6/MyProblem.py b/geatpy/demo/soea_demo/soea_demo6/MyProblem.py new file mode 100644 index 00000000..fffb0f5a --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo6/MyProblem.py @@ -0,0 +1,97 @@ +# -*- coding: utf-8 -*- +import multiprocessing as mp +from multiprocessing import Pool as ProcessPool +from multiprocessing.dummy import Pool as ThreadPool +import numpy as np +from sklearn import preprocessing +from sklearn import svm +from sklearn.model_selection import cross_val_score + +import geatpy as ea + +""" +本问题需要用到一个外部数据集,存放在同目录下的iris.data中, +并且把iris.data按3:2划分为训练集数据iris_train.data和测试集数据iris_test.data。 +有关该数据集的详细描述详见http://archive.ics.uci.edu/ml/datasets/Iris +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self, PoolType): # PoolType是取值为'Process'或'Thread'的字符串 + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [-1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 2 # 初始化Dim(决策变量维数) + varTypes = [0, 0] # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [2 ** (-8)] * Dim # 决策变量下界 + ub = [2 ** 8] * Dim # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + # 目标函数计算中用到的一些数据 + fp = open('iris_train.data') + datas = [] + data_targets = [] + for line in fp.readlines(): + line_data = line.strip('\n').split(',') + data = [] + for i in line_data[0:4]: + data.append(float(i)) + datas.append(data) + data_targets.append(line_data[4]) + fp.close() + self.data = preprocessing.scale(np.array(datas)) # 训练集的特征数据(归一化) + self.dataTarget = np.array(data_targets) + # 设置用多线程还是多进程 + self.PoolType = PoolType + if self.PoolType == 'Thread': + self.pool = ThreadPool(2) # 设置池的大小 + elif self.PoolType == 'Process': + num_cores = int(mp.cpu_count()) # 获得计算机的核心数 + self.pool = ProcessPool(num_cores) # 设置池的大小 + + def evalVars(self, Vars): # 目标函数,采用多线程加速计算 + N = Vars.shape[0] + args = list( + zip(list(range(N)), [Vars] * N, [self.data] * N, [self.dataTarget] * N)) + if self.PoolType == 'Thread': + f = np.array(list(self.pool.map(subAimFunc, args))) + elif self.PoolType == 'Process': + result = self.pool.map_async(subAimFunc, args) + result.wait() + f = np.array(result.get()) + return f + + def test(self, C, G): # 代入优化后的C、Gamma对测试集进行检验 + # 读取测试集数据 + fp = open('iris_test.data') + datas = [] + data_targets = [] + for line in fp.readlines(): + line_data = line.strip('\n').split(',') + data = [] + for i in line_data[0:4]: + data.append(float(i)) + datas.append(data) + data_targets.append(line_data[4]) + fp.close() + data_test = preprocessing.scale(np.array(datas)) # 测试集的特征数据(归一化) + dataTarget_test = np.array(data_targets) # 测试集的标签数据 + svc = svm.SVC(C=C, kernel='rbf', gamma=G).fit(self.data, self.dataTarget) # 创建分类器对象并用训练集的数据拟合分类器模型 + dataTarget_predict = svc.predict(data_test) # 采用训练好的分类器对象对测试集数据进行预测 + print("测试集数据分类正确率 = %s%%" % ( + len(np.where(dataTarget_predict == dataTarget_test)[0]) / len(dataTarget_test) * 100)) + + +def subAimFunc(args): + i = args[0] + Vars = args[1] + data = args[2] + dataTarget = args[3] + C = Vars[i, 0] + G = Vars[i, 1] + svc = svm.SVC(C=C, kernel='rbf', gamma=G).fit(data, dataTarget) # 创建分类器对象并用训练集的数据拟合分类器模型 + scores = cross_val_score(svc, data, dataTarget, cv=30) # 计算交叉验证的得分 + ObjV_i = [scores.mean()] # 把交叉验证的平均得分作为目标函数值 + return ObjV_i diff --git a/geatpy/demo/soea_demo/soea_demo6/iris.data b/geatpy/demo/soea_demo/soea_demo6/iris.data new file mode 100644 index 00000000..396653cc --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo6/iris.data @@ -0,0 +1,150 @@ +5.1,3.5,1.4,0.2,Iris-setosa +4.9,3.0,1.4,0.2,Iris-setosa +4.7,3.2,1.3,0.2,Iris-setosa +4.6,3.1,1.5,0.2,Iris-setosa +5.0,3.6,1.4,0.2,Iris-setosa +5.4,3.9,1.7,0.4,Iris-setosa +4.6,3.4,1.4,0.3,Iris-setosa +5.0,3.4,1.5,0.2,Iris-setosa +4.4,2.9,1.4,0.2,Iris-setosa +4.9,3.1,1.5,0.1,Iris-setosa +5.4,3.7,1.5,0.2,Iris-setosa +4.8,3.4,1.6,0.2,Iris-setosa +4.8,3.0,1.4,0.1,Iris-setosa +4.3,3.0,1.1,0.1,Iris-setosa +5.8,4.0,1.2,0.2,Iris-setosa +5.7,4.4,1.5,0.4,Iris-setosa +5.4,3.9,1.3,0.4,Iris-setosa +5.1,3.5,1.4,0.3,Iris-setosa +5.7,3.8,1.7,0.3,Iris-setosa +5.1,3.8,1.5,0.3,Iris-setosa +5.4,3.4,1.7,0.2,Iris-setosa +5.1,3.7,1.5,0.4,Iris-setosa +4.6,3.6,1.0,0.2,Iris-setosa +5.1,3.3,1.7,0.5,Iris-setosa +4.8,3.4,1.9,0.2,Iris-setosa +5.0,3.0,1.6,0.2,Iris-setosa +5.0,3.4,1.6,0.4,Iris-setosa +5.2,3.5,1.5,0.2,Iris-setosa +5.2,3.4,1.4,0.2,Iris-setosa +4.7,3.2,1.6,0.2,Iris-setosa +4.8,3.1,1.6,0.2,Iris-setosa +5.4,3.4,1.5,0.4,Iris-setosa +5.2,4.1,1.5,0.1,Iris-setosa +5.5,4.2,1.4,0.2,Iris-setosa +4.9,3.1,1.5,0.1,Iris-setosa +5.0,3.2,1.2,0.2,Iris-setosa +5.5,3.5,1.3,0.2,Iris-setosa +4.9,3.1,1.5,0.1,Iris-setosa +4.4,3.0,1.3,0.2,Iris-setosa +5.1,3.4,1.5,0.2,Iris-setosa +5.0,3.5,1.3,0.3,Iris-setosa +4.5,2.3,1.3,0.3,Iris-setosa +4.4,3.2,1.3,0.2,Iris-setosa +5.0,3.5,1.6,0.6,Iris-setosa +5.1,3.8,1.9,0.4,Iris-setosa +4.8,3.0,1.4,0.3,Iris-setosa +5.1,3.8,1.6,0.2,Iris-setosa +4.6,3.2,1.4,0.2,Iris-setosa +5.3,3.7,1.5,0.2,Iris-setosa +5.0,3.3,1.4,0.2,Iris-setosa +7.0,3.2,4.7,1.4,Iris-versicolor +6.4,3.2,4.5,1.5,Iris-versicolor +6.9,3.1,4.9,1.5,Iris-versicolor +5.5,2.3,4.0,1.3,Iris-versicolor +6.5,2.8,4.6,1.5,Iris-versicolor +5.7,2.8,4.5,1.3,Iris-versicolor +6.3,3.3,4.7,1.6,Iris-versicolor +4.9,2.4,3.3,1.0,Iris-versicolor +6.6,2.9,4.6,1.3,Iris-versicolor +5.2,2.7,3.9,1.4,Iris-versicolor +5.0,2.0,3.5,1.0,Iris-versicolor +5.9,3.0,4.2,1.5,Iris-versicolor +6.0,2.2,4.0,1.0,Iris-versicolor +6.1,2.9,4.7,1.4,Iris-versicolor +5.6,2.9,3.6,1.3,Iris-versicolor +6.7,3.1,4.4,1.4,Iris-versicolor +5.6,3.0,4.5,1.5,Iris-versicolor +5.8,2.7,4.1,1.0,Iris-versicolor +6.2,2.2,4.5,1.5,Iris-versicolor +5.6,2.5,3.9,1.1,Iris-versicolor +5.9,3.2,4.8,1.8,Iris-versicolor +6.1,2.8,4.0,1.3,Iris-versicolor +6.3,2.5,4.9,1.5,Iris-versicolor +6.1,2.8,4.7,1.2,Iris-versicolor +6.4,2.9,4.3,1.3,Iris-versicolor +6.6,3.0,4.4,1.4,Iris-versicolor +6.8,2.8,4.8,1.4,Iris-versicolor +6.7,3.0,5.0,1.7,Iris-versicolor +6.0,2.9,4.5,1.5,Iris-versicolor +5.7,2.6,3.5,1.0,Iris-versicolor +5.5,2.4,3.8,1.1,Iris-versicolor +5.5,2.4,3.7,1.0,Iris-versicolor +5.8,2.7,3.9,1.2,Iris-versicolor +6.0,2.7,5.1,1.6,Iris-versicolor +5.4,3.0,4.5,1.5,Iris-versicolor +6.0,3.4,4.5,1.6,Iris-versicolor +6.7,3.1,4.7,1.5,Iris-versicolor +6.3,2.3,4.4,1.3,Iris-versicolor +5.6,3.0,4.1,1.3,Iris-versicolor +5.5,2.5,4.0,1.3,Iris-versicolor +5.5,2.6,4.4,1.2,Iris-versicolor +6.1,3.0,4.6,1.4,Iris-versicolor +5.8,2.6,4.0,1.2,Iris-versicolor +5.0,2.3,3.3,1.0,Iris-versicolor +5.6,2.7,4.2,1.3,Iris-versicolor +5.7,3.0,4.2,1.2,Iris-versicolor +5.7,2.9,4.2,1.3,Iris-versicolor +6.2,2.9,4.3,1.3,Iris-versicolor +5.1,2.5,3.0,1.1,Iris-versicolor +5.7,2.8,4.1,1.3,Iris-versicolor +6.3,3.3,6.0,2.5,Iris-virginica +5.8,2.7,5.1,1.9,Iris-virginica +7.1,3.0,5.9,2.1,Iris-virginica +6.3,2.9,5.6,1.8,Iris-virginica +6.5,3.0,5.8,2.2,Iris-virginica +7.6,3.0,6.6,2.1,Iris-virginica +4.9,2.5,4.5,1.7,Iris-virginica +7.3,2.9,6.3,1.8,Iris-virginica +6.7,2.5,5.8,1.8,Iris-virginica +7.2,3.6,6.1,2.5,Iris-virginica +6.5,3.2,5.1,2.0,Iris-virginica +6.4,2.7,5.3,1.9,Iris-virginica +6.8,3.0,5.5,2.1,Iris-virginica +5.7,2.5,5.0,2.0,Iris-virginica +5.8,2.8,5.1,2.4,Iris-virginica +6.4,3.2,5.3,2.3,Iris-virginica +6.5,3.0,5.5,1.8,Iris-virginica +7.7,3.8,6.7,2.2,Iris-virginica +7.7,2.6,6.9,2.3,Iris-virginica +6.0,2.2,5.0,1.5,Iris-virginica +6.9,3.2,5.7,2.3,Iris-virginica +5.6,2.8,4.9,2.0,Iris-virginica +7.7,2.8,6.7,2.0,Iris-virginica +6.3,2.7,4.9,1.8,Iris-virginica +6.7,3.3,5.7,2.1,Iris-virginica +7.2,3.2,6.0,1.8,Iris-virginica +6.2,2.8,4.8,1.8,Iris-virginica +6.1,3.0,4.9,1.8,Iris-virginica +6.4,2.8,5.6,2.1,Iris-virginica +7.2,3.0,5.8,1.6,Iris-virginica +7.4,2.8,6.1,1.9,Iris-virginica +7.9,3.8,6.4,2.0,Iris-virginica +6.4,2.8,5.6,2.2,Iris-virginica +6.3,2.8,5.1,1.5,Iris-virginica +6.1,2.6,5.6,1.4,Iris-virginica +7.7,3.0,6.1,2.3,Iris-virginica +6.3,3.4,5.6,2.4,Iris-virginica +6.4,3.1,5.5,1.8,Iris-virginica +6.0,3.0,4.8,1.8,Iris-virginica +6.9,3.1,5.4,2.1,Iris-virginica +6.7,3.1,5.6,2.4,Iris-virginica +6.9,3.1,5.1,2.3,Iris-virginica +5.8,2.7,5.1,1.9,Iris-virginica +6.8,3.2,5.9,2.3,Iris-virginica +6.7,3.3,5.7,2.5,Iris-virginica +6.7,3.0,5.2,2.3,Iris-virginica +6.3,2.5,5.0,1.9,Iris-virginica +6.5,3.0,5.2,2.0,Iris-virginica +6.2,3.4,5.4,2.3,Iris-virginica +5.9,3.0,5.1,1.8,Iris-virginica \ No newline at end of file diff --git a/geatpy/demo/soea_demo/soea_demo6/iris_test.data b/geatpy/demo/soea_demo/soea_demo6/iris_test.data new file mode 100644 index 00000000..e779560e --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo6/iris_test.data @@ -0,0 +1,60 @@ +4.8,3.1,1.6,0.2,Iris-setosa +5.4,3.4,1.5,0.4,Iris-setosa +5.2,4.1,1.5,0.1,Iris-setosa +5.5,4.2,1.4,0.2,Iris-setosa +4.9,3.1,1.5,0.1,Iris-setosa +5.0,3.2,1.2,0.2,Iris-setosa +5.5,3.5,1.3,0.2,Iris-setosa +4.9,3.1,1.5,0.1,Iris-setosa +4.4,3.0,1.3,0.2,Iris-setosa +5.1,3.4,1.5,0.2,Iris-setosa +5.0,3.5,1.3,0.3,Iris-setosa +4.5,2.3,1.3,0.3,Iris-setosa +4.4,3.2,1.3,0.2,Iris-setosa +5.0,3.5,1.6,0.6,Iris-setosa +5.1,3.8,1.9,0.4,Iris-setosa +4.8,3.0,1.4,0.3,Iris-setosa +5.1,3.8,1.6,0.2,Iris-setosa +4.6,3.2,1.4,0.2,Iris-setosa +5.3,3.7,1.5,0.2,Iris-setosa +5.0,3.3,1.4,0.2,Iris-setosa +5.5,2.4,3.8,1.1,Iris-versicolor +5.5,2.4,3.7,1.0,Iris-versicolor +5.8,2.7,3.9,1.2,Iris-versicolor +6.0,2.7,5.1,1.6,Iris-versicolor +5.4,3.0,4.5,1.5,Iris-versicolor +6.0,3.4,4.5,1.6,Iris-versicolor +6.7,3.1,4.7,1.5,Iris-versicolor +6.3,2.3,4.4,1.3,Iris-versicolor +5.6,3.0,4.1,1.3,Iris-versicolor +5.5,2.5,4.0,1.3,Iris-versicolor +5.5,2.6,4.4,1.2,Iris-versicolor +6.1,3.0,4.6,1.4,Iris-versicolor +5.8,2.6,4.0,1.2,Iris-versicolor +5.0,2.3,3.3,1.0,Iris-versicolor +5.6,2.7,4.2,1.3,Iris-versicolor +5.7,3.0,4.2,1.2,Iris-versicolor +5.7,2.9,4.2,1.3,Iris-versicolor +6.2,2.9,4.3,1.3,Iris-versicolor +5.1,2.5,3.0,1.1,Iris-versicolor +5.7,2.8,4.1,1.3,Iris-versicolor +7.4,2.8,6.1,1.9,Iris-virginica +7.9,3.8,6.4,2.0,Iris-virginica +6.4,2.8,5.6,2.2,Iris-virginica +6.3,2.8,5.1,1.5,Iris-virginica +6.1,2.6,5.6,1.4,Iris-virginica +7.7,3.0,6.1,2.3,Iris-virginica +6.3,3.4,5.6,2.4,Iris-virginica +6.4,3.1,5.5,1.8,Iris-virginica +6.0,3.0,4.8,1.8,Iris-virginica +6.9,3.1,5.4,2.1,Iris-virginica +6.7,3.1,5.6,2.4,Iris-virginica +6.9,3.1,5.1,2.3,Iris-virginica +5.8,2.7,5.1,1.9,Iris-virginica +6.8,3.2,5.9,2.3,Iris-virginica +6.7,3.3,5.7,2.5,Iris-virginica +6.7,3.0,5.2,2.3,Iris-virginica +6.3,2.5,5.0,1.9,Iris-virginica +6.5,3.0,5.2,2.0,Iris-virginica +6.2,3.4,5.4,2.3,Iris-virginica +5.9,3.0,5.1,1.8,Iris-virginica \ No newline at end of file diff --git a/geatpy/demo/soea_demo/soea_demo6/iris_train.data b/geatpy/demo/soea_demo/soea_demo6/iris_train.data new file mode 100644 index 00000000..e521bab1 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo6/iris_train.data @@ -0,0 +1,90 @@ +5.1,3.5,1.4,0.2,Iris-setosa +4.9,3.0,1.4,0.2,Iris-setosa +4.7,3.2,1.3,0.2,Iris-setosa +4.6,3.1,1.5,0.2,Iris-setosa +5.0,3.6,1.4,0.2,Iris-setosa +5.4,3.9,1.7,0.4,Iris-setosa +4.6,3.4,1.4,0.3,Iris-setosa +5.0,3.4,1.5,0.2,Iris-setosa +4.4,2.9,1.4,0.2,Iris-setosa +4.9,3.1,1.5,0.1,Iris-setosa +5.4,3.7,1.5,0.2,Iris-setosa +4.8,3.4,1.6,0.2,Iris-setosa +4.8,3.0,1.4,0.1,Iris-setosa +4.3,3.0,1.1,0.1,Iris-setosa +5.8,4.0,1.2,0.2,Iris-setosa +5.7,4.4,1.5,0.4,Iris-setosa +5.4,3.9,1.3,0.4,Iris-setosa +5.1,3.5,1.4,0.3,Iris-setosa +5.7,3.8,1.7,0.3,Iris-setosa +5.1,3.8,1.5,0.3,Iris-setosa +5.4,3.4,1.7,0.2,Iris-setosa +5.1,3.7,1.5,0.4,Iris-setosa +4.6,3.6,1.0,0.2,Iris-setosa +5.1,3.3,1.7,0.5,Iris-setosa +4.8,3.4,1.9,0.2,Iris-setosa +5.0,3.0,1.6,0.2,Iris-setosa +5.0,3.4,1.6,0.4,Iris-setosa +5.2,3.5,1.5,0.2,Iris-setosa +5.2,3.4,1.4,0.2,Iris-setosa +4.7,3.2,1.6,0.2,Iris-setosa +7.0,3.2,4.7,1.4,Iris-versicolor +6.4,3.2,4.5,1.5,Iris-versicolor +6.9,3.1,4.9,1.5,Iris-versicolor +5.5,2.3,4.0,1.3,Iris-versicolor +6.5,2.8,4.6,1.5,Iris-versicolor +5.7,2.8,4.5,1.3,Iris-versicolor +6.3,3.3,4.7,1.6,Iris-versicolor +4.9,2.4,3.3,1.0,Iris-versicolor +6.6,2.9,4.6,1.3,Iris-versicolor +5.2,2.7,3.9,1.4,Iris-versicolor +5.0,2.0,3.5,1.0,Iris-versicolor +5.9,3.0,4.2,1.5,Iris-versicolor +6.0,2.2,4.0,1.0,Iris-versicolor +6.1,2.9,4.7,1.4,Iris-versicolor +5.6,2.9,3.6,1.3,Iris-versicolor +6.7,3.1,4.4,1.4,Iris-versicolor +5.6,3.0,4.5,1.5,Iris-versicolor +5.8,2.7,4.1,1.0,Iris-versicolor +6.2,2.2,4.5,1.5,Iris-versicolor +5.6,2.5,3.9,1.1,Iris-versicolor +5.9,3.2,4.8,1.8,Iris-versicolor +6.1,2.8,4.0,1.3,Iris-versicolor +6.3,2.5,4.9,1.5,Iris-versicolor +6.1,2.8,4.7,1.2,Iris-versicolor +6.4,2.9,4.3,1.3,Iris-versicolor +6.6,3.0,4.4,1.4,Iris-versicolor +6.8,2.8,4.8,1.4,Iris-versicolor +6.7,3.0,5.0,1.7,Iris-versicolor +6.0,2.9,4.5,1.5,Iris-versicolor +5.7,2.6,3.5,1.0,Iris-versicolor +6.3,3.3,6.0,2.5,Iris-virginica +5.8,2.7,5.1,1.9,Iris-virginica +7.1,3.0,5.9,2.1,Iris-virginica +6.3,2.9,5.6,1.8,Iris-virginica +6.5,3.0,5.8,2.2,Iris-virginica +7.6,3.0,6.6,2.1,Iris-virginica +4.9,2.5,4.5,1.7,Iris-virginica +7.3,2.9,6.3,1.8,Iris-virginica +6.7,2.5,5.8,1.8,Iris-virginica +7.2,3.6,6.1,2.5,Iris-virginica +6.5,3.2,5.1,2.0,Iris-virginica +6.4,2.7,5.3,1.9,Iris-virginica +6.8,3.0,5.5,2.1,Iris-virginica +5.7,2.5,5.0,2.0,Iris-virginica +5.8,2.8,5.1,2.4,Iris-virginica +6.4,3.2,5.3,2.3,Iris-virginica +6.5,3.0,5.5,1.8,Iris-virginica +7.7,3.8,6.7,2.2,Iris-virginica +7.7,2.6,6.9,2.3,Iris-virginica +6.0,2.2,5.0,1.5,Iris-virginica +6.9,3.2,5.7,2.3,Iris-virginica +5.6,2.8,4.9,2.0,Iris-virginica +7.7,2.8,6.7,2.0,Iris-virginica +6.3,2.7,4.9,1.8,Iris-virginica +6.7,3.3,5.7,2.1,Iris-virginica +7.2,3.2,6.0,1.8,Iris-virginica +6.2,2.8,4.8,1.8,Iris-virginica +6.1,3.0,4.9,1.8,Iris-virginica +6.4,2.8,5.6,2.1,Iris-virginica +7.2,3.0,5.8,1.6,Iris-virginica \ No newline at end of file diff --git a/geatpy/demo/soea_demo/soea_demo6/main.py b/geatpy/demo/soea_demo/soea_demo6/main.py new file mode 100644 index 00000000..fece7b72 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo6/main.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" +该案例展示了如何利用进化算法+多进程/多线程来搜索SVM中的两个参数:C和Gamma的最佳值。问题的定义详见MyProblem.py。 +在执行脚本main.py中设置PoolType字符串来控制采用的是多进程还是多线程。 +注意:使用多进程时,程序必须以“if __name__ == '__main__':”作为入口, + 这个是multiprocessing的多进程模块的硬性要求。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem(PoolType='Thread') # 设置采用多线程,若修改为: PoolType = 'Process',则表示用多进程 + # 构建算法 + algorithm = ea.soea_DE_rand_1_bin_templet(problem, + ea.Population(Encoding='RI', NIND=50), + MAXGEN=30, # 最大进化代数。 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + trappedValue=1e-6, # 单目标优化陷入停滞的判断阈值。 + maxTrappedCount=10) # 进化停滞计数器最大上限值。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + # 检验结果 + if res['success']: + problem.test(C=res['Vars'][0, 0], G=res['Vars'][0, 1]) diff --git a/geatpy/demo/soea_demo/soea_demo7/Data_User_Modeling_Dataset_Hamdi Tolga KAHRAMAN.xls b/geatpy/demo/soea_demo/soea_demo7/Data_User_Modeling_Dataset_Hamdi Tolga KAHRAMAN.xls new file mode 100644 index 00000000..b257524e Binary files /dev/null and b/geatpy/demo/soea_demo/soea_demo7/Data_User_Modeling_Dataset_Hamdi Tolga KAHRAMAN.xls differ diff --git a/geatpy/demo/soea_demo/soea_demo7/MyProblem.py b/geatpy/demo/soea_demo/soea_demo7/MyProblem.py new file mode 100644 index 00000000..9d19a932 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo7/MyProblem.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +import numpy as np +import xlrd +from scoop import futures +from sklearn import preprocessing +from sklearn import svm +from sklearn.model_selection import cross_val_score + +import geatpy as ea + +""" +本案例和soea_demo6类似,同样是用进化算法来搜索SVM的参数C和Gamma的最佳值, +不同的是,本案例选用更庞大的数据集,使得每次训练SVM模型时耗时更高,从而更适合采用分布式加速计算。 +该数据集存放在同目录下的Data_User_Modeling_Dataset_Hamdi Tolga KAHRAMAN.xls中, +有关该数据集的详细描述详见http://archive.ics.uci.edu/ml/datasets/User+Knowledge+Modeling +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [-1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 2 # 初始化Dim(决策变量维数) + varTypes = [0, 0] # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [2 ** (-8), 2 ** (-8)] # 决策变量下界 + ub = [2 ** 8, 1] # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + # 目标函数计算中用到的一些数据 + workbook = xlrd.open_workbook( + "Data_User_Modeling_Dataset_Hamdi Tolga KAHRAMAN.xls") # 打开文件,获取excel文件的workbook(工作簿)对象 + worksheet = workbook.sheet_by_name("Training_Data") # 通过sheet名获得sheet对象 + self.data = np.vstack([worksheet.col_values(0)[1:], + worksheet.col_values(1)[1:], + worksheet.col_values(2)[1:], + worksheet.col_values(3)[1:], + worksheet.col_values(4)[1:]]).T # 获取特征数据 + self.data = preprocessing.scale(self.data) # 归一化特征数据 + self.dataTarget = worksheet.col_values(5)[1:] # 获取标签数据 + + def evalVars(self, Vars): # 目标函数 + N = Vars.shape[0] + args = list( + zip(list(range(N)), [Vars] * N, [self.data] * N, [self.dataTarget] * N)) + ObjV = np.array(list(futures.map(subEvalVars, args))) # 调用SCOOP的map函数进行分布式计算,并构造目标函数值矩阵ObjV + return ObjV + + def test(self, C, G): # 代入优化后的C、Gamma对测试集进行检验 + # 读取测试集数据 + workbook = xlrd.open_workbook( + "Data_User_Modeling_Dataset_Hamdi Tolga KAHRAMAN.xls") # 打开文件,获取excel文件的workbook(工作簿)对象 + worksheet = workbook.sheet_by_name("Test_Data") # 通过sheet名获得sheet对象 + data_test = np.vstack([worksheet.col_values(0)[1:], + worksheet.col_values(1)[1:], + worksheet.col_values(2)[1:], + worksheet.col_values(3)[1:], + worksheet.col_values(4)[1:]]).T # 获取特征数据 + data_test = preprocessing.scale(data_test) # 归一化特征数据 + dataTarget_test = worksheet.col_values(5)[1:] # 获取标签数据 + svc = svm.SVC(C=C, kernel='rbf', gamma=G).fit(self.data, self.dataTarget) # 创建分类器对象并用训练集的数据拟合分类器模型 + dataTarget_predict = svc.predict(data_test) # 采用训练好的分类器对象对测试集数据进行预测 + print("测试集数据分类正确率 = %s%%" % ( + len(np.where(dataTarget_predict == dataTarget_test)[0]) / len(dataTarget_test) * 100)) + + +def subEvalVars(args): # 单独计算单个个体的目标函数值 + i = args[0] + Vars = args[1] + data = args[2] + dataTarget = args[3] + C = Vars[i, 0] + G = Vars[i, 1] + svc = svm.SVC(C=C, kernel='rbf', gamma=G).fit(data, dataTarget) # 创建分类器对象并用训练集的数据拟合分类器模型 + scores = cross_val_score(svc, data, dataTarget, cv=20) # 计算交叉验证的得分 + ObjV_i = [scores.mean()] # 把交叉验证的平均得分作为目标函数值 + return ObjV_i diff --git a/geatpy/demo/soea_demo/soea_demo7/main.py b/geatpy/demo/soea_demo/soea_demo7/main.py new file mode 100644 index 00000000..b2f102b7 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo7/main.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" +本案例和soea_demo6类似,同样是用进化算法来搜索SVM的参数C和Gamma的最佳值。不同的是这里采用SCOOP来 +在执行本案例前,需要确保正确安装sklearn以及SCOOP,以保证SVM和SCOOP部分的代码能够正常执行。 +SCOOP安装方法:控制台执行命令pip install scoop +分布式加速计算注意事项: +1.当目标函数的计算十分耗时,比如计算单个个体的目标函数值就需要很长时间时, + 适合采用分布式计算,否则贸然采用分布式计算反而会大大降低性能。 +2.分布式执行方法:python -m scoop -n 10 main.py 其中10表示把计算任务分发给10个workers。 + 非分布式执行方法:python main.py +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 构建算法 + algorithm = ea.soea_DE_rand_1_bin_templet(problem, + ea.Population(Encoding='RI', NIND=20), + MAXGEN=30, # 最大进化代数。 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + trappedValue=1e-6, # 单目标优化陷入停滞的判断阈值。 + maxTrappedCount=10) # 进化停滞计数器最大上限值。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + # 检验结果 + problem.test(C=res['Vars'][0, 0], G=res['Vars'][0, 1]) diff --git a/geatpy/demo/soea_demo/soea_demo8/MyProblem.py b/geatpy/demo/soea_demo/soea_demo8/MyProblem.py new file mode 100644 index 00000000..0145b1a4 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo8/MyProblem.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +import matplotlib.pyplot as plt +import numpy as np +import geatpy as ea + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self): + # 目标函数计算中用到的一些数据 + self.datas = np.loadtxt('data.csv', delimiter=',') # 读取数据 + self.k = 4 # 分类数目 + # 问题类设置 + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = self.datas.shape[1] * self.k # 初始化Dim + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = list(np.min(self.datas, 0)) * self.k # 决策变量下界 + ub = list(np.max(self.datas, 0)) * self.k # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def aimFunc(self, pop): # 目标函数 + centers = pop.Phen.reshape(int(pop.sizes * self.k), int(pop.Phen.shape[1] / self.k)) # 得到聚类中心 + dis = ea.cdist(centers, self.datas, 'euclidean') # 计算距离 + dis_split = dis.reshape(pop.sizes, self.k, self.datas.shape[0]) # 分割距离矩阵,把各个聚类中心到各个点之间的距离的数据分开 + labels = np.argmin(dis_split, 1)[0] # 得到聚类标签值 + uni_labels = np.unique(labels) + for i in range(len(uni_labels)): + centers[uni_labels[i], :] = np.mean(self.datas[np.where(labels == uni_labels[i])[0], :], 0) + # 直接修改染色体为已知的更优值,加快收敛 + pop.Chrom = centers.reshape(pop.sizes, self.k * centers.shape[1]) + pop.Phen = pop.decoding() # 染色体解码(要同步修改Phen,否则后面会导致数据不一致) + dis = ea.cdist(centers, self.datas, 'euclidean') + dis_split = dis.reshape(pop.sizes, self.k, self.datas.shape[0]) + pop.ObjV = np.sum(np.min(dis_split, 1), 1, keepdims=True) # 计算个体的目标函数值 + + def draw(self, centers): # 绘制聚类效果图 + dis = ea.cdist(centers, self.datas, 'euclidean') + dis_split = dis.reshape(1, self.k, self.datas.shape[0]) + labels = np.argmin(dis_split, 1)[0] + colors = ['r', 'g', 'b', 'y'] + fig = plt.figure() + ax = fig.add_subplot(111, projection='3d') + for i in range(self.k): + idx = np.where(labels == i)[0] # 找到同一类的点的下标 + datas = self.datas[idx, :] + ax.scatter(datas[:, 0], datas[:, 1], datas[:, 2], c=colors[i]) diff --git a/geatpy/demo/soea_demo/soea_demo8/data.csv b/geatpy/demo/soea_demo/soea_demo8/data.csv new file mode 100644 index 00000000..3ccf7341 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo8/data.csv @@ -0,0 +1,15608 @@ +526,40,484 +529,137,294 +86,74,472 +234,83,387 +110,64,0 +526,576,432 +530,647,607 +103,105,69 +19,66,3 +101,125,554 +149,112,429 +177,118,48 +63,99,31 +164,72,505 +57,61,489 +85,121,20 +105,0,524 +112,97,173 +120,106,543 +377,108,103 +65,118,121 +96,121,474 +134,90,114 +102,66,393 +68,46,138 +447,673,572 +19,48,457 +106,31,54 +96,87,507 +92,112,0 +79,94,92 +119,81,77 +156,115,145 +0,88,8 +66,47,86 +611,0,533 +64,92,76 +71,87,422 +128,76,0 +484,576,446 +0,42,148 +48,53,89 +262,105,505 +73,524,528 +145,88,76 +71,94,26 +113,88,453 +63,120,15 +67,39,380 +115,0,0 +604,0,579 +105,0,117 +71,74,0 +87,16,143 +186,76,476 +44,103,451 +619,109,573 +127,154,1 +230,71,518 +134,137,140 +660,45,589 +146,57,511 +179,94,476 +97,50,452 +557,570,578 +481,644,639 +135,0,404 +91,67,140 +567,69,571 +532,117,528 +56,24,0 +101,80,2 +0,58,0 +118,163,403 +70,43,121 +579,15,580 +106,79,499 +107,114,86 +54,60,9 +543,75,579 +604,96,528 +123,49,479 +108,69,466 +88,97,511 +143,123,505 +679,35,611 +641,63,607 +46,135,5 +90,71,123 +537,615,558 +516,30,563 +539,413,474 +117,116,54 +72,56,60 +448,633,576 +81,83,151 +161,62,158 +60,117,479 +0,115,0 +0,62,148 +75,138,0 +27,107,427 +137,49,0 +0,34,78 +103,118,50 +72,114,511 +492,672,587 +51,67,402 +0,185,437 +544,696,644 +70,28,227 +52,4,108 +90,321,459 +71,73,9 +88,6,227 +501,68,573 +110,86,443 +144,55,314 +102,0,588 +530,85,482 +115,18,182 +78,90,495 +440,615,604 +111,66,420 +51,25,428 +520,646,582 +502,671,607 +109,60,83 +104,132,19 +123,0,14 +705,104,622 +99,60,442 +102,14,491 +126,0,455 +560,118,599 +58,0,33 +29,59,129 +60,138,76 +55,97,179 +124,49,47 +73,68,463 +71,67,103 +117,0,282 +112,15,66 +92,137,104 +87,35,17 +179,92,96 +82,95,101 +92,95,152 +79,0,37 +65,43,0 +172,78,607 +128,101,480 +88,41,48 +54,27,444 +86,81,254 +369,110,112 +106,62,59 +103,106,45 +149,95,409 +241,68,204 +87,60,152 +575,30,553 +0,112,365 +45,116,84 +555,652,601 +118,29,80 +601,12,495 +56,140,527 +595,87,553 +127,98,0 +5,33,163 +100,115,455 +35,98,444 +97,104,409 +139,30,171 +303,143,473 +122,0,18 +109,52,5 +612,71,566 +116,106,7 +91,30,134 +102,97,75 +603,74,450 +99,116,113 +0,110,47 +38,149,66 +87,135,0 +23,19,102 +59,69,443 +45,64,101 +91,123,179 +112,0,72 +127,111,472 +16,84,309 +169,65,255 +101,106,98 +84,84,555 +49,0,0 +538,141,540 +41,98,104 +0,0,100 +141,101,122 +185,158,475 +170,67,2 +91,81,419 +78,30,477 +86,107,488 +139,58,514 +95,0,183 +148,119,108 +562,0,542 +600,69,496 +71,111,107 +83,95,595 +11,0,56 +114,90,509 +113,153,506 +17,0,0 +537,0,619 +519,146,291 +55,79,1 +80,2,512 +132,113,0 +0,85,294 +453,645,631 +76,154,361 +118,72,20 +22,97,0 +46,6,14 +152,23,54 +5,80,135 +124,134,478 +114,63,550 +70,143,309 +90,79,140 +91,71,88 +112,63,102 +0,78,0 +113,113,251 +72,70,0 +103,152,94 +518,133,576 +0,83,7 +107,87,227 +67,128,555 +62,96,0 +65,120,144 +70,0,460 +84,103,483 +12,81,66 +80,126,23 +95,93,113 +99,90,449 +130,28,419 +17,104,48 +90,117,503 +111,72,0 +197,0,163 +102,81,123 +92,25,347 +124,78,317 +40,113,319 +131,105,96 +577,94,571 +147,110,168 +0,65,7 +11,75,495 +90,0,176 +537,640,561 +138,115,453 +121,8,88 +111,83,119 +532,49,531 +0,112,23 +93,65,463 +118,50,1 +536,56,616 +142,99,450 +81,77,0 +103,88,95 +571,0,565 +106,0,39 +79,105,54 +319,143,570 +110,46,33 +344,53,330 +129,38,468 +89,54,112 +127,77,467 +110,68,501 +118,27,479 +121,127,104 +40,124,33 +97,34,37 +103,128,0 +6,34,0 +45,46,479 +0,1,0 +80,152,496 +118,16,0 +400,28,301 +0,0,303 +84,98,0 +67,38,0 +121,88,0 +97,95,525 +103,47,0 +99,0,79 +494,646,637 +109,48,465 +0,83,373 +563,63,593 +100,12,99 +105,117,539 +580,80,508 +103,0,92 +21,66,39 +99,76,28 +429,155,670 +204,99,513 +116,129,22 +4,68,51 +97,103,104 +124,81,66 +77,12,481 +115,116,759 +25,0,0 +140,99,492 +91,100,171 +147,91,492 +130,74,0 +215,34,493 +58,12,0 +27,104,70 +0,70,468 +106,0,224 +120,119,130 +587,312,486 +100,29,506 +100,99,16 +161,65,526 +90,110,0 +130,0,50 +55,95,467 +76,0,515 +135,29,104 +530,52,623 +8,34,0 +81,17,28 +151,38,377 +89,128,0 +140,132,164 +158,39,121 +587,118,447 +60,67,346 +125,81,321 +100,89,0 +68,57,264 +141,44,0 +566,699,632 +85,100,484 +0,51,156 +574,77,501 +111,106,98 +415,76,503 +109,102,474 +121,90,486 +429,126,604 +0,58,540 +107,93,53 +11,84,103 +519,75,562 +109,137,85 +129,118,509 +47,100,512 +204,77,479 +78,82,51 +63,126,587 +521,19,572 +123,85,94 +106,50,34 +225,69,447 +121,13,0 +189,21,401 +89,59,349 +107,77,424 +126,86,127 +179,83,574 +105,37,479 +575,0,514 +180,22,161 +227,111,135 +95,102,92 +77,119,474 +82,12,81 +136,0,0 +549,119,489 +143,44,229 +35,147,76 +550,140,494 +48,101,30 +155,73,493 +103,0,36 +87,140,160 +70,126,44 +513,664,634 +381,122,431 +107,109,467 +301,57,329 +593,77,525 +64,449,538 +0,396,306 +54,78,53 +528,662,622 +567,84,544 +0,213,399 +171,123,393 +127,84,0 +199,105,496 +185,87,133 +160,52,67 +117,158,54 +93,76,0 +60,119,470 +499,52,577 +78,134,0 +35,91,34 +0,90,463 +97,0,102 +69,103,0 +46,28,7 +45,123,103 +181,33,458 +122,106,435 +0,72,30 +0,84,445 +166,0,17 +104,0,496 +133,78,116 +195,99,184 +136,139,519 +117,0,0 +201,44,467 +0,66,60 +330,46,531 +171,73,90 +82,20,415 +641,85,628 +137,0,0 +53,94,2 +51,78,32 +0,31,128 +127,117,123 +102,76,390 +108,66,185 +611,87,570 +57,61,2 +83,0,261 +88,138,13 +106,108,462 +66,71,0 +22,53,87 +653,69,543 +539,0,553 +51,90,233 +0,93,460 +35,117,78 +82,0,104 +82,54,470 +37,114,15 +115,35,17 +70,22,127 +97,74,80 +537,118,567 +128,22,0 +149,61,50 +33,80,0 +132,103,104 +94,0,490 +78,93,490 +117,135,0 +69,104,270 +75,139,133 +85,101,62 +30,17,0 +79,116,508 +489,58,545 +607,45,534 +123,72,446 +562,132,555 +115,111,89 +132,9,61 +527,422,593 +36,112,27 +615,420,601 +19,87,422 +0,19,340 +52,125,137 +157,70,149 +159,101,45 +54,42,30 +93,128,62 +636,63,511 +99,79,322 +163,0,37 +132,73,337 +131,0,0 +573,0,568 +75,108,531 +543,20,544 +607,100,552 +100,92,338 +132,29,68 +133,0,80 +58,4,71 +93,118,84 +147,102,517 +484,63,548 +0,142,0 +20,68,67 +72,85,102 +76,115,225 +85,2,485 +89,50,441 +84,8,177 +104,0,51 +26,128,92 +583,61,632 +111,86,116 +390,70,323 +29,0,15 +24,23,0 +495,94,535 +19,107,349 +155,129,0 +93,0,70 +273,108,566 +85,0,22 +69,66,110 +193,59,423 +157,27,460 +0,71,15 +97,108,3 +122,40,132 +310,66,236 +486,0,480 +50,107,94 +83,121,531 +101,118,155 +104,61,95 +28,104,28 +73,25,140 +68,39,508 +187,0,440 +107,0,524 +522,10,536 +131,101,460 +37,84,91 +120,0,371 +596,37,526 +88,88,54 +0,61,183 +105,80,113 +21,78,0 +0,90,429 +557,11,537 +0,109,145 +0,116,98 +0,21,0 +108,83,489 +96,57,422 +30,112,483 +294,120,447 +72,55,28 +50,118,0 +78,107,0 +129,96,58 +596,49,326 +100,24,27 +91,30,25 +52,95,313 +113,112,454 +0,105,99 +89,110,0 +564,0,557 +570,7,458 +553,691,657 +129,0,0 +169,99,441 +69,38,0 +222,144,547 +52,82,153 +87,0,426 +76,0,120 +180,20,500 +45,69,17 +147,22,0 +493,684,629 +305,130,179 +34,66,125 +98,6,427 +116,91,465 +42,51,56 +522,69,582 +93,0,457 +151,98,480 +207,129,406 +100,0,519 +11,121,447 +133,0,66 +17,151,281 +29,465,499 +114,68,72 +609,65,551 +0,143,101 +83,87,127 +169,83,328 +121,62,22 +79,87,158 +107,29,229 +101,110,90 +115,111,312 +114,408,548 +68,116,177 +77,47,564 +27,51,56 +598,618,650 +122,0,54 +87,89,27 +64,129,0 +101,65,50 +57,116,0 +519,695,651 +40,44,50 +477,652,557 +141,122,557 +83,42,30 +72,131,485 +198,103,508 +24,14,138 +35,108,124 +42,99,52 +89,55,64 +127,9,110 +117,96,419 +51,71,0 +50,111,515 +52,112,162 +103,140,120 +135,101,483 +0,144,520 +153,0,422 +95,121,0 +55,81,473 +8,95,17 +57,109,19 +61,110,467 +77,105,566 +57,55,112 +99,109,447 +0,92,116 +562,67,545 +132,98,405 +580,71,499 +119,70,19 +617,0,588 +1,49,163 +220,129,245 +556,28,535 +181,85,506 +85,73,128 +93,42,61 +85,33,97 +75,75,99 +592,38,608 +185,48,112 +476,121,477 +152,123,560 +153,70,54 +136,94,84 +92,77,64 +131,131,90 +211,20,529 +0,0,66 +134,134,515 +55,101,22 +38,91,103 +138,102,180 +0,116,98 +543,53,553 +491,119,531 +75,368,304 +111,127,30 +91,102,60 +66,82,0 +145,2,387 +100,117,121 +93,123,573 +125,106,60 +317,0,179 +46,85,114 +60,125,494 +45,95,63 +30,115,448 +100,82,151 +95,0,455 +492,0,316 +80,5,75 +50,142,5 +104,23,195 +38,139,469 +131,75,11 +57,46,0 +160,81,257 +66,64,83 +120,42,182 +91,0,106 +70,120,577 +98,22,92 +467,136,451 +0,126,368 +87,59,128 +555,27,577 +322,21,460 +96,49,417 +482,633,558 +110,0,20 +70,128,387 +292,72,253 +84,97,99 +126,111,1 +0,112,490 +118,81,362 +327,81,296 +0,116,52 +117,25,36 +48,0,96 +214,84,602 +23,9,473 +92,0,398 +79,91,32 +97,43,102 +93,0,398 +106,55,385 +0,124,44 +63,120,0 +99,97,400 +130,91,533 +624,424,440 +147,41,470 +81,92,457 +416,95,587 +35,137,103 +56,67,3 +108,56,100 +60,0,457 +102,112,173 +117,121,47 +31,105,517 +108,96,0 +23,154,12 +97,114,119 +505,614,558 +458,593,594 +38,79,0 +444,125,352 +528,35,205 +84,60,116 +11,112,479 +0,114,104 +606,122,495 +376,87,608 +80,77,279 +113,113,72 +117,0,574 +0,35,0 +364,189,471 +93,117,74 +0,113,499 +15,84,379 +68,108,468 +577,77,557 +45,132,437 +93,33,563 +53,114,158 +54,78,62 +112,82,455 +95,151,63 +90,122,0 +17,114,0 +128,37,165 +122,107,0 +0,13,22 +60,23,153 +92,80,364 +91,42,47 +137,79,450 +92,17,337 +56,74,53 +81,89,540 +12,107,123 +106,102,0 +582,120,488 +87,116,47 +44,63,108 +0,11,103 +24,74,468 +0,127,0 +563,422,504 +45,68,141 +195,65,0 +0,4,45 +63,19,60 +534,106,516 +2,35,55 +71,36,379 +102,88,134 +592,131,555 +93,50,97 +158,80,506 +111,132,459 +67,109,488 +73,90,43 +97,73,0 +10,92,85 +144,60,447 +110,92,530 +1,70,53 +64,82,46 +37,28,0 +19,50,48 +127,65,0 +90,50,374 +2,131,91 +105,74,78 +71,103,72 +55,105,65 +29,44,126 +51,94,0 +86,75,99 +25,3,505 +152,68,450 +109,104,30 +92,122,360 +58,113,3 +111,24,432 +0,47,75 +76,100,27 +91,109,294 +523,140,579 +141,82,76 +96,91,47 +208,108,520 +37,0,437 +121,0,72 +47,27,374 +31,46,0 +97,95,518 +31,51,450 +0,95,0 +114,20,524 +77,0,0 +129,24,237 +102,97,27 +91,49,499 +0,80,0 +564,77,544 +95,0,67 +39,41,0 +0,119,5 +71,78,0 +144,0,9 +27,0,86 +94,72,66 +57,135,86 +0,76,98 +274,37,614 +71,73,89 +119,60,58 +624,235,385 +101,87,44 +222,0,166 +582,109,521 +63,47,144 +14,78,511 +70,46,59 +217,12,393 +428,109,453 +121,65,8 +82,0,449 +72,72,48 +67,117,507 +59,134,70 +91,57,444 +109,74,70 +625,590,548 +43,105,88 +44,118,187 +161,82,445 +47,124,58 +129,95,531 +127,36,377 +87,131,474 +47,112,490 +582,105,441 +341,123,364 +13,174,117 +0,79,82 +123,81,45 +216,0,592 +345,74,298 +75,0,66 +122,112,0 +117,21,64 +61,28,428 +55,116,1 +52,42,120 +89,102,78 +119,83,13 +126,126,89 +538,689,634 +80,102,501 +106,0,176 +81,42,15 +139,104,29 +73,73,89 +114,0,227 +99,112,0 +58,144,443 +81,64,50 +86,90,435 +20,118,0 +0,0,459 +583,119,531 +205,63,512 +101,111,431 +71,97,91 +517,656,617 +19,127,468 +66,127,139 +167,65,429 +553,625,677 +89,89,86 +101,0,6 +17,498,556 +69,107,446 +51,0,41 +561,87,551 +74,0,486 +152,50,133 +65,86,41 +187,0,339 +128,43,298 +107,85,0 +113,61,80 +71,81,11 +509,114,606 +87,24,194 +191,103,623 +118,0,100 +133,64,491 +103,0,74 +67,40,0 +264,23,585 +643,94,492 +57,433,535 +105,94,523 +68,0,345 +116,92,118 +505,646,560 +101,81,425 +0,91,444 +87,104,455 +42,92,0 +61,50,414 +100,91,7 +591,122,540 +71,82,480 +117,109,37 +122,106,254 +549,43,492 +137,0,59 +110,90,469 +114,84,144 +70,70,113 +34,0,0 +546,129,583 +127,0,105 +141,125,59 +78,0,546 +64,135,14 +10,92,6 +0,153,75 +53,111,448 +76,109,85 +580,58,578 +67,36,447 +70,10,18 +598,74,608 +32,148,443 +528,23,482 +61,107,0 +591,81,497 +508,100,452 +113,96,553 +145,86,455 +102,74,451 +56,106,111 +65,58,0 +629,142,527 +548,664,615 +53,80,0 +511,80,540 +108,65,528 +119,37,0 +115,111,95 +511,688,645 +131,143,257 +116,60,87 +84,137,66 +170,39,516 +587,77,548 +101,92,81 +0,15,19 +104,86,48 +557,672,639 +59,74,642 +94,0,81 +106,101,495 +55,113,0 +91,106,482 +90,0,58 +48,129,367 +124,10,511 +39,84,0 +97,59,151 +520,657,579 +97,156,92 +89,0,35 +193,74,567 +198,0,271 +148,85,100 +611,614,653 +137,48,201 +104,109,0 +29,121,454 +133,156,512 +113,94,419 +126,68,0 +512,684,615 +604,0,445 +54,21,65 +121,66,0 +93,99,35 +69,24,0 +153,4,247 +120,41,82 +158,67,177 +3,28,72 +552,110,501 +76,107,33 +136,100,0 +46,0,1 +66,79,198 +112,0,78 +23,90,86 +92,22,62 +41,76,119 +599,84,563 +70,7,112 +130,116,0 +111,35,505 +0,130,104 +0,113,0 +97,125,474 +542,82,560 +28,33,15 +120,130,557 +606,67,518 +124,1,59 +32,0,13 +103,93,0 +52,118,0 +138,78,47 +52,89,72 +120,120,552 +152,23,425 +583,620,618 +503,112,388 +2,74,0 +110,109,121 +105,0,0 +0,115,0 +41,89,454 +155,81,433 +72,89,430 +106,0,0 +536,108,534 +470,0,599 +24,133,139 +157,82,84 +124,9,133 +5,135,102 +154,115,598 +91,80,0 +37,97,108 +78,77,479 +0,109,396 +0,124,97 +0,45,104 +14,83,58 +687,0,587 +0,76,557 +92,23,362 +534,660,644 +74,69,446 +127,0,524 +75,101,448 +87,91,0 +60,0,98 +130,126,428 +84,13,448 +123,82,92 +484,69,306 +116,80,450 +86,79,31 +125,71,234 +48,101,64 +120,40,390 +240,144,604 +533,104,527 +0,0,137 +100,82,38 +86,127,624 +84,74,52 +41,134,124 +387,620,489 +581,11,413 +82,74,81 +133,93,485 +88,115,610 +75,67,95 +152,99,0 +40,102,68 +43,107,309 +165,20,422 +603,28,592 +30,63,188 +89,89,485 +120,113,371 +472,35,116 +0,76,30 +101,47,55 +72,399,406 +8,104,15 +77,78,51 +42,95,458 +20,0,458 +97,61,109 +161,113,77 +6,52,471 +75,50,0 +151,0,70 +94,126,0 +71,85,156 +93,90,89 +70,0,0 +228,118,215 +530,117,442 +70,0,65 +65,73,66 +103,77,453 +558,712,668 +60,88,135 +109,66,51 +93,0,62 +514,31,524 +489,676,592 +112,4,172 +0,0,92 +42,0,414 +621,59,575 +52,102,0 +0,6,132 +84,75,47 +188,53,84 +16,125,514 +0,23,105 +114,0,0 +72,64,416 +0,143,123 +43,83,515 +83,66,528 +111,125,425 +131,124,179 +67,105,395 +592,24,478 +83,98,0 +84,88,49 +97,44,157 +110,0,77 +358,0,617 +81,76,448 +106,61,130 +87,101,62 +123,107,151 +123,23,145 +122,18,497 +88,80,236 +122,25,130 +131,68,30 +80,145,49 +90,40,20 +126,97,34 +0,58,56 +152,86,464 +94,43,129 +80,73,20 +0,108,37 +0,101,468 +100,80,427 +587,111,597 +60,105,0 +492,685,640 +87,156,0 +132,57,499 +111,97,563 +62,10,116 +142,36,92 +181,107,413 +76,119,70 +61,84,95 +107,69,0 +52,101,158 +501,81,486 +0,102,286 +0,37,485 +469,655,583 +99,0,55 +70,156,104 +130,68,251 +97,0,479 +36,111,453 +67,62,105 +140,82,475 +37,83,0 +603,0,435 +150,33,582 +529,123,543 +586,92,517 +49,90,51 +61,65,462 +108,44,292 +38,60,247 +85,0,0 +99,119,71 +15,96,0 +141,28,135 +65,63,33 +540,56,623 +74,50,509 +50,0,36 +131,72,106 +0,67,83 +117,73,326 +109,461,446 +276,106,464 +131,32,67 +0,95,112 +139,142,357 +163,22,189 +98,79,33 +0,0,402 +61,101,52 +551,106,428 +45,115,479 +134,0,539 +82,71,118 +94,87,73 +81,50,0 +27,53,487 +132,0,131 +126,119,404 +95,84,0 +90,75,321 +41,63,0 +26,0,478 +143,38,313 +480,322,541 +77,120,39 +106,19,56 +705,131,565 +581,115,575 +14,86,437 +640,44,586 +0,105,6 +85,80,0 +134,92,92 +62,0,103 +34,95,422 +245,95,215 +121,17,80 +137,64,84 +0,79,102 +82,104,61 +63,110,40 +538,103,535 +82,120,62 +47,141,49 +48,112,21 +79,103,553 +248,67,609 +119,25,0 +14,85,404 +60,143,463 +122,47,64 +100,0,0 +57,68,501 +111,59,7 +0,0,0 +0,84,0 +253,57,321 +125,108,15 +498,72,498 +136,82,82 +540,0,498 +122,94,286 +596,95,548 +0,88,1 +11,27,514 +37,107,377 +101,84,431 +3,97,0 +7,64,323 +45,37,508 +31,125,77 +137,101,79 +499,695,585 +156,103,126 +558,15,499 +95,36,104 +127,0,41 +105,118,446 +530,15,619 +596,74,509 +73,56,222 +637,96,540 +94,121,539 +90,80,0 +39,0,469 +74,116,29 +541,102,477 +546,106,547 +596,0,479 +550,128,499 +81,54,522 +106,98,113 +110,72,23 +552,23,605 +0,87,0 +113,40,650 +189,29,45 +50,118,476 +92,82,51 +100,0,0 +49,99,58 +139,6,504 +108,87,69 +121,100,76 +54,88,133 +82,104,306 +90,96,131 +145,108,476 +57,46,121 +114,93,473 +91,102,40 +587,109,369 +101,20,30 +152,128,502 +143,100,13 +159,57,248 +123,16,71 +60,123,28 +549,14,629 +70,82,36 +90,25,28 +128,61,503 +0,35,120 +587,65,495 +182,0,486 +91,17,11 +24,125,0 +0,58,383 +162,96,102 +90,88,504 +132,82,175 +125,0,134 +104,14,490 +108,0,492 +90,94,0 +86,138,384 +518,48,441 +70,108,471 +659,55,563 +0,84,0 +193,43,519 +41,0,464 +98,72,0 +632,42,410 +558,65,588 +115,3,63 +127,122,533 +227,32,492 +99,96,107 +66,25,409 +62,114,0 +86,107,43 +82,83,115 +101,94,325 +561,680,626 +0,89,61 +549,116,557 +98,16,507 +18,0,0 +549,76,491 +120,101,324 +0,51,0 +78,85,80 +111,66,577 +143,70,483 +63,102,269 +104,47,0 +42,104,423 +597,73,555 +212,113,208 +107,153,55 +569,125,556 +121,101,454 +106,29,498 +22,95,48 +139,92,38 +532,99,563 +108,72,0 +590,0,558 +71,79,37 +562,108,556 +51,47,376 +68,0,524 +100,130,112 +129,1,23 +142,121,89 +143,154,7 +73,59,82 +542,345,554 +79,20,344 +54,76,101 +100,33,326 +29,108,1 +101,0,580 +126,405,333 +133,79,506 +67,109,46 +64,0,61 +45,0,72 +7,144,545 +581,95,547 +71,75,17 +88,94,81 +106,81,338 +484,666,610 +449,68,532 +74,116,508 +92,17,514 +518,84,557 +121,69,0 +173,88,451 +114,0,59 +50,75,431 +0,0,397 +125,131,135 +264,69,84 +573,75,570 +5,58,155 +82,118,170 +239,167,656 +532,75,455 +89,132,108 +122,0,467 +62,112,41 +84,69,508 +69,43,450 +147,0,0 +85,31,460 +278,111,214 +145,127,147 +0,79,524 +106,115,39 +143,115,543 +73,19,22 +93,112,113 +17,83,63 +107,108,100 +0,100,89 +91,97,473 +87,81,28 +38,150,72 +76,149,0 +111,0,496 +684,433,588 +59,32,23 +551,21,592 +163,81,480 +41,48,109 +0,153,16 +111,41,63 +165,68,619 +0,0,0 +79,52,45 +76,97,107 +0,7,56 +103,87,75 +65,13,72 +101,76,421 +167,53,491 +584,108,605 +154,39,491 +576,123,519 +130,96,476 +0,78,145 +538,0,534 +83,100,538 +119,88,95 +89,20,55 +580,477,582 +585,83,493 +114,77,454 +516,670,602 +142,108,148 +633,70,561 +41,0,53 +133,41,514 +87,0,486 +123,54,132 +152,73,489 +116,91,72 +67,1,0 +0,173,496 +96,115,558 +598,36,575 +203,0,500 +32,105,72 +601,87,584 +0,57,591 +71,98,0 +100,48,11 +86,69,117 +91,122,45 +79,95,317 +198,0,619 +36,112,0 +76,91,89 +31,72,49 +139,110,24 +25,68,0 +73,0,285 +46,122,6 +30,115,0 +98,107,436 +674,81,567 +504,100,580 +120,0,489 +180,96,423 +92,95,387 +173,22,418 +550,82,539 +0,115,44 +117,79,397 +54,82,61 +9,81,31 +486,117,550 +55,5,118 +40,0,31 +83,114,148 +609,95,546 +510,714,691 +102,64,0 +91,84,47 +595,16,508 +116,99,480 +114,134,93 +108,120,483 +40,86,93 +682,105,572 +129,103,0 +33,85,63 +74,131,0 +0,46,67 +570,24,547 +132,49,158 +101,0,362 +499,674,597 +160,33,476 +134,82,531 +83,20,0 +151,92,561 +70,0,498 +103,52,77 +498,638,578 +670,70,573 +95,130,0 +66,122,428 +406,674,619 +64,62,55 +130,0,199 +110,81,499 +102,0,459 +95,114,81 +61,159,120 +544,0,525 +31,45,68 +54,73,41 +89,35,259 +58,0,2 +94,55,519 +86,73,484 +573,129,549 +74,0,449 +127,0,56 +86,62,499 +223,103,486 +85,95,530 +71,80,59 +117,89,23 +124,91,454 +82,161,0 +91,80,101 +130,91,401 +10,132,84 +575,85,581 +532,0,577 +87,62,26 +75,136,0 +557,72,553 +75,80,551 +588,0,593 +512,646,591 +97,136,0 +75,0,90 +528,668,624 +0,0,158 +100,102,559 +62,118,473 +88,39,501 +85,41,50 +99,8,3 +587,619,654 +148,31,418 +156,71,582 +90,78,65 +16,103,0 +205,123,155 +145,70,85 +110,20,401 +118,0,267 +171,37,464 +40,417,501 +64,44,42 +79,75,62 +20,31,0 +109,117,0 +95,62,492 +38,115,479 +679,109,580 +556,662,623 +653,0,587 +186,89,140 +78,92,530 +77,99,0 +605,63,559 +546,83,467 +9,84,76 +115,126,124 +72,89,0 +109,31,56 +539,0,615 +106,296,549 +68,20,72 +119,61,200 +137,63,106 +64,108,187 +53,103,84 +99,88,237 +90,0,0 +56,91,62 +111,9,443 +0,108,496 +90,109,391 +44,90,0 +118,62,240 +67,0,63 +568,0,497 +113,47,531 +99,97,479 +90,71,7 +55,54,0 +81,119,0 +150,72,476 +63,438,533 +80,85,82 +0,134,76 +501,698,625 +83,42,0 +17,68,502 +654,56,597 +71,78,0 +74,65,517 +65,51,0 +89,61,486 +509,96,380 +91,33,163 +103,25,95 +114,42,156 +43,81,69 +0,120,168 +156,60,509 +12,0,0 +65,2,115 +83,103,59 +119,68,68 +79,420,482 +60,7,468 +83,73,23 +120,47,155 +110,88,32 +517,126,540 +104,79,508 +79,55,367 +122,131,531 +580,122,560 +529,610,586 +90,79,62 +606,162,556 +416,631,588 +72,117,432 +178,53,480 +78,93,132 +346,69,226 +95,32,72 +106,0,30 +644,458,571 +102,142,137 +70,77,85 +99,114,15 +571,386,334 +374,112,557 +115,62,413 +61,0,25 +77,86,67 +84,77,373 +92,100,506 +43,85,458 +133,40,490 +76,98,0 +147,76,545 +370,59,164 +82,75,603 +90,116,14 +113,89,478 +62,110,10 +242,107,633 +70,83,72 +61,79,0 +79,0,94 +0,30,72 +122,178,569 +411,584,480 +76,55,0 +127,70,370 +45,62,515 +78,118,108 +0,0,0 +37,89,145 +64,69,489 +35,0,416 +547,35,570 +74,88,0 +568,720,644 +0,105,29 +132,106,472 +142,59,448 +107,3,483 +85,98,454 +133,101,0 +126,52,402 +264,116,218 +42,9,75 +111,73,113 +76,62,32 +121,107,31 +74,99,88 +138,114,0 +107,79,458 +610,92,562 +49,97,0 +139,0,188 +604,95,414 +34,110,277 +5,148,92 +51,29,450 +88,50,93 +482,110,519 +539,103,482 +105,58,0 +87,103,499 +120,86,193 +436,42,186 +70,77,84 +112,85,0 +101,78,469 +135,43,69 +544,11,508 +305,110,562 +134,82,319 +138,99,77 +75,70,9 +128,114,77 +145,92,131 +622,229,486 +102,21,28 +475,51,572 +84,0,499 +0,61,53 +621,74,617 +91,46,259 +114,139,0 +70,114,113 +216,122,170 +57,42,131 +52,28,74 +78,134,63 +94,88,381 +93,92,129 +227,109,585 +74,87,0 +40,101,90 +88,0,127 +109,47,515 +101,90,136 +0,57,370 +136,84,391 +92,0,452 +55,37,67 +119,56,117 +130,71,396 +45,130,66 +0,101,418 +121,31,0 +82,80,544 +21,114,0 +0,39,158 +81,103,112 +41,100,84 +30,134,54 +75,80,393 +20,85,482 +46,78,623 +150,64,0 +131,25,164 +140,9,245 +120,106,65 +199,73,474 +138,72,5 +607,338,535 +0,124,0 +73,145,208 +46,78,186 +0,31,59 +47,92,438 +129,74,609 +178,82,587 +121,97,610 +0,86,0 +72,104,14 +0,96,63 +25,91,56 +32,50,79 +312,22,425 +46,52,102 +371,65,483 +333,95,517 +0,0,0 +117,144,47 +480,118,528 +93,37,56 +107,92,8 +102,98,537 +49,37,115 +26,105,440 +13,82,460 +179,0,86 +104,88,20 +120,114,0 +355,54,600 +126,104,518 +35,129,85 +77,437,520 +24,63,43 +13,57,455 +101,130,441 +0,0,448 +0,97,106 +10,77,0 +31,89,495 +106,111,0 +80,0,0 +135,140,512 +73,72,92 +75,132,82 +14,53,105 +158,63,531 +0,32,0 +20,58,43 +57,74,75 +102,74,490 +111,132,20 +9,96,120 +57,26,338 +517,635,584 +533,694,661 +63,0,476 +127,99,485 +40,133,16 +83,110,483 +0,79,93 +133,34,493 +43,89,112 +42,24,80 +336,171,343 +531,70,575 +418,101,248 +461,85,603 +453,25,282 +134,0,8 +81,73,0 +2,0,0 +537,693,623 +0,161,0 +31,0,483 +95,53,47 +577,79,528 +108,0,0 +16,75,491 +67,72,469 +503,81,562 +0,0,0 +0,91,60 +74,113,64 +56,37,84 +85,28,60 +61,133,453 +136,122,473 +105,68,457 +41,0,111 +62,71,29 +134,106,472 +562,93,523 +113,85,0 +598,74,398 +624,134,505 +69,57,60 +36,6,88 +116,0,515 +73,84,246 +411,65,242 +128,99,510 +70,73,0 +102,68,405 +128,105,54 +5,20,224 +188,51,467 +437,615,508 +76,68,3 +107,92,465 +114,0,39 +114,48,10 +50,140,140 +93,132,292 +104,56,473 +58,91,100 +66,100,78 +88,95,4 +90,66,64 +48,39,438 +106,48,0 +96,29,74 +112,103,88 +202,0,549 +75,108,0 +0,76,0 +43,60,5 +67,139,519 +194,108,457 +27,91,124 +68,130,0 +437,17,559 +98,97,0 +492,79,534 +70,120,22 +89,62,25 +107,0,0 +110,86,0 +102,62,471 +153,15,77 +92,59,77 +238,103,314 +41,415,531 +107,88,52 +164,1,454 +8,122,43 +0,9,519 +93,0,94 +138,51,532 +80,43,450 +79,0,99 +121,0,0 +102,409,518 +136,0,463 +552,130,542 +73,19,26 +80,78,95 +90,69,5 +64,168,1 +49,110,445 +72,108,53 +58,47,119 +79,87,61 +0,89,446 +119,123,466 +118,58,478 +103,123,0 +346,162,597 +68,80,498 +80,87,51 +153,75,95 +92,76,0 +32,53,489 +114,74,62 +143,68,504 +55,73,581 +20,103,0 +87,114,55 +177,110,607 +62,39,553 +65,62,457 +78,108,72 +49,121,0 +0,94,37 +78,125,1 +80,0,68 +65,75,498 +547,48,525 +0,137,89 +164,64,470 +78,38,519 +0,0,0 +225,59,525 +174,67,530 +59,19,0 +75,95,110 +76,0,28 +370,96,232 +68,86,53 +64,111,36 +522,577,602 +74,91,519 +576,22,525 +112,69,475 +112,0,474 +59,97,134 +118,89,445 +150,58,486 +110,13,91 +39,107,535 +165,125,593 +81,80,98 +125,120,527 +107,69,56 +132,54,318 +82,69,39 +49,119,473 +61,120,85 +53,62,128 +69,0,5 +173,72,353 +72,0,453 +79,93,0 +88,88,64 +124,114,0 +85,87,0 +109,89,508 +17,103,84 +123,100,523 +114,11,282 +74,0,13 +93,63,61 +162,62,525 +140,96,509 +91,106,416 +0,65,25 +103,49,97 +79,71,0 +158,0,149 +96,0,43 +0,147,52 +231,102,276 +0,55,0 +155,113,102 +3,129,3 +73,126,0 +21,0,0 +137,40,583 +550,115,467 +72,51,155 +121,0,0 +418,208,740 +393,99,282 +121,64,116 +78,91,113 +98,49,98 +18,0,479 +89,106,101 +613,31,519 +65,62,0 +60,89,68 +163,0,533 +8,104,41 +98,69,0 +42,85,542 +556,675,619 +163,70,493 +131,64,55 +82,106,77 +3,99,495 +155,85,352 +96,35,59 +73,136,114 +83,0,484 +82,90,89 +553,102,533 +0,102,0 +98,98,63 +30,124,541 +37,80,107 +107,62,173 +609,26,567 +527,99,526 +78,0,421 +102,77,183 +79,68,364 +49,92,80 +89,73,0 +0,127,25 +0,324,512 +166,100,28 +78,142,64 +706,7,610 +75,0,74 +92,67,111 +19,77,0 +36,53,349 +113,62,28 +570,710,635 +123,65,446 +23,58,56 +41,123,2 +645,109,502 +133,27,476 +80,84,528 +101,97,31 +526,705,645 +595,92,582 +91,69,54 +496,640,599 +1,116,29 +111,60,51 +34,61,100 +128,77,50 +112,0,86 +70,77,70 +357,203,524 +587,120,467 +557,94,561 +52,96,13 +103,97,510 +121,47,122 +168,0,136 +545,618,614 +104,0,81 +85,106,157 +188,15,530 +185,87,542 +61,126,110 +0,77,434 +36,60,645 +84,70,6 +65,66,133 +41,109,162 +86,90,11 +656,89,509 +59,72,18 +589,98,568 +92,54,515 +0,126,492 +98,26,450 +75,18,116 +21,58,103 +64,99,44 +105,63,295 +64,113,448 +545,648,614 +238,6,464 +532,620,525 +0,83,70 +534,673,649 +44,0,84 +642,58,519 +106,81,458 +97,69,30 +83,114,459 +39,116,373 +95,102,435 +93,102,499 +178,99,384 +59,57,108 +100,93,10 +0,88,97 +36,122,328 +117,77,30 +117,0,0 +52,0,38 +108,133,518 +78,60,57 +75,101,221 +0,36,88 +150,77,487 +528,145,310 +95,53,0 +533,105,569 +129,87,427 +28,149,13 +657,53,487 +86,95,508 +31,0,110 +467,304,399 +121,94,93 +0,51,11 +572,35,559 +32,123,0 +79,57,466 +639,127,334 +232,0,509 +140,165,322 +74,44,0 +70,119,68 +100,0,115 +86,91,513 +142,56,480 +570,63,575 +82,17,422 +0,0,93 +67,125,604 +79,104,508 +21,91,183 +73,142,110 +8,52,5 +91,18,94 +72,73,405 +536,684,626 +133,83,527 +88,102,376 +39,122,196 +0,50,506 +84,138,492 +259,136,631 +0,36,0 +52,61,8 +43,51,59 +79,0,84 +221,73,219 +5,97,420 +145,29,17 +107,100,117 +94,0,39 +44,68,52 +124,139,525 +28,35,497 +379,557,510 +47,72,0 +101,124,440 +64,94,445 +159,35,96 +71,102,86 +108,116,76 +90,91,120 +57,99,533 +45,101,482 +103,0,444 +98,123,22 +222,118,489 +52,62,8 +3,56,65 +131,101,473 +77,69,105 +37,14,0 +50,97,107 +121,103,0 +70,126,0 +104,48,78 +123,0,509 +482,572,435 +37,104,0 +85,116,77 +307,76,511 +15,68,220 +0,4,29 +75,71,14 +8,50,90 +104,0,118 +64,99,44 +107,106,489 +104,102,130 +520,76,490 +88,107,0 +59,201,492 +0,109,469 +76,79,0 +94,102,492 +0,99,509 +424,372,606 +23,73,121 +161,73,591 +149,96,274 +7,89,7 +99,102,0 +24,0,119 +279,95,613 +51,135,143 +0,110,450 +97,72,537 +85,36,16 +62,24,470 +81,30,62 +96,88,61 +117,93,81 +83,111,70 +123,91,114 +0,51,486 +1,122,0 +576,57,530 +587,39,493 +530,150,549 +598,0,557 +485,566,434 +295,56,605 +0,120,101 +537,658,619 +105,49,75 +599,116,500 +143,0,508 +72,137,0 +41,22,0 +100,117,493 +0,122,0 +126,0,442 +55,0,0 +134,51,0 +566,146,629 +57,53,113 +503,135,540 +0,118,121 +57,112,0 +238,91,578 +112,107,0 +0,108,0 +9,119,0 +80,68,40 +52,0,28 +134,172,7 +90,86,520 +43,136,438 +0,67,91 +0,2,0 +122,32,84 +483,670,582 +65,47,476 +585,36,542 +134,162,469 +73,107,79 +72,138,45 +109,59,96 +97,0,526 +0,45,269 +105,46,0 +88,68,412 +109,11,121 +64,55,313 +82,104,528 +658,59,565 +85,60,0 +0,72,91 +127,0,88 +91,84,380 +42,0,514 +74,89,354 +613,8,555 +92,78,56 +85,110,244 +556,136,591 +103,0,51 +109,130,351 +0,67,511 +75,135,491 +528,699,634 +64,56,118 +554,68,577 +556,121,575 +56,126,0 +46,85,107 +512,670,635 +510,694,645 +608,0,470 +93,53,34 +80,21,0 +105,52,432 +53,69,76 +53,71,142 +559,673,603 +104,34,72 +534,0,599 +76,70,441 +76,147,75 +544,711,620 +115,49,66 +111,40,188 +0,103,60 +25,21,475 +107,104,95 +0,42,75 +0,44,80 +108,4,0 +151,87,495 +53,65,284 +489,45,540 +586,107,495 +62,92,468 +9,33,476 +514,683,601 +109,0,57 +80,112,95 +70,76,141 +80,15,60 +93,52,0 +60,99,469 +50,104,0 +102,48,44 +67,61,174 +81,26,151 +47,0,0 +515,43,523 +101,84,522 +0,80,97 +103,0,4 +93,116,37 +108,109,443 +123,0,0 +123,64,498 +639,361,563 +0,24,74 +105,439,493 +499,678,615 +82,94,39 +99,0,35 +552,11,504 +101,38,168 +412,559,563 +28,0,30 +62,51,0 +75,82,101 +0,79,291 +15,64,67 +129,137,183 +2,0,426 +106,55,28 +119,85,516 +177,139,110 +0,49,69 +540,696,626 +49,72,93 +53,59,110 +469,11,421 +65,61,483 +67,0,188 +137,117,110 +109,95,142 +156,121,60 +113,84,0 +114,119,38 +97,18,521 +111,47,0 +98,133,127 +93,58,377 +0,41,7 +116,90,15 +118,98,0 +0,80,0 +540,6,482 +71,77,2 +0,26,377 +97,73,102 +117,0,439 +101,145,95 +0,401,521 +52,127,91 +64,67,446 +166,86,92 +148,118,460 +182,107,130 +550,106,555 +193,94,157 +112,85,54 +77,19,104 +73,91,67 +488,656,601 +611,67,462 +73,62,0 +96,108,40 +548,309,562 +497,107,472 +587,85,450 +73,0,74 +58,0,6 +81,137,0 +53,30,181 +81,2,82 +89,19,123 +119,128,401 +12,81,0 +0,113,435 +35,67,112 +85,56,0 +541,162,565 +36,110,53 +113,136,514 +108,113,543 +135,119,526 +564,675,614 +44,63,68 +167,136,536 +544,600,586 +97,145,479 +107,0,68 +93,41,492 +92,111,549 +591,45,583 +126,0,329 +120,61,495 +580,108,548 +537,697,629 +61,37,0 +355,91,474 +574,42,547 +564,125,509 +0,59,99 +183,54,411 +94,121,116 +516,108,534 +107,128,474 +120,0,429 +559,84,477 +94,45,141 +60,59,0 +117,82,31 +83,147,452 +0,51,68 +101,89,480 +54,116,345 +140,114,467 +95,61,13 +536,136,576 +660,83,600 +558,715,632 +113,116,0 +604,31,593 +103,0,360 +585,92,438 +580,63,549 +119,64,70 +33,110,469 +32,107,0 +142,98,561 +100,0,0 +97,113,0 +96,114,0 +92,54,5 +101,69,95 +97,116,49 +165,0,88 +82,149,238 +103,130,71 +108,67,154 +121,89,43 +107,0,429 +101,54,3 +90,105,387 +141,24,444 +133,102,102 +76,74,86 +73,74,424 +167,0,523 +0,64,486 +97,125,74 +99,69,77 +87,130,62 +670,377,535 +19,0,0 +115,15,57 +227,119,222 +126,125,84 +72,23,447 +599,243,515 +91,0,0 +556,669,626 +74,0,275 +127,97,467 +526,19,543 +121,88,0 +57,0,0 +184,13,531 +0,44,50 +68,77,0 +0,0,397 +139,61,317 +71,96,75 +114,15,445 +118,106,467 +124,82,1 +123,64,440 +77,100,0 +564,65,568 +153,83,638 +124,47,91 +97,0,0 +63,66,0 +63,0,24 +70,46,107 +31,25,0 +70,44,209 +282,50,273 +83,106,22 +42,99,121 +8,111,62 +107,63,598 +113,58,463 +105,0,31 +108,96,383 +103,10,0 +145,54,505 +72,115,25 +497,93,657 +220,40,622 +158,92,39 +81,113,0 +31,0,76 +499,213,470 +61,51,492 +0,78,559 +578,610,594 +54,57,310 +0,95,498 +146,44,388 +637,110,557 +4,94,523 +42,44,85 +79,4,112 +443,51,332 +157,45,424 +14,116,157 +522,48,551 +85,0,23 +38,0,458 +465,94,209 +86,69,31 +558,90,578 +70,0,0 +116,64,28 +79,118,0 +86,0,98 +119,67,401 +588,12,574 +662,102,563 +134,143,343 +137,65,496 +77,17,117 +87,50,393 +22,53,51 +98,57,483 +125,67,112 +173,120,142 +44,122,408 +51,133,36 +574,564,586 +556,0,578 +18,55,103 +131,105,135 +590,101,555 +90,130,146 +110,97,507 +463,597,459 +71,24,224 +0,117,160 +10,116,108 +123,49,150 +149,82,0 +173,48,51 +0,116,0 +56,77,54 +137,119,605 +604,101,578 +72,25,0 +73,52,379 +567,0,514 +107,89,3 +50,153,52 +0,88,94 +49,125,0 +110,98,382 +521,68,521 +65,111,1 +139,126,282 +27,0,496 +209,0,604 +81,121,471 +108,56,0 +504,57,517 +105,54,41 +132,0,125 +108,48,449 +123,101,0 +535,27,525 +68,84,52 +123,115,537 +9,24,0 +42,106,29 +78,126,5 +94,72,493 +526,115,531 +70,43,0 +73,88,0 +74,127,6 +174,12,548 +33,63,492 +162,98,318 +0,88,198 +154,0,63 +90,34,150 +94,0,15 +93,79,467 +85,133,0 +153,12,471 +0,65,448 +59,42,66 +636,75,570 +166,119,488 +84,58,283 +220,135,427 +557,67,629 +33,109,478 +584,89,620 +180,55,546 +523,113,524 +98,129,57 +64,92,150 +574,16,517 +135,144,113 +138,120,528 +343,0,488 +87,64,62 +108,35,449 +90,85,55 +64,41,477 +0,96,399 +118,73,461 +113,31,525 +113,29,177 +30,68,56 +0,68,227 +614,114,551 +0,86,98 +88,4,151 +591,131,497 +107,0,0 +127,73,515 +91,68,160 +123,79,78 +32,84,0 +6,100,386 +86,84,0 +61,79,71 +141,62,486 +0,107,7 +1,0,104 +0,0,34 +149,16,441 +32,93,0 +38,58,0 +546,83,454 +73,89,116 +114,37,185 +440,58,94 +99,0,74 +594,70,526 +93,112,132 +70,57,409 +492,605,479 +584,599,620 +120,88,25 +620,102,496 +75,109,349 +94,132,60 +38,111,47 +560,628,588 +0,90,0 +116,0,425 +551,587,624 +37,27,0 +78,86,0 +37,96,31 +584,131,623 +107,74,460 +513,645,586 +42,70,36 +71,124,74 +73,153,9 +624,175,529 +152,0,2 +48,36,467 +125,26,0 +107,55,72 +148,84,0 +62,82,31 +21,108,509 +204,107,524 +63,121,603 +215,115,519 +53,77,80 +0,30,104 +131,51,387 +124,87,7 +30,130,18 +72,50,519 +142,66,473 +86,31,537 +560,129,479 +138,28,385 +63,90,81 +102,32,0 +77,63,50 +158,134,179 +157,57,110 +96,14,181 +52,0,457 +42,51,455 +123,5,517 +199,141,190 +622,89,591 +562,72,550 +617,89,509 +73,46,0 +68,70,474 +77,20,48 +99,81,61 +518,68,589 +65,55,22 +75,93,0 +60,138,480 +103,137,0 +75,135,426 +634,84,514 +122,27,402 +0,20,88 +103,122,0 +87,103,82 +103,0,448 +114,75,412 +48,37,555 +28,0,67 +0,112,411 +129,107,58 +26,92,126 +219,49,482 +145,2,80 +83,4,453 +0,60,0 +240,152,99 +102,91,430 +565,82,556 +102,46,129 +0,97,514 +116,133,41 +64,109,0 +0,0,467 +114,114,0 +107,6,395 +62,108,0 +60,58,467 +150,80,249 +90,94,90 +110,0,182 +530,700,625 +135,77,533 +4,78,164 +514,90,530 +0,65,8 +592,47,417 +17,123,0 +75,56,32 +96,47,155 +70,102,0 +26,19,392 +691,0,556 +75,69,41 +531,662,588 +551,97,588 +570,76,556 +59,57,79 +118,31,511 +578,103,549 +127,145,0 +62,0,93 +51,72,390 +22,43,112 +110,71,15 +0,26,551 +31,42,59 +49,81,63 +82,139,412 +22,114,82 +105,116,0 +41,130,78 +85,145,587 +94,92,85 +573,119,627 +95,434,425 +117,95,142 +113,56,0 +400,105,398 +89,58,445 +116,36,41 +565,63,512 +13,58,37 +44,112,490 +183,50,555 +564,0,521 +125,126,0 +33,116,395 +79,0,86 +67,0,488 +82,113,0 +0,116,59 +66,93,17 +107,89,124 +45,0,326 +164,57,219 +9,85,463 +101,430,517 +0,86,492 +604,601,578 +11,96,17 +88,73,98 +58,0,85 +141,87,362 +91,70,56 +94,115,3 +509,683,578 +47,108,388 +566,46,592 +66,50,20 +0,57,68 +0,38,0 +572,128,584 +42,124,444 +0,72,478 +98,33,0 +94,111,496 +20,127,119 +60,43,485 +62,93,87 +634,79,573 +60,60,207 +87,25,427 +153,88,500 +553,0,627 +18,0,89 +109,11,482 +90,72,142 +66,42,0 +539,67,559 +142,0,431 +32,92,96 +0,31,36 +538,83,460 +134,140,514 +135,21,163 +34,41,0 +116,37,44 +93,70,0 +84,140,67 +93,60,461 +0,0,512 +506,66,548 +64,19,525 +545,655,598 +70,96,49 +127,86,493 +119,122,0 +92,19,181 +126,117,534 +94,117,501 +61,0,0 +96,84,566 +45,66,187 +89,114,185 +67,0,0 +116,60,89 +137,15,523 +165,113,566 +97,88,380 +55,66,64 +43,0,230 +126,110,125 +551,350,414 +526,625,607 +88,34,55 +26,43,66 +79,25,60 +24,7,0 +79,77,91 +473,648,650 +131,43,43 +693,0,564 +38,46,92 +95,77,11 +105,0,29 +152,70,49 +516,652,594 +119,45,83 +387,0,697 +32,110,511 +43,54,0 +591,94,605 +71,101,525 +536,26,509 +86,75,466 +578,35,547 +65,0,75 +60,44,0 +87,0,153 +514,703,634 +52,48,0 +0,88,3 +86,0,257 +39,49,2 +45,57,5 +614,32,544 +62,55,28 +143,99,71 +43,95,0 +74,61,16 +0,109,0 +111,5,94 +123,138,3 +94,26,27 +153,104,60 +80,89,75 +0,69,506 +89,66,23 +0,20,471 +569,117,562 +62,98,13 +530,697,588 +72,98,549 +606,67,539 +37,5,83 +72,100,0 +93,85,524 +78,122,444 +116,51,525 +567,92,581 +81,89,459 +118,89,0 +139,73,71 +17,109,517 +100,48,400 +136,0,0 +128,120,430 +27,0,398 +594,75,561 +36,138,7 +96,102,370 +89,40,43 +71,136,501 +114,20,432 +45,44,508 +16,52,0 +82,108,510 +628,619,584 +578,184,543 +117,0,415 +100,57,275 +86,132,0 +73,22,21 +38,68,72 +74,0,0 +68,0,420 +149,60,581 +118,0,434 +41,96,0 +595,57,584 +95,127,54 +393,17,266 +48,116,43 +6,5,131 +79,34,13 +65,85,450 +169,104,0 +87,35,409 +465,25,208 +549,140,585 +65,0,0 +62,47,407 +104,59,385 +631,593,534 +0,15,0 +143,97,454 +59,49,94 +122,76,446 +116,114,37 +125,68,389 +488,663,655 +504,65,409 +20,87,75 +106,0,470 +66,6,89 +121,102,431 +49,87,102 +90,75,153 +60,99,121 +105,121,104 +113,57,58 +92,135,121 +77,61,0 +649,8,553 +678,46,547 +103,71,112 +472,647,543 +541,59,567 +65,105,89 +558,95,543 +93,53,59 +106,111,486 +31,64,65 +115,108,43 +116,73,549 +48,77,93 +90,120,125 +51,55,461 +106,109,72 +48,39,0 +113,76,13 +86,88,507 +163,111,190 +76,69,379 +34,0,54 +113,89,424 +73,0,520 +117,87,85 +86,14,481 +108,142,95 +94,87,487 +0,162,0 +463,694,618 +578,679,684 +85,36,121 +119,4,156 +118,130,0 +55,65,51 +274,96,601 +151,92,0 +676,109,566 +127,36,9 +450,652,535 +114,0,113 +12,0,0 +533,66,550 +81,89,74 +134,116,391 +52,65,215 +86,119,0 +53,116,41 +58,72,43 +84,130,176 +517,55,402 +659,63,419 +34,121,525 +12,35,0 +87,0,4 +63,0,326 +92,0,196 +101,126,499 +117,384,464 +33,77,337 +100,0,391 +0,96,126 +37,153,505 +72,8,0 +303,79,546 +50,0,90 +30,61,0 +115,0,161 +14,73,44 +88,0,0 +0,42,71 +7,100,158 +84,21,60 +72,113,392 +22,78,0 +122,49,494 +76,62,0 +126,145,114 +115,91,0 +84,80,468 +143,99,221 +131,102,297 +202,126,419 +111,117,58 +25,84,61 +130,3,0 +92,37,63 +83,68,416 +542,61,608 +231,17,113 +65,8,0 +148,0,442 +76,125,468 +63,0,72 +0,67,0 +575,115,602 +31,125,23 +127,64,437 +44,61,46 +141,49,276 +109,53,0 +32,77,0 +0,51,2 +20,75,74 +183,46,515 +115,134,489 +62,91,0 +59,0,113 +77,110,126 +85,55,72 +125,56,505 +17,31,0 +103,78,0 +541,67,523 +139,107,52 +104,77,551 +105,0,31 +91,61,474 +525,639,597 +11,117,89 +674,503,610 +92,26,74 +82,65,0 +560,113,565 +147,104,6 +160,140,593 +70,112,112 +74,106,32 +32,20,70 +290,54,544 +100,63,477 +0,130,7 +0,33,24 +71,23,89 +70,63,52 +328,26,665 +96,70,0 +10,0,0 +114,105,0 +212,135,123 +54,110,0 +104,108,0 +149,82,110 +107,54,87 +94,143,24 +98,20,98 +83,128,219 +90,159,51 +113,106,49 +48,139,37 +137,100,443 +147,73,221 +168,100,444 +105,97,316 +134,107,538 +63,0,411 +5,81,60 +106,0,80 +104,0,486 +56,40,532 +68,94,0 +576,707,633 +0,117,170 +56,0,7 +59,83,70 +0,46,473 +122,0,322 +14,83,27 +472,0,295 +18,106,17 +110,72,338 +65,68,431 +604,111,576 +245,58,34 +130,0,56 +63,76,10 +124,93,454 +577,107,502 +93,114,421 +428,672,579 +90,71,67 +133,92,0 +116,138,214 +101,6,266 +548,135,528 +462,693,655 +550,661,609 +0,111,78 +0,55,517 +45,95,0 +104,110,0 +87,30,451 +74,47,2 +89,100,1 +126,0,137 +92,0,124 +122,0,0 +0,67,67 +0,89,99 +580,112,524 +554,714,668 +575,93,571 +62,93,0 +109,0,70 +96,66,52 +25,63,0 +89,82,0 +11,97,478 +145,123,201 +74,9,86 +65,99,89 +76,111,82 +525,682,623 +115,84,465 +107,26,545 +15,88,0 +85,95,433 +43,0,0 +42,38,0 +613,63,566 +124,0,521 +144,120,0 +72,0,432 +57,130,14 +143,0,489 +50,42,48 +118,0,154 +114,0,391 +552,0,528 +74,129,194 +43,49,68 +41,99,72 +115,131,492 +0,80,111 +0,112,71 +586,0,461 +0,0,52 +580,118,504 +60,109,632 +100,68,16 +598,64,314 +78,106,64 +0,85,63 +70,80,93 +0,55,65 +72,0,255 +13,82,0 +86,40,0 +75,97,95 +573,0,604 +3,35,490 +129,116,74 +547,118,536 +610,0,447 +178,167,385 +112,88,56 +566,124,594 +129,102,457 +568,37,424 +589,95,506 +126,61,44 +109,0,205 +637,72,507 +80,86,15 +98,114,9 +57,69,0 +112,131,78 +68,48,60 +42,13,0 +76,125,0 +529,92,435 +587,32,403 +75,0,107 +0,86,296 +585,72,660 +81,0,182 +523,649,610 +170,76,469 +120,76,437 +81,110,54 +130,100,116 +51,97,243 +626,135,578 +491,77,605 +115,106,0 +546,93,569 +241,126,520 +41,130,68 +300,168,523 +187,105,568 +582,0,522 +502,90,576 +97,110,61 +80,82,43 +26,93,0 +47,75,70 +69,36,487 +0,111,570 +140,113,28 +130,21,483 +63,95,71 +126,133,225 +89,74,84 +111,70,480 +47,41,0 +66,113,0 +69,59,122 +178,116,613 +0,105,0 +139,75,560 +0,72,0 +83,76,269 +91,105,543 +40,64,2 +162,137,411 +76,128,581 +77,34,471 +21,81,112 +104,86,455 +31,132,2 +167,114,88 +141,60,150 +13,77,43 +144,129,158 +506,668,620 +74,142,515 +173,63,457 +366,64,397 +31,155,0 +117,106,464 +81,135,387 +287,72,436 +42,54,506 +156,0,369 +93,109,176 +0,100,0 +62,95,4 +61,40,83 +106,104,0 +72,93,0 +74,82,433 +557,543,470 +131,117,138 +0,134,76 +60,146,0 +550,87,624 +113,48,428 +142,0,530 +56,16,127 +127,0,369 +161,39,553 +72,97,0 +116,159,480 +31,118,351 +55,34,0 +127,129,156 +124,0,84 +150,86,430 +23,91,0 +485,674,609 +122,60,513 +18,140,2 +77,76,35 +81,144,0 +64,120,521 +582,0,575 +27,137,376 +79,83,49 +89,93,130 +113,127,120 +135,99,487 +0,67,521 +110,110,45 +49,9,85 +561,641,615 +0,62,0 +124,74,480 +104,108,123 +51,0,83 +72,110,499 +117,0,54 +110,0,49 +125,59,573 +87,50,344 +544,109,599 +643,590,533 +567,64,517 +48,89,84 +127,69,61 +36,63,96 +31,115,490 +121,51,11 +128,100,5 +78,47,86 +168,57,533 +150,43,54 +77,93,519 +554,27,588 +125,89,345 +170,0,535 +36,92,34 +539,117,305 +524,684,649 +84,97,97 +142,133,450 +296,130,196 +280,121,262 +116,87,112 +109,88,422 +70,17,107 +67,71,0 +125,2,16 +120,117,458 +96,142,0 +35,123,54 +74,0,157 +76,87,443 +65,37,0 +95,24,0 +59,162,85 +94,78,0 +69,39,53 +0,37,0 +59,0,56 +5,130,67 +56,108,497 +101,135,0 +106,94,484 +49,60,40 +174,110,145 +513,9,395 +88,46,507 +11,134,38 +0,109,77 +91,34,626 +17,78,71 +0,76,58 +48,97,355 +497,82,596 +92,57,98 +111,140,440 +84,172,107 +118,127,490 +9,37,0 +0,66,7 +53,103,0 +37,0,58 +153,3,8 +0,63,42 +72,111,387 +0,62,107 +513,682,656 +126,22,441 +29,95,339 +27,79,0 +497,703,591 +560,700,650 +98,144,492 +83,85,25 +132,89,8 +649,128,552 +526,683,585 +629,0,528 +51,92,7 +93,40,485 +66,102,38 +30,0,0 +104,109,291 +98,0,55 +91,53,103 +134,90,78 +29,88,11 +75,70,43 +137,32,276 +77,99,0 +40,66,124 +77,114,184 +535,103,572 +58,0,4 +198,94,85 +135,35,28 +453,702,651 +36,29,66 +72,108,505 +527,42,464 +126,0,510 +574,669,626 +137,0,469 +70,120,92 +121,64,0 +63,121,77 +140,145,427 +143,0,501 +556,109,525 +77,119,35 +21,157,0 +95,141,452 +29,97,215 +0,100,0 +105,96,0 +0,43,96 +528,690,629 +45,100,0 +73,65,420 +84,27,14 +22,76,148 +72,113,82 +92,132,0 +98,116,551 +108,104,20 +129,29,483 +545,0,573 +14,4,0 +66,101,461 +105,118,385 +46,117,66 +576,112,520 +0,109,0 +480,647,632 +66,0,472 +113,117,513 +681,74,547 +562,643,632 +82,0,42 +120,90,51 +120,22,0 +549,73,562 +33,76,48 +73,113,338 +127,134,186 +553,0,553 +87,84,64 +119,132,33 +559,88,593 +88,60,107 +130,99,458 +71,60,509 +78,57,524 +94,17,448 +111,65,253 +8,72,7 +0,55,0 +124,66,28 +86,81,0 +480,112,573 +51,74,65 +101,104,12 +0,85,46 +37,82,352 +0,46,11 +24,89,20 +104,71,7 +0,0,65 +93,86,433 +23,112,0 +469,129,213 +12,68,428 +28,66,533 +91,75,11 +281,0,510 +125,80,474 +64,0,29 +45,63,0 +152,0,580 +0,85,0 +81,105,84 +6,78,14 +532,644,576 +23,88,49 +45,98,129 +38,0,2 +67,95,22 +0,4,0 +64,63,560 +384,674,633 +58,102,0 +594,102,566 +485,622,562 +69,90,509 +63,43,39 +87,44,530 +434,97,194 +0,124,485 +74,82,474 +595,68,560 +545,40,557 +74,60,102 +0,27,56 +102,139,491 +64,43,76 +104,80,473 +27,117,440 +64,27,71 +8,95,445 +599,0,551 +11,0,118 +37,81,234 +123,76,386 +40,35,20 +98,68,0 +81,0,81 +0,22,115 +116,81,0 +39,120,67 +56,88,126 +110,73,48 +16,77,0 +107,77,101 +121,133,513 +61,2,0 +567,0,562 +481,116,593 +55,0,0 +62,133,287 +485,73,250 +553,398,370 +107,151,223 +89,62,476 +95,60,544 +529,38,183 +46,19,411 +45,17,66 +65,20,56 +119,118,140 +113,52,423 +156,40,613 +130,90,52 +546,585,598 +0,78,63 +65,99,505 +65,113,34 +122,59,505 +104,33,483 +196,80,523 +558,53,575 +47,53,0 +595,98,452 +83,85,88 +70,56,0 +88,140,4 +68,85,49 +43,53,478 +91,64,51 +667,25,379 +607,97,583 +577,93,579 +80,116,476 +45,0,349 +20,78,0 +584,12,571 +120,113,495 +95,105,58 +593,0,618 +108,0,0 +99,96,544 +98,74,355 +0,121,34 +106,49,532 +557,0,571 +487,563,578 +540,78,502 +66,0,30 +545,703,640 +349,99,495 +125,76,394 +259,112,385 +126,87,537 +23,133,471 +100,110,533 +84,98,0 +87,34,47 +104,12,0 +104,124,467 +15,131,75 +120,53,310 +73,60,405 +14,72,72 +60,163,290 +408,575,408 +0,469,467 +0,87,91 +70,47,71 +102,355,516 +119,71,460 +92,60,67 +557,110,490 +0,106,45 +131,80,460 +97,135,437 +541,146,522 +4,73,531 +71,52,0 +456,647,529 +99,45,179 +28,59,71 +108,93,114 +64,0,345 +55,70,501 +561,114,608 +38,7,86 +113,77,0 +161,61,89 +17,126,328 +6,0,0 +149,76,515 +362,74,274 +70,139,0 +113,89,64 +18,101,13 +124,39,0 +14,0,0 +112,135,0 +15,97,474 +134,76,82 +280,1,551 +144,81,0 +58,49,37 +66,140,95 +496,611,575 +137,88,7 +642,69,508 +57,0,59 +173,94,143 +149,54,331 +110,86,171 +0,82,119 +90,24,30 +96,88,0 +525,96,457 +112,116,65 +660,100,541 +624,69,463 +79,34,74 +116,125,531 +97,72,100 +85,136,47 +357,197,538 +663,110,566 +77,137,106 +530,64,507 +653,83,576 +153,103,73 +70,71,19 +594,115,544 +580,108,583 +129,44,0 +78,20,30 +92,97,41 +109,99,0 +127,39,483 +115,88,9 +54,136,343 +557,96,589 +117,88,460 +35,148,22 +105,59,0 +16,93,0 +554,61,545 +121,0,79 +90,86,58 +37,85,0 +559,70,496 +0,19,0 +41,0,71 +528,113,563 +584,139,551 +48,510,464 +9,15,0 +93,2,498 +87,101,0 +107,97,131 +87,96,144 +0,64,13 +57,59,39 +88,77,77 +50,29,2 +126,120,93 +107,79,4 +603,137,536 +152,63,105 +30,35,46 +30,33,461 +110,50,617 +168,55,102 +577,675,699 +107,115,579 +111,92,140 +103,67,86 +8,0,9 +163,99,533 +98,100,493 +0,19,0 +116,76,209 +648,74,549 +108,120,13 +30,142,0 +85,22,66 +115,74,117 +87,56,510 +87,119,412 +186,82,482 +93,31,33 +128,137,425 +590,79,486 +102,102,0 +534,119,559 +124,17,0 +61,115,0 +15,92,0 +145,107,548 +59,61,82 +9,93,399 +130,33,0 +121,133,15 +39,122,0 +24,120,181 +85,103,231 +145,70,32 +15,67,0 +82,77,43 +130,62,438 +54,86,80 +72,127,94 +0,24,0 +122,116,51 +49,8,100 +135,113,410 +57,103,32 +642,111,594 +583,605,663 +61,142,474 +121,61,0 +236,89,274 +120,21,79 +0,45,49 +572,61,530 +0,131,37 +94,87,83 +0,35,440 +0,98,70 +48,57,10 +89,91,28 +0,6,0 +42,107,95 +3,95,30 +80,95,479 +125,42,105 +66,91,467 +488,87,182 +155,28,90 +200,98,543 +84,89,0 +243,4,423 +574,0,533 +156,69,515 +98,94,91 +91,0,50 +114,130,2 +76,107,364 +455,670,632 +39,26,34 +484,77,488 +61,51,0 +43,106,502 +99,98,49 +89,84,189 +0,143,0 +0,43,0 +140,7,464 +101,101,36 +0,107,64 +144,4,38 +161,83,184 +619,75,559 +50,137,310 +71,89,205 +83,99,508 +56,39,37 +589,700,659 +117,480,487 +96,118,284 +125,112,518 +74,81,401 +63,139,19 +78,35,457 +74,114,39 +108,54,413 +125,0,43 +56,61,193 +118,100,95 +45,102,92 +84,103,146 +32,69,96 +100,106,440 +70,53,3 +94,45,86 +337,132,508 +120,83,48 +67,0,0 +71,27,53 +0,152,11 +163,0,516 +85,72,21 +148,59,303 +522,668,582 +377,0,260 +111,69,86 +124,58,47 +0,49,123 +89,103,530 +50,47,18 +106,82,503 +90,55,17 +92,130,493 +93,113,193 +71,0,0 +83,112,176 +152,57,249 +10,99,445 +158,58,0 +37,61,498 +126,60,79 +135,100,54 +18,53,43 +65,102,77 +115,90,55 +104,58,6 +84,100,521 +129,71,489 +139,84,290 +88,77,2 +128,84,418 +64,67,0 +140,25,41 +628,565,506 +115,98,503 +122,14,478 +53,101,560 +103,94,0 +4,92,378 +92,60,406 +208,0,286 +130,84,496 +72,105,143 +666,267,519 +114,64,127 +136,101,76 +0,86,21 +65,17,36 +0,52,40 +73,93,76 +502,73,546 +25,65,0 +139,2,0 +16,122,426 +108,0,508 +81,87,66 +112,119,8 +69,66,118 +70,100,101 +101,22,72 +88,20,10 +353,25,204 +90,76,548 +27,64,94 +93,110,99 +134,120,491 +0,454,497 +60,111,103 +77,0,63 +577,116,575 +35,120,87 +146,73,520 +82,119,505 +13,64,0 +61,126,66 +112,27,438 +559,36,549 +50,132,232 +68,51,32 +11,108,0 +81,105,114 +37,23,457 +103,130,123 +576,118,595 +108,96,42 +84,116,430 +564,673,649 +135,119,397 +66,109,549 +141,0,12 +97,46,0 +33,105,4 +106,30,201 +59,0,0 +509,73,595 +22,63,75 +104,159,437 +95,81,565 +30,493,514 +77,33,46 +468,636,625 +0,40,73 +88,107,0 +532,719,638 +37,86,59 +56,43,0 +121,110,52 +127,17,484 +108,0,94 +0,11,480 +62,4,485 +61,85,0 +73,106,461 +90,129,0 +112,141,100 +479,5,565 +66,113,7 +169,52,254 +0,13,437 +175,110,513 +34,99,62 +77,88,393 +11,53,410 +580,77,600 +0,0,457 +61,72,457 +114,71,0 +59,115,88 +657,112,548 +113,104,80 +31,0,141 +103,78,0 +85,470,502 +39,79,338 +0,35,0 +100,101,523 +107,44,110 +585,22,592 +192,30,473 +38,10,12 +97,59,414 +92,0,483 +541,340,590 +504,594,524 +91,108,357 +166,20,166 +104,152,31 +8,131,8 +42,160,88 +591,0,464 +565,96,646 +218,103,149 +638,635,638 +92,110,506 +0,113,19 +47,42,472 +20,110,462 +44,93,0 +90,73,424 +113,118,83 +80,94,0 +83,82,101 +0,63,231 +86,61,477 +52,82,15 +0,59,154 +142,17,480 +139,149,88 +135,116,200 +97,79,70 +109,121,421 +89,81,455 +111,99,297 +59,0,0 +455,521,514 +190,94,472 +83,64,464 +68,131,92 +73,519,567 +11,44,0 +71,111,462 +0,72,0 +149,110,435 +42,97,0 +129,85,484 +561,65,587 +44,120,480 +620,75,561 +25,74,74 +530,62,575 +59,122,0 +539,4,511 +137,121,6 +566,57,608 +72,0,103 +0,45,0 +100,83,375 +79,97,179 +410,0,535 +105,130,0 +144,89,595 +609,68,381 +131,110,0 +549,83,511 +0,88,0 +104,150,175 +90,109,93 +28,77,110 +116,73,104 +525,134,190 +67,68,501 +139,113,139 +129,91,466 +21,127,410 +0,124,0 +86,99,472 +57,125,0 +74,17,59 +550,0,534 +39,46,495 +0,90,37 +124,90,0 +52,83,500 +71,90,509 +105,108,105 +117,28,452 +606,60,453 +143,31,216 +119,86,56 +112,17,146 +91,70,50 +46,58,319 +67,58,24 +96,61,556 +115,45,267 +148,19,4 +73,5,0 +629,310,469 +89,93,38 +85,59,555 +27,127,0 +77,0,494 +513,35,610 +311,138,277 +555,116,571 +477,40,472 +99,100,409 +101,92,165 +16,155,643 +70,105,87 +0,100,84 +119,12,493 +75,106,134 +0,64,135 +103,132,59 +26,41,410 +63,135,179 +30,75,21 +299,113,433 +70,86,47 +174,132,591 +133,120,148 +0,114,0 +30,18,105 +111,18,76 +26,109,493 +76,90,436 +135,93,523 +114,72,369 +14,74,69 +65,1,5 +135,0,486 +81,37,119 +33,110,102 +158,73,475 +487,667,634 +40,0,316 +92,62,208 +81,118,8 +675,30,600 +140,82,525 +16,3,89 +37,0,54 +527,113,511 +0,77,506 +84,0,174 +70,102,53 +98,61,0 +38,128,32 +62,57,108 +0,0,1 +92,82,81 +105,0,19 +103,66,52 +95,0,419 +146,60,76 +570,60,568 +336,108,562 +55,83,31 +79,138,327 +586,0,555 +0,7,72 +68,0,41 +131,90,59 +117,59,103 +636,0,501 +117,49,448 +2,73,526 +0,86,310 +510,84,540 +96,97,537 +111,96,0 +73,84,40 +138,47,90 +0,129,52 +96,41,383 +438,696,604 +527,77,538 +108,64,506 +30,80,104 +55,76,147 +63,372,367 +112,77,0 +160,123,451 +587,56,560 +35,0,59 +69,65,77 +0,132,38 +132,92,0 +77,109,299 +65,78,83 +42,145,69 +148,66,417 +89,22,486 +45,47,0 +127,11,271 +99,124,79 +119,88,467 +171,130,591 +54,98,105 +140,118,41 +142,48,0 +138,0,357 +489,701,629 +64,89,55 +111,125,27 +673,53,519 +0,87,18 +156,73,4 +503,676,641 +411,7,267 +54,98,76 +91,117,6 +92,131,88 +139,87,0 +86,79,490 +636,0,531 +108,55,329 +123,0,7 +589,0,525 +10,119,22 +107,112,463 +48,75,0 +93,74,10 +529,0,562 +87,98,453 +105,34,67 +163,77,119 +257,99,321 +162,104,198 +44,73,525 +60,73,70 +18,0,123 +647,0,587 +478,48,554 +564,108,557 +88,37,442 +48,57,0 +86,9,0 +0,76,531 +78,100,74 +515,98,637 +89,98,422 +47,68,0 +52,64,112 +100,157,463 +133,98,90 +113,82,494 +140,88,0 +588,55,551 +114,76,478 +122,53,0 +126,107,550 +48,69,443 +64,0,59 +67,0,30 +131,117,435 +137,109,485 +575,89,551 +580,120,570 +158,70,485 +0,119,341 +68,58,531 +51,46,583 +18,45,109 +599,140,509 +125,128,62 +561,0,521 +18,106,0 +572,31,550 +132,142,457 +84,66,3 +0,124,0 +139,19,432 +101,66,0 +117,29,563 +87,62,160 +81,78,156 +73,59,76 +103,159,167 +44,104,89 +259,109,561 +130,85,0 +81,94,509 +77,33,428 +542,79,456 +87,77,441 +106,107,153 +107,76,86 +117,153,200 +53,17,0 +28,0,58 +526,35,562 +78,34,184 +27,44,8 +75,84,54 +578,96,513 +99,81,511 +36,0,108 +0,82,0 +0,0,0 +104,77,0 +128,86,18 +73,58,0 +0,0,97 +89,77,64 +0,26,2 +83,115,77 +79,63,482 +129,75,0 +120,123,106 +0,94,60 +148,74,619 +0,62,69 +88,95,86 +0,11,41 +0,83,437 +16,131,0 +74,82,84 +517,653,591 +0,15,53 +103,30,79 +160,127,264 +7,153,60 +628,119,583 +124,67,440 +45,33,95 +72,65,35 +64,28,53 +479,690,659 +78,52,15 +79,97,563 +59,85,4 +5,0,22 +0,113,45 +549,0,515 +93,96,10 +92,70,468 +83,0,2 +544,96,570 +503,115,598 +79,0,0 +56,38,435 +0,46,0 +56,97,539 +159,70,505 +144,0,294 +123,0,499 +119,0,11 +28,102,152 +69,23,405 +101,43,101 +101,95,546 +0,145,62 +122,127,371 +129,123,33 +47,101,78 +48,134,307 +63,24,113 +666,0,620 +328,134,532 +39,33,0 +112,96,478 +0,111,353 +27,44,30 +515,0,437 +430,645,630 +148,106,540 +69,82,0 +72,65,102 +181,132,471 +52,121,74 +49,73,31 +94,77,1 +76,67,28 +63,147,464 +12,70,89 +80,89,393 +108,151,0 +58,114,45 +358,95,332 +684,115,555 +491,634,495 +179,121,73 +0,52,78 +237,4,664 +0,88,81 +32,86,56 +63,84,0 +138,0,89 +54,19,0 +45,26,108 +53,131,11 +0,79,0 +121,88,40 +150,83,361 +37,117,0 +93,95,64 +551,15,474 +88,107,468 +83,69,467 +80,112,160 +420,71,318 +85,0,112 +571,125,395 +124,126,93 +82,92,54 +52,4,42 +8,38,35 +54,0,0 +128,26,92 +72,59,532 +206,111,609 +0,124,126 +521,55,444 +75,102,79 +66,118,51 +0,107,351 +119,94,492 +69,33,420 +0,0,131 +26,48,85 +569,128,499 +90,124,544 +93,31,107 +40,64,388 +79,81,488 +0,49,33 +566,93,565 +0,89,0 +56,0,84 +137,109,0 +523,58,529 +111,0,585 +21,47,0 +36,32,175 +110,28,66 +671,90,566 +111,66,0 +148,135,0 +49,0,76 +684,0,598 +39,108,0 +88,0,0 +69,58,14 +550,633,568 +160,119,523 +20,126,0 +91,0,513 +637,516,509 +81,0,398 +56,105,153 +70,103,352 +51,88,131 +73,88,435 +86,0,58 +104,98,41 +92,51,91 +128,77,0 +140,79,485 +30,66,158 +212,92,504 +75,59,5 +81,65,0 +127,104,516 +111,66,513 +0,88,78 +155,81,95 +656,47,483 +61,67,528 +75,135,507 +68,61,0 +103,107,120 +35,69,329 +85,82,391 +445,649,535 +108,58,59 +90,78,176 +83,90,0 +43,62,28 +585,107,550 +35,112,464 +55,58,104 +119,68,81 +63,33,479 +123,119,147 +116,93,138 +70,0,84 +140,50,78 +232,51,524 +586,0,544 +76,0,74 +92,32,57 +119,127,105 +145,49,534 +85,75,410 +133,100,53 +112,119,33 +530,0,600 +111,117,120 +511,577,448 +120,109,64 +638,76,569 +162,86,0 +68,92,88 +471,89,522 +133,52,463 +226,111,522 +89,62,491 +84,102,0 +0,0,7 +101,99,112 +0,0,77 +77,95,158 +108,74,519 +11,16,0 +24,83,35 +93,57,411 +43,99,0 +82,63,94 +653,63,548 +598,443,534 +57,76,123 +80,85,237 +37,0,137 +278,127,494 +89,41,129 +117,17,489 +60,98,3 +34,88,479 +71,59,37 +20,0,89 +117,128,88 +122,120,454 +78,108,0 +549,54,672 +35,122,84 +88,108,46 +118,14,0 +126,115,0 +570,68,573 +52,80,10 +111,123,0 +145,17,498 +59,140,246 +531,123,559 +40,24,95 +529,46,539 +140,121,536 +127,138,523 +100,107,9 +0,113,43 +62,78,1 +687,442,588 +508,613,489 +93,0,169 +87,104,63 +114,88,431 +26,36,121 +74,98,62 +100,98,86 +79,26,46 +0,103,508 +47,106,515 +135,104,79 +541,0,506 +71,33,58 +71,127,7 +78,148,60 +100,11,67 +42,60,198 +117,0,112 +128,77,490 +136,55,0 +101,102,64 +105,74,345 +223,81,121 +137,0,0 +49,51,0 +110,73,2 +60,118,0 +100,31,90 +20,0,449 +27,114,33 +25,93,8 +28,89,429 +650,85,540 +17,99,444 +554,665,638 +54,133,0 +109,0,0 +107,111,152 +0,101,499 +135,139,36 +97,37,453 +625,103,617 +604,569,508 +549,143,536 +78,82,493 +75,149,544 +30,52,52 +93,106,568 +82,94,328 +558,18,522 +45,87,427 +0,132,50 +74,78,564 +123,113,79 +249,56,0 +146,0,572 +673,76,573 +57,96,63 +239,68,144 +42,160,135 +91,83,485 +570,118,597 +87,55,103 +113,131,109 +380,29,485 +118,85,481 +138,73,67 +71,101,0 +111,0,0 +1,81,7 +440,105,352 +126,114,45 +48,93,4 +0,102,79 +458,620,567 +596,124,607 +217,71,94 +55,31,51 +480,100,370 +451,624,483 +555,3,538 +122,0,67 +71,137,76 +581,120,513 +56,105,69 +84,108,0 +121,27,0 +0,32,300 +145,48,422 +593,615,634 +95,116,413 +117,86,18 +121,40,492 +49,3,14 +111,366,454 +597,31,557 +77,45,332 +138,73,0 +83,59,475 +61,110,0 +39,44,76 +173,138,667 +137,61,484 +687,131,548 +6,27,4 +455,47,135 +120,77,79 +163,103,429 +535,682,639 +66,76,0 +132,96,42 +105,115,0 +535,62,567 +99,59,0 +186,0,582 +109,58,29 +119,86,449 +0,104,9 +31,74,42 +95,0,471 +48,71,0 +100,99,457 +262,71,434 +125,131,523 +63,65,450 +122,129,218 +71,138,245 +106,99,0 +8,112,492 +121,0,476 +21,0,566 +122,74,11 +530,54,560 +99,0,605 +87,119,24 +80,46,27 +183,132,241 +98,142,80 +80,50,469 +53,123,368 +63,0,0 +102,58,4 +522,683,627 +86,37,105 +91,102,483 +41,155,74 +129,80,13 +70,42,116 +278,67,476 +131,103,419 +12,57,405 +60,82,57 +60,99,84 +158,79,135 +181,77,66 +560,159,655 +122,88,465 +123,40,415 +94,0,502 +544,143,542 +552,124,569 +44,142,66 +110,96,474 +11,0,98 +59,65,543 +129,0,115 +576,17,498 +141,120,413 +109,95,0 +50,111,426 +66,87,66 +63,106,578 +35,50,1 +68,40,15 +119,94,541 +144,105,119 +516,649,599 +0,136,63 +82,137,91 +186,28,463 +520,103,509 +49,48,0 +118,40,508 +16,124,68 +55,2,71 +105,57,0 +50,15,94 +145,27,265 +98,57,141 +589,59,599 +74,100,427 +137,67,489 +0,97,91 +0,139,27 +588,92,548 +136,51,0 +146,78,144 +0,74,76 +69,42,0 +43,98,0 +96,99,0 +526,71,539 +58,69,108 +582,21,580 +102,104,515 +107,89,32 +59,36,442 +140,0,95 +100,121,85 +135,116,127 +37,0,468 +0,85,0 +42,161,0 +145,52,123 +88,90,107 +0,80,39 +81,55,31 +79,135,22 +134,99,481 +83,97,0 +94,87,492 +680,123,499 +100,467,453 +98,10,534 +499,701,617 +100,42,65 +168,199,435 +101,0,75 +542,92,549 +176,103,519 +47,65,0 +103,484,454 +56,106,486 +488,83,564 +305,105,457 +120,69,92 +83,105,20 +89,81,479 +531,0,518 +105,107,436 +56,83,480 +58,133,53 +0,95,0 +56,124,52 +108,81,250 +144,110,469 +105,82,68 +108,82,195 +81,31,91 +77,83,1 +59,0,108 +475,0,407 +588,62,265 +136,37,0 +66,57,0 +158,97,438 +95,21,54 +538,100,447 +75,24,128 +17,98,11 +0,142,56 +76,127,0 +58,0,11 +299,114,293 +120,65,149 +530,222,773 +592,33,554 +179,105,139 +133,56,137 +76,76,89 +90,53,60 +96,41,483 +91,8,57 +55,68,22 +0,117,0 +118,79,0 +122,451,507 +556,69,527 +104,122,202 +51,87,12 +110,79,486 +56,0,154 +0,117,52 +518,66,581 +9,134,425 +160,66,495 +56,94,72 +34,112,0 +118,110,61 +63,102,0 +105,0,77 +154,151,591 +162,153,559 +142,115,496 +41,106,349 +0,127,0 +613,523,508 +93,57,401 +0,85,574 +47,31,59 +562,64,543 +375,572,425 +137,66,495 +428,545,400 +100,8,0 +90,136,25 +554,41,598 +21,79,467 +602,0,467 +79,124,123 +58,0,531 +84,134,63 +69,114,23 +610,111,477 +516,728,627 +545,665,612 +0,76,441 +141,91,303 +31,155,518 +32,158,0 +98,89,36 +208,106,459 +74,36,0 +561,41,512 +116,135,32 +568,104,508 +150,81,95 +89,114,388 +55,32,14 +85,79,0 +548,122,524 +671,0,591 +0,75,59 +99,0,160 +339,79,73 +71,196,401 +156,84,0 +54,79,13 +98,0,424 +546,678,664 +591,111,547 +82,30,266 +93,74,0 +82,103,399 +148,0,11 +249,52,73 +87,51,521 +565,38,548 +102,59,574 +72,0,355 +141,66,449 +0,53,41 +513,0,537 +86,61,0 +622,448,540 +60,0,525 +0,116,26 +544,94,583 +102,52,29 +72,46,26 +606,57,400 +51,415,459 +0,118,381 +153,74,31 +34,128,0 +0,73,496 +110,94,239 +56,89,73 +62,23,508 +576,145,565 +21,0,0 +41,129,23 +0,145,22 +100,52,511 +73,122,396 +172,0,446 +583,101,574 +92,103,0 +0,1,40 +86,63,0 +0,40,381 +72,134,0 +514,679,550 +0,11,520 +14,39,27 +117,72,465 +31,111,116 +140,0,1 +43,94,110 +14,128,496 +70,17,31 +94,91,85 +9,0,71 +99,70,0 +85,117,6 +590,68,516 +140,41,439 +92,1,423 +127,56,150 +112,25,413 +128,96,397 +586,97,568 +0,99,307 +106,34,494 +120,0,352 +102,120,0 +71,0,43 +481,123,283 +0,97,0 +32,0,506 +106,43,397 +620,86,447 +57,88,418 +66,0,45 +484,668,587 +101,56,0 +123,125,557 +673,0,552 +46,0,460 +22,31,0 +0,118,59 +71,1,0 +66,0,462 +38,81,13 +139,44,477 +0,96,17 +518,69,505 +118,64,0 +71,0,87 +113,38,267 +0,99,529 +69,93,0 +68,105,55 +43,86,22 +13,129,61 +115,49,10 +69,0,15 +0,94,28 +367,130,509 +74,96,0 +0,134,0 +508,102,438 +33,8,473 +38,55,493 +542,6,592 +29,106,96 +121,0,69 +112,89,97 +22,115,7 +564,99,429 +74,89,482 +691,79,635 +82,139,55 +584,152,533 +30,41,0 +116,119,41 +103,153,40 +113,72,307 +0,71,0 +97,113,39 +25,126,499 +79,30,96 +184,42,217 +83,40,448 +65,115,577 +130,75,568 +98,2,93 +146,65,0 +29,73,0 +582,113,533 +587,98,602 +31,0,537 +44,33,77 +0,105,435 +109,104,486 +193,127,508 +667,0,583 +573,558,512 +579,31,506 +36,70,68 +53,50,79 +104,113,57 +68,104,77 +53,115,17 +90,14,82 +16,150,4 +620,474,538 +77,115,55 +591,44,611 +103,46,116 +96,0,0 +195,142,610 +29,103,95 +66,103,0 +130,1,415 +635,51,586 +128,10,61 +77,149,333 +507,69,541 +59,125,0 +86,10,0 +135,25,528 +117,108,523 +102,86,509 +68,97,32 +591,59,479 +96,128,489 +46,110,76 +82,0,74 +591,4,552 +146,93,81 +490,104,541 +524,96,655 +93,312,468 +44,73,53 +94,107,49 +315,67,565 +426,70,360 +113,72,0 +0,0,59 +528,586,589 +0,15,0 +54,84,58 +93,117,8 +520,0,562 +97,65,416 +198,138,238 +58,0,505 +30,99,168 +90,60,56 +103,63,92 +96,39,0 +140,133,0 +141,64,23 +148,119,112 +102,55,578 +110,101,432 +90,0,0 +564,0,423 +4,29,415 +99,116,444 +0,67,0 +15,95,0 +95,29,52 +0,0,0 +603,49,541 +655,535,515 +113,101,457 +97,50,525 +342,73,494 +110,111,158 +151,113,143 +80,58,96 +129,67,100 +592,133,575 +87,122,0 +76,43,101 +117,83,0 +49,78,83 +70,80,100 +324,68,578 +504,109,237 +167,60,386 +123,66,448 +60,0,36 +32,95,55 +113,131,21 +109,130,493 +127,54,0 +204,80,220 +527,49,505 +88,74,84 +40,117,5 +138,56,228 +8,99,598 +109,124,31 +665,85,516 +83,123,450 +66,115,105 +76,97,211 +12,95,70 +126,79,480 +69,105,100 +0,114,117 +34,95,141 +21,0,492 +61,104,246 +105,86,0 +154,123,108 +182,100,442 +80,107,466 +516,33,525 +584,24,526 +571,56,508 +96,110,429 +47,90,10 +204,70,139 +80,121,0 +81,55,0 +455,675,623 +93,67,0 +88,93,373 +59,29,84 +419,0,523 +0,119,49 +105,104,0 +86,105,72 +126,71,508 +497,634,630 +619,48,525 +67,33,302 +99,95,0 +392,18,395 +93,128,530 +144,0,0 +68,0,135 +590,7,476 +42,134,402 +0,115,32 +104,36,108 +97,143,473 +129,70,0 +526,92,592 +57,59,461 +99,60,167 +557,693,637 +531,669,596 +145,60,480 +96,89,130 +73,108,439 +93,80,45 +373,73,564 +99,7,492 +87,53,76 +0,83,461 +125,135,489 +152,6,489 +93,43,126 +78,147,305 +121,147,72 +68,0,472 +0,121,406 +39,0,0 +0,34,88 +558,124,388 +84,135,0 +57,99,502 +0,78,3 +98,115,11 +0,85,140 +46,85,169 +20,55,0 +509,25,551 +111,94,56 +527,695,639 +413,10,448 +100,89,448 +119,64,385 +104,448,510 +67,0,468 +93,108,89 +90,135,59 +152,47,345 +64,76,455 +74,94,107 +90,75,76 +116,120,484 +99,86,30 +97,22,7 +104,138,0 +0,122,63 +13,0,0 +528,84,333 +85,0,536 +149,102,532 +90,97,0 +63,0,12 +71,0,600 +68,37,0 +120,0,20 +93,107,313 +113,79,146 +55,103,17 +545,0,582 +538,0,514 +630,362,589 +137,64,470 +56,103,25 +109,0,49 +75,119,45 +72,121,95 +26,67,70 +109,82,514 +0,13,0 +112,79,8 +112,58,4 +121,0,480 +87,95,85 +80,0,71 +34,77,77 +132,137,530 +96,44,0 +51,131,68 +114,0,434 +117,89,0 +22,96,31 +140,141,459 +48,102,17 +158,74,256 +440,668,668 +478,99,545 +118,40,173 +111,44,140 +65,74,27 +528,691,616 +539,93,431 +73,109,6 +0,135,41 +59,0,128 +91,78,359 +14,39,9 +149,10,90 +96,127,10 +26,41,5 +0,105,8 +189,0,265 +597,106,432 +0,99,0 +67,124,9 +526,684,677 +81,114,403 +557,118,561 +86,58,0 +88,49,479 +0,52,0 +64,61,49 +26,135,37 +206,125,443 +124,0,55 +90,108,59 +526,76,480 +0,23,472 +13,103,81 +52,59,8 +80,96,153 +211,72,511 +123,0,504 +580,60,491 +93,42,0 +50,76,353 +8,97,477 +23,49,510 +73,81,45 +80,31,0 +192,35,225 +80,101,566 +95,84,44 +93,114,0 +114,21,18 +0,89,0 +131,43,587 +0,92,463 +63,113,440 +105,115,26 +510,0,581 +107,57,120 +458,611,492 +91,111,89 +60,104,73 +0,149,61 +121,107,41 +589,682,681 +94,123,526 +78,53,23 +7,144,4 +97,78,2 +91,32,16 +26,73,0 +104,119,89 +107,128,92 +92,28,139 +27,54,4 +0,92,6 +91,127,513 +613,586,532 +152,51,535 +582,55,527 +569,115,588 +535,0,559 +52,110,454 +33,69,58 +62,156,59 +0,0,22 +78,0,45 +134,66,450 +92,64,369 +123,94,374 +231,0,486 +49,96,0 +115,115,351 +0,0,31 +66,53,467 +200,247,526 +47,81,115 +77,16,85 +70,5,77 +99,116,83 +521,97,553 +96,93,0 +28,81,2 +79,101,0 +73,109,0 +0,85,0 +97,30,71 +84,23,26 +124,0,39 +34,48,0 +94,118,56 +108,75,74 +135,51,84 +57,34,6 +114,55,0 +107,50,351 +549,0,551 +598,42,575 +113,97,0 +150,71,578 +593,115,502 +43,62,450 +93,5,85 +622,68,560 +125,76,86 +105,81,9 +64,0,487 +507,682,596 +115,102,499 +546,93,552 +89,102,379 +48,7,59 +98,0,131 +76,135,41 +67,82,352 +119,125,64 +490,667,635 +116,0,74 +113,80,443 +80,88,0 +115,0,26 +156,134,41 +92,27,1 +249,32,550 +87,0,529 +138,123,22 +135,55,46 +65,94,496 +0,72,0 +126,123,402 +274,79,454 +130,79,629 +301,42,418 +154,19,443 +330,155,551 +78,34,211 +98,128,68 +148,37,166 +40,134,27 +34,128,85 +133,110,404 +660,210,600 +127,79,17 +113,32,357 +64,91,97 +265,41,4 +74,130,49 +94,0,508 +108,0,526 +101,6,123 +50,0,0 +49,25,142 +58,18,76 +115,88,12 +80,58,507 +75,62,297 +126,160,90 +82,63,109 +109,58,48 +144,126,510 +85,71,114 +122,108,0 +81,0,50 +494,129,499 +146,0,522 +0,57,13 +65,107,451 +589,0,585 +90,98,137 +142,0,368 +541,28,593 +567,82,536 +51,124,0 +535,715,654 +0,142,0 +127,56,82 +75,113,19 +60,105,103 +73,40,530 +53,99,457 +127,41,28 +0,81,0 +423,163,514 +101,32,57 +127,74,56 +47,82,0 +108,85,435 +244,22,598 +62,85,16 +22,48,216 +118,64,423 +53,401,449 +84,119,17 +103,29,0 +577,40,557 +0,40,57 +0,128,95 +54,88,0 +82,75,435 +131,46,53 +124,0,498 +533,19,572 +48,0,419 +529,668,592 +194,44,0 +77,8,72 +97,130,431 +221,78,577 +547,94,542 +124,113,72 +0,109,0 +26,87,36 +42,84,66 +103,84,462 +94,48,107 +554,42,572 +558,654,586 +106,79,0 +145,108,463 +618,660,697 +101,82,0 +63,135,0 +478,72,424 +11,0,8 +95,77,473 +104,77,113 +487,87,537 +68,59,569 +130,35,64 +83,65,457 +239,96,335 +93,17,527 +50,80,0 +231,144,438 +620,30,564 +0,0,134 +502,75,438 +95,39,45 +90,70,66 +577,40,495 +557,0,542 +88,0,472 +129,0,404 +38,121,0 +41,117,30 +81,89,465 +111,42,0 +191,108,24 +156,54,543 +524,123,507 +58,129,0 +203,27,597 +81,82,442 +142,90,286 +547,83,631 +78,64,635 +142,126,57 +140,112,69 +177,2,84 +111,78,22 +175,54,498 +82,40,0 +449,378,421 +103,69,0 +76,41,6 +654,128,454 +0,36,410 +91,87,87 +124,0,0 +71,0,0 +93,51,16 +87,71,413 +114,0,62 +178,131,506 +141,133,454 +80,0,506 +74,55,0 +136,97,523 +88,40,64 +113,69,25 +91,47,98 +573,7,545 +94,115,0 +89,70,348 +67,13,0 +53,85,8 +10,94,68 +569,113,543 +93,92,0 +92,49,80 +29,70,452 +127,135,134 +65,0,30 +138,12,73 +425,133,173 +7,142,0 +8,295,304 +101,61,110 +0,0,9 +0,0,0 +69,155,33 +65,91,523 +79,95,0 +49,38,452 +127,27,72 +88,52,58 +148,59,409 +405,110,600 +86,100,585 +112,106,0 +576,41,553 +120,84,473 +514,692,595 +15,16,386 +55,50,442 +94,47,487 +32,22,100 +510,13,534 +98,107,118 +106,65,91 +100,102,9 +532,37,527 +320,114,294 +242,54,665 +539,91,368 +160,116,43 +50,0,124 +75,38,39 +51,34,90 +113,32,13 +129,109,0 +129,45,132 +93,108,475 +70,62,441 +0,15,0 +609,120,517 +99,78,133 +621,120,210 +452,84,557 +347,0,344 +106,33,3 +141,0,476 +117,167,522 +502,674,585 +133,101,105 +117,91,514 +139,0,492 +320,89,116 +168,33,108 +104,84,41 +103,0,130 +114,0,440 +202,148,232 +89,0,569 +145,0,45 +69,90,36 +0,409,345 +575,53,544 +67,40,120 +685,130,580 +57,71,108 +34,0,172 +511,661,662 +124,60,450 +0,133,0 +92,92,94 +181,122,541 +96,49,104 +164,115,514 +0,96,0 +556,689,633 +491,54,221 +113,91,401 +35,15,396 +81,54,488 +206,65,72 +90,48,0 +0,100,103 +110,0,41 +84,75,392 +598,103,601 +73,87,469 +119,93,42 +44,77,0 +99,11,0 +77,23,102 +108,62,61 +453,63,532 +92,83,486 +168,99,476 +62,124,98 +519,13,610 +32,138,108 +70,145,472 +76,17,14 +522,0,551 +27,2,213 +124,0,448 +93,71,0 +499,677,598 +59,108,40 +27,0,18 +110,84,392 +242,108,114 +51,89,0 +83,101,21 +65,0,48 +72,88,86 +543,669,621 +102,109,133 +56,58,0 +490,665,587 +144,65,532 +502,643,621 +95,61,420 +552,17,568 +172,138,538 +35,130,17 +5,65,62 +281,93,267 +99,142,0 +47,133,146 +26,62,142 +3,7,94 +99,9,4 +16,99,482 +57,43,193 +104,0,0 +18,113,39 +81,139,25 +25,116,65 +114,118,379 +30,0,94 +129,33,102 +60,60,0 +66,61,70 +67,90,395 +148,70,548 +538,0,532 +32,109,494 +674,148,536 +120,74,85 +615,103,306 +89,142,387 +0,4,16 +28,42,89 +140,129,504 +357,36,522 +577,0,442 +26,25,485 +50,118,0 +69,0,90 +101,85,70 +106,130,508 +143,43,536 +93,4,478 +126,62,0 +113,89,0 +305,183,498 +126,108,496 +50,50,67 +90,86,42 +0,115,54 +0,107,95 +609,100,439 +486,669,608 +90,32,0 +111,0,0 +56,93,8 +573,93,517 +544,24,528 +625,86,523 +160,77,529 +50,132,107 +115,38,485 +486,101,583 +537,34,413 +126,56,0 +70,111,0 +351,594,476 +49,93,0 +630,32,484 +85,4,31 +104,141,133 +116,61,152 +105,18,64 +111,25,59 +9,124,0 +597,100,551 +156,8,107 +55,89,39 +160,0,298 +0,98,559 +65,118,647 +67,0,508 +100,98,6 +80,51,0 +136,102,501 +42,122,0 +118,2,564 +533,39,500 +39,0,64 +497,438,580 +569,60,556 +105,130,412 +55,55,77 +52,134,43 +86,38,181 +126,97,512 +114,71,0 +549,91,550 +111,75,160 +256,66,453 +79,100,377 +555,89,536 +532,24,539 +501,95,257 +120,129,109 +0,81,56 +31,15,0 +92,0,74 +118,75,15 +567,110,540 +65,140,169 +79,93,0 +34,144,85 +141,74,434 +111,90,461 +89,0,96 +70,86,35 +105,60,268 +57,89,485 +79,62,364 +68,94,366 +547,0,551 +139,0,456 +123,102,560 +606,600,591 +127,30,535 +107,97,350 +70,127,0 +111,129,108 +247,70,604 +50,93,0 +107,35,485 +103,0,349 +101,43,28 +0,0,0 +10,79,23 +132,89,246 +159,74,428 +80,26,439 +108,79,0 +520,625,552 +69,87,0 +0,78,11 +330,131,264 +84,101,0 +15,81,47 +35,84,50 +83,47,515 +143,0,0 +131,138,83 +91,101,188 +538,113,489 +310,145,662 +44,27,104 +91,120,16 +52,149,508 +0,46,300 +90,94,0 +81,38,425 +13,53,431 +204,103,108 +378,47,289 +79,0,302 +0,75,63 +19,0,521 +54,112,95 +188,63,150 +23,113,22 +53,94,111 +563,69,516 +223,98,180 +590,71,564 +130,0,379 +566,112,599 +55,50,141 +0,23,425 +54,94,456 +107,25,267 +0,81,0 +0,0,105 +76,52,0 +20,92,36 +547,114,564 +94,123,2 +51,48,0 +198,111,442 +96,0,0 +107,47,57 +30,78,351 +97,0,0 +79,138,441 +82,422,503 +102,119,154 +12,23,75 +578,18,497 +53,52,0 +0,83,0 +629,585,552 +125,52,0 +519,48,515 +49,101,0 +524,67,480 +0,143,0 +17,114,100 +66,119,75 +82,133,47 +134,128,460 +115,131,50 +553,161,594 +572,101,508 +92,79,30 +531,695,637 +38,97,0 +517,84,159 +104,86,485 +25,93,269 +131,88,76 +617,20,513 +122,37,74 +102,55,461 +470,603,521 +0,46,464 +655,52,562 +121,57,0 +462,597,450 +117,76,0 +318,109,508 +82,28,256 +577,40,534 +126,100,41 +55,44,36 +60,95,268 +392,602,557 +89,0,319 +62,71,14 +82,147,27 +0,0,0 +196,75,632 +0,65,51 +54,33,0 +74,457,512 +135,112,393 +88,81,496 +213,56,215 +107,0,485 +591,79,522 +86,105,0 +10,56,604 +66,73,15 +478,690,614 +91,86,0 +108,83,49 +0,86,512 +589,109,599 +67,63,0 +101,28,0 +48,67,0 +101,113,473 +578,22,530 +95,78,56 +125,65,176 +114,70,552 +594,38,503 +111,22,140 +67,73,467 +56,0,16 +6,21,496 +59,0,0 +0,12,487 +0,56,67 +65,101,390 +69,101,0 +4,130,17 +0,0,76 +154,0,457 +107,92,0 +110,126,0 +610,122,546 +120,78,611 +58,5,92 +139,8,602 +139,0,489 +692,122,663 +137,55,503 +127,115,460 +532,663,594 +136,76,116 +0,73,64 +92,95,366 +102,107,49 +155,66,66 +83,66,427 +262,21,272 +79,95,0 +29,36,0 +318,14,419 +73,88,0 +21,76,0 +156,50,0 +65,0,25 +107,0,467 +126,97,94 +91,130,392 +88,108,105 +428,92,644 +70,80,563 +2,25,0 +80,0,48 +64,5,0 +62,0,39 +103,102,460 +167,44,406 +18,45,54 +607,73,519 +0,70,0 +302,21,497 +564,102,332 +616,16,566 +64,24,0 +505,54,260 +554,494,591 +117,45,0 +111,42,495 +95,55,467 +378,104,498 +111,0,301 +39,97,262 +136,82,138 +85,104,2 +75,69,50 +56,121,0 +117,117,486 +546,45,533 +93,86,0 +87,122,71 +593,70,504 +566,95,525 +117,68,43 +116,39,381 +88,74,389 +92,78,147 +565,3,492 +128,80,0 +0,75,49 +56,95,407 +48,53,30 +1,115,533 +94,66,0 +125,25,507 +230,42,195 +493,48,531 +94,35,315 +102,141,0 +584,586,535 +27,127,409 +101,146,490 +500,706,611 +553,0,602 +545,0,556 +79,82,28 +74,515,427 +674,94,611 +75,98,108 +57,123,9 +44,0,34 +227,0,224 +111,116,42 +511,688,629 +130,0,81 +59,92,56 +42,54,60 +60,33,35 +153,86,516 +91,13,41 +62,55,28 +70,101,68 +320,131,214 +64,94,0 +54,64,0 +596,511,528 +71,83,448 +79,0,537 +640,118,476 +111,86,101 +76,22,0 +60,98,0 +100,70,519 +52,99,69 +540,110,484 +445,593,557 +91,105,0 +82,16,42 +671,96,572 +624,0,486 +83,72,91 +0,129,36 +27,124,0 +405,524,680 +72,0,0 +131,42,102 +59,110,230 +122,72,554 +0,70,132 +117,64,16 +122,157,74 +605,90,512 +540,667,609 +568,81,521 +539,89,359 +52,82,0 +102,114,0 +116,19,521 +0,69,119 +73,88,0 +79,93,98 +0,77,15 +601,120,528 +117,41,0 +121,56,103 +542,136,458 +520,29,515 +34,60,0 +80,0,473 +56,25,362 +107,116,208 +82,0,39 +87,99,486 +240,40,395 +50,98,94 +0,65,0 +161,55,167 +615,66,611 +95,73,418 +81,134,55 +123,19,399 +114,91,496 +39,131,50 +630,137,575 +32,75,122 +122,59,0 +96,89,513 +0,118,0 +120,69,38 +516,74,292 +49,62,0 +110,55,401 +96,62,84 +548,678,614 +100,110,345 +105,47,104 +573,0,340 +452,0,417 +660,74,550 +28,39,23 +96,74,84 +207,37,487 +105,96,509 +86,21,511 +18,79,0 +114,0,411 +0,67,537 +0,147,0 +64,137,419 +614,89,551 +474,549,404 +522,75,514 +509,671,668 +110,115,0 +12,136,80 +129,57,552 +39,0,594 +125,96,320 +69,135,474 +112,0,0 +15,76,68 +100,112,398 +22,57,0 +145,84,490 +580,130,486 +0,115,442 +0,139,121 +23,108,467 +140,95,0 +117,44,104 +543,664,627 +0,86,88 +118,21,48 +0,106,9 +86,73,345 +69,0,412 +498,643,632 +74,4,8 +0,92,53 +25,114,101 +548,54,528 +80,109,0 +272,104,280 +540,629,618 +547,677,676 +508,97,584 +78,107,190 +78,0,95 +78,44,66 +47,9,2 +93,95,0 +31,57,0 +0,84,387 +98,142,482 +469,56,470 +126,57,399 +135,64,58 +129,65,503 +132,34,449 +167,115,7 +83,91,62 +115,52,88 +102,35,541 +298,0,27 +59,102,0 +358,176,506 +630,49,518 +35,78,460 +32,134,74 +63,97,267 +64,64,49 +55,0,49 +113,110,23 +104,128,0 +114,73,99 +131,29,125 +102,96,110 +121,4,14 +536,574,521 +191,91,445 +87,93,350 +48,121,563 +105,102,35 +695,54,627 +66,94,12 +97,101,63 +480,57,644 +40,26,24 +0,95,80 +48,67,76 +39,26,144 +123,4,0 +343,90,528 +104,62,35 +43,85,0 +518,115,529 +127,69,394 +578,157,574 +20,88,0 +68,102,0 +86,82,0 +38,115,0 +128,94,116 +145,0,455 +107,0,84 +0,61,63 +144,0,211 +506,79,472 +319,117,550 +110,111,369 +427,245,432 +150,55,502 +74,86,98 +80,108,33 +98,58,15 +66,0,72 +127,106,426 +556,98,550 +591,0,578 +129,71,47 +43,122,68 +60,118,432 +110,88,483 +79,92,25 +87,26,439 +142,74,17 +54,0,391 +42,60,0 +510,672,607 +2,100,0 +177,119,491 +495,78,175 +479,595,569 +271,92,151 +128,0,437 +80,11,0 +516,120,417 +136,94,1 +0,67,0 +81,0,0 +35,413,401 +106,99,374 +167,0,187 +80,80,67 +49,82,0 +24,102,6 +69,73,16 +70,0,349 +0,0,0 +163,98,495 +100,116,597 +75,50,433 +147,57,87 +695,78,582 +74,21,448 +64,53,467 +15,31,123 +162,88,507 +99,117,123 +81,0,63 +508,678,612 +116,0,458 +408,58,577 +77,52,464 +88,58,364 +534,684,617 +72,104,14 +83,93,103 +78,17,0 +111,75,55 +181,33,239 +552,56,550 +126,122,0 +43,22,0 +535,74,582 +100,47,0 +80,7,70 +504,664,682 +64,88,63 +100,113,266 +99,24,5 +345,202,709 +501,78,578 +44,29,0 +35,0,8 +110,129,269 +125,131,49 +577,121,483 +68,98,192 +87,45,524 +137,0,70 +34,108,94 +560,19,547 +131,26,17 +103,101,92 +96,22,6 +46,49,0 +131,95,381 +141,90,464 +142,49,188 +103,38,459 +601,56,507 +116,72,2 +127,0,423 +56,54,106 +105,5,40 +120,37,156 +0,79,36 +639,248,503 +527,35,458 +128,103,443 +60,0,22 +112,143,45 +651,48,614 +98,23,410 +104,81,0 +523,128,403 +54,97,0 +66,163,566 +17,35,95 +75,51,17 +0,118,69 +85,63,391 +41,109,511 +394,657,568 +88,62,597 +112,94,0 +113,70,154 +524,43,558 +36,75,63 +110,76,0 +70,116,33 +104,59,580 +75,0,0 +80,47,302 +73,42,13 +55,29,488 +576,72,396 +164,70,366 +120,52,404 +43,0,97 +66,35,8 +107,72,319 +42,83,0 +107,125,0 +507,617,558 +1,166,0 +49,118,11 +0,77,131 +593,56,537 +98,101,0 +137,66,400 +43,0,0 +91,89,61 +109,113,0 +0,63,530 +59,93,489 +64,91,0 +471,89,391 +69,52,0 +94,40,0 +119,0,53 +7,62,0 +0,87,77 +94,6,535 +580,87,618 +62,129,0 +93,40,0 +21,123,0 +0,67,37 +176,98,404 +122,87,317 +81,89,377 +109,98,476 +68,94,0 +137,33,184 +521,664,633 +86,116,80 +82,64,178 +118,63,463 +70,69,415 +587,121,567 +497,109,587 +114,93,0 +63,123,558 +107,57,50 +160,68,461 +27,118,103 +72,119,42 +480,0,436 +117,87,104 +522,34,506 +99,99,474 +64,93,7 +138,105,388 +125,0,393 +90,99,503 +93,122,7 +149,118,0 +5,42,468 +88,114,0 +568,64,563 +96,122,0 +63,0,182 +0,0,486 +75,105,486 +107,65,17 +100,54,556 +553,82,580 +133,80,499 +47,14,11 +8,0,72 +650,64,531 +58,31,61 +0,0,0 +15,536,505 +567,94,615 +55,85,0 +38,74,252 +55,80,74 +572,107,536 +0,99,4 +87,0,329 +109,86,429 +463,611,516 +546,81,595 +18,42,102 +103,123,16 +3,70,0 +106,71,0 +63,108,39 +64,47,6 +68,54,75 +124,65,43 +0,55,53 +71,48,70 +537,106,615 +94,55,47 +75,93,513 +72,0,202 +51,109,0 +67,94,0 +0,103,0 +51,55,71 +123,62,16 +97,0,7 +45,18,63 +113,42,21 +104,109,414 +122,0,20 +80,83,15 +52,28,479 +78,32,85 +56,126,2 +31,88,3 +139,78,10 +620,678,685 +148,69,0 +76,0,0 +6,46,503 +125,96,1 +607,347,498 +81,41,18 +566,55,519 +0,44,0 +161,0,498 +99,133,393 +55,29,583 +50,0,0 +55,116,489 +311,77,470 +0,134,86 +104,30,481 +98,56,61 +30,121,62 +0,55,476 +83,62,0 +0,128,0 +161,139,494 +95,82,124 +1,124,2 +135,91,457 +54,30,11 +128,0,58 +88,126,472 +124,66,489 +89,29,481 +92,119,0 +504,0,540 +37,0,115 +96,94,517 +112,79,0 +117,118,146 +78,114,516 +74,132,444 +430,682,605 +493,97,522 +605,74,565 +60,80,60 +116,81,302 +86,84,80 +526,81,364 +103,44,0 +106,63,443 +87,76,293 +57,2,74 +517,671,611 +92,59,7 +106,148,48 +106,57,119 +86,0,0 +6,0,514 +42,102,237 +65,71,429 +4,104,154 +122,0,520 +93,73,27 +39,51,439 +111,40,83 +0,69,1 +160,107,656 +108,0,486 +619,554,502 +0,143,0 +31,44,86 +75,65,345 +37,87,480 +194,122,367 +536,95,517 +86,11,564 +581,116,529 +60,0,117 +150,43,508 +67,0,51 +0,15,155 +566,23,614 +38,110,0 +94,39,129 +101,77,62 +30,114,482 +513,72,377 +80,88,64 +132,28,48 +94,0,78 +98,76,87 +111,50,13 +104,0,536 +568,130,460 +209,0,487 +96,96,137 +124,143,500 +130,0,28 +145,21,520 +545,103,574 +121,0,512 +128,160,460 +85,11,141 +124,69,436 +0,84,45 +84,91,82 +66,96,17 +53,92,526 +4,111,428 +80,66,0 +21,69,43 +41,109,107 +109,68,7 +112,62,46 +80,43,118 +547,117,608 +99,51,60 +90,120,0 +95,80,11 +134,65,59 +83,62,462 +488,28,506 +619,46,511 +44,0,21 +47,88,0 +69,108,63 +86,145,507 +116,89,442 +533,68,551 +107,118,2 +62,0,18 +0,102,0 +75,103,25 +105,72,453 +60,113,426 +0,121,201 +0,84,44 +36,50,82 +95,39,488 +89,103,158 +72,53,490 +579,112,549 +54,92,592 +584,5,546 +92,0,441 +72,133,161 +91,92,0 +98,96,105 +106,160,521 +103,84,482 +53,90,502 +51,98,222 +41,91,0 +144,12,0 +125,125,44 +106,124,0 +87,142,0 +63,82,532 +97,56,219 +164,84,467 +106,83,0 +149,0,539 +114,67,107 +85,140,528 +53,57,0 +117,0,96 +101,45,79 +0,158,68 +114,85,60 +83,72,38 +589,47,509 +69,67,0 +96,41,0 +42,111,0 +106,113,457 +534,100,451 +14,37,514 +102,72,20 +81,85,55 +117,73,506 +676,71,553 +96,36,0 +92,0,0 +67,83,531 +578,115,584 +68,76,0 +145,60,399 +42,0,67 +47,79,0 +0,142,71 +102,109,284 +630,124,553 +94,0,561 +118,83,7 +93,89,442 +54,53,52 +142,0,0 +99,97,458 +85,26,493 +122,95,451 +150,130,0 +117,0,518 +163,109,458 +171,128,465 +0,97,467 +583,645,640 +107,30,0 +60,0,232 +51,24,0 +81,141,382 +146,6,259 +435,48,534 +106,54,594 +470,661,615 +141,65,579 +563,708,677 +531,39,464 +42,73,477 +81,96,97 +35,60,20 +113,140,140 +597,85,599 +119,60,187 +83,7,17 +105,114,0 +106,62,486 +114,0,109 +91,61,27 +44,84,22 +0,88,0 +557,81,549 +129,106,155 +56,96,130 +137,63,431 +48,69,0 +98,104,168 +121,0,58 +118,67,0 +372,0,509 +167,41,466 +104,127,67 +601,132,493 +92,0,496 +27,19,0 +139,37,424 +62,77,0 +130,84,91 +39,107,240 +495,81,485 +477,583,607 +68,126,87 +52,107,83 +659,80,595 +67,112,62 +97,66,0 +613,11,532 +0,130,412 +123,47,122 +15,14,624 +49,71,498 +537,0,594 +90,127,488 +60,73,0 +134,118,450 +643,104,548 +86,25,0 +79,11,0 +15,76,26 +172,0,493 +121,74,452 +83,102,0 +48,77,20 +0,81,0 +107,123,374 +62,2,0 +129,117,587 +103,129,445 +664,36,586 +68,46,321 +81,137,1 +114,113,465 +112,117,453 +51,117,486 +137,51,485 +104,108,0 +0,97,0 +174,75,170 +110,128,0 +117,109,269 +177,65,3 +129,56,7 +485,621,511 +0,63,313 +101,121,0 +66,68,20 +146,90,464 +103,63,0 +181,148,144 +20,97,0 +552,42,493 +70,50,0 +61,83,0 +21,86,4 +39,107,501 +157,80,0 +105,67,0 +109,7,33 +65,53,72 +109,81,145 +101,115,42 +108,0,0 +130,93,3 +101,103,425 +44,74,17 +150,0,418 +116,105,0 +575,131,342 +91,9,94 +100,127,160 +296,30,88 +491,660,587 +594,13,411 +562,89,521 +106,405,491 +113,85,30 +130,73,0 +458,65,573 +61,108,152 +151,155,28 +509,96,586 +143,111,0 +22,0,438 +123,0,513 +71,31,0 +591,0,440 +77,27,280 +217,81,96 +77,144,65 +88,17,91 +80,37,137 +69,76,104 +88,132,154 +24,39,117 +123,0,312 +108,133,138 +26,80,153 +42,103,55 +96,107,6 +80,74,41 +80,67,0 +0,97,0 +0,44,67 +84,112,51 +128,101,30 +93,68,0 +101,58,22 +233,79,634 +187,119,477 +589,0,589 +135,125,137 +60,34,205 +85,77,10 +118,83,0 +71,104,534 +126,72,502 +110,51,444 +69,56,0 +85,121,499 +141,128,448 +94,0,403 +518,677,631 +515,702,620 +136,74,115 +584,66,534 +126,74,11 +99,19,0 +95,16,0 +136,88,0 +39,41,47 +133,111,559 +105,109,478 +149,53,88 +63,57,0 +91,111,0 +541,94,534 +88,72,466 +85,103,129 +532,79,514 +86,81,0 +52,121,403 +153,0,509 +531,141,600 +522,60,520 +325,153,474 +60,140,110 +11,17,7 +127,465,551 +116,71,15 +461,691,627 +89,146,80 +306,92,294 +41,46,0 +93,45,431 +109,157,8 +62,74,103 +56,36,511 +63,46,91 +478,550,535 +117,79,32 +40,38,29 +487,97,598 +566,69,613 +628,448,505 +56,41,86 +121,1,471 +0,121,0 +108,76,82 +273,96,489 +0,89,40 +147,99,317 +23,0,42 +28,156,504 +0,0,415 +622,82,537 +77,14,0 +71,97,0 +25,122,0 +40,67,54 +17,138,0 +110,90,24 +110,93,63 +638,0,560 +33,42,128 +0,101,27 +81,112,508 +99,0,455 +47,77,94 +67,77,8 +114,84,15 +66,0,131 +109,153,493 +392,0,158 +82,100,483 +108,124,426 +94,90,13 +88,31,0 +105,37,200 +0,30,0 +0,58,94 +567,117,563 +0,122,7 +43,0,0 +117,86,159 +90,0,352 +158,82,526 +0,0,0 +7,0,0 +540,666,602 +0,48,0 +61,48,423 +0,65,514 +83,56,68 +0,89,27 +0,34,0 +85,57,0 +120,47,140 +66,123,62 +80,122,512 +155,11,590 +103,109,0 +101,65,103 +95,34,485 +603,527,494 +577,120,525 +463,99,401 +0,92,144 +51,126,120 +582,24,594 +0,115,257 +65,144,0 +133,98,0 +94,40,108 +7,65,25 +100,97,404 +70,114,485 +88,37,446 +0,27,472 +75,133,361 +577,125,579 +67,0,0 +0,83,481 +63,92,14 +47,128,0 +129,82,444 +80,18,460 +120,25,21 +103,120,214 +82,53,0 +186,0,112 +46,9,199 +147,90,184 +71,36,0 +0,46,10 +96,102,231 +104,76,63 +30,92,105 +652,47,272 +683,105,562 +129,2,128 +16,22,556 +67,376,516 +60,9,532 +55,22,3 +89,123,0 +92,56,458 +17,73,0 +110,100,474 +520,107,518 +558,139,678 +85,76,18 +119,0,503 +30,116,21 +146,111,447 +63,83,66 +622,53,534 +0,52,33 +568,128,453 +126,19,501 +0,90,0 +443,61,116 +167,111,352 +98,82,49 +531,41,529 +110,84,0 +548,91,576 +0,59,35 +44,124,0 +34,109,0 +94,144,0 +3,71,0 +96,121,554 +666,130,558 +65,0,520 +85,104,140 +37,124,3 +59,110,34 +54,104,0 +128,103,63 +104,87,567 +579,72,535 +107,65,0 +124,59,0 +87,89,52 +101,63,480 +181,36,345 +0,0,56 +121,82,0 +624,84,511 +90,88,144 +5,86,47 +33,53,28 +6,72,20 +27,85,0 +0,88,6 +80,58,0 +21,0,0 +0,81,599 +0,74,59 +69,86,85 +133,83,447 +66,69,517 +89,91,38 +97,75,0 +83,93,67 +57,96,53 +154,6,0 +581,73,536 +118,135,432 +101,45,471 +100,16,451 +92,74,11 +97,0,511 +65,13,524 +42,43,422 +530,666,638 +32,60,108 +79,125,508 +102,69,240 +569,53,575 +16,0,56 +80,93,0 +64,87,0 +81,2,309 +67,84,0 +19,107,0 +41,0,5 +79,75,494 +516,0,486 +54,119,74 +183,90,451 +107,95,116 +12,52,0 +96,10,0 +77,110,80 +74,78,493 +306,98,455 +94,0,0 +62,106,92 +98,0,48 +87,14,9 +42,45,0 +27,0,77 +103,147,87 +194,106,222 +99,101,0 +151,28,40 +645,595,516 +579,0,503 +19,68,0 +78,148,102 +554,621,493 +542,95,589 +52,165,7 +81,132,112 +141,100,0 +79,136,0 +104,0,62 +100,105,426 +110,93,436 +76,112,433 +173,0,167 +98,105,432 +545,104,541 +62,13,28 +0,135,0 +0,86,34 +62,126,0 +78,50,24 +0,56,41 +535,129,609 +491,68,559 +125,72,510 +55,48,461 +120,50,0 +102,107,166 +97,78,142 +101,119,52 +621,85,527 +0,93,467 +109,64,481 +595,144,563 +67,114,438 +136,66,0 +75,80,39 +481,54,576 +75,97,0 +113,75,39 +71,110,73 +176,0,225 +22,115,0 +124,0,417 +248,0,266 +43,147,508 +24,75,0 +34,67,0 +102,0,436 +55,110,0 +40,109,476 +136,90,13 +571,113,431 +46,34,1 +135,68,390 +86,69,523 +115,62,14 +40,107,128 +358,669,665 +0,47,0 +89,102,4 +40,135,495 +115,6,0 +84,82,0 +59,150,3 +0,45,0 +74,116,42 +115,0,61 +41,113,490 +26,72,603 +134,51,151 +101,103,37 +63,81,458 +75,93,434 +100,14,2 +92,126,435 +546,107,533 +531,0,534 +161,97,637 +127,84,317 +64,93,126 +79,8,369 +71,25,0 +88,41,97 +63,79,28 +193,83,203 +107,0,0 +49,119,458 +14,0,54 +0,63,11 +89,18,70 +58,100,0 +104,1,421 +531,72,438 +122,77,394 +48,73,39 +147,123,299 +122,97,67 +547,646,604 +141,129,508 +175,104,496 +37,14,0 +102,114,64 +64,12,7 +0,101,119 +24,121,0 +70,44,0 +75,0,486 +527,56,535 +99,66,338 +97,117,18 +537,674,655 +16,122,76 +77,45,54 +183,116,479 +78,58,21 +90,94,333 +63,119,0 +140,28,483 +95,124,486 +227,50,32 +72,74,504 +60,124,72 +83,100,0 +85,50,557 +57,138,0 +55,78,33 +65,66,299 +93,88,0 +68,95,115 +79,124,0 +76,0,540 +82,36,13 +538,100,474 +0,80,523 +0,112,59 +0,0,1 +67,58,387 +77,117,127 +0,83,0 +80,62,81 +261,71,673 +89,38,13 +0,71,0 +565,684,619 +50,0,16 +50,46,0 +534,75,528 +529,58,531 +27,0,84 +145,8,45 +149,22,87 +564,49,539 +587,18,278 +0,75,158 +556,46,559 +118,128,61 +106,9,461 +0,80,124 +69,146,0 +130,42,508 +19,94,0 +0,130,105 +76,112,54 +78,90,498 +91,0,30 +98,0,502 +43,41,517 +338,40,655 +8,99,0 +0,93,58 +4,109,36 +91,70,474 +84,78,30 +84,153,441 +116,94,64 +488,43,528 +157,43,601 +60,0,0 +112,92,437 +120,125,51 +190,56,454 +72,151,18 +138,137,443 +70,105,77 +105,42,450 +54,73,486 +119,53,47 +76,68,5 +50,146,25 +0,85,18 +0,59,132 +24,62,126 +75,36,354 +93,100,236 +89,106,12 +93,86,0 +80,90,56 +103,0,108 +548,128,605 +47,76,99 +62,24,95 +80,114,91 +143,92,470 +14,80,39 +68,88,107 +61,106,0 +58,116,0 +94,91,12 +26,4,0 +95,0,39 +113,109,440 +27,140,449 +119,0,511 +3,65,52 +50,0,56 +0,55,77 +130,64,377 +90,0,66 +65,62,28 +125,0,450 +76,137,488 +0,92,148 +40,111,104 +1,81,11 +139,100,474 +156,146,434 +515,102,565 +160,84,137 +95,60,61 +109,84,9 +160,75,134 +126,70,522 +126,81,54 +0,134,13 +0,120,505 +113,0,391 +625,40,528 +90,131,63 +76,36,0 +0,14,434 +565,55,565 +105,0,0 +127,82,238 +91,1,444 +115,106,61 +115,60,0 +63,0,34 +20,113,72 +109,85,0 +623,122,432 +45,73,504 +76,28,0 +118,20,0 +524,139,551 +96,65,271 +27,42,57 +90,106,0 +67,6,238 +0,0,54 +111,15,499 +539,693,632 +92,50,588 +155,64,201 +337,22,306 +67,121,27 +94,73,9 +52,109,0 +95,49,501 +656,426,579 +94,121,71 +558,647,590 +77,123,120 +81,92,503 +96,53,52 +69,105,92 +82,48,59 +50,107,487 +112,0,255 +326,195,526 +89,73,0 +80,50,0 +653,126,570 +250,17,341 +90,0,59 +589,121,506 +55,61,453 +123,0,0 +461,599,461 +64,0,0 +110,68,489 +68,41,3 +587,20,630 +0,65,26 +61,81,506 +597,0,563 +40,72,481 +555,72,519 +91,49,229 +104,39,253 +59,0,37 +82,0,76 +12,112,0 +272,53,101 +0,76,138 +503,642,600 +63,139,101 +179,82,499 +452,653,599 +109,319,441 +152,111,122 +144,61,0 +66,127,277 +87,79,438 +67,26,0 +94,137,50 +99,119,95 +182,67,486 +0,1,505 +535,81,567 +650,0,565 +80,122,96 +135,116,100 +520,679,598 +571,0,577 +73,0,0 +99,54,94 +127,51,313 +39,55,0 +557,72,479 +64,89,102 +79,89,18 +524,90,602 +5,97,0 +480,104,482 +87,28,177 +219,121,254 +265,112,224 +56,99,28 +96,56,519 +50,62,518 +153,68,466 +128,0,481 +82,129,404 +132,97,519 +152,48,420 +110,100,468 +105,113,499 +132,66,314 +495,673,603 +0,134,0 +78,132,64 +95,117,46 +94,91,68 +84,29,62 +105,105,27 +0,100,143 +24,124,58 +68,160,69 +53,104,410 +99,98,0 +103,120,56 +100,0,552 +18,81,38 +48,0,0 +39,0,85 +116,37,0 +36,2,93 +514,651,576 +0,104,0 +457,0,589 +601,91,403 +101,137,461 +143,78,97 +81,436,566 +130,57,485 +27,59,46 +504,82,560 +418,554,422 +113,84,355 +105,63,504 +96,109,65 +69,60,532 +33,103,0 +289,41,492 +47,51,0 +93,0,70 +131,0,71 +86,108,395 +89,62,9 +62,68,0 +50,50,36 +131,90,489 +135,2,90 +566,60,570 +28,75,480 +129,99,693 +117,27,434 +55,92,129 +112,114,61 +107,84,458 +39,135,117 +78,42,348 +105,72,87 +573,15,595 +55,130,3 +64,7,124 +118,22,0 +158,80,542 +72,59,50 +62,77,423 +27,104,307 +131,112,151 +83,108,56 +80,127,366 +337,115,555 +71,80,0 +108,120,531 +680,34,571 +575,71,570 +41,71,424 +0,102,111 +85,48,53 +128,54,550 +228,139,267 +188,15,467 +145,103,118 +75,0,0 +78,107,448 +608,64,499 +139,25,293 +97,0,502 +99,91,96 +112,132,81 +51,47,124 +99,143,119 +138,72,29 +522,46,579 +87,91,115 +97,114,0 +560,441,549 +72,138,548 +154,94,0 +28,3,480 +543,113,519 +41,58,0 +78,53,4 +46,86,35 +98,60,0 +39,96,0 +95,75,9 +133,83,0 +23,129,33 +539,689,664 +22,0,6 +566,629,590 +142,124,0 +598,94,295 +126,0,0 +81,118,457 +6,18,57 +0,33,71 +96,24,80 +47,101,86 +0,41,0 +67,88,133 +141,56,519 +601,505,586 +83,0,433 +1,0,509 +0,47,362 +45,40,67 +111,72,2 +18,80,0 +139,111,96 +89,48,130 +56,68,27 +33,113,91 +88,127,369 +93,0,85 +0,99,0 +94,115,299 +108,53,390 +66,37,103 +99,103,82 +96,84,373 +141,6,509 +34,71,13 +69,3,311 +70,48,20 +85,30,0 +112,74,51 +59,148,56 +134,120,68 +48,28,176 +550,0,511 +109,58,0 +93,88,91 +41,115,331 +33,18,0 +485,709,625 +638,87,608 +79,149,0 +139,126,423 +80,97,45 +603,65,582 +0,17,0 +90,82,95 +156,153,484 +0,70,1 +70,59,525 +97,1,47 +97,87,373 +44,94,84 +105,30,34 +669,60,587 +93,0,0 +6,154,90 +143,70,0 +57,125,0 +32,5,22 +81,66,0 +26,91,11 +639,3,344 +1,40,19 +64,52,454 +93,135,465 +42,35,263 +544,665,636 +97,89,473 +40,80,124 +6,3,0 +69,45,0 +597,106,442 +124,19,484 +22,116,42 +14,74,466 +159,51,480 +86,108,10 +68,0,28 +581,85,519 +552,80,547 +82,30,425 +70,45,0 +98,518,508 +46,71,0 +543,80,476 +21,9,19 +63,134,514 +143,74,504 +49,62,500 +78,95,125 +76,83,89 +112,0,44 +23,91,486 +74,127,137 +61,370,203 +32,132,0 +66,46,301 +116,96,452 +89,132,451 +13,30,297 +255,93,533 +26,72,64 +121,100,145 +77,124,0 +45,105,461 +151,53,442 +30,103,60 +548,40,463 +31,86,7 +74,34,57 +0,95,35 +91,27,511 +147,0,0 +51,79,214 +88,68,151 +482,101,385 +79,116,559 +84,139,55 +464,67,587 +158,73,445 +600,57,546 +134,55,467 +78,22,12 +72,139,18 +41,32,69 +113,134,46 +359,0,165 +0,123,548 +138,58,23 +0,41,21 +59,108,86 +28,40,99 +161,107,628 +6,69,100 +0,42,0 +138,50,437 +30,78,359 +121,99,543 +147,92,401 +147,93,285 +118,0,0 +232,7,154 +91,107,557 +549,48,479 +88,0,86 +179,107,90 +75,0,108 +149,14,0 +80,57,103 +60,75,6 +87,34,65 +106,0,524 +91,0,68 +118,76,129 +351,96,439 +2,151,108 +67,98,26 +30,141,251 +74,56,34 +544,67,586 +61,119,478 +41,104,0 +533,81,534 +502,631,501 +585,716,674 +33,149,45 +140,102,472 +112,13,0 +0,102,452 +66,29,41 +207,116,288 +248,90,158 +0,372,455 +96,66,0 +48,120,73 +0,0,519 +181,119,87 +179,90,123 +95,109,0 +21,115,0 +0,49,19 +111,138,80 +89,73,0 +98,79,0 +571,649,630 +0,135,565 +75,105,509 +36,34,102 +553,50,515 +122,115,404 +40,44,327 +105,108,89 +503,707,618 +0,59,0 +267,48,580 +28,149,32 +48,97,37 +85,70,0 +548,0,434 +501,111,527 +0,6,59 +26,29,17 +112,50,499 +107,89,489 +113,123,537 +52,0,62 +61,92,89 +536,22,576 +157,23,119 +39,72,0 +559,144,532 +25,0,0 +610,101,517 +601,79,549 +115,104,0 +99,17,411 +95,60,51 +54,115,0 +110,67,52 +104,69,0 +570,113,540 +64,127,0 +132,96,0 +54,140,124 +0,0,8 +66,71,85 +103,80,0 +90,156,117 +96,68,0 +161,0,432 +0,62,83 +115,95,505 +559,108,529 +127,128,534 +656,33,546 +397,90,295 +123,62,15 +0,137,67 +97,154,485 +90,0,17 +310,81,479 +122,55,435 +109,110,46 +148,95,196 +44,43,59 +158,55,514 +87,22,459 +304,94,464 +143,115,130 +510,674,559 +540,0,645 +0,38,299 +94,77,0 +0,46,389 +597,92,549 +0,0,0 +122,0,0 +137,15,96 +129,53,16 +96,0,31 +69,33,471 +121,81,454 +23,74,311 +122,80,106 +49,91,392 +171,87,450 +93,128,76 +0,31,79 +117,46,0 +108,32,0 +109,16,64 +419,9,195 +0,75,395 +103,136,414 +131,65,423 +75,129,0 +106,0,0 +93,92,61 +107,73,12 +106,48,487 +58,76,24 +141,67,527 +75,43,389 +110,77,53 +79,0,43 +45,119,479 +5,27,0 +0,41,0 +40,29,15 +542,99,527 +51,89,0 +601,664,678 +68,71,75 +82,90,331 +73,87,0 +117,65,6 +597,411,527 +93,130,119 +76,4,567 +104,99,0 +36,133,15 +82,91,0 +161,56,294 +126,51,0 +123,0,31 +0,89,65 +575,72,454 +54,8,71 +96,141,12 +314,0,551 +547,586,581 +60,66,0 +103,18,100 +91,136,485 +580,69,562 +57,108,94 +82,107,157 +123,96,540 +104,0,0 +556,43,635 +58,63,37 +77,64,116 +439,666,576 +8,17,37 +68,101,455 +539,0,555 +93,43,103 +585,51,579 +133,57,322 +126,33,522 +516,120,548 +16,107,179 +30,18,0 +79,90,0 +118,88,57 +74,14,494 +81,118,472 +0,125,7 +0,82,0 +2,77,282 +557,109,587 +45,0,9 +10,0,93 +666,83,558 +0,137,0 +96,79,476 +39,133,322 +97,94,467 +66,154,107 +93,75,513 +130,35,552 +45,48,0 +55,91,396 +84,17,91 +62,105,579 +563,107,543 +98,84,128 +108,62,45 +91,114,427 +90,98,0 +0,99,90 +527,655,619 +2,72,37 +534,67,479 +79,125,10 +0,92,0 +73,65,47 +92,60,0 +71,119,97 +58,77,0 +20,133,351 +0,0,615 +121,0,462 +548,102,362 +93,95,18 +543,43,559 +85,60,89 +527,110,549 +71,0,55 +82,81,0 +106,0,419 +88,41,14 +505,701,615 +144,109,449 +531,686,614 +0,52,470 +73,31,483 +93,12,96 +34,66,51 +98,6,0 +520,18,327 +576,29,545 +101,26,0 +98,58,495 +89,119,254 +90,10,55 +162,123,492 +0,95,88 +102,99,64 +86,96,478 +110,0,0 +12,0,12 +107,142,0 +117,77,33 +119,80,67 +152,34,8 +51,26,451 +108,70,486 +111,80,0 +71,98,555 +196,133,187 +50,69,483 +68,0,12 +54,5,294 +0,117,471 +84,0,488 +152,99,36 +129,81,61 +17,13,431 +0,108,114 +149,49,14 +51,98,4 +83,63,444 +567,22,611 +574,13,554 +0,119,68 +89,76,287 +47,97,488 +599,78,515 +545,690,604 +62,13,0 +588,124,552 +581,651,624 +121,0,0 +613,72,549 +67,125,0 +74,395,521 +41,90,491 +92,21,0 +0,94,93 +97,41,427 +48,129,0 +53,71,72 +89,0,33 +95,136,220 +64,58,74 +62,69,190 +73,79,2 +80,82,0 +119,106,0 +88,120,93 +15,131,0 +77,134,319 +65,115,105 +19,8,462 +42,20,23 +67,79,78 +171,88,565 +99,81,0 +125,62,171 +615,8,562 +128,56,87 +78,69,110 +82,0,0 +94,133,402 +105,122,6 +59,132,27 +28,87,456 +133,54,0 +88,18,0 +91,88,498 +104,67,125 +55,0,0 +75,77,18 +110,47,0 +40,50,83 +13,76,64 +107,36,496 +519,569,441 +30,29,53 +57,148,8 +0,19,65 +144,68,504 +132,71,153 +97,86,58 +58,28,0 +69,106,31 +102,22,0 +0,0,0 +101,49,590 +505,89,506 +70,16,0 +0,86,0 +117,70,243 +567,108,453 +237,50,626 +120,47,0 +64,83,65 +94,63,555 +25,34,26 +47,121,0 +112,85,91 +112,90,0 +74,35,420 +99,35,0 +577,0,613 +108,88,51 +29,101,9 +463,699,604 +128,83,479 +515,651,576 +75,106,60 +65,103,464 +21,114,63 +0,64,63 +77,51,0 +16,5,350 +116,64,0 +23,86,427 +269,92,189 +574,122,504 +546,642,627 +71,150,49 +100,0,42 +146,29,105 +595,127,439 +145,100,447 +136,97,519 +73,65,0 +159,90,290 +12,15,512 +301,50,498 +81,135,81 +143,128,492 +0,32,59 +42,0,0 +56,71,18 +101,113,14 +64,73,42 +542,43,550 +101,131,254 +166,72,458 +260,0,636 +34,0,0 +44,133,40 +53,138,399 +99,147,489 +33,93,4 +113,0,479 +112,0,444 +568,113,548 +48,97,97 +55,124,557 +105,96,0 +73,109,103 +58,82,25 +401,182,679 +629,41,567 +121,0,572 +293,27,313 +0,83,0 +56,99,0 +129,110,514 +64,66,53 +27,66,43 +103,131,11 +0,43,84 +96,52,0 +517,43,580 +0,67,477 +52,58,414 +62,44,0 +119,0,504 +70,62,0 +128,86,0 +0,134,110 +140,128,0 +422,129,251 +77,114,451 +83,82,15 +38,119,113 +88,119,41 +94,40,31 +127,0,96 +75,0,139 +47,116,0 +254,0,633 +122,108,302 +36,0,5 +123,114,442 +113,0,0 +46,87,506 +38,43,45 +95,145,102 +89,20,230 +525,652,608 +72,93,401 +64,35,40 +130,56,511 +74,28,0 +143,82,487 +181,60,580 +526,45,476 +122,104,163 +14,60,172 +673,143,562 +66,143,0 +111,114,431 +120,5,539 +123,152,0 +35,117,99 +154,0,511 +469,120,575 +126,105,421 +461,15,500 +66,113,509 +107,30,466 +96,135,116 +56,93,450 +57,89,30 +89,76,565 +609,88,621 +22,130,3 +141,18,4 +79,117,456 +60,75,0 +129,0,478 +129,0,420 +0,150,460 +136,0,156 +0,0,2 +0,122,29 +113,63,474 +45,63,58 +82,35,487 +88,56,0 +161,103,204 +581,141,537 +136,83,251 +105,92,429 +113,76,413 +104,0,41 +584,77,572 +524,620,501 +569,1,521 +109,90,53 +65,71,79 +131,0,505 +0,102,0 +572,0,519 +87,58,475 +0,117,0 +52,31,52 +0,56,11 +78,25,80 +103,19,459 +76,94,126 +102,30,0 +201,41,486 +88,70,0 +154,99,113 +0,112,2 +54,128,97 +59,65,84 +127,44,0 +0,117,67 +87,91,49 +108,115,107 +114,35,10 +103,140,44 +51,0,36 +68,67,333 +104,74,468 +226,76,551 +0,86,90 +85,60,436 +40,126,60 +111,77,558 +665,59,529 +169,94,520 +80,112,24 +572,104,323 +48,83,236 +573,0,541 +48,58,0 +0,85,6 +44,30,396 +506,653,583 +178,68,85 +3,0,10 +43,15,220 +46,31,175 +29,81,0 +608,593,551 +218,123,448 +0,53,0 +90,161,86 +135,77,0 +87,130,60 +79,123,465 +58,91,425 +33,104,31 +0,23,0 +28,98,231 +77,0,25 +6,102,64 +112,36,614 +151,58,476 +135,91,3 +41,64,120 +39,103,0 +112,109,21 +179,3,590 +98,0,0 +585,142,534 +62,91,0 +525,11,372 +119,0,125 +95,136,52 +106,134,94 +47,36,357 +0,126,76 +565,117,557 +0,114,99 +18,147,106 +0,93,0 +112,0,0 +104,44,440 +0,80,33 +101,20,19 +0,89,0 +7,91,462 +113,21,407 +107,107,120 +588,69,539 +69,80,0 +75,80,0 +60,100,30 +78,108,48 +135,59,128 +83,101,391 +103,53,11 +47,0,0 +34,81,0 +25,0,0 +121,73,492 +109,83,0 +0,80,0 +11,105,0 +0,92,87 +500,605,576 +331,46,194 +149,0,488 +195,0,27 +90,57,0 +572,33,511 +584,0,612 +631,57,541 +0,91,61 +0,136,0 +130,73,450 +434,39,572 +476,27,422 +47,0,451 +69,87,252 +46,61,62 +100,104,280 +140,0,434 +110,86,533 +110,0,131 +126,74,75 +104,63,0 +130,112,42 +0,44,0 +22,36,0 +571,675,603 +533,705,642 +190,110,353 +174,110,477 +125,117,495 +674,81,523 +106,119,0 +13,113,477 +168,60,518 +114,0,0 +11,11,367 +101,45,48 +64,120,290 +48,90,0 +99,124,7 +384,61,630 +498,96,247 +533,115,519 +124,59,466 +98,135,314 +495,73,559 +76,23,0 +111,118,444 +102,161,0 +0,100,424 +48,33,406 +111,45,0 +119,93,242 +117,69,498 +121,79,304 +172,98,0 +589,35,440 +642,691,682 +100,128,89 +72,44,445 +69,0,0 +0,0,445 +162,0,471 +585,107,544 +103,78,0 +43,0,19 +412,200,402 +10,109,56 +35,96,0 +354,104,422 +0,156,0 +48,0,56 +124,90,60 +153,96,31 +112,64,0 +82,123,100 +186,46,182 +0,0,145 +71,133,67 +59,82,0 +0,79,78 +149,130,521 +202,141,143 +155,106,232 +66,60,81 +46,78,11 +554,698,611 +37,135,47 +0,97,0 +83,140,41 +101,109,464 +85,94,111 +0,121,57 +68,0,24 +479,672,618 +49,95,466 +59,93,0 +98,131,71 +266,80,457 +22,28,66 +58,93,56 +0,24,33 +571,73,522 +97,1,477 +60,66,75 +0,99,412 +103,113,121 +131,98,492 +38,59,110 +11,113,132 +93,41,82 +22,95,7 +43,69,535 +123,80,470 +89,66,83 +172,115,526 +151,17,406 +28,22,43 +86,63,0 +108,136,113 +43,138,0 +0,83,575 +78,86,0 +118,89,13 +520,630,582 +112,54,537 +56,0,15 +198,14,394 +0,109,83 +13,53,495 +0,0,472 +68,120,72 +51,28,0 +97,0,14 +107,68,91 +26,51,119 +551,98,615 +48,49,0 +114,115,55 +59,67,77 +56,0,94 +123,131,435 +35,107,70 +169,109,407 +80,61,514 +85,119,0 +73,126,4 +114,119,34 +540,109,564 +59,43,76 +52,0,13 +577,42,545 +129,106,477 +151,112,16 +86,61,481 +598,87,504 +50,46,454 +0,76,121 +41,52,210 +149,120,550 +0,6,89 +86,77,61 +94,144,66 +122,0,101 +96,92,500 +100,0,46 +524,66,394 +168,127,484 +122,80,68 +0,59,87 +61,0,76 +561,0,551 +44,130,120 +16,114,2 +85,68,455 +175,122,239 +0,108,0 +152,0,56 +45,166,508 +0,85,5 +123,88,120 +39,63,253 +63,110,0 +224,105,469 +108,114,100 +99,39,496 +61,95,11 +25,128,397 +117,90,0 +40,58,15 +0,0,0 +601,0,599 +132,101,286 +171,41,508 +94,104,77 +93,38,57 +75,96,0 +159,104,52 +500,546,451 +604,64,470 +101,63,398 +81,0,0 +18,124,0 +98,66,50 +71,104,484 +104,34,30 +74,83,0 +127,97,0 +109,142,377 +50,66,105 +131,70,476 +576,136,602 +527,114,600 +64,83,59 +135,88,419 +82,0,246 +120,77,114 +68,127,18 +108,78,441 +0,88,0 +15,126,91 +662,65,590 +68,127,391 +0,0,0 +135,76,529 +16,73,0 +116,43,70 +237,21,185 +109,101,38 +91,39,151 +38,70,526 +579,42,472 +91,102,104 +116,16,255 +79,130,495 +107,36,0 +187,0,366 +123,154,461 +53,137,69 +235,68,99 +134,106,491 +0,115,111 +32,94,0 +85,112,102 +605,137,371 +142,45,79 +540,616,646 +103,73,501 +574,132,578 +0,72,15 +0,61,472 +55,0,4 +111,77,86 +48,74,20 +119,153,0 +124,111,1 +159,102,514 +89,138,489 +206,41,165 +120,124,77 +90,108,472 +120,134,117 +53,121,367 +214,87,0 +45,93,26 +180,107,415 +135,100,533 +97,0,0 +86,95,91 +328,57,514 +64,65,133 +634,33,581 +537,687,617 +561,671,611 +84,66,141 +112,126,0 +653,83,524 +189,119,467 +73,100,528 +58,19,0 +85,142,9 +0,0,59 +187,44,155 +627,99,588 +515,704,624 +70,127,0 +117,0,107 +18,69,465 +130,9,505 +24,79,80 +58,42,61 +44,0,0 +85,69,27 +600,92,567 +116,14,117 +163,75,403 +467,130,666 +80,64,0 +52,147,204 +62,143,75 +87,66,67 +127,97,489 +559,129,395 +97,150,57 +251,113,530 +180,75,225 +52,34,35 +76,103,457 +26,0,528 +29,39,313 +120,10,473 +567,101,453 +0,0,56 +100,0,12 +59,92,0 +90,107,227 +0,74,0 +170,0,5 +48,0,0 +116,114,0 +585,111,543 +79,109,0 +0,47,63 +41,0,0 +93,83,0 +16,133,0 +67,31,114 +43,148,123 +90,3,207 +0,86,59 +86,125,133 +55,134,529 +18,94,491 +57,16,382 +65,109,50 +169,100,92 +152,72,541 +114,84,173 +128,0,515 +61,77,52 +612,54,581 +569,0,457 +58,66,386 +45,67,71 +0,35,57 +89,139,53 +78,127,0 +114,0,44 +82,0,92 +551,58,580 +104,114,487 +119,118,394 +52,36,72 +134,94,90 +55,55,39 +81,117,484 +95,101,547 +98,95,0 +72,141,30 +40,108,0 +100,120,455 +120,0,338 +522,100,559 +20,125,89 +98,71,470 +0,0,492 +104,86,0 +102,82,1 +142,28,617 +322,252,352 +133,51,59 +77,51,432 +47,42,0 +3,47,37 +51,51,502 +126,130,43 +212,115,502 +0,100,79 +102,123,94 +8,12,116 +76,81,0 +389,3,383 +98,115,13 +122,80,518 +563,11,587 +106,124,2 +74,65,112 +76,118,41 +0,63,0 +37,42,48 +128,116,517 +0,141,358 +9,74,104 +648,125,586 +542,692,611 +124,79,361 +100,46,0 +452,67,350 +75,60,12 +220,63,585 +61,0,72 +62,104,171 +0,91,0 +529,704,581 +137,32,443 +145,85,395 +163,100,513 +45,57,55 +66,133,153 +522,611,601 +39,121,0 +528,680,618 +41,129,113 +69,97,63 +147,118,0 +98,131,50 +90,69,25 +73,67,87 +111,122,110 +103,76,22 +19,85,0 +109,53,451 +117,87,80 +117,47,84 +76,0,4 +65,54,95 +86,94,51 +146,61,240 +108,18,0 +134,112,9 +497,626,550 +347,101,547 +55,55,435 +78,116,342 +62,77,8 +26,57,31 +102,90,151 +0,115,82 +75,25,508 +212,16,312 +103,117,77 +70,0,0 +104,0,2 +76,408,488 +94,97,56 +75,149,74 +82,122,62 +23,0,0 +40,144,89 +177,55,475 +123,25,61 +152,126,512 +135,52,82 +401,114,349 +68,51,13 +117,103,378 +0,123,39 +539,87,585 +66,69,533 +657,107,579 +582,117,541 +45,110,0 +93,120,0 +137,91,412 +0,75,44 +113,87,81 +151,113,449 +243,32,435 +559,684,648 +55,48,35 +654,85,576 +106,110,0 +0,0,0 +523,413,532 +0,77,0 +0,88,12 +115,0,4 +55,31,42 +97,86,501 +43,391,462 +194,48,238 +103,45,2 +79,49,51 +101,92,452 +0,125,123 +482,673,595 +45,77,80 +588,142,548 +447,86,560 +0,66,75 +31,39,0 +78,50,0 +0,107,13 +79,110,187 +675,108,541 +82,125,466 +101,95,0 +126,50,13 +0,52,84 +100,3,440 +648,23,475 +117,133,88 +13,126,12 +52,91,91 +21,83,519 +0,63,91 +9,125,254 +21,109,6 +74,71,492 +67,68,87 +74,135,28 +90,88,596 +131,99,60 +62,97,112 +101,71,64 +58,46,54 +0,54,461 +145,43,583 +0,138,85 +0,110,476 +593,94,522 +587,44,603 +83,78,452 +92,141,221 +137,98,481 +63,112,0 +165,97,471 +148,120,93 +51,64,0 +98,77,89 +68,0,409 +55,64,101 +20,132,13 +71,126,29 +66,83,104 +78,0,38 +526,675,656 +0,0,90 +0,130,301 +80,0,106 +51,88,20 +122,0,38 +31,108,67 +531,103,502 +93,97,24 +79,95,519 +51,28,90 +667,513,522 +473,88,592 +562,57,390 +44,122,45 +136,116,116 +107,48,79 +84,20,327 +0,109,28 +85,105,443 +517,131,577 +213,68,668 +299,86,254 +182,69,145 +89,131,474 +610,138,504 +52,0,509 +537,50,540 +66,97,480 +0,75,403 +90,128,0 +11,105,36 +84,0,136 +9,21,361 +539,37,486 +594,112,426 +61,0,78 +70,123,4 +84,120,0 +75,153,513 +47,97,0 +77,95,463 +83,0,0 +85,35,115 +107,68,474 +29,79,327 +23,105,492 +0,79,112 +670,66,612 +0,121,0 +128,0,36 +553,56,521 +70,17,50 +77,154,508 +58,77,0 +148,115,352 +89,64,92 +70,1,470 +118,33,83 +91,0,0 +495,666,553 +85,117,23 +92,90,77 +104,28,199 +106,94,86 +402,151,685 +52,107,17 +48,33,0 +96,86,467 +145,110,116 +76,93,13 +72,99,477 +106,99,467 +490,565,512 +140,88,339 +39,100,330 +98,140,225 +33,101,186 +96,129,73 +108,92,10 +202,83,458 +86,0,0 +77,87,167 +68,64,0 +131,11,7 +5,19,0 +21,71,476 +4,115,356 +150,34,516 +85,105,0 +0,34,496 +127,92,512 +15,112,13 +59,0,70 +116,0,88 +149,80,523 +62,85,0 +564,67,560 +546,612,604 +12,76,44 +107,100,39 +107,39,480 +196,60,208 +80,75,0 +68,103,0 +549,102,455 +423,112,598 +18,70,25 +81,90,104 +429,74,497 +557,69,566 +62,51,22 +34,43,0 +117,54,509 +131,73,409 +491,558,441 +378,166,587 +83,39,331 +139,66,50 +548,70,467 +95,121,127 +40,87,0 +34,136,58 +85,89,93 +47,77,79 +90,67,476 +100,0,476 +556,117,558 +92,79,16 +117,20,211 +317,131,582 +20,58,18 +45,54,29 +121,128,31 +532,705,645 +582,49,558 +531,109,550 +106,108,539 +44,0,2 +99,94,160 +564,78,525 +130,43,355 +473,672,607 +466,710,639 +107,69,25 +86,140,44 +0,63,86 +120,128,281 +74,83,86 +0,110,500 +115,65,95 +78,153,3 +71,55,0 +73,69,104 +36,102,32 +72,88,24 +92,92,543 +130,117,2 +179,115,108 +78,61,477 +69,0,0 +71,107,7 +92,51,461 +77,0,403 +117,47,0 +50,76,0 +664,144,391 +484,660,593 +112,69,441 +476,577,451 +305,120,539 +0,116,25 +543,699,624 +550,123,620 +83,94,102 +4,0,50 +55,93,0 +0,44,35 +66,0,19 +105,99,50 +92,20,107 +82,4,0 +62,66,0 +2,84,62 +87,33,92 +111,105,525 +68,57,0 +87,89,0 +148,54,405 +485,662,616 +76,126,463 +52,56,518 +124,0,0 +7,11,550 +74,76,6 +148,22,442 +0,127,124 +84,68,349 +128,88,469 +124,0,411 +0,82,272 +80,81,5 +85,107,34 +111,97,510 +90,59,57 +94,108,104 +20,14,17 +46,61,108 +630,66,544 +94,44,0 +304,61,575 +419,112,309 +486,632,513 +72,98,0 +535,70,528 +74,31,300 +164,126,124 +0,32,68 +72,0,64 +529,30,533 +99,2,478 +85,12,77 +135,0,486 +109,106,86 +132,74,44 +0,54,72 +387,99,586 +60,6,70 +85,113,47 +20,62,73 +77,114,73 +35,141,0 +81,135,0 +103,34,92 +118,34,468 +106,153,465 +0,53,504 +68,93,74 +482,0,483 +50,130,0 +82,95,0 +64,140,179 +62,50,115 +0,12,0 +0,45,0 +87,68,526 +80,76,0 +292,0,147 +46,72,429 +128,84,72 +518,83,463 +44,98,319 +532,100,605 +41,29,522 +78,114,0 +96,106,47 +86,2,61 +66,87,43 +28,75,427 +469,73,260 +0,101,6 +90,0,397 +54,99,327 +79,133,369 +0,145,533 +58,109,73 +0,126,0 +543,658,610 +100,0,80 +149,4,145 +71,70,566 +0,61,0 +58,74,104 +109,107,0 +104,108,530 +74,46,7 +116,60,120 +85,93,0 +159,16,675 +62,68,73 +96,0,7 +158,0,101 +60,97,17 +40,106,85 +588,120,525 +107,103,82 +145,130,151 +56,55,525 +0,127,82 +136,0,41 +76,46,85 +66,0,0 +102,0,69 +2,110,89 +114,157,21 +125,84,212 +5,8,0 +566,691,625 +543,675,619 +86,94,71 +40,105,78 +242,114,126 +41,67,60 +129,93,0 +280,142,569 +29,0,469 +17,58,174 +50,75,94 +76,0,115 +54,0,40 +51,34,81 +18,19,11 +72,108,56 +41,118,0 +42,0,79 +70,115,16 +56,43,181 +47,115,473 +0,110,65 +108,112,23 +96,94,473 +2,100,7 +44,83,54 +104,116,508 +61,154,80 +124,111,47 +106,69,128 +83,76,134 +89,102,77 +133,101,0 +146,114,275 +64,7,84 +69,54,3 +112,142,537 +0,115,54 +94,119,472 +44,91,39 +140,73,440 +120,65,121 +60,138,32 +125,0,127 +104,97,0 +594,107,557 +111,104,475 +123,106,115 +650,0,546 +67,126,90 +0,81,0 +626,123,549 +132,84,60 +182,88,98 +151,70,499 +70,0,0 +525,86,302 +63,113,74 +144,69,493 +133,68,71 +0,149,53 +119,143,130 +99,0,58 +117,75,553 +84,0,39 +0,111,516 +30,0,0 +114,60,152 +0,99,548 +35,69,0 +30,106,9 +105,122,14 +70,483,493 +84,0,113 +119,78,490 +519,56,335 +124,1,312 +677,0,531 +0,76,490 +458,106,575 +81,67,152 +554,104,553 +47,36,275 +264,57,108 +597,46,533 +111,64,79 +126,8,82 +67,112,63 +77,119,455 +2,100,442 +443,73,300 +139,61,555 +127,74,89 +115,42,95 +95,68,83 +0,101,13 +141,0,130 +99,57,11 +68,109,267 +117,117,0 +641,94,572 +59,120,383 +80,30,0 +448,64,422 +29,41,65 +0,20,66 +532,649,606 +86,81,75 +127,57,0 +116,26,0 +24,100,71 +0,54,75 +7,0,399 +69,79,111 +129,112,39 +111,32,43 +66,73,511 +533,36,548 +65,30,210 +312,6,146 +0,378,565 +60,20,55 +0,80,116 +88,57,93 +82,84,0 +98,133,12 +69,116,104 +169,123,543 +87,4,2 +105,109,19 +100,49,0 +529,628,597 +18,28,86 +43,82,91 +41,81,96 +59,52,128 +61,64,54 +168,100,181 +41,90,460 +107,47,209 +90,35,467 +535,634,677 +0,121,167 +101,60,123 +43,120,0 +0,104,46 +90,84,8 +59,80,225 +35,0,53 +42,79,0 +115,106,65 +147,37,147 +58,51,366 +6,76,4 +111,132,494 +579,108,524 +114,35,611 +570,90,607 +74,71,90 +112,0,93 +55,108,42 +347,117,451 +117,101,583 +86,92,36 +120,132,487 +112,91,0 +32,0,42 +49,43,326 +3,101,514 +61,0,460 +63,0,51 +61,78,75 +130,126,72 +382,125,591 +27,104,421 +104,68,15 +102,156,76 +31,84,42 +100,106,56 +57,0,569 +183,98,142 +52,112,0 +60,0,99 +91,65,560 +308,132,527 +67,66,54 +76,98,140 +34,109,124 +45,55,124 +206,21,182 +96,0,0 +66,93,0 +98,29,112 +0,66,68 +74,0,0 +95,105,109 +549,133,479 +62,0,89 +562,111,617 +73,96,83 +642,104,557 +294,13,493 +592,0,578 +94,105,136 +74,73,415 +90,51,100 +115,128,145 +95,123,70 +552,27,567 +87,0,0 +0,82,102 +13,54,41 +222,43,433 +168,102,110 +152,94,508 +538,89,567 +577,663,635 +26,59,0 +23,110,98 +0,0,0 +118,75,88 +89,89,482 +0,13,17 +114,154,111 +71,77,5 +91,74,7 +135,43,514 +97,119,122 +101,97,521 +483,63,550 +61,107,132 +0,0,43 +552,79,493 +99,103,25 +692,42,582 +152,17,468 +79,113,27 +13,0,66 +637,67,508 +61,90,0 +134,139,303 +0,39,27 +0,54,58 +103,138,25 +17,81,42 +667,29,544 +101,0,106 +0,111,0 +261,0,501 +124,54,0 +122,0,56 +116,0,309 +77,134,1 +0,28,47 +21,93,0 +44,63,116 +537,62,516 +95,127,619 +0,104,59 +42,29,0 +68,140,532 +98,82,55 +97,0,445 +177,95,410 +106,0,417 +102,76,415 +10,92,0 +88,0,87 +73,0,47 +98,59,137 +109,103,473 +112,103,63 +208,113,486 +94,29,533 +98,287,412 +57,36,0 +605,391,571 +91,15,497 +0,20,0 +177,26,527 +61,41,68 +497,52,240 +140,94,576 +10,78,54 +54,62,29 +132,97,477 +36,103,83 +82,49,78 +160,0,540 +56,96,0 +99,56,249 +89,61,0 +623,59,524 +64,100,42 +92,141,61 +95,39,62 +94,82,84 +98,138,0 +0,128,72 +40,102,0 +88,106,450 +41,94,41 +110,92,99 +119,116,370 +0,10,327 +447,71,602 +78,69,527 +128,134,0 +0,41,183 +335,4,141 +107,60,246 +580,116,527 +152,103,543 +57,107,0 +84,61,0 +78,89,442 +0,88,11 +561,48,541 +15,115,150 +91,136,0 +100,37,51 +92,57,442 +40,115,42 +482,499,451 +81,73,83 +146,117,107 +74,0,429 +117,103,0 +93,59,51 +89,3,20 +139,81,0 +623,247,574 +0,52,534 +71,78,141 +32,11,128 +474,88,361 +84,100,409 +59,59,65 +112,103,422 +435,603,595 +0,129,75 +48,75,54 +90,91,402 +107,100,502 +25,144,512 +145,110,462 +538,665,597 +52,139,0 +544,0,537 +510,62,539 +98,0,103 +164,92,164 +124,92,557 +114,77,147 +83,78,0 +103,146,75 +57,88,61 +101,94,659 +18,59,2 +34,57,67 +145,34,89 +138,143,140 +273,72,502 +115,0,461 +58,54,149 +73,61,335 +130,74,85 +46,54,67 +536,70,393 +42,49,70 +34,91,107 +180,36,232 +31,76,66 +117,152,493 +86,70,0 +27,127,501 +74,115,54 +40,114,297 +129,0,289 +107,114,428 +58,28,62 +497,685,648 +93,46,454 +122,89,487 +130,89,145 +223,135,447 +95,91,88 +80,162,3 +88,103,170 +70,68,80 +68,116,134 +188,70,170 +116,7,558 +99,25,0 +115,81,505 +33,0,41 +630,59,589 +143,139,311 +74,68,123 +580,82,401 +53,94,434 +110,100,154 +98,124,119 +671,0,595 +85,67,159 +116,121,470 +101,104,143 +0,0,48 +572,6,565 +95,75,417 +33,22,4 +534,85,499 +98,118,44 +71,28,113 +52,0,78 +21,21,73 +120,129,110 +42,65,0 +642,0,492 +48,72,499 +126,0,85 +54,97,456 +122,78,75 +675,248,541 +49,66,0 +73,74,70 +536,157,581 +108,60,58 +23,67,0 +86,31,480 +632,65,541 +142,106,435 +28,68,91 +101,38,471 +117,0,62 +23,54,212 +55,60,5 +593,80,541 +537,691,632 +99,0,451 +23,31,89 +0,18,78 +560,65,432 +47,104,114 +111,0,94 +599,54,413 +0,38,8 +136,89,434 +487,704,619 +161,0,505 +103,119,43 +0,105,460 +64,30,87 +111,77,0 +0,131,101 +63,0,87 +117,52,55 +531,57,493 +94,89,93 +107,55,504 +31,77,0 +93,87,0 +84,64,173 +105,85,115 +128,0,59 +72,37,88 +121,62,464 +0,0,45 +55,0,358 +590,516,525 +599,122,633 +87,137,41 +24,0,60 +474,99,565 +67,40,0 +89,77,0 +0,89,473 +80,77,461 +592,72,518 +98,93,84 +24,93,81 +135,0,429 +47,31,20 +65,91,62 +136,0,485 +0,55,0 +130,103,513 +13,62,53 +95,41,45 +45,100,91 +22,97,20 +85,479,493 +0,23,196 +0,10,101 +120,0,0 +77,62,17 +70,122,321 +575,698,643 +111,109,81 +570,123,624 +65,108,143 +96,135,104 +677,65,555 +33,30,20 +133,77,538 +590,112,536 +635,392,564 +0,45,0 +80,76,91 +30,99,96 +51,43,602 +545,645,586 +135,99,66 +70,34,49 +75,0,0 +126,123,485 +62,91,114 +89,33,14 +23,116,0 +128,84,59 +112,94,0 +101,92,101 +119,106,403 +88,107,0 +33,102,0 +37,80,100 +127,0,460 +29,37,44 +119,90,408 +91,47,0 +215,0,225 +114,29,0 +106,57,147 +585,51,576 +4,0,0 +122,22,35 +58,39,398 +124,10,89 +49,116,97 +36,123,92 +79,147,59 +55,73,0 +19,9,502 +74,53,109 +133,54,400 +18,75,143 +33,131,387 +83,67,412 +53,67,56 +74,81,0 +140,88,76 +92,0,67 +526,177,467 +581,672,618 +62,68,337 +67,59,5 +114,66,0 +107,6,121 +92,79,0 +579,125,473 +123,95,0 +34,56,485 +522,108,563 +605,54,534 +69,62,69 +119,0,441 +539,635,559 +579,86,506 +55,70,492 +118,101,115 +86,107,478 +597,107,556 +51,53,93 +122,100,505 +80,146,366 +49,0,34 +120,68,92 +115,54,1 +103,114,495 +67,58,0 +181,98,404 +416,605,526 +139,107,45 +90,6,437 +0,25,0 +144,8,180 +81,15,103 +5,66,0 +97,0,521 +101,83,4 +140,88,469 +39,0,106 +87,82,474 +70,68,77 +83,59,490 +0,122,36 +531,69,591 +89,128,141 +91,0,131 +124,0,398 +129,0,0 +100,119,0 +628,40,571 +56,90,46 +55,102,26 +51,123,0 +492,0,576 +81,125,501 +70,12,0 +90,0,449 +56,96,87 +0,51,64 +138,42,489 +98,59,86 +125,10,30 +117,51,448 +553,680,674 +622,5,547 +541,101,532 +0,75,0 +518,666,530 +74,88,203 +103,40,293 +512,668,622 +0,117,105 +558,8,595 +546,114,547 +45,98,0 +0,79,429 +128,46,497 +41,100,406 +84,89,67 +76,119,222 +570,165,546 +0,29,0 +17,463,514 +145,62,560 +554,0,499 +50,129,390 +33,98,51 +103,39,224 +83,81,107 +32,77,47 +0,103,102 +0,0,110 +10,106,0 +93,52,0 +67,85,95 +697,95,619 +93,6,99 +587,0,595 +82,128,0 +94,140,476 +75,95,117 +45,0,76 +498,641,622 +120,111,521 +129,33,530 +297,120,166 +122,70,88 +120,96,503 +95,0,72 +84,102,417 +127,0,0 +85,140,0 +79,75,45 +504,0,450 +69,109,565 +578,98,531 +46,31,43 +33,121,0 +144,113,392 +50,113,0 +126,150,327 +142,57,464 +118,46,0 +46,102,185 +86,103,483 +298,16,244 +42,113,92 +91,43,25 +21,13,45 +112,31,466 +60,39,0 +91,48,15 +106,48,113 +77,123,109 +119,33,329 +72,53,63 +69,109,477 +141,127,494 +128,97,415 +75,47,95 +91,96,0 +105,105,300 +33,101,0 +132,86,493 +227,103,605 +0,86,427 +0,137,164 +153,137,459 +110,155,52 +144,67,314 +30,0,88 +96,19,7 +62,61,416 +99,97,1 +73,49,2 +15,92,73 +69,102,66 +81,113,0 +102,40,97 +595,55,486 +659,89,570 +81,65,0 +78,60,0 +0,0,96 +99,148,123 +564,97,548 +27,91,0 +611,103,557 +614,5,602 +569,97,419 +85,120,0 +653,116,493 +62,70,157 +50,110,9 +140,57,179 +568,117,419 +184,128,435 +109,19,394 +69,26,0 +76,142,495 +53,65,0 +58,60,374 +51,54,100 +39,108,98 +136,54,208 +56,128,519 +92,54,474 +181,127,544 +539,611,531 +562,38,469 +55,85,0 +62,69,137 +42,96,0 +644,32,623 +72,7,46 +66,58,0 +16,81,29 +163,148,474 +671,90,461 +558,46,604 +79,100,7 +78,145,90 +34,50,103 +106,129,482 +174,40,0 +569,468,505 +536,691,643 +122,170,0 +98,68,454 +59,24,64 +97,0,447 +21,107,442 +105,142,516 +89,55,163 +96,13,115 +18,85,65 +102,49,218 +37,121,49 +45,148,0 +120,78,88 +0,52,479 +74,83,23 +583,72,489 +51,13,123 +111,105,465 +25,118,110 +130,138,4 +38,94,89 +99,97,505 +0,90,51 +72,91,8 +67,103,456 +93,72,71 +104,155,20 +14,22,0 +123,0,484 +140,78,155 +122,82,349 +110,87,16 +100,97,129 +107,51,47 +127,94,11 +56,79,36 +47,148,0 +552,42,559 +0,107,281 +144,57,1 +119,0,0 +124,140,153 +109,68,0 +514,681,575 +83,120,0 +123,60,37 +117,68,100 +31,111,51 +62,98,456 +122,67,465 +599,48,510 +92,118,425 +164,78,4 +73,0,81 +128,0,557 +88,32,501 +0,106,0 +83,40,84 +63,98,94 +43,72,174 +52,80,51 +93,56,80 +59,0,86 +141,140,465 +5,89,468 +0,33,143 +88,101,0 +132,122,39 +92,122,5 +94,95,116 +89,109,45 +132,91,535 +88,28,84 +492,51,500 +537,62,443 +142,17,516 +509,119,539 +589,70,480 +49,108,0 +430,614,586 +72,64,156 +134,84,385 +128,88,157 +113,135,340 +84,63,0 +85,21,30 +449,647,604 +66,100,0 +525,61,477 +98,0,532 +102,0,127 +0,109,76 +519,49,553 +544,95,480 +68,109,58 +419,0,561 +552,83,560 +111,17,32 +11,0,27 +586,2,538 +0,132,0 +133,93,87 +0,61,537 +121,154,142 +105,119,442 +509,693,664 +21,111,2 +70,40,0 +544,704,627 +44,10,324 +41,44,365 +537,672,598 +580,87,511 +582,100,593 +44,119,16 +134,72,504 +183,0,158 +138,58,539 +0,119,531 +80,107,3 +0,118,440 +86,52,0 +76,32,105 +78,0,94 +126,82,0 +85,125,13 +49,79,63 +81,31,489 +76,4,77 +58,79,496 +3,119,40 +62,81,351 +112,51,0 +531,93,529 +481,615,604 +128,0,0 +122,53,111 +513,680,593 +23,331,304 +82,0,201 +82,1,97 +35,33,65 +60,96,84 +71,40,122 +97,0,91 +24,117,82 +54,58,217 +105,101,83 +602,450,408 +0,129,399 +8,50,0 +114,0,51 +135,83,464 +112,90,15 +48,150,156 +71,93,105 +114,110,92 +428,69,573 +110,0,0 +119,114,425 +604,77,556 +122,74,43 +476,88,534 +493,18,556 +93,120,67 +13,95,0 +81,79,486 +568,659,570 +652,95,608 +65,0,123 +84,63,95 +552,12,521 +49,13,82 +67,0,0 +61,92,119 +80,0,143 +555,84,410 +95,92,0 +91,102,517 +532,83,332 +43,90,178 +125,113,75 +115,25,190 +152,125,90 +53,95,86 +85,120,505 +114,40,503 +131,87,63 +80,94,28 +84,110,11 +102,72,73 +79,133,18 +540,123,502 +79,118,309 +70,104,0 +77,32,466 +315,127,559 +74,99,62 +145,90,5 +76,126,27 +79,14,170 +96,87,107 +69,69,15 +33,103,444 +46,132,68 +70,1,0 +104,29,538 +95,43,6 +422,109,186 +18,64,4 +0,135,44 +123,65,102 +128,87,519 +55,96,64 +0,122,107 +89,37,631 +121,57,500 +152,110,126 +552,80,495 +44,13,66 +112,78,112 +88,105,0 +71,98,70 +538,70,383 +95,82,435 +102,0,123 +106,73,26 +47,47,488 +101,64,486 +0,51,465 +102,102,126 +152,119,655 +67,0,456 +73,41,0 +101,77,31 +80,0,8 +119,45,102 +45,39,443 +96,29,506 +44,104,0 +80,27,95 +0,133,52 +108,131,198 +58,102,29 +59,127,89 +672,123,524 +93,64,524 +53,62,0 +121,78,446 +567,101,544 +92,0,541 +81,126,415 +15,62,75 +36,101,4 +648,0,476 +121,45,19 +105,21,96 +599,75,560 +118,95,0 +38,113,120 +109,0,172 +58,63,0 +109,0,0 +491,655,590 +109,0,100 +512,678,629 +62,20,0 +47,139,505 +80,112,100 +0,116,93 +120,135,177 +24,110,517 +117,0,498 +122,70,238 +45,89,0 +45,132,0 +105,86,65 +488,639,579 +512,694,611 +419,84,220 +0,39,559 +114,93,0 +117,99,488 +90,84,30 +79,103,18 +224,100,483 +87,49,445 +59,127,126 +95,35,127 +677,124,578 +0,68,80 +74,80,0 +1,67,72 +491,122,404 +76,86,430 +58,0,477 +95,0,28 +94,14,20 +47,99,72 +98,5,26 +0,7,467 +90,94,0 +89,101,29 +87,117,1 +55,52,11 +149,46,522 +123,22,356 +112,10,432 +123,89,85 +552,686,625 +138,45,63 +125,51,118 +13,69,50 +2,88,4 +108,20,49 +124,88,419 +475,134,584 +108,101,79 +125,20,3 +520,117,570 +109,0,0 +39,88,143 +31,95,0 +14,37,95 +0,38,65 +13,91,183 +167,51,263 +5,59,63 +104,547,472 +9,103,292 +66,111,72 +75,55,22 +67,136,70 +49,117,324 +8,57,479 +73,11,11 +157,31,100 +50,18,0 +115,131,76 +0,0,85 +87,95,430 +0,93,148 +139,98,48 +0,125,64 +120,95,39 +30,127,59 +0,1,518 +114,94,611 +34,23,428 +110,104,0 +564,70,581 +114,53,0 +456,626,521 +146,165,477 +88,119,56 +109,0,39 +77,5,66 +87,0,0 +89,4,0 +113,111,85 +131,62,68 +93,76,109 +57,80,63 +80,28,20 +173,115,495 +290,43,319 +552,70,507 +0,36,433 +131,83,377 +77,71,0 +104,34,536 +124,69,0 +469,602,590 +26,16,145 +112,38,58 +69,0,80 +19,71,490 +21,83,504 +42,0,281 +654,45,410 +531,674,591 +124,56,492 +64,0,40 +115,136,61 +77,84,0 +92,108,0 +76,104,486 +117,129,62 +43,111,264 +84,75,63 +253,140,441 +102,64,460 +0,115,0 +105,101,80 +80,40,92 +56,76,40 +18,131,139 +105,82,0 +0,84,521 +22,59,309 +559,660,611 +589,144,531 +93,102,470 +577,685,699 +76,60,583 +64,5,513 +131,98,411 +14,87,546 +0,101,75 +0,84,0 +0,113,114 +57,111,108 +158,83,0 +509,66,581 +132,97,471 +45,26,501 +118,44,0 +18,0,134 +144,88,409 +61,58,2 +90,100,0 +0,135,0 +0,8,425 +126,70,190 +0,119,15 +128,123,515 +141,69,456 +629,60,538 +51,0,102 +50,113,427 +147,99,516 +92,125,36 +90,0,12 +104,100,90 +577,686,650 +59,0,366 +51,153,0 +74,76,12 +561,44,536 +195,67,618 +90,126,0 +110,88,493 +530,633,538 +105,0,403 +90,84,45 +624,453,589 +518,89,380 +0,16,371 +596,70,351 +44,26,0 +96,73,0 +117,88,70 +572,24,475 +58,68,399 +111,109,0 +0,5,135 +72,81,0 +101,0,145 +664,275,500 +0,102,437 +115,28,486 +0,102,0 +45,0,36 +201,101,467 +0,111,18 +60,0,144 +138,73,124 +111,69,58 +538,685,602 +4,121,324 +56,106,66 +57,140,463 +0,0,56 +5,94,40 +103,111,29 +27,92,129 +95,87,66 +87,91,49 +89,12,605 +50,125,175 +554,31,609 +591,108,544 +50,58,434 +0,114,569 +653,80,671 +89,95,0 +38,133,47 +0,90,8 +169,92,531 +577,132,576 +124,68,16 +607,0,536 +65,69,27 +115,91,74 +482,674,600 +140,75,490 +176,145,23 +40,89,0 +99,21,168 +76,75,524 +571,733,693 +93,78,0 +8,63,76 +30,24,516 +84,103,73 +10,45,16 +41,62,502 +73,108,25 +126,93,69 +3,104,602 +101,79,4 +44,9,18 +93,0,85 +111,8,79 +651,44,610 +51,136,138 +128,73,96 +131,152,103 +64,154,564 +102,101,483 +103,103,46 +105,0,91 +83,98,35 +49,89,69 +87,102,72 +108,82,60 +76,0,516 +604,0,575 +463,638,583 +103,19,10 +74,140,94 +83,126,486 +95,77,518 +10,82,41 +0,121,13 +49,78,350 +96,93,12 +569,0,533 +0,68,72 +99,80,132 +90,0,450 +571,118,489 +92,77,3 +87,83,112 +590,134,607 +144,141,25 +101,134,108 +116,81,558 +94,116,0 +12,103,78 +126,60,525 +195,0,68 +95,67,98 +371,102,541 +586,79,556 +45,85,0 +495,649,619 +45,0,88 +114,14,501 +22,78,518 +60,0,416 +92,87,0 +5,151,0 +34,92,0 +561,622,611 +45,107,0 +39,32,0 +85,0,62 +28,13,53 +609,75,576 +106,121,32 +104,46,36 +78,56,392 +111,29,343 +107,123,142 +48,20,105 +150,0,87 +583,157,498 +122,130,516 +193,114,539 +9,66,0 +0,19,82 +44,102,118 +158,127,525 +75,159,49 +72,101,111 +5,58,185 +109,84,70 +601,455,573 +14,70,494 +107,57,0 +29,143,0 +29,117,504 +611,752,661 +101,32,0 +53,0,13 +85,119,75 +600,97,607 +40,103,101 +56,59,190 +0,76,113 +97,91,46 +82,0,0 +198,122,540 +35,0,0 +98,61,69 +103,10,0 +38,94,36 +0,49,41 +85,128,503 +57,87,0 +113,48,93 +525,115,467 +11,150,0 +127,94,106 +335,103,164 +441,105,557 +94,31,373 +25,37,64 +0,15,104 +520,57,529 +126,116,12 +37,26,11 +123,92,2 +107,78,68 +0,93,104 +687,65,508 +95,66,121 +19,43,0 +77,54,0 +149,70,34 +139,53,0 +100,0,138 +64,54,70 +96,97,8 +0,49,49 +546,88,525 +579,0,517 +78,87,39 +0,45,171 +117,89,484 +116,90,87 +587,86,596 +563,95,581 +117,70,0 +63,54,424 +51,129,139 +546,0,578 +146,122,270 +94,135,439 +74,85,1 +84,129,86 +97,45,69 +73,0,21 +73,71,496 +79,121,0 +110,22,63 +124,138,537 +35,93,18 +64,85,20 +534,6,545 +508,645,537 +86,28,423 +31,0,513 +117,69,42 +98,4,34 +224,109,499 +556,650,610 +52,140,0 +114,112,96 +79,134,484 +138,111,425 +94,0,44 +21,73,380 +126,22,0 +49,129,94 +87,76,0 +87,0,36 +126,158,579 +102,99,401 +508,139,540 +1,126,0 +128,74,96 +560,649,658 +535,95,522 +94,72,89 +93,105,77 +125,0,503 +613,188,451 +67,0,67 +61,150,99 +68,0,460 +127,58,464 +62,21,43 +61,61,56 +49,51,483 +41,117,38 +65,44,50 +245,77,215 +49,64,79 +100,120,0 +114,32,101 +0,141,0 +109,0,491 +0,111,0 +69,54,0 +594,93,562 +555,11,621 +12,14,1 +55,91,63 +125,82,512 +130,76,448 +64,78,282 +11,82,30 +83,114,31 +143,44,0 +34,91,78 +75,78,0 +156,30,239 +78,47,81 +53,113,99 +91,0,95 +32,101,0 +129,74,594 +32,134,9 +68,105,122 +0,130,0 +75,107,121 +219,73,617 +147,76,492 +503,135,334 +94,100,473 +119,96,73 +127,0,509 +105,115,137 +29,93,85 +103,49,498 +153,97,382 +579,99,576 +0,80,541 +132,32,291 +0,16,169 +507,11,567 +2,49,547 +222,106,504 +124,83,335 +102,110,0 +94,0,0 +495,89,573 +109,17,127 +135,125,0 +113,134,79 +142,82,24 +138,128,449 +106,85,447 +570,686,627 +43,81,488 +256,121,624 +147,62,158 +505,665,552 +53,79,47 +111,0,197 +87,0,94 +616,87,506 +11,69,82 +47,54,441 +106,83,425 +113,57,98 +583,98,563 +73,129,81 +102,0,12 +127,79,60 +99,51,2 +512,653,534 +144,86,387 +141,86,467 +526,644,581 +114,86,80 +48,55,75 +0,74,497 +0,90,0 +541,95,532 +0,151,0 +87,25,95 +46,44,73 +0,44,140 +71,68,51 +575,706,614 +534,68,398 +94,99,484 +117,94,0 +85,70,400 +88,19,62 +79,83,0 +92,90,102 +60,121,83 +139,97,96 +488,648,602 +44,100,37 +75,81,6 +134,94,478 +32,5,39 +101,68,347 +51,81,32 +67,0,54 +19,80,0 +96,91,0 +110,0,534 +574,118,541 +614,0,442 +12,107,600 +128,131,26 +561,29,514 +56,106,397 +114,0,557 +26,86,4 +143,73,498 +555,69,532 +0,106,0 +26,0,132 +541,696,642 +109,74,66 +69,75,31 +524,81,318 +41,96,49 +52,62,37 +54,0,104 +134,65,0 +70,121,553 +43,83,450 +85,0,64 +0,48,101 +128,92,51 +139,120,51 +37,83,498 +97,86,47 +159,88,88 +109,82,60 +78,98,454 +659,0,494 +236,54,581 +78,99,497 +122,56,118 +49,106,43 +107,97,469 +674,71,575 +131,0,43 +102,200,428 +56,97,14 +110,27,94 +111,396,377 +134,11,50 +102,103,428 +17,45,434 +44,55,80 +12,93,471 +91,107,530 +105,39,0 +97,31,474 +130,57,463 +107,51,73 +531,119,573 +44,28,64 +617,79,470 +76,132,509 +56,70,0 +19,99,464 +140,93,77 +40,0,361 +0,86,0 +86,54,77 +79,163,22 +141,97,415 +113,108,31 +162,112,528 +629,0,614 +682,104,592 +84,23,0 +112,56,0 +108,87,28 +9,73,17 +117,112,79 +68,89,474 +106,113,0 +0,137,76 +107,10,383 +82,35,106 +97,106,58 +542,151,401 +89,85,506 +80,0,72 +112,106,67 +106,131,148 +99,114,575 +90,113,50 +106,106,7 +131,94,550 +105,70,3 +63,114,506 +67,101,0 +48,3,115 +59,28,445 +0,70,67 +87,127,135 +682,88,573 +45,72,106 +76,69,432 +59,137,18 +122,61,83 +27,53,42 +129,109,127 +123,26,93 +4,102,30 +237,26,100 +33,84,33 +39,100,110 +40,36,115 +115,112,138 +151,15,44 +38,74,18 +100,90,532 +40,73,0 +142,51,210 +1,49,483 +41,121,0 +86,110,53 +70,93,444 +149,19,0 +110,40,63 +100,0,80 +84,370,425 +5,60,476 +124,46,328 +516,138,669 +84,86,491 +72,77,0 +549,7,589 +13,21,35 +101,79,47 +103,73,583 +56,153,67 +113,4,0 +124,60,60 +528,36,560 +55,14,87 +78,115,63 +134,124,548 +61,88,56 +67,37,127 +160,40,195 +139,0,4 +74,94,61 +442,0,458 +562,0,538 +686,330,444 +55,50,0 +62,62,61 +62,55,119 +113,71,172 +79,67,55 +55,56,52 +132,0,518 +48,57,13 +102,76,460 +514,734,655 +570,57,619 +117,139,71 +85,95,511 +66,0,47 +0,104,54 +64,131,0 +78,138,34 +0,26,3 +77,46,24 +0,67,92 +69,141,49 +46,114,5 +525,98,407 +77,80,408 +0,2,0 +66,99,117 +483,674,646 +24,67,0 +70,62,110 +169,81,521 +45,54,0 +0,123,28 +0,54,428 +59,141,59 +561,652,600 +650,102,609 +567,47,391 +77,64,543 +0,13,0 +96,129,0 +8,93,103 +94,53,100 +0,119,76 +91,71,479 +166,0,107 +93,73,500 +546,700,644 +114,103,28 +10,6,108 +37,106,79 +99,79,77 +83,0,496 +79,63,198 +106,46,422 +129,9,99 +8,125,521 +0,69,433 +110,103,451 +488,75,524 +91,61,505 +91,89,312 +57,140,471 +84,48,29 +276,115,342 +551,685,647 +8,98,18 +23,110,0 +455,530,361 +87,91,406 +28,2,0 +122,93,12 +142,112,70 +431,660,575 +41,130,160 +528,630,559 +43,32,71 +66,69,56 +96,0,482 +83,97,22 +167,69,67 +253,171,148 +0,76,23 +76,106,4 +15,18,65 +0,78,129 +584,91,509 +30,0,83 +0,85,116 +67,0,345 +97,109,100 +66,0,39 +75,110,74 +103,62,97 +104,81,120 +0,102,473 +0,56,73 +116,118,21 +79,133,126 +202,64,455 +168,72,465 +109,124,374 +532,623,618 +112,103,5 +115,33,62 +69,82,6 +57,71,137 +87,106,0 +105,66,116 +0,0,0 +102,75,89 +29,0,0 +0,88,9 +106,35,507 +0,98,45 +147,89,121 +25,39,0 +79,32,0 +114,82,68 +64,103,61 +141,0,63 +79,59,490 +544,69,571 +130,57,0 +24,110,49 +88,31,2 +540,657,702 +95,102,38 +222,48,189 +67,125,457 +570,91,490 +65,73,60 +58,58,538 +111,70,136 +706,143,577 +122,65,67 +245,154,553 +0,104,68 +0,53,13 +582,77,553 +518,680,615 +57,0,89 +0,124,0 +72,38,71 +107,107,499 +91,82,65 +51,71,489 +85,71,0 +79,0,499 +115,0,0 +81,120,86 +511,672,634 +16,0,80 +34,58,58 +100,12,484 +0,53,419 +91,62,158 +580,73,600 +60,26,495 +0,105,423 +64,43,525 +86,94,121 +520,684,625 +116,12,20 +35,101,75 +95,113,85 +49,122,62 +85,83,406 +101,0,76 +133,80,615 +141,135,0 +108,137,216 +85,0,0 +106,84,88 +60,88,73 +20,0,378 +207,125,656 +46,69,13 +39,38,76 +104,106,528 +462,536,368 +128,10,40 +69,116,501 +475,666,626 +524,303,251 +265,60,531 +597,37,569 +78,50,459 +607,116,502 +477,106,224 +376,119,217 +134,109,405 +48,100,60 +94,107,45 +18,0,40 +82,163,192 +48,0,36 +565,680,613 +102,137,431 +33,101,0 +582,40,604 +29,0,0 +121,86,129 +567,720,629 +88,48,28 +115,169,594 +147,136,508 +70,53,0 +61,51,124 +49,0,480 +504,0,541 +75,135,423 +97,98,63 +101,48,527 +23,114,0 +102,80,96 +90,120,0 +0,65,18 +124,111,29 +70,142,0 +88,77,9 +31,133,130 +102,143,55 +169,115,471 +67,101,28 +140,76,103 +91,97,11 +113,54,4 +30,0,0 +0,144,67 +84,119,0 +127,118,128 +129,88,0 +124,23,54 +516,649,573 +39,101,39 +618,730,652 +31,49,25 +118,0,81 +94,34,361 +516,586,603 +46,103,15 +58,106,83 +538,86,518 +77,0,79 +57,4,0 +81,0,495 +540,0,558 +88,90,4 +106,72,68 +11,126,75 +517,0,527 +326,20,202 +95,8,19 +46,37,476 +66,78,31 +22,49,123 +108,35,0 +143,104,0 +54,75,68 +673,88,530 +98,109,8 +615,530,524 +216,34,458 +121,6,73 +588,117,580 +496,652,609 +101,9,388 +12,73,21 +71,68,0 +48,0,472 +508,708,643 +106,61,434 +539,667,659 +97,90,121 +502,645,590 +213,32,203 +116,143,0 +97,67,79 +47,76,0 +110,107,0 +85,10,477 +215,103,243 +544,63,611 +50,99,30 +73,117,312 +54,87,17 +126,91,514 +79,109,143 +129,65,48 +94,61,50 +221,0,288 +63,89,400 +598,0,476 +75,0,126 +107,69,28 +35,77,358 +0,105,0 +66,70,92 +127,60,66 +531,634,588 +139,86,500 +0,90,71 +43,0,88 +578,135,563 +107,98,345 +0,75,64 +21,119,85 +105,117,122 +133,128,396 +40,152,0 +497,77,369 +66,78,172 +105,0,78 +86,0,0 +58,73,86 +91,60,133 +63,111,23 +43,6,92 +46,141,48 +76,116,342 +97,91,0 +112,75,23 +152,113,527 +143,91,0 +54,116,430 +141,107,487 +91,136,74 +108,69,95 +81,30,51 +0,0,395 +47,38,0 +79,46,132 +5,0,105 +69,107,82 +170,106,230 +91,473,530 +103,39,0 +61,111,565 +65,117,15 +0,99,50 +93,114,2 +575,7,577 +104,9,406 +73,100,127 +195,51,242 +106,46,98 +60,127,43 +13,124,423 +28,0,115 +584,74,516 +1,71,93 +86,124,465 +19,115,0 +92,131,34 +86,89,72 +71,35,0 +66,78,353 +77,91,549 +112,2,488 +69,0,104 +107,11,273 +181,119,160 +99,14,450 +6,35,142 +122,75,129 +585,123,543 +468,100,530 +102,0,123 +151,43,409 +119,47,63 +76,69,49 +135,80,154 +475,655,546 +117,131,396 +99,88,0 +102,0,159 +73,0,439 +89,81,23 +96,97,496 +529,664,603 +43,50,508 +64,0,57 +86,27,0 +56,94,80 +565,36,356 +548,616,548 +21,62,151 +594,102,619 +0,88,18 +66,76,74 +8,446,487 +116,117,425 +455,610,517 +45,77,63 +149,119,108 +75,131,555 +71,99,20 +80,0,0 +90,163,121 +94,106,95 +89,50,510 +0,36,517 +580,71,532 +142,0,86 +87,22,90 +50,44,84 +147,384,610 +88,46,3 +94,90,473 +36,58,364 +132,110,28 +191,69,663 +0,104,0 +29,118,31 +580,111,569 +16,143,8 +84,77,423 +55,120,16 +115,30,34 +49,59,496 +82,100,298 +92,112,118 +104,95,108 +116,0,0 +75,67,50 +111,85,50 +524,587,467 +92,89,394 +89,120,237 +104,79,67 +47,31,74 +124,40,0 +105,60,359 +0,27,0 +76,76,57 +101,40,13 +21,0,103 +61,113,65 +0,142,68 +82,83,160 +83,56,66 +41,34,59 +89,155,58 +532,94,535 +25,106,499 +639,73,312 +557,533,451 +87,76,94 +100,57,479 +53,35,57 +0,119,26 +625,119,583 +517,147,546 +592,140,529 +3,82,18 +73,6,96 +107,113,14 +275,31,646 +75,0,68 +53,22,107 +99,46,99 +124,0,501 +56,94,41 +54,93,43 +512,118,460 +0,130,76 +533,126,544 +485,87,451 +134,66,483 +176,9,217 +594,0,592 +128,62,545 +55,126,0 +158,80,509 +30,99,36 +0,69,32 +60,58,82 +0,78,479 +31,430,537 +170,0,610 +542,37,529 +123,0,67 +34,50,0 +76,88,138 +131,83,441 +51,138,464 +562,0,316 +99,88,94 +2,112,91 +79,104,76 +74,0,34 +133,91,166 +105,83,0 +0,21,0 +115,96,464 +79,23,77 +131,85,0 +60,0,63 +558,92,451 +0,0,7 +17,145,367 +104,100,491 +78,98,534 +54,99,41 +59,53,396 +168,115,39 +10,70,15 +96,98,174 +545,698,637 +75,127,2 +126,92,207 +549,68,542 +136,16,358 +85,95,98 +134,27,106 +101,48,131 +17,139,22 +130,132,385 +81,60,86 +53,137,0 +63,63,0 +453,645,594 +669,139,524 +83,134,0 +55,64,84 +131,69,55 +101,43,117 +0,21,28 +52,137,1 +118,90,439 +82,47,68 +26,69,0 +0,106,0 +95,70,89 +0,47,45 +56,86,11 +89,17,280 +77,53,457 +688,135,416 +23,79,508 +108,154,3 +57,0,43 +110,0,153 +87,94,466 +547,75,530 +81,119,43 +84,79,106 +500,648,535 +31,74,0 +83,130,63 +179,0,111 +156,58,9 +544,0,602 +135,127,0 +102,45,0 +88,45,63 +23,392,472 +66,104,105 +41,106,23 +53,23,77 +92,0,16 +75,95,121 +530,65,615 +125,112,100 +115,105,112 +0,134,90 +0,119,502 +72,75,422 +110,0,512 +15,100,9 +515,675,660 +0,59,37 +78,89,56 +69,49,134 +90,0,334 +38,70,63 +31,0,191 +117,47,22 +40,115,101 +0,95,62 +76,41,82 +87,88,22 +132,0,395 +119,121,463 +10,74,1 +50,103,128 +86,141,0 +82,58,448 +41,23,528 +96,31,536 +522,686,642 +0,92,73 +75,15,447 +119,43,27 +53,12,0 +0,0,0 +0,105,141 +54,69,59 +130,36,555 +10,64,148 +79,97,88 +71,95,65 +119,44,544 +467,683,574 +0,0,126 +110,67,524 +94,92,493 +127,100,460 +36,111,101 +84,86,456 +23,109,624 +67,115,36 +88,76,95 +0,131,76 +0,102,31 +86,33,0 +99,83,56 +34,0,113 +94,109,50 +14,72,42 +120,78,462 +332,97,671 +100,79,93 +34,97,27 +123,105,512 +0,0,535 +106,101,506 +114,110,501 +112,55,496 +78,98,16 +26,70,0 +52,144,65 +68,125,59 +90,92,495 +50,83,0 +169,86,131 +62,66,388 +138,16,519 +585,80,508 +98,11,1 +117,109,65 +0,70,49 +100,104,0 +111,134,27 +0,49,57 +47,0,563 +72,103,62 +85,146,488 +312,133,333 +128,97,70 +618,67,570 +112,129,95 +91,69,129 +97,0,1 +5,97,467 +107,105,472 +0,79,25 +0,0,436 +30,71,467 +681,112,506 +153,0,525 +8,78,111 +96,99,5 +695,247,551 +13,67,0 +24,0,340 +47,0,12 +140,153,172 +519,87,497 +144,47,297 +0,71,450 +145,114,310 +18,57,81 +61,0,15 +489,102,466 +526,71,483 +99,87,1 +67,43,100 +158,52,268 +36,19,170 +79,106,69 +451,672,556 +94,84,479 +591,102,566 +69,113,0 +79,68,106 +114,109,588 +95,113,65 +157,105,227 +46,15,203 +121,95,145 +357,423,453 +57,71,0 +585,57,540 +55,3,45 +81,0,352 +94,53,0 +57,93,471 +80,46,89 +601,115,573 +146,0,85 +99,73,0 +116,111,465 +72,46,145 +0,0,66 +121,0,469 +489,547,422 +77,46,475 +228,69,46 +82,108,0 +125,60,433 +114,109,487 +125,118,0 +0,138,0 +338,75,563 +116,118,0 +531,698,591 +601,65,571 +504,79,511 +590,426,522 +0,14,0 +28,0,485 +18,69,113 +129,0,0 +92,82,62 +104,135,111 +186,0,444 +89,141,83 +151,99,337 +60,37,68 +106,28,70 +85,60,91 +69,407,466 +150,97,495 +0,106,0 +4,92,499 +14,115,493 +558,26,539 +66,102,0 +47,18,70 +63,105,75 +77,117,413 +108,117,502 +106,88,13 +63,25,0 +76,81,71 +49,50,21 +33,30,31 +574,57,552 +75,0,0 +133,100,105 +99,31,600 +32,147,77 +62,115,50 +69,39,24 +52,84,102 +102,0,467 +25,83,80 +107,95,81 +72,0,92 +57,93,0 +148,103,497 +65,11,419 +35,56,0 +45,50,52 +57,0,59 +120,0,93 +594,83,549 +77,120,345 +602,16,601 +97,106,510 +101,70,0 +32,34,76 +92,84,3 +47,125,83 +117,0,448 +73,55,83 +179,111,488 +99,118,426 +28,0,0 +99,145,102 +379,114,230 +88,73,539 +59,57,64 +72,98,0 +117,131,52 +84,78,59 +40,35,48 +108,107,360 +37,119,37 +59,443,463 +90,61,493 +126,89,297 +129,110,70 +46,75,0 +120,56,540 +150,12,297 +483,138,385 +42,141,0 +108,76,85 +87,84,86 +95,125,355 +41,60,492 +83,107,0 +74,86,448 +94,100,7 +127,33,0 +615,470,373 +120,82,426 +546,40,500 +115,92,75 +0,92,56 +32,114,81 +79,118,0 +125,99,0 +0,156,75 +14,13,25 +108,59,49 +563,144,592 +93,0,382 +579,75,570 +13,112,460 +154,69,282 +77,0,0 +18,129,6 +117,0,0 +60,0,0 +90,58,81 +35,60,0 +91,81,119 +36,106,0 +40,118,0 +19,96,248 +4,125,527 +552,118,447 +89,98,63 +38,79,52 +63,115,0 +128,55,504 +62,83,100 +117,106,13 +55,128,479 +115,60,0 +614,68,613 +63,72,61 +96,122,55 +569,1,551 +88,0,0 +105,70,533 +78,21,46 +104,135,407 +57,75,95 +47,37,551 +192,55,162 +77,58,446 +131,10,0 +104,130,496 +124,355,543 +482,67,430 +121,64,15 +137,35,0 +103,111,493 +0,58,129 +152,0,0 +183,108,551 +101,83,465 +34,83,34 +1,27,0 +119,74,0 +0,23,11 +96,122,14 +594,0,588 +163,84,492 +111,121,450 +97,159,47 +536,0,599 +121,9,1 +204,87,629 +19,54,6 +80,0,53 +69,57,0 +125,0,509 +130,0,0 +17,94,341 +79,65,179 +123,51,0 +73,50,596 +90,33,353 +64,29,0 +120,102,0 +120,0,424 +60,0,282 +0,80,104 +93,98,94 +372,213,541 +41,70,80 +111,75,132 +63,87,479 +0,96,491 +85,86,4 +106,118,84 +130,110,63 +112,97,141 +102,107,15 +38,60,117 +131,65,488 +50,61,22 +557,700,644 +36,29,23 +93,38,168 +84,91,120 +139,48,0 +67,47,89 +96,35,0 +101,118,424 +17,62,112 +119,91,40 +98,49,0 +43,44,217 +108,0,105 +593,97,542 +125,117,567 +333,88,523 +115,9,101 +108,0,112 +93,85,0 +40,0,36 +0,74,255 +80,94,496 +67,93,96 +83,110,110 +140,82,84 +158,118,454 +0,87,0 +552,116,473 +168,0,433 +15,33,94 +620,58,562 +86,93,101 +26,149,70 +219,50,319 +66,57,685 +89,0,209 +88,126,376 +669,98,550 +127,1,39 +539,686,618 +57,88,18 +99,65,168 +602,223,516 +0,99,0 +146,0,544 +135,49,526 +17,91,0 +58,121,346 +0,93,216 +53,78,19 +0,0,122 +47,89,64 +104,80,91 +22,113,0 +50,101,48 +73,6,97 +79,10,512 +86,120,73 +153,112,20 +30,133,88 +541,133,566 +50,4,61 +117,107,445 +94,119,4 +30,50,0 +18,70,0 +93,121,79 +124,0,163 +57,62,423 +101,135,68 +118,110,527 +41,107,37 +124,61,171 +253,35,279 +65,56,467 +23,42,34 +88,36,0 +125,63,506 +96,61,0 +120,157,71 +60,51,135 +10,39,0 +551,114,581 +570,102,548 +11,21,83 +635,23,504 +66,145,84 +32,231,544 +94,13,464 +85,5,461 +93,94,88 +572,69,544 +71,88,485 +88,113,0 +620,106,401 +82,106,42 +90,0,124 +581,24,522 +258,33,233 +553,103,556 +17,136,521 +85,95,25 +111,99,67 +50,49,74 +0,28,83 +119,76,20 +0,114,36 +72,103,31 +91,66,65 +106,154,8 +98,160,46 +51,31,9 +106,71,506 +77,93,75 +112,57,366 +37,67,205 +83,136,604 +74,112,70 +55,0,0 +125,0,40 +50,88,42 +519,615,572 +122,0,77 +0,41,85 +107,86,14 +123,0,455 +56,54,80 +95,30,76 +158,87,72 +116,55,66 +130,112,15 +101,36,52 +64,15,427 +613,37,510 +94,89,56 +548,103,563 +103,70,424 +609,108,533 +34,392,470 +476,107,524 +2,29,436 +76,133,492 +627,0,555 +154,104,151 +129,26,68 +101,89,124 +0,106,112 +659,87,573 +101,108,526 +59,29,58 +76,91,276 +599,98,529 +80,32,463 +574,36,266 +103,109,468 +42,9,68 +104,87,411 +142,95,79 +327,110,698 +583,125,582 +85,82,0 +95,10,389 +32,21,34 +623,91,603 +184,72,118 +55,43,42 +168,124,198 +0,104,63 +111,48,511 +72,35,486 +132,128,4 +86,114,63 +96,0,471 +114,56,129 +113,96,62 +27,116,50 +72,109,69 +84,22,236 +114,50,0 +0,107,102 +511,74,622 +473,651,618 +158,54,457 +628,120,271 +183,139,480 +110,107,79 +30,98,41 +61,63,616 +577,0,547 +74,89,22 +59,67,98 +56,70,88 +0,78,467 +317,106,460 +11,59,0 +101,88,407 +0,111,60 +140,106,19 +86,0,123 +125,143,529 +103,130,45 +80,127,0 +89,40,469 +105,0,83 +0,38,52 +95,80,436 +655,78,517 +38,87,139 +16,84,0 +91,130,125 +553,52,513 +634,8,494 +180,28,451 +531,141,499 +43,79,108 +21,141,0 +0,60,71 +63,0,472 +90,129,76 +3,44,0 +526,94,415 +122,127,307 +156,76,385 +49,62,50 +566,77,426 +0,15,2 +92,90,18 +116,21,494 +68,106,89 +50,114,0 +96,117,42 +135,112,62 +49,0,91 +561,120,448 +25,62,82 +43,89,447 +82,4,79 +541,707,631 +49,111,48 +137,104,0 +94,55,448 +0,30,0 +131,109,427 +56,105,50 +499,653,591 +83,91,60 +94,44,323 +103,20,177 +61,0,349 +92,89,69 +0,79,483 +0,25,89 +0,44,0 +566,11,483 +16,129,96 +553,108,560 +605,79,569 +103,112,0 +543,68,569 +565,130,399 +64,45,97 +605,1,550 +25,116,109 +131,118,28 +65,63,58 +85,114,72 +72,82,355 +126,47,103 +126,59,13 +128,76,476 +86,99,16 +153,76,8 +592,371,511 +19,39,47 +103,65,82 +52,15,321 +80,82,4 +78,1,0 +116,76,0 +0,70,544 +113,133,94 +596,53,501 +17,72,0 +121,125,500 +540,58,432 +329,147,634 +94,100,22 +611,142,525 +179,12,103 +121,35,11 +134,101,478 +55,31,0 +29,102,382 +606,0,485 +60,0,0 +83,13,119 +108,0,90 +135,110,430 +24,139,0 +565,70,594 +50,98,478 +69,102,463 +41,89,43 +82,42,129 +114,65,42 +39,105,139 +152,120,83 +80,62,273 +574,105,568 +47,66,0 +77,47,106 +120,53,44 +48,57,37 +14,79,0 +504,149,531 +0,120,0 +91,73,273 +75,86,57 +618,0,548 +0,106,497 +0,89,5 +122,80,83 +0,18,0 +70,137,0 +31,42,0 +129,106,146 +195,74,45 +108,135,87 +24,101,141 +98,0,0 +119,74,0 +129,134,534 +26,87,0 +99,82,0 +573,81,557 +476,0,583 +495,99,396 +607,65,602 +63,86,72 +81,0,0 +18,0,0 +59,0,164 +0,84,0 +64,97,0 +526,683,619 +89,102,0 +0,66,15 +93,116,0 +7,88,63 +115,27,128 +156,13,617 +114,0,438 +13,97,153 +59,114,113 +73,119,1 +112,53,288 +0,102,92 +122,75,136 +68,7,70 +0,109,147 +126,39,438 +0,143,0 +549,41,523 +530,0,589 +58,77,261 +659,0,584 +520,0,353 +476,585,478 +55,14,65 +0,80,345 +77,98,101 +113,82,28 +45,58,70 +12,103,459 +97,63,87 +573,685,628 +591,47,567 +77,4,0 +525,0,374 +34,115,18 +28,49,480 +119,39,4 +74,0,508 +0,60,379 +0,54,0 +73,51,473 +122,145,12 +79,68,70 +75,426,508 +96,35,95 +124,89,447 +96,79,439 +556,97,525 +0,58,2 +532,77,515 +70,87,63 +58,117,0 +94,37,120 +667,69,550 +110,128,19 +103,117,99 +69,95,0 +239,111,596 +0,78,586 +107,30,520 +124,100,0 +496,99,628 +44,11,479 +117,123,45 +88,142,107 +51,72,84 +298,66,112 +77,0,71 +73,53,132 +137,0,254 +51,69,440 +0,118,113 +56,38,500 +536,103,500 +632,83,506 +505,63,407 +31,115,68 +95,40,1 +68,40,438 +683,0,460 +126,113,463 +62,51,60 +86,60,35 +91,0,513 +104,83,124 +109,68,67 +109,115,137 +109,108,57 +41,60,384 +36,129,395 +45,107,0 +65,121,54 +79,100,103 +120,87,480 +534,684,636 +63,142,0 +152,88,150 +111,108,339 +114,117,70 +35,35,0 +151,117,457 +110,43,0 +36,79,286 +41,87,48 +60,27,0 +57,97,28 +95,39,0 +520,74,330 +107,94,0 +93,110,79 +187,70,457 +136,102,460 +56,72,71 +62,130,64 +76,132,152 +92,111,51 +70,117,116 +106,0,532 +83,168,142 +18,101,0 +90,0,230 +94,44,463 +523,676,626 +143,0,108 +229,44,249 +77,121,62 +123,122,365 +24,18,0 +48,70,480 +102,87,74 +157,75,437 +87,68,86 +579,85,565 +100,78,108 +104,132,115 +137,104,432 +116,20,601 +42,31,1 +104,148,485 +93,87,478 +106,0,44 +553,122,509 +107,35,0 +72,53,567 +202,10,625 +31,72,128 +163,72,46 +75,111,63 +118,0,424 +84,73,72 +94,92,0 +104,96,9 +109,49,425 +153,73,462 +58,34,172 +103,41,115 +173,49,471 +90,65,0 +104,78,0 +0,115,0 +97,51,0 +562,537,454 +67,16,71 +55,35,0 +100,44,12 +0,106,0 +51,49,490 +53,0,72 +0,128,0 +590,92,554 +147,87,0 +191,43,262 +24,101,110 +154,33,116 +0,72,501 +99,64,0 +521,94,528 +117,55,122 +129,105,0 +0,113,470 +0,49,0 +86,79,0 +74,156,0 +68,0,57 +0,124,492 +509,695,668 +64,28,1 +95,90,9 +7,109,41 +119,109,63 +54,81,7 +115,46,393 +100,32,412 +110,0,0 +600,93,519 +59,119,0 +452,0,543 +102,89,122 +519,70,591 +7,97,8 +140,128,471 +100,93,262 +119,108,11 +110,114,390 +87,84,435 +462,62,458 +59,102,34 +143,122,176 +552,106,523 +704,98,563 +64,29,0 +269,137,551 +270,42,329 +538,87,575 +18,119,411 +120,91,56 +23,51,61 +130,75,526 +117,91,0 +119,12,2 +0,68,282 +99,51,133 +124,87,409 +110,90,73 +74,14,84 +85,0,153 +82,49,476 +125,0,525 +96,30,68 +502,119,479 +118,25,452 +74,72,32 +23,28,361 +103,96,32 +650,85,554 +85,19,0 +549,67,548 +79,87,22 +8,14,420 +282,0,328 +136,0,127 +87,24,43 +558,7,555 +57,1,99 +16,98,180 +72,97,27 +105,67,497 +552,29,608 +37,86,84 +80,104,2 +10,92,564 +86,122,0 +521,448,356 +110,49,458 +29,33,74 +38,0,56 +60,76,278 +137,29,450 +286,116,519 +130,130,0 +23,0,112 +531,55,552 +659,109,611 +584,99,541 +120,34,247 +97,0,455 +112,110,483 +32,0,0 +75,50,109 +113,58,638 +70,148,94 +8,50,66 +0,29,106 +109,0,496 +285,117,512 +78,129,77 +58,119,578 +459,108,249 +0,63,75 +85,35,273 +34,114,489 +107,87,14 +76,35,29 +72,0,425 +147,94,425 +80,105,27 +71,48,54 +118,69,508 +30,70,221 +57,0,110 +61,86,53 +64,73,471 +46,93,7 +31,98,1 +125,84,545 +443,123,542 +119,46,59 +427,108,546 +50,92,374 +54,81,47 +534,689,592 +0,88,90 +33,103,123 +34,0,69 +87,111,282 +0,79,124 +45,61,95 +41,39,74 +120,100,83 +115,74,65 +37,113,111 +69,101,162 +513,101,557 +0,0,56 +46,101,113 +94,75,427 +54,108,75 +24,107,72 +35,0,65 +98,112,518 +33,66,481 +60,84,14 +430,596,620 +147,58,0 +193,117,400 +31,131,25 +585,55,567 +473,667,545 +22,146,97 +66,68,120 +87,0,280 +375,126,189 +116,87,54 +97,66,492 +568,93,560 +549,702,630 +27,86,117 +87,0,578 +19,55,0 +137,110,124 +93,49,70 +54,29,88 +89,65,68 +27,143,38 +48,0,498 +52,52,51 +101,108,56 +7,1,0 +105,77,94 +113,61,77 +0,82,454 +100,56,84 +100,65,36 +529,54,575 +158,76,0 +158,44,32 +110,102,35 +67,83,0 +8,88,95 +37,164,49 +24,120,58 +128,10,481 +69,107,0 +82,17,467 +108,81,138 +100,99,95 +65,84,469 +111,0,557 +137,58,450 +466,122,369 +144,106,524 +61,4,52 +513,59,590 +149,59,453 +82,70,444 +84,68,293 +0,121,487 +68,95,487 +0,69,74 +93,82,1 +101,97,90 +569,71,448 +83,137,86 +93,54,9 +128,67,84 +44,17,52 +152,42,271 +114,94,129 +60,128,442 +609,519,476 +59,66,121 +584,645,673 +92,90,5 +91,97,31 +77,96,62 +212,64,609 +79,77,85 +99,83,0 +207,92,629 +11,0,73 +62,90,41 +100,8,503 +81,106,0 +0,38,83 +30,0,493 +71,14,58 +91,77,459 +451,12,516 +99,0,514 +58,19,445 +48,84,520 +139,23,498 +96,116,0 +66,82,0 +537,677,632 +686,144,458 +103,0,64 +92,112,390 +136,121,0 +0,24,10 +25,70,506 +23,0,58 +72,100,153 +85,70,104 +120,106,401 +158,61,504 +565,602,580 +79,99,91 +117,75,74 +9,116,366 +0,72,414 +0,65,457 +0,68,34 +184,0,127 +132,107,192 +532,67,512 +52,13,489 +0,143,132 +0,19,55 +57,38,62 +256,57,495 +144,80,471 +74,99,0 +108,38,18 +117,134,104 +82,95,11 +93,91,76 +0,60,396 +164,79,565 +573,96,627 +58,104,0 +8,19,0 +29,0,1 +230,122,527 +0,86,37 +165,110,102 +542,666,609 +77,127,480 +586,76,554 +46,127,440 +96,76,321 +296,53,291 +104,70,50 +68,97,269 +529,102,472 +145,32,220 +88,61,18 +0,29,471 +54,0,441 +85,158,139 +20,122,330 +143,0,425 +118,105,483 +116,75,55 +25,65,444 +62,0,111 +0,118,497 +74,55,48 +358,62,504 +127,67,8 +0,89,456 +96,80,202 +109,17,435 +0,86,0 +113,41,57 +46,156,0 +153,0,313 +78,51,374 +79,98,0 +107,105,595 +95,69,11 +93,0,448 +652,535,544 +605,99,553 +34,70,71 +79,123,53 +526,645,600 +42,103,156 +56,69,0 +125,115,98 +129,0,374 +520,61,526 +0,0,492 +128,85,0 +50,48,153 +110,73,57 +118,19,440 +515,708,611 +0,0,344 +102,76,89 +34,28,0 +94,121,482 +202,99,204 +0,113,57 +512,67,531 +92,88,3 +5,29,37 +110,86,0 +0,110,76 +85,102,277 +49,119,464 +72,80,511 +573,64,607 +59,59,487 +613,158,511 +104,92,516 +580,74,523 +112,59,0 +483,120,551 +101,113,69 +103,80,125 +65,96,515 +55,34,2 +142,35,223 +69,0,356 +117,106,90 +534,104,574 +94,120,95 +91,0,64 +106,24,16 +126,83,82 +91,135,68 +0,0,127 +49,19,0 +361,0,262 +41,48,121 +134,50,542 +92,0,0 +132,20,198 +53,168,420 +0,48,0 +0,0,55 +537,409,504 +530,51,568 +79,0,126 +329,117,512 +74,32,0 +104,21,71 +510,656,651 +88,137,115 +90,112,550 +86,81,115 +649,161,371 +123,76,330 +39,103,502 +92,79,0 +79,95,0 +83,125,1 +90,106,0 +118,0,399 +85,14,41 +77,107,21 +80,66,132 +111,66,70 +88,101,522 +203,99,119 +92,3,75 +560,34,572 +39,29,95 +68,99,158 +128,129,397 +88,103,496 +87,137,25 +78,43,448 +107,78,128 +92,128,0 +91,0,404 +0,99,123 +142,103,462 +0,18,500 +59,129,22 +101,88,456 +96,105,139 +40,38,49 +71,104,487 +43,55,61 +122,122,7 +99,113,252 +111,63,398 +70,107,505 +46,59,55 +119,394,510 +525,585,589 +187,123,156 +98,103,0 +0,0,0 +102,16,95 +89,112,0 +71,97,0 +67,89,297 +118,125,30 +161,53,470 +107,127,77 +70,63,0 +125,95,480 +82,0,477 +123,55,478 +114,65,40 +71,116,413 +120,36,517 +62,0,1 +58,86,9 +525,0,493 +0,79,0 +143,42,86 +122,148,503 +63,0,100 +32,95,56 +57,103,100 +85,103,21 +12,89,112 +23,129,413 +67,121,539 +164,25,537 +103,91,447 +135,0,464 +117,93,181 +96,67,399 +82,0,59 +109,125,124 +476,65,305 +107,158,27 +246,74,217 +136,116,72 +149,86,0 +37,80,77 +64,33,15 +84,108,114 +86,0,502 +90,42,110 +276,74,192 +83,96,61 +44,11,0 +78,89,63 +119,107,0 +36,118,73 +0,97,17 +0,0,444 +553,131,503 +0,82,404 +117,82,445 +42,95,102 +6,61,413 +77,68,75 +559,79,530 +601,0,508 +81,71,99 +492,77,570 +115,127,0 +101,97,113 +34,143,453 +21,101,0 +118,26,539 +108,125,0 +100,116,209 +61,87,77 +301,91,511 +38,37,429 +607,96,543 +110,0,7 +166,4,445 +127,87,2 +0,11,0 +24,38,75 +0,442,451 +73,94,0 +154,72,202 +68,66,70 +123,36,44 +501,664,559 +135,158,502 +139,136,486 +101,110,68 +557,21,460 +88,27,93 +132,47,86 +58,92,4 +51,110,432 +153,105,0 +11,50,116 +65,0,463 +113,78,133 +84,42,464 +68,72,376 +105,63,75 +603,11,573 +147,64,21 +133,40,36 +145,37,168 +73,114,452 +88,99,502 +72,0,415 +69,65,56 +531,74,479 +110,162,464 +81,44,507 +540,0,466 +117,44,655 +101,131,31 +103,64,75 +83,97,0 +59,0,0 +1,19,437 +123,112,0 +103,95,0 +139,126,531 +21,117,8 +130,24,106 +128,50,622 +94,89,584 +63,30,0 +52,87,551 +146,73,0 +89,0,200 +544,659,577 +258,38,200 +122,0,421 +165,127,569 +0,64,18 +107,65,430 +359,68,527 +79,22,0 +24,105,21 +56,0,63 +538,107,549 +68,147,115 +20,50,58 +66,0,283 +70,0,59 +367,130,545 +54,55,332 +99,114,0 +59,101,0 +55,66,0 +99,109,99 +656,107,546 +118,80,449 +106,156,214 +44,0,32 +127,122,400 +180,72,457 +66,93,0 +0,9,78 +93,0,52 +129,71,196 +87,39,37 +578,89,496 +578,119,524 +124,72,418 +89,25,7 +352,66,541 +547,688,609 +488,363,590 +539,671,655 +42,0,9 +115,48,0 +62,43,108 +227,0,181 +80,69,383 +60,65,0 +64,113,84 +72,0,83 +27,81,0 +55,116,157 +80,52,542 +82,99,489 +65,89,125 +142,0,73 +55,0,0 +80,125,0 +105,130,0 +0,67,0 +125,92,60 +107,120,527 +141,118,486 +112,47,62 +91,0,29 +530,674,594 +126,86,88 +49,46,465 +523,649,588 +125,136,28 +69,0,462 +574,57,605 +113,81,86 +578,89,635 +87,74,73 +174,0,477 +141,36,510 +527,103,576 +101,21,59 +114,123,89 +88,30,64 +650,21,556 +40,104,100 +98,74,514 +0,0,449 +21,12,30 +660,116,543 +0,49,514 +635,53,535 +68,84,472 +86,74,44 +41,110,453 +25,60,499 +725,84,594 +69,113,437 +113,27,0 +541,340,570 +39,122,0 +0,86,99 +138,15,111 +35,90,287 +119,51,54 +154,4,5 +0,87,0 +0,97,0 +330,114,143 +50,130,78 +78,91,62 +143,94,447 +93,139,387 +0,52,50 +66,28,30 +27,71,0 +106,140,0 +160,81,270 +0,82,509 +54,121,511 +61,270,449 +160,0,485 +50,0,76 +68,42,17 +54,89,119 +90,146,0 +136,0,34 +109,20,391 +42,0,29 +57,58,5 +40,12,498 +33,81,74 +239,116,275 +79,89,0 +76,115,29 +97,76,377 +494,675,608 +105,88,466 +83,0,67 +0,63,34 +74,98,464 +42,140,214 +73,60,72 +88,94,56 +99,101,37 +83,79,0 +149,52,447 +64,140,13 +0,72,0 +169,55,434 +162,92,31 +93,130,0 +0,0,110 +85,20,568 +33,109,101 +577,95,554 +155,96,549 +187,50,511 +126,105,5 +331,111,356 +133,157,119 +158,0,511 +556,72,535 +72,0,420 +110,112,17 +121,93,115 +50,0,24 +133,63,533 +96,83,0 +569,99,511 +87,94,40 +231,131,668 +66,125,0 +115,70,0 +129,129,20 +498,96,648 +31,0,0 +92,108,511 +71,121,62 +113,21,76 +51,95,30 +131,90,51 +57,48,0 +56,49,50 +0,37,0 +526,74,571 +50,0,81 +104,92,500 +22,49,81 +83,99,0 +96,105,38 +137,92,0 +119,110,63 +115,57,0 +0,114,300 +180,99,123 +95,59,101 +83,100,6 +154,93,524 +126,106,266 +108,41,120 +148,110,18 +124,76,612 +94,62,349 +39,114,0 +148,161,517 +110,111,11 +475,100,541 +0,107,44 +159,124,10 +105,36,459 +0,73,0 +116,115,618 +86,73,482 +101,115,2 +118,72,291 +63,131,57 +82,61,324 +69,0,87 +30,132,507 +132,0,75 +164,96,517 +124,54,151 +20,72,457 +17,31,399 +538,111,570 +0,61,162 +71,58,0 +0,110,0 +66,55,100 +33,181,58 +98,43,53 +0,67,0 +86,123,1 +85,0,531 +93,128,230 +83,49,0 +92,61,88 +71,92,23 +0,106,484 +182,0,121 +200,0,593 +129,0,2 +88,110,180 +536,95,489 +44,0,408 +3,17,58 +113,30,53 +0,16,0 +45,0,87 +80,18,0 +0,93,25 +540,702,643 +439,33,219 +171,0,481 +583,594,496 +64,76,0 +646,67,528 +140,110,63 +68,76,0 +117,62,6 +615,117,571 +606,121,603 +54,97,78 +561,90,391 +102,97,45 +47,98,432 +108,111,481 +242,95,480 +192,130,237 +208,0,99 +188,114,639 +72,75,52 +81,91,443 +154,32,539 +109,46,87 +0,72,297 +121,37,0 +116,104,0 +110,112,92 +95,126,32 +129,43,89 +255,137,500 +119,96,492 +24,98,59 +77,35,494 +41,70,60 +69,28,73 +118,59,74 +121,76,496 +599,61,556 +93,93,117 +12,116,75 +60,86,77 +184,0,290 +33,135,17 +92,111,93 +525,699,593 +509,22,452 +53,31,0 +558,669,637 +24,64,139 +639,52,390 +31,79,466 +71,129,53 +63,0,528 +218,118,203 +140,96,49 +74,47,0 +117,87,167 +43,121,28 +135,90,336 +108,126,44 +8,38,0 +193,112,422 +426,625,473 +101,64,570 +40,40,9 +109,81,50 +0,4,0 +144,100,54 +80,128,31 +90,66,476 +40,59,0 +75,76,474 +46,45,79 +0,149,64 +495,0,363 +116,90,361 +132,91,405 +533,0,514 +78,121,485 +87,83,487 +0,95,101 +64,93,105 +98,30,16 +546,43,559 +556,57,465 +108,44,71 +100,162,34 +133,20,41 +44,80,51 +47,42,93 +127,65,66 +82,85,91 +729,36,624 +74,83,111 +135,58,118 +138,88,86 +37,49,69 +563,30,501 +123,68,52 +82,26,163 +102,39,75 +106,73,97 +390,85,654 +432,548,386 +63,69,247 +133,116,157 +555,100,525 +570,66,492 +74,63,124 +59,119,505 +345,158,354 +261,124,168 +0,122,516 +154,8,126 +74,108,608 +564,148,576 +0,99,91 +561,84,586 +70,131,0 +0,118,230 +101,74,64 +122,76,64 +112,96,42 +151,24,34 +166,0,495 +111,102,453 +103,72,104 +521,617,561 +169,60,515 +24,52,37 +13,110,109 +0,83,81 +71,60,0 +144,125,187 +589,107,594 +90,136,517 +111,92,163 +109,71,89 +58,50,561 +0,98,132 +123,31,77 +591,69,664 +50,98,1 +120,124,477 +83,58,72 +0,70,152 +79,78,431 +152,19,408 +517,588,585 +40,115,0 +69,26,496 +0,109,456 +85,71,118 +89,49,7 +72,78,12 +137,36,103 +94,44,95 +156,121,52 +70,0,0 +148,88,290 +124,0,112 +28,73,110 +121,106,363 +76,122,94 +0,80,50 +15,30,83 +0,85,39 +82,58,100 +80,113,91 +63,0,161 +51,111,16 +84,85,445 +104,119,82 +70,68,0 +55,87,107 +91,126,416 +114,98,488 +103,61,0 +0,137,0 +48,106,132 +22,83,0 +62,104,323 +168,93,517 +498,659,594 +168,118,420 +75,128,0 +52,110,31 +54,50,9 +88,53,4 +54,100,5 +587,101,621 +107,0,116 +132,86,24 +67,133,22 +104,491,536 +125,75,82 +545,40,614 +110,50,124 +513,61,426 +549,78,589 +118,0,618 +112,84,108 +79,73,34 +75,65,98 +89,50,74 +525,677,570 +41,79,488 +77,87,2 +87,129,463 +269,108,634 +0,118,41 +606,125,564 +521,671,624 +147,95,506 +42,98,86 +0,93,61 +83,73,68 +560,68,528 +111,40,220 +43,114,495 +99,64,466 +81,154,57 +83,116,540 +27,36,529 +107,0,115 +125,61,412 +25,103,6 +106,74,55 +49,117,0 +118,70,356 +0,95,67 +96,36,13 +0,68,93 +125,93,98 +683,19,563 +581,49,548 +98,91,160 +539,645,607 +211,72,449 +34,94,445 +84,78,0 +114,106,60 +80,98,126 +186,52,396 +124,76,506 +112,86,33 +0,0,92 +607,88,538 +94,78,0 +0,0,0 +0,88,0 +37,8,570 +106,77,8 +94,107,28 +575,332,557 +0,79,95 +92,115,104 +70,130,168 +130,50,0 +593,122,510 +582,95,589 +601,89,474 +23,2,1 +95,114,397 +514,99,529 +141,104,466 +46,68,166 +127,34,267 +98,77,434 +138,124,494 +83,0,21 +125,102,0 +77,71,133 +34,0,99 +148,0,470 +78,16,52 +171,76,94 +63,80,37 +147,112,135 +63,85,83 +583,127,584 +75,31,411 +67,79,83 +11,0,2 +85,91,0 +163,25,467 +529,699,686 +1,62,407 +98,22,1 +70,146,74 +9,56,469 +89,9,60 +111,0,4 +0,108,97 +136,61,123 +518,27,557 +86,11,494 +0,68,215 +81,68,27 +466,635,615 +115,114,521 +79,88,513 +0,0,0 +90,112,211 +0,66,43 +141,0,381 +116,51,480 +132,113,4 +41,3,68 +124,121,72 +100,121,563 +76,85,142 +564,94,561 +612,310,557 +58,71,15 +90,147,0 +88,51,125 +535,74,604 +104,129,1 +123,393,465 +84,109,0 +537,93,435 +29,64,0 +0,0,3 +88,99,159 +0,10,0 +621,329,582 +158,65,499 +110,66,506 +101,86,57 +23,23,92 +136,82,376 +535,54,559 +117,40,120 +87,0,122 +0,123,454 +214,147,176 +114,61,123 +228,90,413 +90,137,17 +102,13,0 +84,74,82 +64,0,39 +68,19,0 +99,104,64 +112,76,82 +123,115,49 +88,87,0 +503,649,599 +573,57,422 +86,63,87 +68,29,43 +45,85,99 +5,72,76 +78,0,123 +80,37,48 +88,7,48 +67,105,192 +0,30,14 +68,95,89 +11,104,116 +109,49,144 +36,109,107 +128,123,112 +199,102,527 +104,110,0 +456,599,451 +79,33,0 +25,148,53 +4,117,95 +118,120,0 +0,84,69 +34,26,105 +59,76,0 +49,106,124 +87,91,237 +75,67,95 +603,70,511 +77,0,98 +40,0,83 +100,0,529 +63,42,158 +92,95,94 +123,127,99 +602,58,588 +127,105,496 +597,466,560 +90,143,101 +92,111,467 +111,84,509 +75,86,0 +0,120,82 +253,150,171 +135,75,78 +121,85,39 +98,3,10 +61,99,50 +66,76,29 +107,5,455 +16,60,45 +0,68,1 +613,124,560 +122,59,499 +108,117,0 +56,0,76 +126,5,3 +66,76,0 +21,97,143 +75,16,309 +86,0,0 +0,65,198 +90,17,60 +134,0,457 +165,132,0 +77,122,80 +73,79,467 +61,91,127 +30,92,5 +142,100,506 +120,0,0 +114,99,115 +661,60,482 +78,8,94 +0,53,0 +81,129,0 +111,99,515 +34,59,128 +555,617,508 +577,623,620 +129,94,385 +379,88,498 +571,127,575 +8,120,56 +74,28,0 +62,101,0 +127,109,511 +48,145,64 +101,85,456 +57,98,47 +324,105,393 +141,46,52 +128,67,104 +102,116,508 +17,61,543 +588,92,486 +127,85,3 +88,145,142 +0,121,0 +0,71,407 +27,79,474 +144,0,425 +196,22,228 +69,88,170 +121,95,473 +57,123,51 +60,133,64 +95,10,114 +56,120,0 +628,91,549 +46,85,115 +126,99,142 +138,112,2 +72,39,66 +67,106,126 +109,11,353 +50,50,31 +99,134,42 +565,47,495 +79,121,0 +282,30,251 +78,71,45 +58,115,9 +57,73,140 +71,117,17 +83,75,74 +106,94,508 +65,116,44 +72,125,15 +7,98,63 +524,702,588 +97,50,111 +62,68,84 +0,85,42 +87,51,64 +89,78,576 +61,79,0 +66,2,0 +167,7,176 +663,79,554 +120,0,129 +104,118,66 +76,91,142 +78,45,402 +0,19,40 +109,109,465 +48,126,62 +190,30,313 +69,118,459 +0,89,31 +136,98,483 +70,93,103 +94,47,87 +118,38,0 +88,9,66 +129,97,14 +517,662,560 +600,12,587 +24,0,0 +578,40,612 +73,80,83 +515,88,467 +59,77,65 +57,29,80 +111,59,26 +83,168,45 +104,122,46 +100,69,443 +157,63,467 +91,80,515 +496,645,603 +108,78,58 +126,84,435 +0,0,25 +0,42,65 +114,53,27 +556,57,575 +119,76,503 +110,0,483 +66,49,64 +544,161,556 +4,17,64 +101,95,124 +475,662,607 +54,0,454 +98,121,0 +78,136,286 +0,0,54 +144,82,94 +71,93,178 +473,58,227 +480,124,74 +81,80,81 +86,79,192 +107,81,573 +0,81,0 +78,52,506 +24,78,0 +253,42,275 +12,63,553 +102,104,0 +79,158,430 +63,0,121 +59,155,107 +99,65,96 +112,29,13 +112,58,337 +107,113,51 +77,130,48 +193,33,515 +101,91,0 +110,68,448 +120,110,6 +111,85,56 +542,94,554 +43,83,225 +42,81,0 +167,0,463 +131,113,128 +29,100,84 +79,91,2 +255,49,454 +69,40,77 +142,62,7 +79,14,476 +0,119,85 +29,21,306 +105,117,385 +51,103,149 +81,140,139 +152,0,172 +529,146,413 +85,96,54 +157,92,433 +0,0,0 +86,126,43 +90,45,115 +78,81,476 +47,74,33 +125,76,500 +135,114,72 +131,62,397 +120,72,397 +14,19,136 +607,127,594 +192,86,0 +0,35,0 +542,105,492 +111,39,89 +79,25,160 +93,86,31 +544,0,559 +69,0,0 +108,68,232 +564,89,584 +97,101,62 +87,89,9 +57,0,515 +98,96,98 +104,147,51 +127,47,458 +2,378,463 +680,103,592 +73,111,443 +91,130,105 +74,43,258 +0,103,21 +572,25,419 +82,90,29 +371,158,572 +97,91,3 +52,90,387 +539,678,579 +104,87,72 +73,107,63 +0,50,76 +127,57,121 +441,305,382 +75,41,48 +86,125,0 +108,115,101 +23,0,79 +8,143,70 +132,110,0 +516,602,576 +0,129,117 +566,646,592 +75,91,93 +614,97,576 +538,65,447 +7,0,325 +122,108,99 +47,300,541 +0,110,0 +89,84,68 +80,0,448 +7,85,30 +0,145,76 +0,139,55 +644,98,573 +88,6,88 +62,62,91 +116,107,51 +17,49,397 +136,83,36 +107,109,0 +84,95,4 +64,77,333 +580,0,580 +52,36,497 +520,105,405 +0,144,31 +79,26,447 +113,60,11 +129,15,94 +111,97,0 +133,10,66 +608,429,529 +75,120,0 +163,82,0 +126,52,15 +18,67,17 +125,117,15 +55,107,59 +128,56,0 +23,32,153 +113,113,28 +98,68,98 +27,84,82 +89,76,82 +0,104,103 +79,55,131 +549,71,577 +80,109,134 +73,123,0 +159,118,428 +27,68,90 +50,130,475 +148,127,182 +567,673,640 +77,67,27 +0,104,139 +88,62,67 +19,91,116 +125,112,380 +79,422,501 +85,59,117 +485,609,520 +103,42,69 +0,77,539 +86,118,330 +535,0,227 +86,68,0 +109,70,36 +95,87,432 +1,54,22 +105,0,76 +0,123,57 +49,43,39 +153,76,426 +560,695,666 +88,30,85 +97,0,18 +126,72,192 +84,114,11 +81,107,499 +396,115,409 +549,29,559 +71,0,82 +54,115,444 +0,122,22 +85,132,62 +139,52,418 +134,0,455 +0,121,63 +116,73,68 +62,28,7 +66,96,78 +103,132,19 +125,119,95 +103,70,141 +133,101,4 +83,0,36 +114,71,0 +137,127,77 +115,0,341 +551,104,448 +66,109,0 +0,122,496 +120,113,60 +0,88,478 +516,649,619 +523,651,596 +0,58,51 +54,62,46 +597,130,541 +138,0,647 +5,107,103 +105,122,84 +0,112,0 +17,0,132 +101,0,105 +0,70,104 +112,51,102 +77,19,61 +90,79,530 +62,89,530 +63,55,492 +0,0,0 +82,91,0 +101,0,39 +56,0,477 +123,94,0 +500,654,591 +77,118,62 +53,0,0 +187,44,482 +0,85,46 +135,0,164 +87,63,184 +74,19,89 +147,104,39 +141,122,10 +39,36,497 +455,663,542 +114,83,0 +148,72,0 +67,51,0 +28,60,129 +118,109,473 +102,0,77 +538,89,543 +0,94,61 +76,126,492 +231,66,296 +110,88,28 +76,73,100 +73,33,14 +89,48,2 +84,97,85 +137,101,120 +169,0,589 +622,55,335 +0,0,44 +87,68,46 +566,142,539 +44,76,1 +69,69,9 +122,70,24 +112,134,76 +101,98,39 +99,119,0 +116,100,334 +131,97,589 +99,0,441 +465,0,508 +0,99,76 +76,105,71 +524,14,553 +135,121,90 +17,62,0 +80,63,11 +553,301,508 +112,23,400 +23,130,85 +514,68,463 +0,73,424 +608,0,574 +63,0,0 +516,564,434 +0,118,82 +138,87,398 +541,18,608 +131,20,3 +153,96,289 +72,51,465 +0,97,0 +52,88,476 +113,82,82 +0,0,258 +85,133,86 +0,0,41 +227,119,276 +141,83,1 +98,113,51 +64,91,300 +63,0,0 +522,647,525 +106,0,171 +57,82,89 +41,37,0 +80,0,0 +48,115,86 +523,119,406 +173,114,131 +124,95,52 +127,86,270 +137,54,14 +85,66,561 +94,0,527 +19,50,471 +142,19,471 +9,30,112 +0,79,12 +103,71,76 +94,24,486 +57,18,95 +53,49,120 +12,0,91 +60,436,552 +75,131,0 +78,79,0 +9,0,460 +73,118,87 +122,43,570 +112,134,146 +365,571,431 +2,88,101 +629,144,544 +104,101,562 +19,118,72 +95,108,485 +0,0,87 +604,489,486 +104,74,49 +101,11,399 +224,101,417 +58,76,475 +43,19,0 +58,41,84 +42,71,70 +115,34,496 +71,138,0 +106,50,420 +87,63,77 +14,73,0 +0,56,106 +0,93,73 +65,1,63 +112,51,24 +65,56,77 +53,142,164 +32,101,66 +148,87,195 +510,94,341 +112,0,131 +84,81,38 +37,143,13 +130,49,470 +73,159,0 +566,108,603 +160,63,98 +48,129,73 +57,90,0 +107,81,60 +99,101,67 +6,84,60 +72,134,65 +97,23,134 +82,56,45 +98,89,31 +35,93,108 +126,122,0 +67,17,0 +0,0,475 +129,7,286 +136,91,469 +20,70,103 +51,101,0 +533,99,498 +556,118,511 +52,108,23 +352,134,347 +56,95,286 +107,62,9 +40,97,61 +148,118,451 +395,108,246 +98,111,0 +100,0,47 +92,77,25 +51,88,42 +58,109,143 +63,130,0 +174,47,91 +121,72,0 +84,0,0 +78,81,0 +11,134,0 +67,107,0 +113,359,484 +92,97,23 +594,33,422 +49,23,0 +52,18,375 +128,78,0 +128,96,323 +182,115,198 +28,115,0 +63,69,75 +50,94,522 +133,143,479 +508,679,569 +125,64,204 +76,82,14 +96,85,76 +73,124,3 +0,108,30 +571,0,618 +87,81,4 +52,97,0 +86,94,17 +115,102,124 +61,27,108 +62,0,323 +21,62,0 +117,0,0 +354,53,335 +124,119,11 +39,111,87 +507,696,638 +39,74,16 +90,116,451 +76,0,71 +1,101,15 +90,20,188 +98,135,13 +151,119,22 +61,98,0 +40,88,403 +325,38,182 +33,71,455 +71,25,120 +546,68,400 +110,65,460 +538,662,603 +569,0,501 +62,154,79 +69,136,161 +117,73,10 +67,88,431 +62,50,0 +28,127,228 +669,0,530 +329,81,210 +128,97,523 +34,0,581 +81,92,49 +598,134,571 +506,95,615 +562,137,550 +136,98,286 +5,73,46 +75,32,501 +31,146,88 +92,76,0 +49,58,19 +103,129,510 +79,0,49 +557,70,566 +105,101,543 +0,68,111 +0,124,49 +374,0,612 +93,129,76 +91,83,378 +112,115,113 +111,127,0 +500,503,577 +557,576,629 +0,66,452 +59,132,508 +21,0,115 +66,11,100 +97,0,127 +105,90,65 +146,57,129 +654,141,606 +95,122,432 +52,72,486 +72,115,84 +558,85,501 +0,75,107 +199,127,599 +508,132,399 +573,147,521 +599,639,605 +86,68,214 +58,73,85 +56,32,456 +103,120,62 +126,69,2 +173,0,580 +0,103,395 +661,112,585 +137,82,86 +607,130,511 +555,0,535 +59,70,587 +464,574,555 +126,53,291 +145,117,92 +0,131,74 +177,57,549 +492,699,639 +253,58,521 +165,147,474 +506,698,595 +98,93,48 +136,147,55 +125,23,111 +54,49,29 +142,95,77 +126,76,397 +0,50,80 +140,0,0 +61,59,210 +92,89,54 +115,54,72 +111,63,541 +0,88,151 +66,35,105 +96,93,84 +168,72,480 +579,64,564 +544,131,369 +117,0,472 +0,132,95 +74,131,75 +128,114,150 +122,122,0 +114,60,4 +58,104,0 +77,150,85 +12,0,451 +71,11,0 +591,45,521 +0,93,71 +0,107,98 +98,94,91 +37,122,79 +0,3,76 +96,101,411 +23,131,38 +73,73,123 +62,0,49 +0,88,97 +116,63,148 +100,16,80 +15,62,300 +600,56,617 +515,137,265 +103,104,236 +110,0,52 +135,111,50 +118,77,101 +137,0,502 +0,5,0 +0,90,19 +122,45,511 +80,34,60 +104,88,18 +80,128,9 +105,360,488 +88,103,0 +101,71,63 +1,133,55 +511,643,594 +0,34,0 +91,76,144 +135,0,409 +115,0,30 +482,62,192 +159,32,479 +26,114,229 +92,88,459 +118,49,70 +68,66,66 +205,71,175 +0,107,495 +68,0,478 +153,31,165 +0,111,0 +15,60,99 +94,73,0 +28,60,112 +82,86,52 +94,84,3 +556,26,528 +34,70,0 +105,10,500 +2,0,0 +62,46,69 +157,109,98 +52,35,89 +88,100,25 +651,0,548 +694,0,572 +107,71,0 +147,83,104 +29,27,49 +102,59,79 +39,103,465 +74,106,48 +591,48,530 +88,109,11 +51,15,454 +111,65,565 +62,22,490 +46,65,92 +60,54,369 +122,104,75 +62,129,65 +88,119,46 +84,67,155 +93,113,511 +107,95,25 +89,0,91 +32,56,62 +1,94,15 +142,50,520 +101,62,0 +0,0,0 +40,9,105 +2,59,30 +144,86,232 +0,143,0 +520,0,523 +77,54,7 +86,84,3 +40,103,427 +76,59,19 +38,89,405 +111,100,0 +559,48,521 +40,30,0 +36,35,469 +27,125,5 +0,104,114 +472,54,476 +487,0,499 +58,67,8 +464,675,630 +119,47,83 +124,65,142 +53,106,0 +61,122,0 +0,150,27 +102,68,76 +136,90,484 +24,87,0 +88,141,0 +44,119,108 +91,109,63 +0,0,155 +39,99,80 +44,0,591 +0,111,486 +29,73,103 +105,97,437 +87,112,462 +160,30,571 +2,88,32 +27,31,56 +153,89,466 +129,92,49 +86,0,13 +98,80,96 +0,90,180 +111,47,72 +560,0,525 +645,46,536 +116,110,11 +96,0,68 +0,23,0 +46,103,50 +94,41,470 +0,132,0 +120,21,0 +71,422,561 +118,35,76 +589,51,496 +83,64,81 +120,67,551 +93,94,499 +85,55,444 +43,69,109 +73,116,43 +77,130,537 +80,94,0 +95,92,134 +623,74,534 +74,72,39 +80,104,31 +93,74,453 +584,0,487 +494,27,554 +54,15,84 +570,60,530 +582,69,531 +87,128,481 +462,684,641 +0,101,441 +75,99,503 +76,46,602 +142,78,119 +90,126,139 +164,0,511 +170,14,477 +120,80,483 +87,100,0 +589,88,596 +73,73,0 +56,75,81 +16,98,108 +46,85,297 +76,0,227 +99,56,39 +86,70,0 +16,93,72 +114,104,74 +0,0,103 +16,145,122 +551,47,597 +89,83,21 +102,66,114 +0,0,112 +103,59,104 +110,34,49 +122,80,91 +117,117,488 +157,0,508 +521,16,595 +82,61,451 +40,123,472 +592,98,495 +557,34,490 +101,87,119 +93,78,102 +11,60,80 +62,117,500 +580,0,390 +93,113,0 +68,0,0 +134,104,56 +133,97,113 +134,126,39 +133,0,11 +64,132,174 +115,111,0 +135,73,77 +56,0,0 +335,192,594 +110,57,457 +130,84,14 +122,0,111 +122,135,331 +559,15,581 +70,104,26 +120,100,116 +526,662,582 +11,77,279 +3,82,109 +118,106,159 +0,86,85 +59,128,154 +74,53,79 +76,99,504 +65,91,140 +72,38,18 +91,122,45 +100,117,128 +93,108,441 +103,59,422 +71,126,413 +72,0,529 +100,22,0 +139,117,436 +37,0,96 +73,74,280 +127,115,84 +0,67,560 +130,79,99 +132,99,503 +0,95,58 +23,98,0 +126,107,35 +89,116,36 +0,58,34 +44,102,10 +104,98,498 +84,28,421 +304,145,513 +52,77,1 +81,33,467 +88,49,116 +89,90,19 +54,113,104 +81,90,78 +103,140,0 +100,22,22 +510,57,337 +78,77,58 +16,125,405 +100,0,29 +61,456,472 +0,45,0 +103,125,349 +19,73,129 +116,63,76 +66,53,50 +533,39,574 +127,98,0 +37,76,52 +0,88,0 +445,120,528 +82,67,0 +116,20,102 +46,128,163 +59,105,49 +42,123,84 +182,119,184 +110,95,0 +86,84,108 +58,119,127 +106,6,101 +69,108,69 +78,103,44 +102,95,129 +189,137,533 +64,119,0 +119,55,98 +87,88,47 +71,0,206 +75,81,36 +102,133,139 +27,134,15 +87,103,540 +138,0,476 +120,100,125 +90,145,0 +65,0,0 +66,99,0 +48,119,0 +0,6,507 +41,87,75 +109,136,56 +108,106,369 +0,0,110 +556,155,523 +38,112,86 +86,33,195 +1,41,0 +66,97,319 +61,93,105 +70,124,95 +24,159,184 +199,85,595 +105,427,446 +585,548,549 +98,140,0 +100,18,2 +255,56,513 +0,115,185 +580,90,561 +522,653,644 +105,86,17 +0,54,492 +151,0,527 +103,103,72 +104,40,68 +644,562,524 +215,101,132 +86,52,0 +131,93,0 +593,513,516 +75,0,23 +85,40,460 +23,108,506 +109,28,550 +0,72,354 +116,72,109 +115,96,116 +355,17,336 +104,0,368 +64,72,100 +82,0,95 +81,77,29 +578,700,657 +509,92,557 +184,96,174 +532,56,538 +597,111,545 +115,74,0 +157,40,415 +105,78,43 +425,0,315 +115,62,393 +556,32,534 +77,75,6 +90,25,82 +597,49,232 +0,0,58 +495,691,597 +101,33,179 +68,90,69 +617,419,470 +34,82,103 +106,0,16 +49,61,16 +87,75,95 +529,655,615 +45,103,82 +29,116,50 +0,80,0 +127,79,143 +465,96,329 +91,42,70 +78,96,161 +72,0,128 +111,118,76 +30,44,19 +67,67,0 +88,64,147 +113,0,67 +144,113,9 +271,90,541 +572,92,535 +69,43,131 +575,87,577 +210,103,585 +649,95,539 +56,132,7 +154,108,619 +225,0,573 +73,70,84 +170,24,131 +56,75,51 +520,19,547 +101,62,9 +115,25,1 +149,81,618 +144,92,478 +73,114,115 +84,87,152 +58,66,155 +91,64,57 +111,120,449 +105,73,87 +168,81,547 +103,44,500 +136,79,51 +89,94,166 +45,0,241 +115,30,88 +109,121,62 +0,92,387 +90,55,14 +42,83,21 +46,106,108 +34,56,1 +125,58,0 +174,89,169 +27,65,104 +80,32,359 +100,63,110 +102,87,42 +70,100,71 +110,19,0 +59,61,152 +45,87,409 +472,99,297 +84,81,42 +81,100,177 +74,110,127 +0,55,32 +39,71,32 +511,661,601 +0,49,0 +76,0,0 +569,139,586 +9,470,427 +94,55,75 +119,84,92 +106,65,319 +32,122,421 +87,68,100 +31,19,50 +132,143,6 +32,140,193 +0,123,124 +60,74,98 +129,71,0 +301,130,236 +154,125,464 +33,91,445 +30,99,157 +71,0,82 +93,117,78 +47,81,79 +89,18,30 +128,103,0 +88,90,434 +0,87,0 +137,120,350 +17,118,507 +143,14,490 +101,102,105 +69,108,45 +113,71,566 +8,135,111 +141,0,91 +659,85,592 +86,39,0 +41,68,102 +95,91,100 +10,93,82 +591,543,476 +61,137,0 +85,111,591 +75,79,366 +74,139,86 +111,0,0 +604,33,551 +48,86,473 +58,67,0 +20,98,82 +105,66,20 +595,53,586 +0,158,32 +107,51,27 +80,61,32 +63,0,352 +520,652,562 +584,95,507 +58,76,442 +71,70,58 +89,96,0 +113,0,51 +117,0,228 +98,41,18 +596,2,553 +591,130,538 +642,540,556 +0,115,440 +0,17,488 +92,125,471 +92,42,0 +42,117,405 +89,110,123 +64,80,63 +76,0,82 +35,101,148 +126,46,519 +101,122,444 +66,65,58 +75,139,89 +116,42,90 +81,0,86 +56,97,76 +554,666,643 +41,40,71 +509,134,305 +89,41,117 +58,0,505 +17,132,106 +96,46,448 +115,149,395 +78,0,190 +86,72,451 +139,85,453 +79,98,104 +36,132,1 +21,128,73 +0,85,97 +566,125,564 +117,104,74 +125,120,2 +69,96,111 +100,58,84 +91,44,88 +147,14,126 +94,61,0 +0,163,362 +94,0,489 +104,105,108 +125,80,493 +3,28,381 +138,0,71 +0,16,0 +560,0,536 +87,2,53 +135,80,556 +95,112,62 +119,86,18 +105,87,30 +86,40,65 +93,24,140 +585,651,619 +204,111,416 +91,68,423 +100,44,120 +0,61,74 +60,40,92 +76,20,0 +110,0,308 +84,83,78 +80,130,484 +45,94,84 +0,72,464 +489,0,556 +79,0,198 +32,15,2 +11,0,45 +136,41,309 +140,104,305 +82,0,12 +549,57,515 +147,17,449 +17,115,72 +111,92,59 +22,70,103 +0,61,0 +35,0,0 +87,95,128 +5,12,423 +76,126,485 +98,77,160 +31,107,55 +93,89,0 +0,74,94 +491,55,248 +112,270,412 +99,12,52 +211,134,714 +538,0,514 +0,84,115 +92,108,461 +154,83,511 +75,136,79 +134,16,101 +109,58,186 +523,694,562 +596,162,502 +113,0,149 +112,13,469 +178,88,483 +85,1,0 +133,82,89 +102,66,441 +95,0,476 +14,98,0 +61,62,75 +81,56,133 +86,26,0 +148,38,75 +111,0,55 +102,103,218 +509,120,589 +0,68,81 +71,116,5 +98,27,133 +110,90,478 +40,54,20 +25,78,544 +498,693,630 +109,3,78 +105,106,78 +101,126,4 +140,74,84 +92,128,0 +88,109,474 +112,78,0 +557,53,336 +182,104,100 +125,109,117 +609,106,460 +60,58,105 +44,4,42 +146,46,509 +539,695,612 +121,78,0 +90,0,38 +53,6,41 +555,90,516 +109,44,473 +97,68,498 +119,0,450 +197,11,463 +583,121,538 +53,0,96 +668,62,505 +107,83,495 +130,34,102 +116,51,418 +545,108,577 +100,18,514 +80,45,0 +98,62,351 +73,115,610 +126,85,345 +209,29,129 +115,91,613 +39,120,28 +92,120,84 +60,52,4 +12,123,149 +609,10,524 +519,679,591 +45,92,455 +127,71,78 +94,80,118 +55,37,145 +272,90,490 +559,0,526 +57,61,77 +119,149,121 +91,95,7 +173,42,132 +3,76,0 +141,103,491 +97,138,122 +97,72,415 +109,59,107 +76,99,139 +63,44,0 +45,153,0 +647,61,424 +71,135,369 +107,131,0 +526,46,262 +227,170,519 +139,90,116 +108,145,116 +0,98,62 +0,132,492 +38,118,75 +0,54,67 +93,104,58 +45,0,137 +75,89,59 +153,74,526 +121,114,121 +36,56,477 +0,126,30 +80,48,57 +136,79,0 +89,42,68 +78,39,77 +25,91,386 +27,84,73 +89,116,132 +87,78,1 +144,3,76 +0,75,0 +84,58,26 +0,148,58 +215,0,569 +55,38,512 +114,68,450 +44,107,21 +113,81,0 +581,94,517 +124,22,55 +78,35,45 +121,127,168 +0,53,85 +80,109,0 +457,667,622 +51,110,492 +32,14,56 +88,81,53 +77,127,0 +90,108,58 +45,63,284 +63,93,0 +11,71,49 +8,150,502 +122,135,204 +0,131,486 +135,125,122 +580,90,537 +76,0,49 +17,62,134 +133,49,530 +21,0,83 +94,124,384 +161,111,54 +145,130,1 +467,643,554 +28,150,409 +13,78,477 +0,119,41 +51,74,106 +35,159,108 +0,47,0 +133,104,115 +601,54,585 +133,68,123 +54,0,120 +82,121,177 +172,0,183 +64,62,4 +102,107,180 +139,124,547 +91,97,91 +561,696,617 +0,122,76 +0,60,8 +47,0,254 +98,113,70 +18,7,541 +96,64,0 +137,90,226 +34,53,24 +100,198,486 +92,127,508 +141,91,515 +50,129,127 +0,0,17 +87,144,39 +141,18,454 +97,98,0 +556,89,615 +41,0,36 +7,68,96 +0,82,0 +51,117,55 +118,113,1 +0,128,72 +33,84,97 +66,0,539 +65,8,100 +119,121,4 +112,39,64 +96,24,63 +601,80,576 +95,129,104 +70,66,48 +129,112,191 +105,50,111 +103,58,155 +131,87,84 +96,142,529 +42,103,68 +88,93,84 +85,0,23 +176,59,342 +4,63,0 +51,75,89 +52,37,448 +541,152,517 +82,87,124 +9,102,97 +86,0,575 +0,102,118 +63,56,410 +55,0,94 +28,80,102 +66,131,554 +110,79,106 +24,62,120 +1,43,77 +54,82,35 +554,89,508 +111,87,48 +514,84,554 +67,118,100 +132,9,314 +603,124,459 +40,119,105 +681,47,555 +511,101,546 +374,86,544 +68,109,471 +151,68,502 +646,446,611 +76,39,51 +530,547,415 +453,546,422 +122,99,14 +0,110,87 +48,143,442 +147,83,131 +278,0,122 +92,117,111 +109,106,143 +100,66,0 +204,82,449 +148,65,158 +41,80,0 +594,110,519 +82,95,89 +74,135,16 +83,0,76 +119,57,508 +0,98,17 +534,42,547 +581,71,443 +0,52,11 +62,85,6 +0,74,181 +121,6,499 +124,95,82 +50,41,296 +93,110,107 +543,87,278 +48,433,376 +82,85,49 +91,51,511 +52,87,34 +75,68,76 +49,17,42 +227,101,409 +103,119,407 +152,0,497 +51,33,64 +158,91,213 +109,0,132 +46,0,102 +16,105,15 +145,68,98 +86,82,160 +30,87,40 +532,111,476 +79,80,129 +573,92,476 +103,92,56 +93,57,0 +86,113,62 +144,74,495 +90,95,60 +568,0,593 +86,117,202 +81,24,10 +89,130,361 +87,41,0 +0,26,103 +127,63,433 +40,115,67 +102,123,97 +653,0,583 +79,385,284 +7,76,175 +117,73,6 +75,31,121 +69,90,111 +0,107,8 +300,154,590 +119,0,459 +0,121,9 +44,104,0 +122,10,0 +544,120,385 +136,20,380 +0,0,603 +536,668,605 +62,64,451 +96,0,527 +576,74,536 +510,0,538 +43,13,0 +96,50,78 +36,127,80 +389,100,269 +126,117,104 +29,101,15 +574,16,578 +110,45,503 +82,70,44 +101,96,63 +561,70,541 +118,76,525 +549,3,618 +26,15,0 +0,86,64 +90,0,0 +163,20,0 +254,143,523 +116,73,482 +94,0,457 +123,90,395 +673,0,511 +4,122,47 +58,109,55 +129,8,0 +110,32,461 +153,29,122 +95,105,178 +135,104,410 +94,28,0 +113,109,32 +103,29,142 +693,47,622 +125,100,32 +109,0,484 +103,57,80 +0,71,121 +13,63,410 +91,84,30 +61,106,109 +470,669,621 +549,124,557 +112,76,0 +61,74,89 +101,93,97 +111,0,58 +38,0,29 +0,60,412 +0,101,427 +42,7,386 +66,92,45 +113,137,73 +316,0,392 +66,49,463 +107,104,606 +60,29,9 +113,91,64 +68,140,20 +71,73,0 +147,125,175 +454,95,82 +100,0,1 +139,98,477 +127,57,467 +35,0,124 +0,39,0 +80,0,0 +124,0,125 +121,76,479 +308,82,368 +20,16,566 +102,112,423 +115,25,138 +39,113,0 +93,84,0 +617,121,578 +578,56,619 +90,28,499 +53,0,67 +564,139,538 +94,125,76 +46,48,116 +116,111,154 +593,88,561 +78,98,70 +129,38,522 +56,110,0 +92,121,0 +147,45,367 +66,113,40 +126,106,0 +91,0,283 +544,659,632 +88,43,73 +32,23,59 +72,12,43 +111,100,95 +562,98,588 +588,66,535 +581,25,528 +573,83,545 +78,43,137 +136,88,8 +82,74,526 +78,122,109 +123,46,81 +43,32,67 +75,80,490 +126,124,596 +528,674,617 +0,3,467 +47,43,0 +104,12,100 +123,80,111 +132,86,113 +63,80,73 +234,7,637 +63,93,0 +557,143,589 +85,58,200 +101,64,61 +521,647,553 +79,94,144 +104,24,17 +0,14,283 +60,84,67 +0,81,20 +75,106,50 +49,122,315 +70,100,455 +77,65,70 +98,107,41 +0,132,1 +95,0,492 +44,94,0 +0,128,73 +43,115,0 +81,31,51 +13,51,62 +89,18,6 +70,44,119 +73,142,465 +122,37,53 +135,43,0 +40,86,73 +555,54,340 +0,57,91 +120,119,124 +575,574,591 +71,90,393 +0,0,61 +87,99,87 +114,11,89 +424,96,301 +0,96,105 +66,125,336 +14,82,103 +109,149,82 +72,76,98 +133,12,428 +140,52,473 +153,49,416 +166,115,144 +117,123,360 +101,45,94 +90,135,15 +73,45,0 +92,43,0 +95,56,23 +128,86,21 +88,0,46 +525,95,578 +113,0,50 +194,116,491 +114,0,543 +108,140,114 +142,92,34 +502,542,594 +64,89,67 +69,150,80 +78,0,462 +102,131,79 +634,121,502 +47,26,55 +97,101,86 +105,62,446 +40,72,43 +0,50,0 +118,82,24 +90,52,46 +127,73,44 +0,58,25 +652,89,566 +27,110,0 +83,0,2 +296,100,323 +8,113,95 +61,71,9 +12,59,62 +106,114,266 +70,49,159 +644,81,448 +74,129,88 +62,141,100 +179,45,502 +3,0,0 +4,92,0 +57,0,21 +0,99,78 +0,71,120 +114,0,94 +105,116,476 +13,92,456 +0,29,20 +144,59,505 +108,83,431 +61,118,52 +132,17,588 +0,63,0 +110,93,103 +44,16,106 +39,97,0 +110,72,472 +161,30,391 +21,0,533 +98,70,401 +563,78,541 +563,0,537 +632,81,553 +108,138,532 +590,500,398 +79,19,79 +0,45,475 +53,78,27 +87,106,58 +563,115,489 +63,81,120 +502,99,534 +0,0,0 +214,63,121 +590,56,472 +36,0,31 +101,44,451 +115,86,0 +59,14,25 +0,36,103 +71,43,490 +107,2,61 +117,96,401 +71,108,0 +0,144,0 +100,10,472 +134,25,180 +79,90,2 +122,75,102 +59,75,97 +607,0,544 +74,83,81 +97,87,35 +22,46,89 +15,99,386 +128,81,36 +140,131,131 +24,53,51 +100,102,0 +80,78,88 +0,3,86 +91,84,6 +157,59,389 +126,67,0 +51,115,521 +84,74,82 +78,118,82 +47,95,79 +61,128,49 +552,73,551 +554,2,540 +632,46,532 +597,92,558 +53,0,45 +146,0,3 +145,16,288 diff --git a/geatpy/demo/soea_demo/soea_demo8/main.py b/geatpy/demo/soea_demo/soea_demo8/main.py new file mode 100644 index 00000000..ce29eba5 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo8/main.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" +该案例展示了如何利用进化算法进行仿k-means聚类(可称之为EA-KMeans算法)。问题的定义详见MyProblem.py。 +本案例采用与k-means类似的聚类方法,采用展开的聚类中心点坐标作为染色体的编码,基本流程大致如下: +1) 初始化种群染色体。 +2) 迭代进化(循环第3步至第6步),直到满足终止条件。 +3) 重组变异,然后根据得到的新染色体计算出对应的聚类中心点。 +4) 计算各数据点到聚类中心点的欧式距离。 +5) 把与各中心点关联的数据点的坐标平均值作为新的中心点,并以此更新种群的染色体。 +6) 把各中心点到与其关联的数据点之间的距离之和作为待优化的目标函数值。 +注意:导入的数据是以列为特征的,即每一列代表一个特征(如第一列代表x,第二列代表y......)。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 构建算法 + algorithm = ea.soea_DE_rand_1_bin_templet(problem, + ea.Population(Encoding='RI', NIND=2), + MAXGEN=20, # 最大进化代数。 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + trappedValue=1e-4, # 单目标优化陷入停滞的判断阈值。 + maxTrappedCount=10) # 进化停滞计数器最大上限值。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + # 检验结果 + if res['success']: + print('最优的聚类中心为:') + Vars = res['Vars'][0, :] + centers = Vars.reshape(problem.k, int(len(Vars) / problem.k)) # 得到最优的聚类中心 + print(centers) + """=================================检验结果===============================""" + problem.draw(centers) diff --git a/geatpy/demo/soea_demo/soea_demo9/MyProblem.py b/geatpy/demo/soea_demo/soea_demo9/MyProblem.py new file mode 100644 index 00000000..33ec8935 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo9/MyProblem.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea + +""" +max f = x * np.sin(10 * np.pi * x) + 2.0 +s.t. +-1 <= x <= 2 +""" + + +class MyProblem(ea.Problem): # 继承Problem父类 + def __init__(self): + name = 'MyProblem' # 初始化name(函数名称,可以随意设置) + M = 1 # 初始化M(目标维数) + maxormins = [-1] # 初始化maxormins(目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标) + Dim = 1 # 初始化Dim(决策变量维数) + varTypes = [0] * Dim # 初始化varTypes(决策变量的类型,元素为0表示对应的变量是连续的;1表示是离散的) + lb = [-1] # 决策变量下界 + ub = [2] # 决策变量上界 + lbin = [1] * Dim # 决策变量下边界(0表示不包含该变量的下边界,1表示包含) + ubin = [1] * Dim # 决策变量上边界(0表示不包含该变量的上边界,1表示包含) + # 调用父类构造方法完成实例化 + ea.Problem.__init__(self, name, M, maxormins, Dim, varTypes, lb, ub, lbin, ubin) + + def evalVars(self, x): # 目标函数 + f = x * np.sin(10 * np.pi * x) + 2.0 + return f diff --git a/geatpy/demo/soea_demo/soea_demo9/main.py b/geatpy/demo/soea_demo/soea_demo9/main.py new file mode 100644 index 00000000..1f4b6c57 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_demo9/main.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +from MyProblem import MyProblem # 导入自定义问题接口 +import geatpy as ea # import geatpy + +""" +该案例是soea_demo1的拓展,展示了如何利用多种群来进行单目标优化。问题的定义详见MyProblem.py。 +在执行脚本main.py中,通过调用带"multi"字样的进化算法类来进行多种群进化优化。 +""" + +if __name__ == '__main__': + # 实例化问题对象 + problem = MyProblem() + # 种群设置 + Encoding = 'RI' # 编码方式 + NINDs = [5, 10, 15, 20] # 种群规模 + population = [] # 创建种群列表 + for i in range(len(NINDs)): + Field = ea.crtfld(Encoding, problem.varTypes, problem.ranges, problem.borders) # 创建区域描述器。 + population.append(ea.Population(Encoding, Field, NINDs[i])) # 实例化种群对象(此时种群还没被初始化,仅仅是完成种群对象的实例化)。 + # 构建算法 + algorithm = ea.soea_multi_SEGA_templet(problem, + population, + MAXGEN=30, # 最大进化代数。 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + trappedValue=1e-6, # 单目标优化陷入停滞的判断阈值。 + maxTrappedCount=5) # 进化停滞计数器最大上限值。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=False) + print(res) diff --git a/geatpy/demo/soea_demo/soea_quick_start_aimFunc/Objective Value Trace Plot.gif b/geatpy/demo/soea_demo/soea_quick_start_aimFunc/Objective Value Trace Plot.gif new file mode 100644 index 00000000..0e1b7f22 Binary files /dev/null and b/geatpy/demo/soea_demo/soea_quick_start_aimFunc/Objective Value Trace Plot.gif differ diff --git a/geatpy/demo/soea_demo/soea_quick_start_aimFunc/main.py b/geatpy/demo/soea_demo/soea_quick_start_aimFunc/main.py new file mode 100644 index 00000000..a76c431d --- /dev/null +++ b/geatpy/demo/soea_demo/soea_quick_start_aimFunc/main.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +import geatpy as ea +import numpy as np + +""" + +本案例展示了如何快速创建问题对象、快速调用算法求解一个含两个约束的单目标优化问题。 +跟soea_quick_start_evalVars案例不同的是,这里的目标函数定义成aimFunc,而不是evalVars。 +aimFunc(pop)传入的是一个种群对象pop。 +pop.Phen是种群的表现型矩阵,等价于决策变量矩阵。它是Numpy ndarray的二维数组,每一行表示一组决策变量值。 +pop.ObjV是种群的目标函数值矩阵。它是Numpy ndarray的二维数组,每一行表示一组目标函数值。 +pop.CV是种群的违反约束程度矩阵。它是Numpy ndarray的二维数组,每一行表示一组违反约束程度值。 + +""" + +if __name__ == '__main__': + # 构建问题 + r = 1 # 模拟该案例问题计算目标函数时需要用到的额外数据 + def aimFunc(pop): # 定义目标函数(含约束) + Vars = pop.Phen + pop.ObjV = np.sum((Vars - r) ** 2, 1, keepdims=True) # 计算目标函数值,赋值给种群对象的ObjV属性 + x1 = Vars[:, [0]] # 把Vars的第0列取出来 + x2 = Vars[:, [1]] # 把Vars的第1列取出来 + pop.CV = np.hstack([(x1 - 0.5) ** 2 - 0.25, + (x2 - 1) ** 2 - 1]) # 计算违反约束程度值,赋值给种群对象的CV属性 + + problem = ea.Problem(name='soea quick start demo', + M=1, # 目标维数 + maxormins=[1], # 目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标 + Dim=5, # 决策变量维数 + varTypes=[0, 0, 1, 1, 1], # 决策变量的类型列表,0:实数;1:整数 + lb=[-1, 1, 2, 1, 0], # 决策变量下界 + ub=[1, 4, 5, 2, 1], # 决策变量上界 + aimFunc=aimFunc) + # 构建算法 + algorithm = ea.soea_SEGA_templet(problem, + ea.Population(Encoding='RI', NIND=20), + MAXGEN=50, # 最大进化代数。 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + trappedValue=1e-6, # 单目标优化陷入停滞的判断阈值。 + maxTrappedCount=10) # 进化停滞计数器最大上限值。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + print(res) diff --git a/geatpy/demo/soea_demo/soea_quick_start_aimFunc_single/main.py b/geatpy/demo/soea_demo/soea_quick_start_aimFunc_single/main.py new file mode 100644 index 00000000..097917cc --- /dev/null +++ b/geatpy/demo/soea_demo/soea_quick_start_aimFunc_single/main.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- + +import geatpy as ea +import numpy as np + +""" + +本案例展示了如何快速创建问题对象、快速调用算法求解一个含两个约束的单目标优化问题。 +跟soea_quick_start_aimFunc案例不同的是,本案例通过装饰器single标记目标函数aimFunc,使得它传入的种群对象只有单个个体。 + +""" + +if __name__ == '__main__': + # 构建问题 + r = 1 # 模拟该案例问题计算目标函数时需要用到的额外数据 + @ea.Problem.single + def aimFunc(pop): # 定义目标函数(含约束) + Vars = pop.Phen + pop.ObjV = np.sum((Vars - r) ** 2, 1, keepdims=True) # 计算目标函数值,赋值给种群对象的ObjV属性 + x1 = Vars[:, [0]] # 把Vars的第0列取出来 + x2 = Vars[:, [1]] # 把Vars的第1列取出来 + pop.CV = np.hstack([(x1 - 0.5) ** 2 - 0.25, + (x2 - 1) ** 2 - 1]) # 计算违反约束程度值,赋值给种群对象的CV属性 + + problem = ea.Problem(name='soea quick start demo', + M=1, # 目标维数 + maxormins=[1], # 目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标 + Dim=5, # 决策变量维数 + varTypes=[0, 0, 1, 1, 1], # 决策变量的类型列表,0:实数;1:整数 + lb=[-1, 1, 2, 1, 0], # 决策变量下界 + ub=[1, 4, 5, 2, 1], # 决策变量上界 + aimFunc=aimFunc) + # 构建算法 + algorithm = ea.soea_SEGA_templet(problem, + ea.Population(Encoding='RI', NIND=20), + MAXGEN=50, # 最大进化代数。 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + trappedValue=1e-6, # 单目标优化陷入停滞的判断阈值。 + maxTrappedCount=10) # 进化停滞计数器最大上限值。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + print(res) diff --git a/geatpy/demo/soea_demo/soea_quick_start_evalVars/Objective Value Trace Plot.gif b/geatpy/demo/soea_demo/soea_quick_start_evalVars/Objective Value Trace Plot.gif new file mode 100644 index 00000000..0e1b7f22 Binary files /dev/null and b/geatpy/demo/soea_demo/soea_quick_start_evalVars/Objective Value Trace Plot.gif differ diff --git a/geatpy/demo/soea_demo/soea_quick_start_evalVars/main.py b/geatpy/demo/soea_demo/soea_quick_start_evalVars/main.py new file mode 100644 index 00000000..0bb36a26 --- /dev/null +++ b/geatpy/demo/soea_demo/soea_quick_start_evalVars/main.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- + +import geatpy as ea +import numpy as np + +""" + +本案例展示了如何快速创建问题对象、快速调用算法求解一个含两个约束的单目标优化问题。 +跟soea_quick_start_aimFunc案例不同的是,这里的目标函数定义成evalVars,而不是aimFunc。 +区别: + aimFunc(pop)传入的是一个种群对象。 + 而evalVars(Vars)传入的是一个Numpy ndarray二维数组。其每一行的所有元素表示一组决策变量。 + 函数evalVars可以有一个或两个返回值。第一个返回值表示目标函数值矩阵;第二个返回值表示违反约束程度矩阵。 + 如果没有约束,则只需返回一个返回值即可。因此用法为: + ObjV = evalVars(Vars) + 或 + ObjV, CV = evalVars(Vars) + +""" + +if __name__ == '__main__': + # 构建问题 + r = 1 # 模拟该案例问题计算目标函数时需要用到的额外数据 + def evalVars(Vars): # 定义目标函数(含约束) + ObjV = np.sum((Vars - r) ** 2, 1, keepdims=True) # 计算目标函数值 + x1 = Vars[:, [0]] # 把Vars的第0列取出来 + x2 = Vars[:, [1]] # 把Vars的第1列取出来 + CV = np.hstack([(x1 - 0.5) ** 2 - 0.25, + (x2 - 1) ** 2 - 1]) # 计算违反约束程度 + return ObjV, CV # 返回目标函数值矩阵和违反约束程度矩阵 + + problem = ea.Problem(name='soea quick start demo', + M=1, # 目标维数 + maxormins=[1], # 目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标 + Dim=5, # 决策变量维数 + varTypes=[0, 0, 1, 1, 1], # 决策变量的类型列表,0:实数;1:整数 + lb=[-1, 1, 2, 1, 0], # 决策变量下界 + ub=[1, 4, 5, 2, 1], # 决策变量上界 + evalVars=evalVars) + # 构建算法 + algorithm = ea.soea_SEGA_templet(problem, + ea.Population(Encoding='RI', NIND=20), + MAXGEN=50, # 最大进化代数。 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + trappedValue=1e-6, # 单目标优化陷入停滞的判断阈值。 + maxTrappedCount=10) # 进化停滞计数器最大上限值。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + print(res) diff --git a/geatpy/demo/soea_demo/soea_quick_start_evalVars_loop/main.py b/geatpy/demo/soea_demo/soea_quick_start_evalVars_loop/main.py new file mode 100644 index 00000000..c12f79bc --- /dev/null +++ b/geatpy/demo/soea_demo/soea_quick_start_evalVars_loop/main.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +import geatpy as ea +import numpy as np + +""" + +本案例展示了如何快速创建问题对象、快速调用算法求解一个含两个约束的单目标优化问题。 +与soea_quick_start_evalVars案例不同的是,本案例采用循环计算每个个体的目标函数值和违反约束程度值。 + +""" + +if __name__ == '__main__': + # 构建问题 + r = 1 # 目标函数需要用到的额外数据 + def evalVars(Vars): # 定义目标函数(含约束) + f = [] # 存储目标函数值 + CV = [] # 存储违反约束程度 + for i in range(Vars.shape[0]): # 遍历每一组决策变量,计算对应的目标函数值 + f.append(np.sum((Vars[i, :] - r) ** 2)) # 用Vars[i, :] 取出每一组决策变量 + x1 = Vars[i, 0] + x2 = Vars[i, 1] + CV.append(np.array([(x1 - 0.5)**2 - 0.25, + (x2 - 1)**2 - 1])) + return np.vstack(f), np.vstack(CV) # 返回目标函数值矩阵和违反约束程度矩阵 + + problem = ea.Problem(name='soea quick start demo', + M=1, # 目标维数 + maxormins=[1], # 目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标 + Dim=5, # 决策变量维数 + varTypes=[0, 0, 1, 1, 1], # 决策变量的类型列表,0:实数;1:整数 + lb=[-1, 1, 2, 1, 0], # 决策变量下界 + ub=[1, 4, 5, 2, 1], # 决策变量上界 + evalVars=evalVars) + # 构建算法 + algorithm = ea.soea_SEGA_templet(problem, + ea.Population(Encoding='RI', NIND=20), + MAXGEN=50, # 最大进化代数。 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + trappedValue=1e-6, # 单目标优化陷入停滞的判断阈值。 + maxTrappedCount=10) # 进化停滞计数器最大上限值。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + print(res) diff --git a/geatpy/demo/soea_demo/soea_quick_start_evalVars_single/main.py b/geatpy/demo/soea_demo/soea_quick_start_evalVars_single/main.py new file mode 100644 index 00000000..31804b7c --- /dev/null +++ b/geatpy/demo/soea_demo/soea_quick_start_evalVars_single/main.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*- + +import geatpy as ea +import numpy as np + +""" + +本案例展示了如何快速创建问题对象、快速调用算法求解一个含两个约束的单目标优化问题。 +与soea_quick_start_evalVars案例不同的是,本案例通过装饰器single标记目标函数evalVars,使得目标函数只传入一组决策变量。 +此时目标函数只需计算这组变量对应的目标函数值以及违反约束程度值。 +用法: + ObjV = evalVars(Vars) -- 若无约束 + 或 + ObjV, CV = evalVars(Vars) -- 若有约束 +注意: + 加了装饰器single后,evalVars的传入参数Vars不再是Numpy ndarray二维数组,而是Numpy ndarray一维数组。 + 在设置返回值时: + 返回值ObjV可以赋值为一个Numpy ndarray一维数组,也可以是一个标量(当只有一个优化目标时)。 + 返回值CV可以赋值为一个Numpy ndarray一维数组,也可以是一个标量(当只有一个优化目标时)。 + 值得注意的是: + 通过调用evalVars(Vars)得到的返回值会被single装饰器修正为Numpy ndarray二维数组。 + 即ObjV = evalVars(Vars)得到的ObjV或:ObjV, CV = evalVars(Vars)得到的ObjV和CV,均为Numpy ndarray二维数组。 + +""" + +if __name__ == '__main__': + # 构建问题 + r = 1 # 目标函数需要用到的额外数据 + @ea.Problem.single + def evalVars(Vars): # 定义目标函数(含约束) + f = np.sum((Vars - r) ** 2) # 计算目标函数值 + x1 = Vars[0] + x2 = Vars[1] + CV = np.array([(x1 - 0.5)**2 - 0.25, + (x2 - 1)**2 - 1]) # 计算违反约束程度 + return f, CV + + problem = ea.Problem(name='soea quick start demo', + M=1, # 目标维数 + maxormins=[1], # 目标最小最大化标记列表,1:最小化该目标;-1:最大化该目标 + Dim=5, # 决策变量维数 + varTypes=[0, 0, 1, 1, 1], # 决策变量的类型列表,0:实数;1:整数 + lb=[-1, 1, 2, 1, 0], # 决策变量下界 + ub=[1, 4, 5, 2, 1], # 决策变量上界 + evalVars=evalVars) + # 构建算法 + algorithm = ea.soea_SEGA_templet(problem, + ea.Population(Encoding='RI', NIND=20), + MAXGEN=50, # 最大进化代数。 + logTras=1, # 表示每隔多少代记录一次日志信息,0表示不记录。 + trappedValue=1e-6, # 单目标优化陷入停滞的判断阈值。 + maxTrappedCount=10) # 进化停滞计数器最大上限值。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True) + print(res) diff --git a/geatpy/operators/migration/Migrate.py b/geatpy/operators/migration/Migrate.py new file mode 100644 index 00000000..b3815bcc --- /dev/null +++ b/geatpy/operators/migration/Migrate.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +from geatpy.core.migrate import migrate + + +class Migrate: + """ + Migrate - class : 一个用于调用内核中的种群迁移函数migrate的种群迁移算子类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(migrate)查看各参数的详细含义及用法。 + + """ + + def __init__(self, MIGR=0.2, Structure=0, Select=0, Replacement=0): + self.MIGR = MIGR # 表示种群个体的迁出概率 + self.Structure = Structure # 表示种群迁移的结构(0:完全网状结构;1:邻近结构;2:环状结构) + self.Select = Select # 表示选择迁出个体的方式(0:随机选择迁出个体;1:择优选择迁出个体) + self.Replacement = Replacement # 表示种群在迁入个体时采用什么个体替换方式(0:替换迁出的个体;1:随机替换;2:择劣替换) + + def do(self, populations, *args): # 执行变异,populations为存储着种群类对象的列表 + if type(populations) != list: + raise RuntimeError('error in Migrate: The populations must be a list. (输入参数populations必须是list类型。)') + + PopSizes = list(pop.sizes for pop in populations) + FitnVs = list(pop.FitnV for pop in populations) + # 调用种群迁移算子进行种群个体迁移 + [Aborigines, Foreigners, FromPlaces] = migrate(PopSizes, self.MIGR, self.Structure, self.Select, + self.Replacement, FitnVs) + NewPopulations = [] + for i in range(len(populations)): # 更新迁移个体后的种群 + NewPopulations.append((populations[i])[Aborigines[i]] + (populations[FromPlaces[i]])[Foreigners[i]]) + return NewPopulations + + def getHelp(self): # 查看内核中的变异算子的API文档 + help(migrate) diff --git a/geatpy/operators/mutation/Mutation.py b/geatpy/operators/mutation/Mutation.py new file mode 100644 index 00000000..514df485 --- /dev/null +++ b/geatpy/operators/mutation/Mutation.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +class Mutation: + """ + Mutation - Interface : 变异算子接口 + 进化算法框架中的所有变异算子类都实现该接口。 + + """ + + def __init__(self): + pass + + def do(self): # 用于调用内核中的变异算子函数执行变异 + pass + + def getHelp(self): # 查看内核中的变异算子的API文档 + pass diff --git a/geatpy/operators/mutation/Mutbga.py b/geatpy/operators/mutation/Mutbga.py new file mode 100644 index 00000000..e6b5d0f0 --- /dev/null +++ b/geatpy/operators/mutation/Mutbga.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from geatpy.core.mutbga import mutbga + +from geatpy.operators.mutation.Mutation import Mutation + + +class Mutbga(Mutation): + """ + Mutbga - class : 一个用于调用内核中的变异函数mutbga(Breeder GA变异)的变异算子类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(mutbga)查看各参数的详细含义及用法。 + + """ + + def __init__(self, Pm=None, MutShrink=0.5, Gradient=20, FixType=1, Parallel=False): + self.Pm = Pm # 表示染色体上变异算子所发生作用的最小片段发生变异的概率 + self.MutShrink = MutShrink # 压缩率,用于压缩变异的范围 + self.Gradient = Gradient # 变异距离的梯度划分个数,表示将变异距离划分多少个梯度 + self.FixType = FixType # 表示采用哪种方式来修复超出边界的染色体元素,可取值1,2,3,4,详细含义见help()帮助文档 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, Encoding, OldChrom, FieldDR, *args): # 执行变异 + return mutbga(Encoding, OldChrom, FieldDR, self.Pm, self.MutShrink, self.Gradient, self.FixType, self.Parallel) + + def getHelp(self): # 查看内核中的变异算子的API文档 + help(mutbga) diff --git a/geatpy/operators/mutation/Mutbin.py b/geatpy/operators/mutation/Mutbin.py new file mode 100644 index 00000000..844f7acc --- /dev/null +++ b/geatpy/operators/mutation/Mutbin.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from geatpy.core.mutbin import mutbin + +from geatpy.operators.mutation.Mutation import Mutation + + +class Mutbin(Mutation): + """ + Mutbin - class : 一个用于调用内核中的变异函数mutbin(二进制变异)的变异算子类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(mutbin)查看各参数的详细含义及用法。 + + """ + + def __init__(self, Pm=None, Parallel=False): + self.Pm = Pm # 表示染色体上变异算子所发生作用的最小片段发生变异的概率 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, Encoding, OldChrom, FieldDR, *args): # 执行变异 + return mutbin(Encoding, OldChrom, Pm=self.Pm, Parallel=self.Parallel) + + def getHelp(self): # 查看内核中的变异算子的API文档 + help(mutbin) diff --git a/geatpy/operators/mutation/Mutde.py b/geatpy/operators/mutation/Mutde.py new file mode 100644 index 00000000..d1497124 --- /dev/null +++ b/geatpy/operators/mutation/Mutde.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +from geatpy.core.mutde import mutde + +from geatpy.operators.mutation.Mutation import Mutation + + +class Mutde(Mutation): + """ + Mutde - class : 一个用于调用内核中的变异函数mutde(差分变异)的变异算子类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(mutde)查看各参数的详细含义及用法。 + + """ + + def __init__(self, F=0.5, FixType=1, Parallel=False): + self.F = F # 差分变异缩放因子 + self.FixType = FixType # 表示采用哪种方式来修复超出边界的染色体元素,可取值1,2,3,4,详细含义见help()帮助文档 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, Encoding, OldChrom, FieldDR, *args): # 执行变异 + if len(args) != 0: + XrList = args[0] + else: + XrList = None + return mutde(Encoding, OldChrom, FieldDR, XrList, self.F, self.FixType, Parallel=self.Parallel) + + def getHelp(self): # 查看内核中的变异算子的API文档 + help(mutde) diff --git a/geatpy/operators/mutation/Mutgau.py b/geatpy/operators/mutation/Mutgau.py new file mode 100644 index 00000000..ed75ff37 --- /dev/null +++ b/geatpy/operators/mutation/Mutgau.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from geatpy.core.mutgau import mutgau + +from geatpy.operators.mutation.Mutation import Mutation + + +class Mutgau(Mutation): + """ + Mutgau - class : 一个用于调用内核中的变异函数mutgau(高斯变异)的变异算子类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(mutgau)查看各参数的详细含义及用法。 + + """ + + def __init__(self, Pm=None, Sigma3=False, Middle=False, FixType=1, Parallel=False): + self.Pm = Pm # 表示染色体上变异算子所发生作用的最小片段发生变异的概率 + self.Sigma3 = Sigma3 # 表示3倍的高斯变异的标准差 + self.Middle = Middle # 表示变异中心是否为搜索域的中央 + self.FixType = FixType # 表示采用哪种方式来修复超出边界的染色体元素,可取值1,2,3,4,详细含义见help()帮助文档 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, Encoding, OldChrom, FieldDR, *args): # 执行变异 + return mutgau(Encoding, OldChrom, FieldDR, self.Pm, self.Sigma3, self.Middle, self.FixType, self.Parallel) + + def getHelp(self): # 查看内核中的变异算子的API文档 + help(mutgau) diff --git a/geatpy/operators/mutation/Mutinv.py b/geatpy/operators/mutation/Mutinv.py new file mode 100644 index 00000000..6386ba76 --- /dev/null +++ b/geatpy/operators/mutation/Mutinv.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from geatpy.core.mutinv import mutinv + +from geatpy.operators.mutation.Mutation import Mutation + + +class Mutinv(Mutation): + """ + Mutinv - class : 一个用于调用内核中的变异函数mutinv(染色体片段逆转变异)的变异算子类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(mutinv)查看各参数的详细含义及用法。 + + """ + + def __init__(self, Pm=None, InvertLen=None, Parallel=False): + self.Pm = Pm # 表示染色体上变异算子所发生作用的最小片段发生变异的概率 + self.InvertLen = None # 控制染色体发生反转的片段长度,当设置为None时取默认值,详见help(mutinv)帮助文档 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, Encoding, OldChrom, FieldDR, *args): # 执行变异 + return mutinv(Encoding, OldChrom, FieldDR, self.Pm, self.InvertLen, self.Parallel) + + def getHelp(self): # 查看内核中的变异算子的API文档 + help(mutinv) diff --git a/geatpy/operators/mutation/Mutmove.py b/geatpy/operators/mutation/Mutmove.py new file mode 100644 index 00000000..2d923463 --- /dev/null +++ b/geatpy/operators/mutation/Mutmove.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.mutmove import mutmove + +from geatpy.operators.mutation.Mutation import Mutation + + +class Mutmove(Mutation): + """ + Mutmove - class : 一个用于调用内核中的变异函数mutmove(染色体片段移位变异)的变异算子类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(mutmove)查看各参数的详细含义及用法。 + + """ + + def __init__(self, Pm=None, MoveLen=None, Pr=0, Parallel=False): + self.Pm = Pm # 表示染色体上变异算子所发生作用的最小片段发生变异的概率 + self.MoveLen = MoveLen # 发生移位的片段长度 + self.Pr = Pr # 表示移位片段在移位后发生逆转的概率 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, Encoding, OldChrom, FieldDR, *args): # 执行变异 + return mutmove(Encoding, OldChrom, FieldDR, self.Pm, self.MoveLen, self.Pr, self.Parallel) + + def getHelp(self): # 查看内核中的变异算子的API文档 + help(mutmove) diff --git a/geatpy/operators/mutation/Mutpolyn.py b/geatpy/operators/mutation/Mutpolyn.py new file mode 100644 index 00000000..52aec3ca --- /dev/null +++ b/geatpy/operators/mutation/Mutpolyn.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from geatpy.core.mutpolyn import mutpolyn + +from geatpy.operators.mutation.Mutation import Mutation + + +class Mutpolyn(Mutation): + """ + Mutpolyn - class : 一个用于调用内核中的变异函数mutpolyn(多项式变异)的变异算子类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(mutpolyn)查看各参数的详细含义及用法。 + """ + + def __init__(self, Pm=None, DisI=20, FixType=1, Parallel=False): + self.Pm = Pm # 表示染色体上变异算子所发生作用的最小片段发生变异的概率 + self.DisI = DisI # 多项式变异中的分布指数 + self.FixType = FixType # 表示采用哪种方式来修复超出边界的染色体元素,可取值1,2,3,4,详细含义见help()帮助文档 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, Encoding, OldChrom, FieldDR, *args): # 执行变异 + return mutpolyn(Encoding, OldChrom, FieldDR, self.Pm, self.DisI, self.FixType, self.Parallel) + + def getHelp(self): # 查看内核中的变异算子的API文档 + help(mutpolyn) diff --git a/geatpy/operators/mutation/Mutpp.py b/geatpy/operators/mutation/Mutpp.py new file mode 100644 index 00000000..c59dab21 --- /dev/null +++ b/geatpy/operators/mutation/Mutpp.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from geatpy.core.mutpp import mutpp + +from geatpy.operators.mutation.Mutation import Mutation + + +class Mutpp(Mutation): + """ + Mutpp - class : 一个用于调用内核中的变异函数mutpp(排列编码种群染色体变异)的变异算子类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(mutpp)查看各参数的详细含义及用法。 + + """ + + def __init__(self, Pm=None, MutN=1, Parallel=False): + self.Pm = Pm # 表示染色体上变异算子所发生作用的最小片段发生变异的概率 + self.MutN = MutN # 表示发生变异的染色体中有多少位元素发生变异。 + self.Parallel = Parallel # 表示是否采用并行计算,缺省或为None时默认为False + + def do(self, Encoding, OldChrom, FieldDR, *args): # 执行变异 + return mutpp(Encoding, OldChrom, FieldDR, self.Pm, self.MutN, self.Parallel) + + def getHelp(self): # 查看内核中的变异算子的API文档 + help(mutpp) diff --git a/geatpy/operators/mutation/Mutswap.py b/geatpy/operators/mutation/Mutswap.py new file mode 100644 index 00000000..129f6004 --- /dev/null +++ b/geatpy/operators/mutation/Mutswap.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +from geatpy.core.mutswap import mutswap + +from geatpy.operators.mutation.Mutation import Mutation + + +class Mutswap(Mutation): + """ + Mutswap - class : 一个用于调用内核中的变异函数mutswap(染色体两点互换变异)的变异算子类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(mutswap)查看各参数的详细含义及用法。 + + """ + + def __init__(self, Pm=None, Parallel=False): + self.Pm = Pm # 表示染色体上变异算子所发生作用的最小片段发生变异的概率 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, Encoding, OldChrom, FieldDR, *args): # 执行变异 + return mutswap(Encoding, OldChrom, FieldDR, self.Pm, self.Parallel) + + def getHelp(self): # 查看内核中的变异算子的API文档 + help(mutswap) diff --git a/geatpy/operators/mutation/Mutuni.py b/geatpy/operators/mutation/Mutuni.py new file mode 100644 index 00000000..0724939d --- /dev/null +++ b/geatpy/operators/mutation/Mutuni.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.mutuni import mutuni + +from geatpy.operators.mutation.Mutation import Mutation + + +class Mutuni(Mutation): + """ + Mutuni - class : 一个用于调用内核中的变异函数mutuni(均匀变异)的变异算子类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(mutuni)查看各参数的详细含义及用法。 + """ + + def __init__(self, Pm=None, Alpha=False, Middle=False, FixType=1, Parallel=False): + self.Pm = Pm # 表示染色体上变异算子所发生作用的最小片段发生变异的概率 + self.Alpha = Alpha # 表示均匀变异的变异半径 + self.Middle = Middle # 表示变异中心是否为搜索域的中央 + self.FixType = FixType # 表示采用哪种方式来修复超出边界的染色体元素,可取值1,2,3,4,详细含义见help()帮助文档 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, Encoding, OldChrom, FieldDR, *args): # 执行变异 + return mutuni(Encoding, OldChrom, FieldDR, self.Pm, self.Alpha, self.Middle, self.FixType, self.Parallel) + + def getHelp(self): # 查看内核中的变异算子的API文档 + help(mutuni) diff --git a/geatpy/operators/recombination/Recdis.py b/geatpy/operators/recombination/Recdis.py new file mode 100644 index 00000000..2831a457 --- /dev/null +++ b/geatpy/operators/recombination/Recdis.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.recdis import recdis + +from geatpy.operators.recombination.Recombination import Recombination + + +class Recdis(Recombination): + """ + Recdis - class : 一个用于调用内核中的函数recdis(离散重组)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(recdis)查看各参数的详细含义及用法。 + + """ + + def __init__(self, RecOpt=0.7, Half_N=False, GeneID=None, Parallel=False): + self.RecOpt = RecOpt # 发生重组的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.GeneID = GeneID # 基因ID,是一个Numpy ndarray一维数组,若设置了该参数,则该函数会对具有相同基因ID的染色体片段进行整体离散重组 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, OldChrom): # 执行内核函数 + return recdis(OldChrom, self.RecOpt, self.Half_N, self.GeneID, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(recdis) diff --git a/geatpy/operators/recombination/Recint.py b/geatpy/operators/recombination/Recint.py new file mode 100644 index 00000000..8487e599 --- /dev/null +++ b/geatpy/operators/recombination/Recint.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.recint import recint + +from geatpy.operators.recombination.Recombination import Recombination + + +class Recint(Recombination): + """ + Recint - class : 一个用于调用内核中的函数recint(中间重组)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(recint)查看各参数的详细含义及用法。 + + """ + + def __init__(self, RecOpt=0.7, Half_N=False, Alpha=None, Parallel=False): + self.RecOpt = RecOpt # 发生重组的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.Alpha = Alpha # 与中间重组里面的a有关的参数 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, OldChrom): # 执行内核函数 + return recint(OldChrom, self.RecOpt, self.Half_N, self.Alpha, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(recint) diff --git a/geatpy/operators/recombination/Reclin.py b/geatpy/operators/recombination/Reclin.py new file mode 100644 index 00000000..c1ba1753 --- /dev/null +++ b/geatpy/operators/recombination/Reclin.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.reclin import reclin + +from geatpy.operators.recombination.Recombination import Recombination + + +class Reclin(Recombination): + """ + Reclin - class : 一个用于调用内核中的函数reclin(线性重组)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(reclin)查看各参数的详细含义及用法。 + + """ + + def __init__(self, RecOpt=0.7, Half_N=False, Alpha=None, Parallel=False): + self.RecOpt = RecOpt # 发生重组的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.Alpha = Alpha # 与线性重组里面的a有关的参数 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, OldChrom): # 执行内核函数 + return reclin(OldChrom, self.RecOpt, self.Half_N, self.Alpha, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(reclin) diff --git a/geatpy/operators/recombination/Recndx.py b/geatpy/operators/recombination/Recndx.py new file mode 100644 index 00000000..7d672999 --- /dev/null +++ b/geatpy/operators/recombination/Recndx.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.recndx import recndx + +from geatpy.operators.recombination.Recombination import Recombination + + +class Recndx(Recombination): + """ + Recndx - class : 一个用于调用内核中的函数recndx(正态分布交叉)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(recndx)查看各参数的详细含义及用法。 + + """ + + def __init__(self, XOVR=0.7, Half_N=False, A=1.4826, Parallel=False): + self.XOVR = XOVR # 发生交叉的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.A = A # 一个跟交叉算子开发概率有关的参数 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, OldChrom): # 执行内核函数 + return recndx(OldChrom, self.XOVR, self.Half_N, self.A, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(recndx) diff --git a/geatpy/operators/recombination/Recombination.py b/geatpy/operators/recombination/Recombination.py new file mode 100644 index 00000000..b872d3e7 --- /dev/null +++ b/geatpy/operators/recombination/Recombination.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +class Recombination: + """ + Recombination - Interface : 重组算子接口 + 进化算法框架中的所有重组算子类都实现该接口。 + + """ + + def __init__(self): + pass + + def do(self): # 用于调用内核层的重组算子函数执行重组 + pass + + def getHelp(self): # 查看内核中的重组算子的API文档 + pass diff --git a/geatpy/operators/recombination/Recsbx.py b/geatpy/operators/recombination/Recsbx.py new file mode 100644 index 00000000..63b503a6 --- /dev/null +++ b/geatpy/operators/recombination/Recsbx.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from geatpy.core.recsbx import recsbx + +from geatpy.operators.recombination.Recombination import Recombination + + +class Recsbx(Recombination): + """ + Recsbx - class : 一个用于调用内核中的函数recsbx(模拟二进制交叉)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(recsbx)查看各参数的详细含义及用法。 + """ + + def __init__(self, XOVR=0.7, Half_N=False, n=20, Parallel=False): + self.XOVR = XOVR # 发生交叉的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.n = n # 分布指数,必须不小于0 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, OldChrom): # 执行内核函数 + return recsbx(OldChrom, self.XOVR, self.Half_N, self.n, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(recsbx) diff --git a/geatpy/operators/recombination/Xovbd.py b/geatpy/operators/recombination/Xovbd.py new file mode 100644 index 00000000..6c1fb6e7 --- /dev/null +++ b/geatpy/operators/recombination/Xovbd.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.xovbd import xovbd + +from geatpy.operators.recombination.Recombination import Recombination + + +class Xovbd(Recombination): + """ + Xovbd - class : 一个用于调用内核中的函数xovbd(二项式分布交叉)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(xovbd)查看各参数的详细含义及用法。 + + """ + + def __init__(self, XOVR=0.7, Half_N=False, GeneID=None, Parallel=False): + self.XOVR = XOVR # 发生交叉的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.GeneID = GeneID # 基因ID,是一个Numpy ndarray一维数组,若设置了该参数,则该函数会对具有相同基因ID的染色体片段进行整体交叉 + self.Parallel = Parallel # 表示是否采用并行计算,缺省或为None时默认为False + + def do(self, OldChrom): # 执行内核函数 + return xovbd(OldChrom, self.XOVR, self.Half_N, self.GeneID, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(xovbd) diff --git a/geatpy/operators/recombination/Xovdp.py b/geatpy/operators/recombination/Xovdp.py new file mode 100644 index 00000000..c956bdb2 --- /dev/null +++ b/geatpy/operators/recombination/Xovdp.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.xovdp import xovdp + +from geatpy.operators.recombination.Recombination import Recombination + + +class Xovdp(Recombination): + """ + Xovdp - class : 一个用于调用内核中的函数xovdp(两点交叉)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(xovdp)查看各参数的详细含义及用法。 + + """ + + def __init__(self, XOVR=0.7, Half_N=False, GeneID=None, Parallel=False): + self.XOVR = XOVR # 发生交叉的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.GeneID = GeneID # 基因ID,是一个Numpy ndarray一维数组,若设置了该参数,则该函数会对具有相同基因ID的染色体片段进行整体交叉 + self.Parallel = Parallel # 表示是否采用并行计算,缺省或为None时默认为False + + def do(self, OldChrom): # 执行内核函数 + return xovdp(OldChrom, self.XOVR, self.Half_N, self.GeneID, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(xovdp) diff --git a/geatpy/operators/recombination/Xovexp.py b/geatpy/operators/recombination/Xovexp.py new file mode 100644 index 00000000..02c22e76 --- /dev/null +++ b/geatpy/operators/recombination/Xovexp.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.xovexp import xovexp + +from geatpy.operators.recombination.Recombination import Recombination + + +class Xovexp(Recombination): + """ + Xovexp - class : 一个用于调用内核中的函数xovexp(指数交叉)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(xovexp)查看各参数的详细含义及用法。 + + """ + + def __init__(self, XOVR=0.7, Half_N=False, GeneID=None, Parallel=False): + self.XOVR = XOVR # 发生交叉的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.GeneID = GeneID # 基因ID,是一个Numpy ndarray一维数组,若设置了该参数,则该函数会对具有相同基因ID的染色体片段进行整体交叉 + self.Parallel = Parallel # 表示是否采用并行计算,缺省或为None时默认为False + + def do(self, OldChrom): # 执行内核函数 + return xovexp(OldChrom, self.XOVR, self.Half_N, self.GeneID, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(xovexp) diff --git a/geatpy/operators/recombination/Xovox.py b/geatpy/operators/recombination/Xovox.py new file mode 100644 index 00000000..a6e1798e --- /dev/null +++ b/geatpy/operators/recombination/Xovox.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from geatpy.core.xovox import xovox + +from geatpy.operators.recombination.Recombination import Recombination + + +class Xovox(Recombination): + """ + Xovox - class : 一个用于调用内核中的函数xovox(顺序交叉)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(xovox)查看各参数的详细含义及用法。 + + """ + + def __init__(self, XOVR=0.7, Half_N=False, Parallel=False): + self.XOVR = XOVR # 发生交叉的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, OldChrom): # 执行内核函数 + return xovox(OldChrom, self.XOVR, self.Half_N, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(xovox) diff --git a/geatpy/operators/recombination/Xovpmx.py b/geatpy/operators/recombination/Xovpmx.py new file mode 100644 index 00000000..d7e0eb4f --- /dev/null +++ b/geatpy/operators/recombination/Xovpmx.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.xovpmx import xovpmx + +from geatpy.operators.recombination.Recombination import Recombination + + +class Xovpmx(Recombination): + """ + Xovpmx - class : 一个用于调用内核中的函数xovpmx(部分匹配交叉)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(xovpmx)查看各参数的详细含义及用法。 + + """ + + def __init__(self, XOVR=0.7, Half_N=False, Method=1, Parallel=False): + self.XOVR = XOVR # 发生交叉的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.Method = Method # 表示部分匹配交叉采用什么方法进行交叉。 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, OldChrom): # 执行内核函数 + return xovpmx(OldChrom, self.XOVR, self.Half_N, self.Method, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(xovpmx) diff --git a/geatpy/operators/recombination/Xovsec.py b/geatpy/operators/recombination/Xovsec.py new file mode 100644 index 00000000..4c91696d --- /dev/null +++ b/geatpy/operators/recombination/Xovsec.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.xovsec import xovsec + +from geatpy.operators.recombination.Recombination import Recombination + + +class Xovsec(Recombination): + """ + Xovsec - class : 一个用于调用内核中的函数xovsec(洗牌指数交叉)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(xovsec)查看各参数的详细含义及用法。 + + """ + + def __init__(self, XOVR=0.7, Half_N=False, GeneID=None, Parallel=False): + self.XOVR = XOVR # 发生交叉的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.GeneID = GeneID # 基因ID,是一个Numpy ndarray一维数组,若设置了该参数,则该函数会对具有相同基因ID的染色体片段进行整体交叉。 + self.Parallel = Parallel # 表示是否采用并行计算,缺省时默认为False + + def do(self, OldChrom): # 执行内核函数 + return xovsec(OldChrom, self.XOVR, self.Half_N, self.GeneID, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(xovsec) diff --git a/geatpy/operators/recombination/Xovsh.py b/geatpy/operators/recombination/Xovsh.py new file mode 100644 index 00000000..7683a881 --- /dev/null +++ b/geatpy/operators/recombination/Xovsh.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.xovsh import xovsh + +from geatpy.operators.recombination.Recombination import Recombination + + +class Xovsh(Recombination): + """ + Xovsh - class : 一个用于调用内核中的函数xovsh(洗牌交叉)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(xovsh)查看各参数的详细含义及用法。 + + """ + + def __init__(self, XOVR=0.7, Half_N=False, GeneID=None, Parallel=False): + self.XOVR = XOVR # 发生交叉的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.GeneID = GeneID # 基因ID,是一个Numpy ndarray一维数组,若设置了该参数,则该函数会对具有相同基因ID的染色体片段进行整体交叉 + self.Parallel = Parallel # 表示是否采用并行计算,缺省或为None时默认为False + + def do(self, OldChrom): # 执行内核函数 + return xovsh(OldChrom, self.XOVR, self.Half_N, self.GeneID, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(xovsh) diff --git a/geatpy/operators/recombination/Xovsp.py b/geatpy/operators/recombination/Xovsp.py new file mode 100644 index 00000000..aa41b85a --- /dev/null +++ b/geatpy/operators/recombination/Xovsp.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.xovsp import xovsp + +from geatpy.operators.recombination.Recombination import Recombination + + +class Xovsp(Recombination): + """ + Xovsp - class : 一个用于调用内核中的函数xovsp(单点交叉)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(xovsp)查看各参数的详细含义及用法。 + + """ + + def __init__(self, XOVR=0.7, Half_N=False, GeneID=None, Parallel=False): + self.XOVR = XOVR # 发生交叉的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.GeneID = GeneID # 基因ID,是一个Numpy ndarray一维数组,若设置了该参数,则该函数会对具有相同基因ID的染色体片段进行整体交叉 + self.Parallel = Parallel # 表示是否采用并行计算,缺省或为None时默认为False + + def do(self, OldChrom): # 执行内核函数 + return xovsp(OldChrom, self.XOVR, self.Half_N, self.GeneID, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(xovsp) diff --git a/geatpy/operators/recombination/Xovud.py b/geatpy/operators/recombination/Xovud.py new file mode 100644 index 00000000..78626470 --- /dev/null +++ b/geatpy/operators/recombination/Xovud.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from geatpy.core.xovud import xovud + +from geatpy.operators.recombination.Recombination import Recombination + + +class Xovud(Recombination): + """ + Xovud - class : 一个用于调用内核中的函数xovud(均匀分布交叉)的类, + 该类的各成员属性与内核中的对应函数的同名参数含义一致, + 可利用help(xovud)查看各参数的详细含义及用法。 + + """ + + def __init__(self, XOVR=0.7, Half_N=False, GeneID=None, Parallel=False): + self.XOVR = XOVR # 发生交叉的概率 + self.Half_N = Half_N # 该参数是旧版的输入参数Half的升级版,用于控制交配方式 + self.GeneID = GeneID # 基因ID,是一个Numpy ndarray一维数组,若设置了该参数,则该函数会对具有相同基因ID的染色体片段进行整体交叉 + self.Parallel = Parallel # 表示是否采用并行计算,缺省或为None时默认为False + + def do(self, OldChrom): # 执行内核函数 + return xovud(OldChrom, self.XOVR, self.Half_N, self.GeneID, self.Parallel) + + def getHelp(self): # 查看内核中的重组算子的API文档 + help(xovud) diff --git a/geatpy/optimize.py b/geatpy/optimize.py new file mode 100644 index 00000000..ab8dad48 --- /dev/null +++ b/geatpy/optimize.py @@ -0,0 +1,198 @@ +# -*- coding: utf-8 -*- + +import os +import time +import numpy as np +import geatpy as ea + + +def optimize(algorithm, + seed=None, + prophet=None, + verbose=None, + drawing=None, + outputMsg=True, + drawLog=True, + saveFlag=True, + dirName=None, + **kwargs): + + """ + + 描述: 该函数用于快速部署问题和算法,然后对问题进行求解。 + + 输入参数: + algorithm : - 算法类的引用。 + + seed : int - 随机数种子。 + + prophet : / Numpy ndarray - 先验知识。可以是种群对象, + 也可以是一组或多组决策变量组成的矩阵(矩阵的每一行对应一组决策变量)。 + + verbose : bool - 控制是否在输入输出流中打印输出日志信息。 + 该参数将被传递给algorithm.verbose。 + 如果algorithm已设置了该参数的值,则调用optimize函数时,可以不传入该参数。 + + drawing : int - 算法类控制绘图方式的参数, + 0表示不绘图; + 1表示绘制最终结果图; + 2表示实时绘制目标空间动态图; + 3表示实时绘制决策空间动态图。 + 该参数将被传递给algorithm.drawing。 + 如果algorithm已设置了该参数的值,则调用optimize函数时,可以不传入该参数。 + + outputMsg : bool - 控制是否输出结果以及相关指标信息。 + + drawLog : bool - 用于控制是否根据日志绘制迭代变化图像。 + + saveFlag : bool - 控制是否保存结果。 + + dirName : str - 文件保存的路径。当缺省或为None时,默认保存在当前工作目录的'result of job xxxx-xx-xx xxh-xxm-xxs'文件夹下。 + + 输出参数: + result : dict - 一个保存着结果的字典。内容为: + {'success': True or False, # 表示算法是否成功求解。 + 'stopMsg': xxx, # 存储着算法停止原因的字符串。 + 'optPop': xxx, # 存储着算法求解结果的种群对象。如果无可行解,则optPop.sizes=0。optPop.Phen为决策变量矩阵,optPop.ObjV为目标函数值矩阵。 + 'lastPop': xxx, # 算法进化结束后的最后一代种群对象。 + 'Vars': xxx, # 等于optPop.Phen,此处即最优解。若无可行解,则Vars=None。 + 'ObjV': xxx, # 等于optPop.ObjV,此处即最优解对应的目标函数值。若无可行解,ObjV=None。 + 'CV': xxx, # 等于optPop.CV,此处即最优解对应的违反约束程度矩阵。若无可行解,CV=None。 + 'startTime': xxx, # 程序执行开始时间。 + 'endTime': xxx, # 程序执行结束时间。 + 'executeTime': xxx, # 算法所用时间。 + 'nfev': xxx, # 算法评价次数 + 'gd': xxx, # (多目标优化且给定了理论最优解时才有) GD指标值。 + 'igd': xxx, # (多目标优化且给定了理论最优解时才有) IGD指标值。 + 'hv': xxx, # (多目标优化才有) HV指标值。 + 'spacing': xxx} # (多目标优化才有) Spacing指标值。 + + """ + + startTime = time.strftime("%Y-%m-%d %Hh-%Mm-%Ss", time.localtime()) # 记录程序开始时间 + if dirName is None: + dirName = 'result of job ' + str(startTime) + if dirName != '': + dirName += '/' + if saveFlag: + if dirName != '': + if not os.path.exists(dirName): + os.makedirs(dirName) + algorithm.dirName = dirName # 只有在设置了saveFlag=True时,才让algorithm的dirName同步成一致。 + if seed is not None: + np.random.seed(seed) + # 处理先验知识 + prophetPop = None + if prophet is not None: + if type(prophet) == np.ndarray: + if prophet.ndim != 2: + prophet = np.atleast_2d(prophet) + if algorithm.population.Encoding == 'RI' or algorithm.population.Encoding == 'P': + prophetPop = ea.Population(algorithm.population.Encoding, algorithm.population.Field, 1, prophet) + elif algorithm.population.Encoding == 'BG': + prophetPop = ea.Population(algorithm.population.Encoding, algorithm.population.Field, 1, ea.ri2bs(prophet, algorithm.population.Field)) + else: + raise RuntimeError('error in optimize: The encoding should be ''RI'', ''P'' or ''BG''. (种群编码必须为''RI'', ''P'' 或 ''BG''。)') + elif type(prophet) == ea.Population: + prophetPop = prophet.copy() + else: + raise RuntimeError('error in optimize: The type of prophet must be Numpy ndarray or Population. (prophet的类型必须为Numpy ndarray数组或种群类。)') + # 参数设置 + algorithm.verbose = verbose if verbose is not None else algorithm.verbose + algorithm.drawing = drawing if drawing is not None else algorithm.drawing + # 开始求解 + [optPop, lastPop] = algorithm.run(prophetPop) + # 生成结果 + result = {} + result['success'] = True if optPop.sizes > 0 else False + result['stopMsg'] = algorithm.stopMsg + result['optPop'] = optPop + result['lastPop'] = lastPop + result['Vars'] = optPop.Phen if optPop.sizes > 0 else None + result['ObjV'] = optPop.ObjV if optPop.sizes > 0 else None + result['CV'] = optPop.CV if optPop.sizes > 0 else None + result['executeTime'] = algorithm.passTime + result['nfev'] = algorithm.evalsNum + # 计算指标 + if algorithm.problem.M > 1 and optPop.sizes != 0: + if algorithm.problem.ReferObjV is not None: + GD = ea.indicator.GD(optPop.ObjV, algorithm.problem.ReferObjV) + result['gd'] = GD + IGD = ea.indicator.IGD(optPop.ObjV, algorithm.problem.ReferObjV) + result['igd'] = IGD + HV = ea.indicator.HV(optPop.ObjV) + result['hv'] = HV + Spacing = ea.indicator.Spacing(optPop.ObjV) + result['spacing'] = Spacing + # 输出结果 + if outputMsg: + print('Execution time: %s s' % algorithm.passTime) + print('Evaluation number: %s' % algorithm.evalsNum) + if algorithm.problem.M == 1: + if optPop.sizes != 0: + print('The best objective value is: %s' % optPop.ObjV[0][0]) + print('The best variables are: ') + for i in range(optPop.Phen.shape[1]): + print(optPop.Phen[0, i], end='\t') + print() + else: + print('Optimization fail: Could not find any feasible solution.') + else: + if optPop.sizes != 0: + print('The number of non-dominated solutions is: %d' % optPop.sizes) + if optPop.sizes != 0: + if algorithm.problem.ReferObjV is not None: + print('gd: %.5f' % result['gd']) + print('igd: %.5f' % result['igd']) + print('hv: %.5f' % result['hv']) + print('spacing: %.5f' % result['spacing']) + else: + print('Optimization fail: Could not find any feasible solution.') + # 根据算法执行日志绘制迭代变化曲线 + if drawLog and algorithm.log is not None: + if algorithm.problem.M == 1: + trace = np.array(algorithm.log['f_opt']) + plotter = ea.ParCoordPlotter(len(trace), grid=True, legend=True, title='Best Objective Value Trace Plot', coordLabels=['Generation Number', 'Value'], saveName=dirName + 'Best Objective Value Trace Plot' if saveFlag else None) + plotter.add(trace, color='blue', label='Best-found objective value') + plotter.draw() + plotter.show() + else: + drawNameList = ['GD', 'IGD', 'HV', 'Spacing'] + for drawName in drawNameList: + trace = np.array(algorithm.log[drawName.lower()]) + if trace[0] is not None: + plotter = ea.ParCoordPlotter(len(trace), grid=True, legend=True, title=drawName + ' Trace Plot', coordLabels=['Generation Number', 'Value'], saveName=dirName + drawName + ' Trace Plot' if saveFlag else None) + plotter.add(trace, color='blue', label=drawName) + plotter.draw() + plotter.show() + endTime = time.strftime("%Y-%m-%d %Hh-%Mm-%Ss", time.localtime()) # 记录程序结束时间 + result['startTime'] = startTime + result['endTime'] = endTime + # 保存结果 + if saveFlag: + optPop.save(dirName+'optPop') + # 记录问题 + with open(dirName + 'problem info.txt', 'w') as file: + file.write(str(algorithm.problem)) + # 记录种群参数 + popInfo = {} + if isinstance(algorithm.population, ea.Population): + popInfo['Population Info'] = algorithm.population.getInfo() + elif isinstance(algorithm.population, list): + infoList = [] + for pop in algorithm.population: + infoList.append(pop.getInfo()) + popInfo['Population Info'] = infoList + with open(dirName + 'population info.txt', 'w') as file: + file.write(str(popInfo)) + # 记录算法参数 + with open(dirName + 'algorithm info.txt', 'w') as file: + file.write(str(algorithm)) + # 记录结果 + resultInfo = result.copy() + resultInfo.pop('optPop') + resultInfo.pop('lastPop') + with open(dirName + 'result info.txt', 'w') as file: + file.write(str(resultInfo)) + + return result diff --git a/geatpy/testbed/moea_test/main.py b/geatpy/testbed/moea_test/main.py new file mode 100644 index 00000000..9f987dd9 --- /dev/null +++ b/geatpy/testbed/moea_test/main.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +import numpy as np +import geatpy as ea # import geatpy + +if __name__ == '__main__': + problem = ea.benchmarks.DTLZ1() # 生成问题对象 + # 构建算法 + algorithm = ea.moea_NSGA3_templet(problem, + ea.Population(Encoding='RI', NIND=100), + MAXGEN=500, # 最大进化代数。 + logTras=1) # 表示每隔多少代记录一次日志信息,0表示不记录。 + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=True, saveFlag=True, dirName='result') + print(res) diff --git a/geatpy/testbed/moea_test/result/GD Trace Plot.svg b/geatpy/testbed/moea_test/result/GD Trace Plot.svg new file mode 100644 index 00000000..924463b3 --- /dev/null +++ b/geatpy/testbed/moea_test/result/GD Trace Plot.svg @@ -0,0 +1,954 @@ + + + + + + + + + 2022-01-09T15:27:49.347336 + image/svg+xml + + + Matplotlib v3.3.4, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geatpy/testbed/moea_test/result/HV Trace Plot.svg b/geatpy/testbed/moea_test/result/HV Trace Plot.svg new file mode 100644 index 00000000..0f68da47 --- /dev/null +++ b/geatpy/testbed/moea_test/result/HV Trace Plot.svg @@ -0,0 +1,1303 @@ + + + + + + + + + 2022-01-09T15:27:50.979104 + image/svg+xml + + + Matplotlib v3.3.4, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geatpy/testbed/moea_test/result/IGD Trace Plot.svg b/geatpy/testbed/moea_test/result/IGD Trace Plot.svg new file mode 100644 index 00000000..6857172e --- /dev/null +++ b/geatpy/testbed/moea_test/result/IGD Trace Plot.svg @@ -0,0 +1,1096 @@ + + + + + + + + + 2022-01-09T15:27:50.272813 + image/svg+xml + + + Matplotlib v3.3.4, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geatpy/testbed/moea_test/result/Pareto Front Plot.svg b/geatpy/testbed/moea_test/result/Pareto Front Plot.svg new file mode 100644 index 00000000..85f90e15 --- /dev/null +++ b/geatpy/testbed/moea_test/result/Pareto Front Plot.svg @@ -0,0 +1,10953 @@ + + + + + + + + + 2022-01-09T15:27:41.988847 + image/svg+xml + + + Matplotlib v3.3.4, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geatpy/testbed/moea_test/result/Spacing Trace Plot.svg b/geatpy/testbed/moea_test/result/Spacing Trace Plot.svg new file mode 100644 index 00000000..8ab18bce --- /dev/null +++ b/geatpy/testbed/moea_test/result/Spacing Trace Plot.svg @@ -0,0 +1,1080 @@ + + + + + + + + + 2022-01-09T15:27:51.685067 + image/svg+xml + + + Matplotlib v3.3.4, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geatpy/testbed/moea_test/result/algorithm info.txt b/geatpy/testbed/moea_test/result/algorithm info.txt new file mode 100644 index 00000000..ac9e786f --- /dev/null +++ b/geatpy/testbed/moea_test/result/algorithm info.txt @@ -0,0 +1 @@ +{'Algorithm Name': 'NSGA3', 'Algorithm MAXGEN': 500, 'Algorithm MAXTIME': None, 'Algorithm MAXEVALS': None} \ No newline at end of file diff --git a/geatpy/testbed/moea_test/result/optPop/Chrom.csv b/geatpy/testbed/moea_test/result/optPop/Chrom.csv new file mode 100644 index 00000000..79eb4408 --- /dev/null +++ b/geatpy/testbed/moea_test/result/optPop/Chrom.csv @@ -0,0 +1,91 @@ +6.666521817157936569e-01,5.003385209212026785e-01,5.000155976086523291e-01,4.999254566407436706e-01,4.999622437641073613e-01,4.999985059175477975e-01,4.999914274660773872e-01 +9.165904952656122040e-01,9.093171004119831036e-01,5.000005182050029084e-01,4.999258593651764726e-01,4.999649622979362995e-01,4.999956762407744004e-01,4.999926171618832571e-01 +8.334540132380767741e-01,2.990579560339728382e-01,5.000009229351349838e-01,4.999251552034714718e-01,4.999641250575779239e-01,4.999877531562089694e-01,4.999945716762289050e-01 +9.165904044927728478e-01,2.722816778408999050e-01,5.000153564771155912e-01,4.999253290088666035e-01,4.999624038810274729e-01,4.999973055466959693e-01,4.999923332165950862e-01 +5.833997198962594943e-01,8.569949580128757294e-01,5.000016581983364183e-01,4.999251640842476974e-01,4.999599994955756244e-01,4.999947243121132257e-01,4.999949867954927574e-01 +5.000406484827695230e-01,6.667208967675466447e-01,5.000161008174319743e-01,4.999253700411117052e-01,4.999619620501553618e-01,4.999971151173012718e-01,4.999922706456549348e-01 +1.000000000000000000e+00,1.670115710754945804e-01,5.000147317114219669e-01,4.999251986979773577e-01,4.999623540000486255e-01,4.999887266626348303e-01,4.999944437482940485e-01 +2.501146922413525764e-01,6.654988542017026276e-01,5.000010994118628815e-01,4.999251546749516883e-01,4.999625047534846933e-01,4.999881068634477455e-01,4.999852438783697339e-01 +9.165941973502171880e-01,7.273823805938703924e-01,5.000023569503266874e-01,4.999253221800759039e-01,4.999621021614066296e-01,4.999995088984287572e-01,4.999898546933529975e-01 +5.000423745731393810e-01,1.000000000000000000e+00,5.000154457189210921e-01,4.999254500362096398e-01,4.999622008815011176e-01,4.999970549933292485e-01,4.999879769501833771e-01 +4.998112213212638211e-01,3.336040098024675160e-01,5.000031829590315668e-01,4.999258573179516385e-01,4.999527812296553630e-01,4.999996403948985257e-01,4.999947460444980618e-01 +9.167304751555592768e-01,5.453623870326147483e-01,5.000153720873947716e-01,4.999250618847799754e-01,4.999625638138099903e-01,5.000008240865521092e-01,4.999911732756621152e-01 +4.167688334010672402e-01,7.995980812331622278e-01,5.000145128499600133e-01,4.999254498236548883e-01,4.999622008815011176e-01,4.999993275513008872e-01,4.999877835635752055e-01 +9.165904952656122040e-01,1.814736095585842701e-01,5.000006834515426934e-01,4.999254610851592284e-01,4.999622106648524689e-01,4.999994710395832542e-01,4.999922249806409980e-01 +2.501257559416535381e-01,3.333639309979022358e-01,5.000158088956364599e-01,4.999250389037960818e-01,4.999623580223743202e-01,4.999980935943359461e-01,4.999982936026340363e-01 +9.167304751555592768e-01,0.000000000000000000e+00,5.000147859855524901e-01,4.999254555614350282e-01,4.999625671927003245e-01,5.000008268155462510e-01,4.999926873850131792e-01 +7.500232333885776814e-01,0.000000000000000000e+00,5.000012447649383462e-01,4.999254585793255212e-01,4.999622777604249002e-01,4.999974642077766318e-01,4.999927496340026423e-01 +9.168894340191203751e-01,4.544600151603172544e-01,5.000007122266088011e-01,4.999257985844491881e-01,4.999620780367606820e-01,4.999957767706834644e-01,4.999916127414422706e-01 +4.999621104528046978e-01,0.000000000000000000e+00,5.000153195515711912e-01,4.999254606022717762e-01,4.999614585666752875e-01,4.999995139744885519e-01,4.999983809839708693e-01 +5.836908994781424553e-01,7.141988674832346895e-01,5.000216337308220904e-01,4.999249657060774732e-01,4.999625019835845507e-01,4.999995268721245112e-01,4.999302133466208553e-01 +1.669649802432623675e-01,0.000000000000000000e+00,5.000019604129687378e-01,4.999251857320318182e-01,4.999618118545248735e-01,4.999957648521516917e-01,4.999944793361538187e-01 +6.666521817157936569e-01,1.000000000000000000e+00,5.000157643731512058e-01,4.999258639951733585e-01,4.999622176695360798e-01,4.999996376097707307e-01,4.999947409699517231e-01 +7.500188377951789720e-01,5.548743492758080320e-01,5.000009367961369966e-01,4.999252450031691497e-01,4.999637024569624777e-01,4.999890443022331765e-01,4.999954848074802394e-01 +3.331213703114027647e-01,5.002745233104348710e-01,5.000157475968386445e-01,4.999258594354926699e-01,4.999621840512047943e-01,4.999998081693705076e-01,4.999949994869145042e-01 +8.325210637352344067e-02,1.000000000000000000e+00,5.000001687621995483e-01,4.999253174274492784e-01,4.999641039125470865e-01,4.999991438673976329e-01,4.999924791159005011e-01 +6.666521817157936569e-01,3.754334239200317613e-01,5.000158079790941734e-01,4.999254559850525581e-01,4.999637328578839801e-01,4.999955093567707287e-01,4.999981385692997549e-01 +1.000000000000000000e+00,4.171628200912571027e-01,5.000021735884749852e-01,4.999251581077196471e-01,4.999624742221071561e-01,5.000008906326769420e-01,4.999911483716155680e-01 +1.000000000000000000e+00,8.325668675908299843e-01,5.000145208336026492e-01,4.999254640993034959e-01,4.999625199118587493e-01,4.999993296634905882e-01,4.999944561911608409e-01 +1.000000000000000000e+00,5.832336457703192201e-01,5.000153708314468703e-01,4.999254267796140461e-01,4.999627422882808037e-01,4.999874088993701560e-01,4.999942450744292999e-01 +8.366135294655749344e-02,0.000000000000000000e+00,5.000007563984431025e-01,4.999253350785347050e-01,4.999642127396116131e-01,4.999973371924003596e-01,4.999919132028110003e-01 +7.500190342612733652e-01,1.000000000000000000e+00,5.000146449266223980e-01,4.999252592814996121e-01,4.999637245115276518e-01,4.999889220350093311e-01,4.999956067371195134e-01 +6.666485429283669495e-01,7.498584547223740016e-01,5.000155441415435886e-01,4.999254265374694639e-01,4.999639383026955319e-01,4.999957994367035252e-01,4.999935166472639914e-01 +8.329889159136872889e-01,7.003810717514001860e-01,5.000152686170010741e-01,4.999258105191163870e-01,4.999644099064907143e-01,4.999985136336567160e-01,4.999947315706519957e-01 +7.499468229491179638e-01,3.336036949557587006e-01,5.000192488177133132e-01,4.999255110518099898e-01,4.999620996560970032e-01,4.999973601956143598e-01,4.999945831744861402e-01 +6.666521817157936569e-01,0.000000000000000000e+00,5.000018791195128820e-01,4.999254361987907069e-01,4.999624871379961810e-01,4.999996702091596967e-01,4.999977598489447339e-01 +5.834342966730177160e-01,4.285822664360898759e-01,5.000162154488185795e-01,4.999254590009026278e-01,4.999625736262838238e-01,4.999992057791268762e-01,4.999941053597472540e-01 +1.000000000000000000e+00,7.498603240110413015e-01,5.000020028235855341e-01,4.999252813172321286e-01,4.999637362472829083e-01,4.999986379462496577e-01,4.999982023983590151e-01 +9.165970297296509584e-01,9.118611964600907560e-02,5.000160324270540579e-01,4.999254409976764957e-01,4.999622093911632592e-01,4.999952851409971699e-01,4.999922567370908566e-01 +4.167202041006395907e-01,2.001507650414072470e-01,5.000194389478161971e-01,4.999258423991971290e-01,4.999624567522816809e-01,4.999997688575816279e-01,4.999789346991965200e-01 +7.502249847101793989e-01,8.880007994686079931e-01,5.000146740594493266e-01,4.999255138583416080e-01,4.999619778069467335e-01,4.999974348075157948e-01,4.999906863011567282e-01 +5.833717467863014372e-01,0.000000000000000000e+00,5.000007175687630756e-01,4.999259141586677169e-01,4.999618858658060327e-01,4.999993157468871630e-01,4.999890802898513953e-01 +5.828888858545107077e-01,5.714727324349682114e-01,5.000154640760400282e-01,4.999249908413825327e-01,4.999645454136277811e-01,4.999880792955908593e-01,4.999927194357050020e-01 +1.000000000000000000e+00,6.668449986667467355e-01,5.000153342908464360e-01,4.999253536382410879e-01,4.999550322676883374e-01,4.999995527246569593e-01,4.999923238666068026e-01 +1.000000000000000000e+00,3.332372674013548419e-01,5.000015694085367945e-01,4.999258707746380703e-01,4.999622767481868291e-01,5.000010497640497986e-01,4.999940994500656211e-01 +1.673571497938979857e-01,9.973924592332488182e-01,5.000152225890299729e-01,4.999252653298293936e-01,4.999623629991608031e-01,4.999973005017973593e-01,4.999918874911150612e-01 +6.667927264689560429e-01,8.737469816620480056e-01,5.000004864649200131e-01,4.999258593517594274e-01,4.999620168478703941e-01,4.999957593458898009e-01,4.999910793723499336e-01 +8.332157985396368982e-01,8.006609475273407384e-01,5.000149506552029610e-01,4.999250955124325824e-01,4.999623598445263051e-01,4.999947670319364601e-01,4.999973952301399738e-01 +0.000000000000000000e+00,5.048713158640587562e-01,5.000008519529379747e-01,4.999258497695194814e-01,4.999636747071767306e-01,4.999956133084754728e-01,4.999923713775988321e-01 +4.167688334010672402e-01,5.509290640018068755e-05,5.000008814478881236e-01,4.999258108281456336e-01,4.999623347263975059e-01,4.999968185444422231e-01,4.999926060213973900e-01 +8.329841242131299506e-01,1.995703375431087390e-01,5.000153007320111698e-01,4.999258683067434594e-01,4.999616189567526181e-01,4.999941077419183255e-01,4.999919844734035945e-01 +5.833996040717264187e-01,2.865785080124877426e-01,5.000157120312426207e-01,4.999252513349145555e-01,4.999624288535384764e-01,4.999996614174954668e-01,4.999940980802466406e-01 +2.501257559416535381e-01,4.922714495016033281e-04,5.000164513438303260e-01,4.999258601590323980e-01,4.999624352926168580e-01,4.999980799154901678e-01,4.999982936026340363e-01 +4.167688334010672957e-01,1.000000000000000000e+00,5.000153041562641620e-01,4.999254276096329330e-01,4.999625195845062708e-01,4.999997207994521520e-01,4.999899597869161272e-01 +5.833997220786112381e-01,1.000000000000000000e+00,5.000158736835522699e-01,4.999254580264284598e-01,4.999623539817310558e-01,4.999975423293968047e-01,4.999954713493607872e-01 +8.336372604785232676e-01,4.998350814906284967e-01,5.000158767286787542e-01,4.999254568258753029e-01,4.999637277067756624e-01,4.999996923626172096e-01,4.999955407827987308e-01 +7.501651965968233471e-01,7.776574418326690497e-01,5.000002547870052716e-01,4.999242677991532213e-01,4.999637018182919723e-01,4.999991319718240512e-01,4.999924531523152194e-01 +8.333448396573407413e-01,9.999999999999998890e-01,5.000152178332362141e-01,4.999254262064684595e-01,4.999625010452871110e-01,4.999984610741511903e-01,4.999977277735668801e-01 +7.501672695707695127e-01,6.667955747811701306e-01,5.000153323015430473e-01,4.999253591995818091e-01,4.999550171452186165e-01,4.999994777083815456e-01,4.999943982143489341e-01 +9.164297019251742560e-01,8.181663534755400091e-01,5.000007215815970296e-01,4.999258936937894804e-01,4.999625276386586714e-01,4.999996200448869055e-01,4.999943427249687877e-01 +3.331833711021365829e-01,7.496859379186606720e-01,5.000147744191556498e-01,4.999253216308119918e-01,4.999621590449586650e-01,4.999996914562866990e-01,4.999947727748220716e-01 +1.666378830482334594e-01,4.997253573517500547e-01,4.999999643290730100e-01,4.999254550345531567e-01,4.999619884688814575e-01,4.999954872793758165e-01,4.999940952115848325e-01 +2.501146922413525764e-01,1.000000000000000000e+00,5.000006667198589883e-01,4.999258382817939328e-01,4.999625119481988511e-01,4.999985628258909465e-01,4.999947214922292882e-01 +8.333379533904780034e-01,0.000000000000000000e+00,4.999993653283330564e-01,4.999251729731306049e-01,4.999640487050548976e-01,4.999963942478575230e-01,4.999946652178555717e-01 +8.331360042780687758e-01,5.994077530455627079e-01,5.000152781969997573e-01,4.999258734363629664e-01,4.999608440324382896e-01,4.999995085618935131e-01,4.999919745385490444e-01 +6.666521817157936569e-01,1.245807292135735905e-01,5.000148233032881695e-01,4.999251403056897969e-01,4.999641590241363232e-01,5.000010432168903174e-01,4.999913827544471556e-01 +1.000000000000000000e+00,0.000000000000000000e+00,4.999997234281410852e-01,4.999258622056299006e-01,4.999648438574373355e-01,4.999995199877448337e-01,4.999926029117323645e-01 +7.502245685624484572e-01,1.108292742816016363e-01,5.000030787925824338e-01,4.999258315377029249e-01,4.999638024708535355e-01,4.999995459407410303e-01,4.999925760158367982e-01 +1.000000000000000000e+00,9.170994755600196946e-01,5.000153647387159950e-01,4.999258396455958930e-01,4.999624446521994670e-01,4.999997864869688002e-01,4.999939115383532640e-01 +4.999621104528046978e-01,8.325668675908299843e-01,5.000020028834052388e-01,4.999254555784045095e-01,4.999614847188086353e-01,4.999997419468910631e-01,4.999983244604049304e-01 +4.168179319091955826e-01,4.004863876823347435e-01,5.000154375480692082e-01,4.999246127635434966e-01,4.999641904948871063e-01,4.999977588033139853e-01,4.999977519530126591e-01 +6.662417175871059305e-01,6.253831916724816864e-01,5.000174955625174000e-01,4.999254023506549127e-01,4.999621457710417549e-01,4.999999634663772063e-01,4.999933585384893631e-01 +3.331833711021365829e-01,2.485256123034872422e-01,5.000014281800327920e-01,4.999258510646908404e-01,4.999621630692144825e-01,4.999994244607754434e-01,4.999949859314206657e-01 +6.666521817157936569e-01,2.497948796462338694e-01,5.000153651829364332e-01,4.999254463051129305e-01,4.999637330362700083e-01,4.999954562553014514e-01,4.999981385692997549e-01 +9.999999999999998890e-01,8.325827177718736483e-02,5.000189021995580241e-01,4.999258451288773886e-01,4.999638142284095754e-01,4.999983665515622122e-01,4.999977035259628999e-01 +8.333495267027075659e-01,3.998679420689549291e-01,5.000010239909378207e-01,4.999252457377401093e-01,4.999626818592660116e-01,4.999996528118045847e-01,4.999940818200349635e-01 +1.000000000000000000e+00,5.001590851542732086e-01,5.000000039751753000e-01,4.999252248997894665e-01,4.999619728771130811e-01,4.999974178482651799e-01,4.999906998746183051e-01 +9.167295291381503120e-01,6.363165337610247052e-01,5.000153055147195102e-01,4.999250662224494213e-01,4.999625337128030256e-01,4.999997112387972176e-01,4.999948068835808335e-01 +8.332261681965873468e-01,8.992918806692553613e-01,5.000013892722610098e-01,4.999258569102607574e-01,4.999642751909254001e-01,4.999961537634967090e-01,4.999982961579148011e-01 +3.331833711021365829e-01,0.000000000000000000e+00,5.000006615364909202e-01,4.999253273767345074e-01,4.999621630692144825e-01,4.999997453910175471e-01,4.999945512263328506e-01 +4.167259476889265679e-01,6.007933328785060034e-01,5.000007760868117046e-01,4.999252466405242346e-01,4.999624463273106834e-01,5.000008870231502645e-01,4.999985259507482294e-01 +1.000000000000000000e+00,1.000000000000000000e+00,4.999985675567834020e-01,4.999258313069276927e-01,4.999645361902688157e-01,4.999991879755838475e-01,4.999944122482678499e-01 +4.999621104528046978e-01,1.664630203044252799e-01,5.000014593261378204e-01,4.999258969837428457e-01,4.999614710538987650e-01,4.999978640894338078e-01,4.999939277112206981e-01 +5.005631331457106592e-01,5.000747394899337506e-01,5.000155699194225312e-01,4.999251461133327190e-01,4.999628552428766470e-01,4.999995624344212297e-01,4.999923718376012016e-01 +7.500733209281048586e-01,4.444088274224528567e-01,5.000015991735063947e-01,4.999258161419467550e-01,4.999620907650863533e-01,4.999985509974937958e-01,4.999950213007970379e-01 +7.499456505308829124e-01,2.228580719040064162e-01,5.000148073925062553e-01,4.999251932085999051e-01,4.999622540056013476e-01,5.000009795563561399e-01,4.999920828030988140e-01 +1.000000000000000000e+00,2.492702151141098499e-01,4.999991387715645441e-01,4.999258349946363311e-01,4.999624314017001581e-01,4.999996535417892130e-01,4.999945884774305571e-01 +9.167676777957378675e-01,3.635345528712079499e-01,5.000156416279495364e-01,4.999254073368614715e-01,4.999642002248279593e-01,4.999998317015351135e-01,4.999949511640205957e-01 +9.167295291381503120e-01,1.000000000000000000e+00,5.000153055147195102e-01,4.999250576957986469e-01,4.999625386380840419e-01,4.999997082838390505e-01,4.999947385713073844e-01 +3.333895212095553395e-01,1.000000000000000000e+00,5.000148694669800387e-01,4.999258566856448760e-01,4.999622026696954324e-01,4.999993303363621244e-01,4.999928747373887372e-01 +8.333562756609880218e-01,9.991050975429503767e-02,5.000006474637167520e-01,4.999250981870395627e-01,4.999524645522037125e-01,5.000000004109509399e-01,4.999899591675530108e-01 +5.834367218101836894e-01,1.425942599356102847e-01,4.999990004401383414e-01,4.999258441127917840e-01,4.999622988957452829e-01,4.999970289865370843e-01,4.999927429796597322e-01 diff --git a/geatpy/testbed/moea_test/result/optPop/Encoding.txt b/geatpy/testbed/moea_test/result/optPop/Encoding.txt new file mode 100644 index 00000000..959bb74d --- /dev/null +++ b/geatpy/testbed/moea_test/result/optPop/Encoding.txt @@ -0,0 +1 @@ +RI \ No newline at end of file diff --git a/geatpy/testbed/moea_test/result/optPop/Field.csv b/geatpy/testbed/moea_test/result/optPop/Field.csv new file mode 100644 index 00000000..bfa035aa --- /dev/null +++ b/geatpy/testbed/moea_test/result/optPop/Field.csv @@ -0,0 +1,3 @@ +0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00 +1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00 +0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00 diff --git a/geatpy/testbed/moea_test/result/optPop/ObjV.csv b/geatpy/testbed/moea_test/result/optPop/ObjV.csv new file mode 100644 index 00000000..70644b89 --- /dev/null +++ b/geatpy/testbed/moea_test/result/optPop/ObjV.csv @@ -0,0 +1,91 @@ +1.670163636539130081e-01,1.667903625330081074e-01,1.669142424714087081e-01 +4.172951892725557665e-01,4.161533719119640817e-02,4.176074258619337509e-02 +1.247995141570525657e-01,2.925092771291267768e-01,8.338924922703463971e-02 +1.249650687944255933e-01,3.339900463104747419e-01,4.176484972920579269e-02 +2.503435466351579541e-01,4.177432908214203516e-02,2.085986412005425006e-01 +1.669355380763461461e-01,8.344740160005714724e-02,2.503422322393575317e-01 +8.362761702852877788e-02,4.171018623123153302e-01,0.000000000000000000e+00 +8.334662551911134476e-02,4.189269682215634311e-02,3.754882487540592284e-01 +3.338260970878749179e-01,1.251155902476404624e-01,4.176155589062573170e-02 +2.503855049865821303e-01,0.000000000000000000e+00,2.503430686674475436e-01 +8.349735656762143077e-02,1.667914712467133131e-01,2.504778959752788636e-01 +2.503371305515012524e-01,2.086918316650113736e-01,4.169505062774277876e-02 +1.668655402560733081e-01,4.182122897519931909e-02,2.920386989575831094e-01 +8.328421224302703929e-02,3.756487006229662362e-01,4.176277974317172542e-02 +4.175149744834941862e-02,8.349149846716295842e-02,3.754771136310135482e-01 +0.000000000000000000e+00,4.590198004710274726e-01,4.169421843746006634e-02 +0.000000000000000000e+00,3.755330065828434982e-01,1.251621584005118137e-01 +2.086341597084682420e-01,2.504472836499084809e-01,4.161299844146548049e-02 +0.000000000000000000e+00,2.503404191119106281e-01,2.503783631277730626e-01 +2.089450845852920402e-01,8.361360473550401295e-02,2.086632580872627429e-01 +0.000000000000000000e+00,8.359967662089286267e-02,4.171021861235637562e-01 +3.338000579678132018e-01,0.000000000000000000e+00,1.669109081445251663e-01 +2.083727063084872821e-01,1.671586307959293527e-01,1.251645363597238547e-01 +8.344455043652714010e-02,8.335297082111119138e-02,3.339134391401156754e-01 +4.168296861074873710e-02,0.000000000000000000e+00,4.590006828482504631e-01 +1.253183562436397946e-01,2.084781260597922681e-01,1.669091201957970949e-01 +2.088736077138337865e-01,2.918268326277606572e-01,0.000000000000000000e+00 +4.168755611572848019e-01,8.383564581589590670e-02,0.000000000000000000e+00 +2.920416912123126041e-01,2.086867789818097618e-01,0.000000000000000000e+00 +0.000000000000000000e+00,4.188791543580473731e-02,4.587962590427331899e-01 +3.755470971638439348e-01,0.000000000000000000e+00,1.251696580232250777e-01 +2.502996025372998257e-01,8.349619713794718956e-02,1.669115118700423284e-01 +2.921100489487024610e-01,1.249629713404391412e-01,8.362154157266102339e-02 +1.252751297741158398e-01,2.502456803018318077e-01,1.252091064789836172e-01 +0.000000000000000000e+00,3.337852909699826065e-01,1.669035241643261336e-01 +1.252039426726093974e-01,1.669312026140885585e-01,2.085812969118026883e-01 +3.754415980356567983e-01,1.252404436909949625e-01,0.000000000000000000e+00 +4.185093000767086541e-02,4.171106989128173792e-01,4.176182319004101418e-02 +4.176710304868722079e-02,1.669111053011356205e-01,2.920851486853600076e-01 +3.335805865053217412e-01,4.207288892503935340e-02,1.250676190230319562e-01 +0.000000000000000000e+00,2.920926621396489065e-01,2.086046440784515010e-01 +1.667932498408849773e-01,1.250723814906423148e-01,2.088569564797919942e-01 +3.339419389677016348e-01,1.668370121159337138e-01,0.000000000000000000e+00 +1.668475451952877442e-01,3.338393872609630719e-01,0.000000000000000000e+00 +8.358081308276849031e-02,2.185101515596701621e-04,4.169221776846816496e-01 +2.917089261250290222e-01,4.215079785380308058e-02,1.668351857374268665e-01 +3.340415899666397404e-01,8.316570732724132275e-02,8.351208179748179083e-02 +0.000000000000000000e+00,0.000000000000000000e+00,5.006809465805446280e-01 +1.149634771737601373e-05,2.086605173207847774e-01,2.920180498509351574e-01 +8.323932170447843892e-02,3.338533320898164902e-01,8.362835837181004095e-02 +8.371509449698168182e-02,2.084041403946096105e-01,2.085997111837929463e-01 +6.165224430080590192e-05,1.251786889601815278e-01,3.754691548367689036e-01 +2.086848804772768462e-01,0.000000000000000000e+00,2.920360558132112372e-01 +2.921176511074153326e-01,0.000000000000000000e+00,2.085984789356727098e-01 +2.086345348714076786e-01,2.087722110680915732e-01,8.329873560279653366e-02 +2.920953894421423058e-01,8.351393894514183569e-02,1.250928237403565735e-01 +4.172654412291402215e-01,4.632577002329666149e-17,8.344617462572449795e-02 +2.504924118907836950e-01,1.251735663559835343e-01,1.251103065699719630e-01 +3.754089589040731090e-01,8.343288580067417803e-02,4.184232533125548797e-02 +1.250703765092086028e-01,4.175998562408576864e-02,3.338859898906273438e-01 +4.169461722004834392e-02,4.174044687396771119e-02,4.172617916735629762e-01 +1.252286423244435287e-01,0.000000000000000000e+00,3.754562282932407125e-01 +0.000000000000000000e+00,4.172395207467795020e-01,8.344512831932772434e-02 +2.500553542817862129e-01,1.671153496526668891e-01,8.355270952064174084e-02 +4.158492069980608552e-02,2.922140621951763717e-01,1.669103705730711762e-01 +0.000000000000000000e+00,5.006702269533587213e-01,0.000000000000000000e+00 +4.162987720156834798e-02,3.339917938001984998e-01,1.250573079891754147e-01 +4.592002608235757899e-01,4.150906576628918265e-02,0.000000000000000000e+00 +2.084156056342675867e-01,4.191336342181872093e-02,2.503669113364675458e-01 +8.358386611909801589e-02,1.251220192489625183e-01,2.920064626158727084e-01 +2.086305036690442871e-01,1.249737671958269652e-01,1.671213097443242090e-01 +4.145918707732907521e-02,1.253613940815301586e-01,3.338664147348247013e-01 +8.338045655207521056e-02,2.504152428239921901e-01,1.669087287065977310e-01 +4.168811293440205512e-02,4.590202496648866370e-01,5.558979527800919614e-17 +1.668457762330941840e-01,2.504064180033784837e-01,8.344070936113731629e-02 +2.504317102361372505e-01,2.502724010545574473e-01,0.000000000000000000e+00 +2.920844228117744357e-01,1.669393606586544176e-01,4.169509694130312666e-02 +3.751593954650598861e-01,4.201260789592374534e-02,8.349878601652677146e-02 +0.000000000000000000e+00,1.668232334535560690e-01,3.338717229055258584e-01 +1.253561910144269376e-01,8.329491104395225776e-02,2.920403072851325277e-01 +5.006707424386132033e-01,0.000000000000000000e+00,0.000000000000000000e+00 +4.167028712117959444e-02,2.086573054274449834e-01,2.503655346203690346e-01 +1.253395260111065113e-01,1.253020603624630247e-01,2.500776431838525604e-01 +1.668990195776443863e-01,2.086538706420428824e-01,1.251353488380572143e-01 +8.368625806153430491e-02,2.918274370294884901e-01,1.252075169397403320e-01 +1.248059806419297979e-01,3.758795127484323428e-01,0.000000000000000000e+00 +1.668725450899068152e-01,2.921554723899775774e-01,4.167464536220479715e-02 +4.590239305515884105e-01,0.000000000000000000e+00,4.169511030131501511e-02 +1.669317310594512771e-01,0.000000000000000000e+00,3.337790604909665615e-01 +4.169606135445429185e-02,3.756380254898161186e-01,8.345303030230188934e-02 +4.165472975506556708e-02,2.504659332637343416e-01,2.085688755355438462e-01 diff --git a/geatpy/testbed/moea_test/result/optPop/Phen.csv b/geatpy/testbed/moea_test/result/optPop/Phen.csv new file mode 100644 index 00000000..79eb4408 --- /dev/null +++ b/geatpy/testbed/moea_test/result/optPop/Phen.csv @@ -0,0 +1,91 @@ +6.666521817157936569e-01,5.003385209212026785e-01,5.000155976086523291e-01,4.999254566407436706e-01,4.999622437641073613e-01,4.999985059175477975e-01,4.999914274660773872e-01 +9.165904952656122040e-01,9.093171004119831036e-01,5.000005182050029084e-01,4.999258593651764726e-01,4.999649622979362995e-01,4.999956762407744004e-01,4.999926171618832571e-01 +8.334540132380767741e-01,2.990579560339728382e-01,5.000009229351349838e-01,4.999251552034714718e-01,4.999641250575779239e-01,4.999877531562089694e-01,4.999945716762289050e-01 +9.165904044927728478e-01,2.722816778408999050e-01,5.000153564771155912e-01,4.999253290088666035e-01,4.999624038810274729e-01,4.999973055466959693e-01,4.999923332165950862e-01 +5.833997198962594943e-01,8.569949580128757294e-01,5.000016581983364183e-01,4.999251640842476974e-01,4.999599994955756244e-01,4.999947243121132257e-01,4.999949867954927574e-01 +5.000406484827695230e-01,6.667208967675466447e-01,5.000161008174319743e-01,4.999253700411117052e-01,4.999619620501553618e-01,4.999971151173012718e-01,4.999922706456549348e-01 +1.000000000000000000e+00,1.670115710754945804e-01,5.000147317114219669e-01,4.999251986979773577e-01,4.999623540000486255e-01,4.999887266626348303e-01,4.999944437482940485e-01 +2.501146922413525764e-01,6.654988542017026276e-01,5.000010994118628815e-01,4.999251546749516883e-01,4.999625047534846933e-01,4.999881068634477455e-01,4.999852438783697339e-01 +9.165941973502171880e-01,7.273823805938703924e-01,5.000023569503266874e-01,4.999253221800759039e-01,4.999621021614066296e-01,4.999995088984287572e-01,4.999898546933529975e-01 +5.000423745731393810e-01,1.000000000000000000e+00,5.000154457189210921e-01,4.999254500362096398e-01,4.999622008815011176e-01,4.999970549933292485e-01,4.999879769501833771e-01 +4.998112213212638211e-01,3.336040098024675160e-01,5.000031829590315668e-01,4.999258573179516385e-01,4.999527812296553630e-01,4.999996403948985257e-01,4.999947460444980618e-01 +9.167304751555592768e-01,5.453623870326147483e-01,5.000153720873947716e-01,4.999250618847799754e-01,4.999625638138099903e-01,5.000008240865521092e-01,4.999911732756621152e-01 +4.167688334010672402e-01,7.995980812331622278e-01,5.000145128499600133e-01,4.999254498236548883e-01,4.999622008815011176e-01,4.999993275513008872e-01,4.999877835635752055e-01 +9.165904952656122040e-01,1.814736095585842701e-01,5.000006834515426934e-01,4.999254610851592284e-01,4.999622106648524689e-01,4.999994710395832542e-01,4.999922249806409980e-01 +2.501257559416535381e-01,3.333639309979022358e-01,5.000158088956364599e-01,4.999250389037960818e-01,4.999623580223743202e-01,4.999980935943359461e-01,4.999982936026340363e-01 +9.167304751555592768e-01,0.000000000000000000e+00,5.000147859855524901e-01,4.999254555614350282e-01,4.999625671927003245e-01,5.000008268155462510e-01,4.999926873850131792e-01 +7.500232333885776814e-01,0.000000000000000000e+00,5.000012447649383462e-01,4.999254585793255212e-01,4.999622777604249002e-01,4.999974642077766318e-01,4.999927496340026423e-01 +9.168894340191203751e-01,4.544600151603172544e-01,5.000007122266088011e-01,4.999257985844491881e-01,4.999620780367606820e-01,4.999957767706834644e-01,4.999916127414422706e-01 +4.999621104528046978e-01,0.000000000000000000e+00,5.000153195515711912e-01,4.999254606022717762e-01,4.999614585666752875e-01,4.999995139744885519e-01,4.999983809839708693e-01 +5.836908994781424553e-01,7.141988674832346895e-01,5.000216337308220904e-01,4.999249657060774732e-01,4.999625019835845507e-01,4.999995268721245112e-01,4.999302133466208553e-01 +1.669649802432623675e-01,0.000000000000000000e+00,5.000019604129687378e-01,4.999251857320318182e-01,4.999618118545248735e-01,4.999957648521516917e-01,4.999944793361538187e-01 +6.666521817157936569e-01,1.000000000000000000e+00,5.000157643731512058e-01,4.999258639951733585e-01,4.999622176695360798e-01,4.999996376097707307e-01,4.999947409699517231e-01 +7.500188377951789720e-01,5.548743492758080320e-01,5.000009367961369966e-01,4.999252450031691497e-01,4.999637024569624777e-01,4.999890443022331765e-01,4.999954848074802394e-01 +3.331213703114027647e-01,5.002745233104348710e-01,5.000157475968386445e-01,4.999258594354926699e-01,4.999621840512047943e-01,4.999998081693705076e-01,4.999949994869145042e-01 +8.325210637352344067e-02,1.000000000000000000e+00,5.000001687621995483e-01,4.999253174274492784e-01,4.999641039125470865e-01,4.999991438673976329e-01,4.999924791159005011e-01 +6.666521817157936569e-01,3.754334239200317613e-01,5.000158079790941734e-01,4.999254559850525581e-01,4.999637328578839801e-01,4.999955093567707287e-01,4.999981385692997549e-01 +1.000000000000000000e+00,4.171628200912571027e-01,5.000021735884749852e-01,4.999251581077196471e-01,4.999624742221071561e-01,5.000008906326769420e-01,4.999911483716155680e-01 +1.000000000000000000e+00,8.325668675908299843e-01,5.000145208336026492e-01,4.999254640993034959e-01,4.999625199118587493e-01,4.999993296634905882e-01,4.999944561911608409e-01 +1.000000000000000000e+00,5.832336457703192201e-01,5.000153708314468703e-01,4.999254267796140461e-01,4.999627422882808037e-01,4.999874088993701560e-01,4.999942450744292999e-01 +8.366135294655749344e-02,0.000000000000000000e+00,5.000007563984431025e-01,4.999253350785347050e-01,4.999642127396116131e-01,4.999973371924003596e-01,4.999919132028110003e-01 +7.500190342612733652e-01,1.000000000000000000e+00,5.000146449266223980e-01,4.999252592814996121e-01,4.999637245115276518e-01,4.999889220350093311e-01,4.999956067371195134e-01 +6.666485429283669495e-01,7.498584547223740016e-01,5.000155441415435886e-01,4.999254265374694639e-01,4.999639383026955319e-01,4.999957994367035252e-01,4.999935166472639914e-01 +8.329889159136872889e-01,7.003810717514001860e-01,5.000152686170010741e-01,4.999258105191163870e-01,4.999644099064907143e-01,4.999985136336567160e-01,4.999947315706519957e-01 +7.499468229491179638e-01,3.336036949557587006e-01,5.000192488177133132e-01,4.999255110518099898e-01,4.999620996560970032e-01,4.999973601956143598e-01,4.999945831744861402e-01 +6.666521817157936569e-01,0.000000000000000000e+00,5.000018791195128820e-01,4.999254361987907069e-01,4.999624871379961810e-01,4.999996702091596967e-01,4.999977598489447339e-01 +5.834342966730177160e-01,4.285822664360898759e-01,5.000162154488185795e-01,4.999254590009026278e-01,4.999625736262838238e-01,4.999992057791268762e-01,4.999941053597472540e-01 +1.000000000000000000e+00,7.498603240110413015e-01,5.000020028235855341e-01,4.999252813172321286e-01,4.999637362472829083e-01,4.999986379462496577e-01,4.999982023983590151e-01 +9.165970297296509584e-01,9.118611964600907560e-02,5.000160324270540579e-01,4.999254409976764957e-01,4.999622093911632592e-01,4.999952851409971699e-01,4.999922567370908566e-01 +4.167202041006395907e-01,2.001507650414072470e-01,5.000194389478161971e-01,4.999258423991971290e-01,4.999624567522816809e-01,4.999997688575816279e-01,4.999789346991965200e-01 +7.502249847101793989e-01,8.880007994686079931e-01,5.000146740594493266e-01,4.999255138583416080e-01,4.999619778069467335e-01,4.999974348075157948e-01,4.999906863011567282e-01 +5.833717467863014372e-01,0.000000000000000000e+00,5.000007175687630756e-01,4.999259141586677169e-01,4.999618858658060327e-01,4.999993157468871630e-01,4.999890802898513953e-01 +5.828888858545107077e-01,5.714727324349682114e-01,5.000154640760400282e-01,4.999249908413825327e-01,4.999645454136277811e-01,4.999880792955908593e-01,4.999927194357050020e-01 +1.000000000000000000e+00,6.668449986667467355e-01,5.000153342908464360e-01,4.999253536382410879e-01,4.999550322676883374e-01,4.999995527246569593e-01,4.999923238666068026e-01 +1.000000000000000000e+00,3.332372674013548419e-01,5.000015694085367945e-01,4.999258707746380703e-01,4.999622767481868291e-01,5.000010497640497986e-01,4.999940994500656211e-01 +1.673571497938979857e-01,9.973924592332488182e-01,5.000152225890299729e-01,4.999252653298293936e-01,4.999623629991608031e-01,4.999973005017973593e-01,4.999918874911150612e-01 +6.667927264689560429e-01,8.737469816620480056e-01,5.000004864649200131e-01,4.999258593517594274e-01,4.999620168478703941e-01,4.999957593458898009e-01,4.999910793723499336e-01 +8.332157985396368982e-01,8.006609475273407384e-01,5.000149506552029610e-01,4.999250955124325824e-01,4.999623598445263051e-01,4.999947670319364601e-01,4.999973952301399738e-01 +0.000000000000000000e+00,5.048713158640587562e-01,5.000008519529379747e-01,4.999258497695194814e-01,4.999636747071767306e-01,4.999956133084754728e-01,4.999923713775988321e-01 +4.167688334010672402e-01,5.509290640018068755e-05,5.000008814478881236e-01,4.999258108281456336e-01,4.999623347263975059e-01,4.999968185444422231e-01,4.999926060213973900e-01 +8.329841242131299506e-01,1.995703375431087390e-01,5.000153007320111698e-01,4.999258683067434594e-01,4.999616189567526181e-01,4.999941077419183255e-01,4.999919844734035945e-01 +5.833996040717264187e-01,2.865785080124877426e-01,5.000157120312426207e-01,4.999252513349145555e-01,4.999624288535384764e-01,4.999996614174954668e-01,4.999940980802466406e-01 +2.501257559416535381e-01,4.922714495016033281e-04,5.000164513438303260e-01,4.999258601590323980e-01,4.999624352926168580e-01,4.999980799154901678e-01,4.999982936026340363e-01 +4.167688334010672957e-01,1.000000000000000000e+00,5.000153041562641620e-01,4.999254276096329330e-01,4.999625195845062708e-01,4.999997207994521520e-01,4.999899597869161272e-01 +5.833997220786112381e-01,1.000000000000000000e+00,5.000158736835522699e-01,4.999254580264284598e-01,4.999623539817310558e-01,4.999975423293968047e-01,4.999954713493607872e-01 +8.336372604785232676e-01,4.998350814906284967e-01,5.000158767286787542e-01,4.999254568258753029e-01,4.999637277067756624e-01,4.999996923626172096e-01,4.999955407827987308e-01 +7.501651965968233471e-01,7.776574418326690497e-01,5.000002547870052716e-01,4.999242677991532213e-01,4.999637018182919723e-01,4.999991319718240512e-01,4.999924531523152194e-01 +8.333448396573407413e-01,9.999999999999998890e-01,5.000152178332362141e-01,4.999254262064684595e-01,4.999625010452871110e-01,4.999984610741511903e-01,4.999977277735668801e-01 +7.501672695707695127e-01,6.667955747811701306e-01,5.000153323015430473e-01,4.999253591995818091e-01,4.999550171452186165e-01,4.999994777083815456e-01,4.999943982143489341e-01 +9.164297019251742560e-01,8.181663534755400091e-01,5.000007215815970296e-01,4.999258936937894804e-01,4.999625276386586714e-01,4.999996200448869055e-01,4.999943427249687877e-01 +3.331833711021365829e-01,7.496859379186606720e-01,5.000147744191556498e-01,4.999253216308119918e-01,4.999621590449586650e-01,4.999996914562866990e-01,4.999947727748220716e-01 +1.666378830482334594e-01,4.997253573517500547e-01,4.999999643290730100e-01,4.999254550345531567e-01,4.999619884688814575e-01,4.999954872793758165e-01,4.999940952115848325e-01 +2.501146922413525764e-01,1.000000000000000000e+00,5.000006667198589883e-01,4.999258382817939328e-01,4.999625119481988511e-01,4.999985628258909465e-01,4.999947214922292882e-01 +8.333379533904780034e-01,0.000000000000000000e+00,4.999993653283330564e-01,4.999251729731306049e-01,4.999640487050548976e-01,4.999963942478575230e-01,4.999946652178555717e-01 +8.331360042780687758e-01,5.994077530455627079e-01,5.000152781969997573e-01,4.999258734363629664e-01,4.999608440324382896e-01,4.999995085618935131e-01,4.999919745385490444e-01 +6.666521817157936569e-01,1.245807292135735905e-01,5.000148233032881695e-01,4.999251403056897969e-01,4.999641590241363232e-01,5.000010432168903174e-01,4.999913827544471556e-01 +1.000000000000000000e+00,0.000000000000000000e+00,4.999997234281410852e-01,4.999258622056299006e-01,4.999648438574373355e-01,4.999995199877448337e-01,4.999926029117323645e-01 +7.502245685624484572e-01,1.108292742816016363e-01,5.000030787925824338e-01,4.999258315377029249e-01,4.999638024708535355e-01,4.999995459407410303e-01,4.999925760158367982e-01 +1.000000000000000000e+00,9.170994755600196946e-01,5.000153647387159950e-01,4.999258396455958930e-01,4.999624446521994670e-01,4.999997864869688002e-01,4.999939115383532640e-01 +4.999621104528046978e-01,8.325668675908299843e-01,5.000020028834052388e-01,4.999254555784045095e-01,4.999614847188086353e-01,4.999997419468910631e-01,4.999983244604049304e-01 +4.168179319091955826e-01,4.004863876823347435e-01,5.000154375480692082e-01,4.999246127635434966e-01,4.999641904948871063e-01,4.999977588033139853e-01,4.999977519530126591e-01 +6.662417175871059305e-01,6.253831916724816864e-01,5.000174955625174000e-01,4.999254023506549127e-01,4.999621457710417549e-01,4.999999634663772063e-01,4.999933585384893631e-01 +3.331833711021365829e-01,2.485256123034872422e-01,5.000014281800327920e-01,4.999258510646908404e-01,4.999621630692144825e-01,4.999994244607754434e-01,4.999949859314206657e-01 +6.666521817157936569e-01,2.497948796462338694e-01,5.000153651829364332e-01,4.999254463051129305e-01,4.999637330362700083e-01,4.999954562553014514e-01,4.999981385692997549e-01 +9.999999999999998890e-01,8.325827177718736483e-02,5.000189021995580241e-01,4.999258451288773886e-01,4.999638142284095754e-01,4.999983665515622122e-01,4.999977035259628999e-01 +8.333495267027075659e-01,3.998679420689549291e-01,5.000010239909378207e-01,4.999252457377401093e-01,4.999626818592660116e-01,4.999996528118045847e-01,4.999940818200349635e-01 +1.000000000000000000e+00,5.001590851542732086e-01,5.000000039751753000e-01,4.999252248997894665e-01,4.999619728771130811e-01,4.999974178482651799e-01,4.999906998746183051e-01 +9.167295291381503120e-01,6.363165337610247052e-01,5.000153055147195102e-01,4.999250662224494213e-01,4.999625337128030256e-01,4.999997112387972176e-01,4.999948068835808335e-01 +8.332261681965873468e-01,8.992918806692553613e-01,5.000013892722610098e-01,4.999258569102607574e-01,4.999642751909254001e-01,4.999961537634967090e-01,4.999982961579148011e-01 +3.331833711021365829e-01,0.000000000000000000e+00,5.000006615364909202e-01,4.999253273767345074e-01,4.999621630692144825e-01,4.999997453910175471e-01,4.999945512263328506e-01 +4.167259476889265679e-01,6.007933328785060034e-01,5.000007760868117046e-01,4.999252466405242346e-01,4.999624463273106834e-01,5.000008870231502645e-01,4.999985259507482294e-01 +1.000000000000000000e+00,1.000000000000000000e+00,4.999985675567834020e-01,4.999258313069276927e-01,4.999645361902688157e-01,4.999991879755838475e-01,4.999944122482678499e-01 +4.999621104528046978e-01,1.664630203044252799e-01,5.000014593261378204e-01,4.999258969837428457e-01,4.999614710538987650e-01,4.999978640894338078e-01,4.999939277112206981e-01 +5.005631331457106592e-01,5.000747394899337506e-01,5.000155699194225312e-01,4.999251461133327190e-01,4.999628552428766470e-01,4.999995624344212297e-01,4.999923718376012016e-01 +7.500733209281048586e-01,4.444088274224528567e-01,5.000015991735063947e-01,4.999258161419467550e-01,4.999620907650863533e-01,4.999985509974937958e-01,4.999950213007970379e-01 +7.499456505308829124e-01,2.228580719040064162e-01,5.000148073925062553e-01,4.999251932085999051e-01,4.999622540056013476e-01,5.000009795563561399e-01,4.999920828030988140e-01 +1.000000000000000000e+00,2.492702151141098499e-01,4.999991387715645441e-01,4.999258349946363311e-01,4.999624314017001581e-01,4.999996535417892130e-01,4.999945884774305571e-01 +9.167676777957378675e-01,3.635345528712079499e-01,5.000156416279495364e-01,4.999254073368614715e-01,4.999642002248279593e-01,4.999998317015351135e-01,4.999949511640205957e-01 +9.167295291381503120e-01,1.000000000000000000e+00,5.000153055147195102e-01,4.999250576957986469e-01,4.999625386380840419e-01,4.999997082838390505e-01,4.999947385713073844e-01 +3.333895212095553395e-01,1.000000000000000000e+00,5.000148694669800387e-01,4.999258566856448760e-01,4.999622026696954324e-01,4.999993303363621244e-01,4.999928747373887372e-01 +8.333562756609880218e-01,9.991050975429503767e-02,5.000006474637167520e-01,4.999250981870395627e-01,4.999524645522037125e-01,5.000000004109509399e-01,4.999899591675530108e-01 +5.834367218101836894e-01,1.425942599356102847e-01,4.999990004401383414e-01,4.999258441127917840e-01,4.999622988957452829e-01,4.999970289865370843e-01,4.999927429796597322e-01 diff --git a/geatpy/testbed/moea_test/result/population info.txt b/geatpy/testbed/moea_test/result/population info.txt new file mode 100644 index 00000000..1b182ad0 --- /dev/null +++ b/geatpy/testbed/moea_test/result/population info.txt @@ -0,0 +1,3 @@ +{'Population Info': {'Type': 'Population', 'Population Encoding:': 'RI', 'Population ChromNum': 1, 'Population Field:': array([[0., 0., 0., 0., 0., 0., 0.], + [1., 1., 1., 1., 1., 1., 1.], + [0., 0., 0., 0., 0., 0., 0.]]), 'Population size:': 91}} \ No newline at end of file diff --git a/geatpy/testbed/moea_test/result/problem info.txt b/geatpy/testbed/moea_test/result/problem info.txt new file mode 100644 index 00000000..5f891e1b --- /dev/null +++ b/geatpy/testbed/moea_test/result/problem info.txt @@ -0,0 +1,2 @@ +{'name': 'DTLZ1', 'M': 3, 'maxormins': array([1, 1, 1]), 'Dim': 7, 'varTypes': array([0, 0, 0, 0, 0, 0, 0]), 'lb': array([0, 0, 0, 0, 0, 0, 0]), 'ub': array([1, 1, 1, 1, 1, 1, 1]), 'borders': array([[1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1]])} \ No newline at end of file diff --git a/geatpy/testbed/moea_test/result/result info.txt b/geatpy/testbed/moea_test/result/result info.txt new file mode 100644 index 00000000..fd4edb52 --- /dev/null +++ b/geatpy/testbed/moea_test/result/result info.txt @@ -0,0 +1,272 @@ +{'success': True, 'stopMsg': 'The algotirhm stepped because it exceeded the generation limit.', 'Vars': array([[6.66652182e-01, 5.00338521e-01, 5.00015598e-01, 4.99925457e-01, + 4.99962244e-01, 4.99998506e-01, 4.99991427e-01], + [9.16590495e-01, 9.09317100e-01, 5.00000518e-01, 4.99925859e-01, + 4.99964962e-01, 4.99995676e-01, 4.99992617e-01], + [8.33454013e-01, 2.99057956e-01, 5.00000923e-01, 4.99925155e-01, + 4.99964125e-01, 4.99987753e-01, 4.99994572e-01], + [9.16590404e-01, 2.72281678e-01, 5.00015356e-01, 4.99925329e-01, + 4.99962404e-01, 4.99997306e-01, 4.99992333e-01], + [5.83399720e-01, 8.56994958e-01, 5.00001658e-01, 4.99925164e-01, + 4.99959999e-01, 4.99994724e-01, 4.99994987e-01], + [5.00040648e-01, 6.66720897e-01, 5.00016101e-01, 4.99925370e-01, + 4.99961962e-01, 4.99997115e-01, 4.99992271e-01], + [1.00000000e+00, 1.67011571e-01, 5.00014732e-01, 4.99925199e-01, + 4.99962354e-01, 4.99988727e-01, 4.99994444e-01], + [2.50114692e-01, 6.65498854e-01, 5.00001099e-01, 4.99925155e-01, + 4.99962505e-01, 4.99988107e-01, 4.99985244e-01], + [9.16594197e-01, 7.27382381e-01, 5.00002357e-01, 4.99925322e-01, + 4.99962102e-01, 4.99999509e-01, 4.99989855e-01], + [5.00042375e-01, 1.00000000e+00, 5.00015446e-01, 4.99925450e-01, + 4.99962201e-01, 4.99997055e-01, 4.99987977e-01], + [4.99811221e-01, 3.33604010e-01, 5.00003183e-01, 4.99925857e-01, + 4.99952781e-01, 4.99999640e-01, 4.99994746e-01], + [9.16730475e-01, 5.45362387e-01, 5.00015372e-01, 4.99925062e-01, + 4.99962564e-01, 5.00000824e-01, 4.99991173e-01], + [4.16768833e-01, 7.99598081e-01, 5.00014513e-01, 4.99925450e-01, + 4.99962201e-01, 4.99999328e-01, 4.99987784e-01], + [9.16590495e-01, 1.81473610e-01, 5.00000683e-01, 4.99925461e-01, + 4.99962211e-01, 4.99999471e-01, 4.99992225e-01], + [2.50125756e-01, 3.33363931e-01, 5.00015809e-01, 4.99925039e-01, + 4.99962358e-01, 4.99998094e-01, 4.99998294e-01], + [9.16730475e-01, 0.00000000e+00, 5.00014786e-01, 4.99925456e-01, + 4.99962567e-01, 5.00000827e-01, 4.99992687e-01], + [7.50023233e-01, 0.00000000e+00, 5.00001245e-01, 4.99925459e-01, + 4.99962278e-01, 4.99997464e-01, 4.99992750e-01], + [9.16889434e-01, 4.54460015e-01, 5.00000712e-01, 4.99925799e-01, + 4.99962078e-01, 4.99995777e-01, 4.99991613e-01], + [4.99962110e-01, 0.00000000e+00, 5.00015320e-01, 4.99925461e-01, + 4.99961459e-01, 4.99999514e-01, 4.99998381e-01], + [5.83690899e-01, 7.14198867e-01, 5.00021634e-01, 4.99924966e-01, + 4.99962502e-01, 4.99999527e-01, 4.99930213e-01], + [1.66964980e-01, 0.00000000e+00, 5.00001960e-01, 4.99925186e-01, + 4.99961812e-01, 4.99995765e-01, 4.99994479e-01], + [6.66652182e-01, 1.00000000e+00, 5.00015764e-01, 4.99925864e-01, + 4.99962218e-01, 4.99999638e-01, 4.99994741e-01], + [7.50018838e-01, 5.54874349e-01, 5.00000937e-01, 4.99925245e-01, + 4.99963702e-01, 4.99989044e-01, 4.99995485e-01], + [3.33121370e-01, 5.00274523e-01, 5.00015748e-01, 4.99925859e-01, + 4.99962184e-01, 4.99999808e-01, 4.99994999e-01], + [8.32521064e-02, 1.00000000e+00, 5.00000169e-01, 4.99925317e-01, + 4.99964104e-01, 4.99999144e-01, 4.99992479e-01], + [6.66652182e-01, 3.75433424e-01, 5.00015808e-01, 4.99925456e-01, + 4.99963733e-01, 4.99995509e-01, 4.99998139e-01], + [1.00000000e+00, 4.17162820e-01, 5.00002174e-01, 4.99925158e-01, + 4.99962474e-01, 5.00000891e-01, 4.99991148e-01], + [1.00000000e+00, 8.32566868e-01, 5.00014521e-01, 4.99925464e-01, + 4.99962520e-01, 4.99999330e-01, 4.99994456e-01], + [1.00000000e+00, 5.83233646e-01, 5.00015371e-01, 4.99925427e-01, + 4.99962742e-01, 4.99987409e-01, 4.99994245e-01], + [8.36613529e-02, 0.00000000e+00, 5.00000756e-01, 4.99925335e-01, + 4.99964213e-01, 4.99997337e-01, 4.99991913e-01], + [7.50019034e-01, 1.00000000e+00, 5.00014645e-01, 4.99925259e-01, + 4.99963725e-01, 4.99988922e-01, 4.99995607e-01], + [6.66648543e-01, 7.49858455e-01, 5.00015544e-01, 4.99925427e-01, + 4.99963938e-01, 4.99995799e-01, 4.99993517e-01], + [8.32988916e-01, 7.00381072e-01, 5.00015269e-01, 4.99925811e-01, + 4.99964410e-01, 4.99998514e-01, 4.99994732e-01], + [7.49946823e-01, 3.33603695e-01, 5.00019249e-01, 4.99925511e-01, + 4.99962100e-01, 4.99997360e-01, 4.99994583e-01], + [6.66652182e-01, 0.00000000e+00, 5.00001879e-01, 4.99925436e-01, + 4.99962487e-01, 4.99999670e-01, 4.99997760e-01], + [5.83434297e-01, 4.28582266e-01, 5.00016215e-01, 4.99925459e-01, + 4.99962574e-01, 4.99999206e-01, 4.99994105e-01], + [1.00000000e+00, 7.49860324e-01, 5.00002003e-01, 4.99925281e-01, + 4.99963736e-01, 4.99998638e-01, 4.99998202e-01], + [9.16597030e-01, 9.11861196e-02, 5.00016032e-01, 4.99925441e-01, + 4.99962209e-01, 4.99995285e-01, 4.99992257e-01], + [4.16720204e-01, 2.00150765e-01, 5.00019439e-01, 4.99925842e-01, + 4.99962457e-01, 4.99999769e-01, 4.99978935e-01], + [7.50224985e-01, 8.88000799e-01, 5.00014674e-01, 4.99925514e-01, + 4.99961978e-01, 4.99997435e-01, 4.99990686e-01], + [5.83371747e-01, 0.00000000e+00, 5.00000718e-01, 4.99925914e-01, + 4.99961886e-01, 4.99999316e-01, 4.99989080e-01], + [5.82888886e-01, 5.71472732e-01, 5.00015464e-01, 4.99924991e-01, + 4.99964545e-01, 4.99988079e-01, 4.99992719e-01], + [1.00000000e+00, 6.66844999e-01, 5.00015334e-01, 4.99925354e-01, + 4.99955032e-01, 4.99999553e-01, 4.99992324e-01], + [1.00000000e+00, 3.33237267e-01, 5.00001569e-01, 4.99925871e-01, + 4.99962277e-01, 5.00001050e-01, 4.99994099e-01], + [1.67357150e-01, 9.97392459e-01, 5.00015223e-01, 4.99925265e-01, + 4.99962363e-01, 4.99997301e-01, 4.99991887e-01], + [6.66792726e-01, 8.73746982e-01, 5.00000486e-01, 4.99925859e-01, + 4.99962017e-01, 4.99995759e-01, 4.99991079e-01], + [8.33215799e-01, 8.00660948e-01, 5.00014951e-01, 4.99925096e-01, + 4.99962360e-01, 4.99994767e-01, 4.99997395e-01], + [0.00000000e+00, 5.04871316e-01, 5.00000852e-01, 4.99925850e-01, + 4.99963675e-01, 4.99995613e-01, 4.99992371e-01], + [4.16768833e-01, 5.50929064e-05, 5.00000881e-01, 4.99925811e-01, + 4.99962335e-01, 4.99996819e-01, 4.99992606e-01], + [8.32984124e-01, 1.99570338e-01, 5.00015301e-01, 4.99925868e-01, + 4.99961619e-01, 4.99994108e-01, 4.99991984e-01], + [5.83399604e-01, 2.86578508e-01, 5.00015712e-01, 4.99925251e-01, + 4.99962429e-01, 4.99999661e-01, 4.99994098e-01], + [2.50125756e-01, 4.92271450e-04, 5.00016451e-01, 4.99925860e-01, + 4.99962435e-01, 4.99998080e-01, 4.99998294e-01], + [4.16768833e-01, 1.00000000e+00, 5.00015304e-01, 4.99925428e-01, + 4.99962520e-01, 4.99999721e-01, 4.99989960e-01], + [5.83399722e-01, 1.00000000e+00, 5.00015874e-01, 4.99925458e-01, + 4.99962354e-01, 4.99997542e-01, 4.99995471e-01], + [8.33637260e-01, 4.99835081e-01, 5.00015877e-01, 4.99925457e-01, + 4.99963728e-01, 4.99999692e-01, 4.99995541e-01], + [7.50165197e-01, 7.77657442e-01, 5.00000255e-01, 4.99924268e-01, + 4.99963702e-01, 4.99999132e-01, 4.99992453e-01], + [8.33344840e-01, 1.00000000e+00, 5.00015218e-01, 4.99925426e-01, + 4.99962501e-01, 4.99998461e-01, 4.99997728e-01], + [7.50167270e-01, 6.66795575e-01, 5.00015332e-01, 4.99925359e-01, + 4.99955017e-01, 4.99999478e-01, 4.99994398e-01], + [9.16429702e-01, 8.18166353e-01, 5.00000722e-01, 4.99925894e-01, + 4.99962528e-01, 4.99999620e-01, 4.99994343e-01], + [3.33183371e-01, 7.49685938e-01, 5.00014774e-01, 4.99925322e-01, + 4.99962159e-01, 4.99999691e-01, 4.99994773e-01], + [1.66637883e-01, 4.99725357e-01, 4.99999964e-01, 4.99925455e-01, + 4.99961988e-01, 4.99995487e-01, 4.99994095e-01], + [2.50114692e-01, 1.00000000e+00, 5.00000667e-01, 4.99925838e-01, + 4.99962512e-01, 4.99998563e-01, 4.99994721e-01], + [8.33337953e-01, 0.00000000e+00, 4.99999365e-01, 4.99925173e-01, + 4.99964049e-01, 4.99996394e-01, 4.99994665e-01], + [8.33136004e-01, 5.99407753e-01, 5.00015278e-01, 4.99925873e-01, + 4.99960844e-01, 4.99999509e-01, 4.99991975e-01], + [6.66652182e-01, 1.24580729e-01, 5.00014823e-01, 4.99925140e-01, + 4.99964159e-01, 5.00001043e-01, 4.99991383e-01], + [1.00000000e+00, 0.00000000e+00, 4.99999723e-01, 4.99925862e-01, + 4.99964844e-01, 4.99999520e-01, 4.99992603e-01], + [7.50224569e-01, 1.10829274e-01, 5.00003079e-01, 4.99925832e-01, + 4.99963802e-01, 4.99999546e-01, 4.99992576e-01], + [1.00000000e+00, 9.17099476e-01, 5.00015365e-01, 4.99925840e-01, + 4.99962445e-01, 4.99999786e-01, 4.99993912e-01], + [4.99962110e-01, 8.32566868e-01, 5.00002003e-01, 4.99925456e-01, + 4.99961485e-01, 4.99999742e-01, 4.99998324e-01], + [4.16817932e-01, 4.00486388e-01, 5.00015438e-01, 4.99924613e-01, + 4.99964190e-01, 4.99997759e-01, 4.99997752e-01], + [6.66241718e-01, 6.25383192e-01, 5.00017496e-01, 4.99925402e-01, + 4.99962146e-01, 4.99999963e-01, 4.99993359e-01], + [3.33183371e-01, 2.48525612e-01, 5.00001428e-01, 4.99925851e-01, + 4.99962163e-01, 4.99999424e-01, 4.99994986e-01], + [6.66652182e-01, 2.49794880e-01, 5.00015365e-01, 4.99925446e-01, + 4.99963733e-01, 4.99995456e-01, 4.99998139e-01], + [1.00000000e+00, 8.32582718e-02, 5.00018902e-01, 4.99925845e-01, + 4.99963814e-01, 4.99998367e-01, 4.99997704e-01], + [8.33349527e-01, 3.99867942e-01, 5.00001024e-01, 4.99925246e-01, + 4.99962682e-01, 4.99999653e-01, 4.99994082e-01], + [1.00000000e+00, 5.00159085e-01, 5.00000004e-01, 4.99925225e-01, + 4.99961973e-01, 4.99997418e-01, 4.99990700e-01], + [9.16729529e-01, 6.36316534e-01, 5.00015306e-01, 4.99925066e-01, + 4.99962534e-01, 4.99999711e-01, 4.99994807e-01], + [8.33226168e-01, 8.99291881e-01, 5.00001389e-01, 4.99925857e-01, + 4.99964275e-01, 4.99996154e-01, 4.99998296e-01], + [3.33183371e-01, 0.00000000e+00, 5.00000662e-01, 4.99925327e-01, + 4.99962163e-01, 4.99999745e-01, 4.99994551e-01], + [4.16725948e-01, 6.00793333e-01, 5.00000776e-01, 4.99925247e-01, + 4.99962446e-01, 5.00000887e-01, 4.99998526e-01], + [1.00000000e+00, 1.00000000e+00, 4.99998568e-01, 4.99925831e-01, + 4.99964536e-01, 4.99999188e-01, 4.99994412e-01], + [4.99962110e-01, 1.66463020e-01, 5.00001459e-01, 4.99925897e-01, + 4.99961471e-01, 4.99997864e-01, 4.99993928e-01], + [5.00563133e-01, 5.00074739e-01, 5.00015570e-01, 4.99925146e-01, + 4.99962855e-01, 4.99999562e-01, 4.99992372e-01], + [7.50073321e-01, 4.44408827e-01, 5.00001599e-01, 4.99925816e-01, + 4.99962091e-01, 4.99998551e-01, 4.99995021e-01], + [7.49945651e-01, 2.22858072e-01, 5.00014807e-01, 4.99925193e-01, + 4.99962254e-01, 5.00000980e-01, 4.99992083e-01], + [1.00000000e+00, 2.49270215e-01, 4.99999139e-01, 4.99925835e-01, + 4.99962431e-01, 4.99999654e-01, 4.99994588e-01], + [9.16767678e-01, 3.63534553e-01, 5.00015642e-01, 4.99925407e-01, + 4.99964200e-01, 4.99999832e-01, 4.99994951e-01], + [9.16729529e-01, 1.00000000e+00, 5.00015306e-01, 4.99925058e-01, + 4.99962539e-01, 4.99999708e-01, 4.99994739e-01], + [3.33389521e-01, 1.00000000e+00, 5.00014869e-01, 4.99925857e-01, + 4.99962203e-01, 4.99999330e-01, 4.99992875e-01], + [8.33356276e-01, 9.99105098e-02, 5.00000647e-01, 4.99925098e-01, + 4.99952465e-01, 5.00000000e-01, 4.99989959e-01], + [5.83436722e-01, 1.42594260e-01, 4.99999000e-01, 4.99925844e-01, + 4.99962299e-01, 4.99997029e-01, 4.99992743e-01]]), 'ObjV': array([[1.67016364e-01, 1.66790363e-01, 1.66914242e-01], + [4.17295189e-01, 4.16153372e-02, 4.17607426e-02], + [1.24799514e-01, 2.92509277e-01, 8.33892492e-02], + [1.24965069e-01, 3.33990046e-01, 4.17648497e-02], + [2.50343547e-01, 4.17743291e-02, 2.08598641e-01], + [1.66935538e-01, 8.34474016e-02, 2.50342232e-01], + [8.36276170e-02, 4.17101862e-01, 0.00000000e+00], + [8.33466255e-02, 4.18926968e-02, 3.75488249e-01], + [3.33826097e-01, 1.25115590e-01, 4.17615559e-02], + [2.50385505e-01, 0.00000000e+00, 2.50343069e-01], + [8.34973566e-02, 1.66791471e-01, 2.50477896e-01], + [2.50337131e-01, 2.08691832e-01, 4.16950506e-02], + [1.66865540e-01, 4.18212290e-02, 2.92038699e-01], + [8.32842122e-02, 3.75648701e-01, 4.17627797e-02], + [4.17514974e-02, 8.34914985e-02, 3.75477114e-01], + [0.00000000e+00, 4.59019800e-01, 4.16942184e-02], + [0.00000000e+00, 3.75533007e-01, 1.25162158e-01], + [2.08634160e-01, 2.50447284e-01, 4.16129984e-02], + [0.00000000e+00, 2.50340419e-01, 2.50378363e-01], + [2.08945085e-01, 8.36136047e-02, 2.08663258e-01], + [0.00000000e+00, 8.35996766e-02, 4.17102186e-01], + [3.33800058e-01, 0.00000000e+00, 1.66910908e-01], + [2.08372706e-01, 1.67158631e-01, 1.25164536e-01], + [8.34445504e-02, 8.33529708e-02, 3.33913439e-01], + [4.16829686e-02, 0.00000000e+00, 4.59000683e-01], + [1.25318356e-01, 2.08478126e-01, 1.66909120e-01], + [2.08873608e-01, 2.91826833e-01, 0.00000000e+00], + [4.16875561e-01, 8.38356458e-02, 0.00000000e+00], + [2.92041691e-01, 2.08686779e-01, 0.00000000e+00], + [0.00000000e+00, 4.18879154e-02, 4.58796259e-01], + [3.75547097e-01, 0.00000000e+00, 1.25169658e-01], + [2.50299603e-01, 8.34961971e-02, 1.66911512e-01], + [2.92110049e-01, 1.24962971e-01, 8.36215416e-02], + [1.25275130e-01, 2.50245680e-01, 1.25209106e-01], + [0.00000000e+00, 3.33785291e-01, 1.66903524e-01], + [1.25203943e-01, 1.66931203e-01, 2.08581297e-01], + [3.75441598e-01, 1.25240444e-01, 0.00000000e+00], + [4.18509300e-02, 4.17110699e-01, 4.17618232e-02], + [4.17671030e-02, 1.66911105e-01, 2.92085149e-01], + [3.33580587e-01, 4.20728889e-02, 1.25067619e-01], + [0.00000000e+00, 2.92092662e-01, 2.08604644e-01], + [1.66793250e-01, 1.25072381e-01, 2.08856956e-01], + [3.33941939e-01, 1.66837012e-01, 0.00000000e+00], + [1.66847545e-01, 3.33839387e-01, 0.00000000e+00], + [8.35808131e-02, 2.18510152e-04, 4.16922178e-01], + [2.91708926e-01, 4.21507979e-02, 1.66835186e-01], + [3.34041590e-01, 8.31657073e-02, 8.35120818e-02], + [0.00000000e+00, 0.00000000e+00, 5.00680947e-01], + [1.14963477e-05, 2.08660517e-01, 2.92018050e-01], + [8.32393217e-02, 3.33853332e-01, 8.36283584e-02], + [8.37150945e-02, 2.08404140e-01, 2.08599711e-01], + [6.16522443e-05, 1.25178689e-01, 3.75469155e-01], + [2.08684880e-01, 0.00000000e+00, 2.92036056e-01], + [2.92117651e-01, 0.00000000e+00, 2.08598479e-01], + [2.08634535e-01, 2.08772211e-01, 8.32987356e-02], + [2.92095389e-01, 8.35139389e-02, 1.25092824e-01], + [4.17265441e-01, 4.63257700e-17, 8.34461746e-02], + [2.50492412e-01, 1.25173566e-01, 1.25110307e-01], + [3.75408959e-01, 8.34328858e-02, 4.18423253e-02], + [1.25070377e-01, 4.17599856e-02, 3.33885990e-01], + [4.16946172e-02, 4.17404469e-02, 4.17261792e-01], + [1.25228642e-01, 0.00000000e+00, 3.75456228e-01], + [0.00000000e+00, 4.17239521e-01, 8.34451283e-02], + [2.50055354e-01, 1.67115350e-01, 8.35527095e-02], + [4.15849207e-02, 2.92214062e-01, 1.66910371e-01], + [0.00000000e+00, 5.00670227e-01, 0.00000000e+00], + [4.16298772e-02, 3.33991794e-01, 1.25057308e-01], + [4.59200261e-01, 4.15090658e-02, 0.00000000e+00], + [2.08415606e-01, 4.19133634e-02, 2.50366911e-01], + [8.35838661e-02, 1.25122019e-01, 2.92006463e-01], + [2.08630504e-01, 1.24973767e-01, 1.67121310e-01], + [4.14591871e-02, 1.25361394e-01, 3.33866415e-01], + [8.33804566e-02, 2.50415243e-01, 1.66908729e-01], + [4.16881129e-02, 4.59020250e-01, 5.55897953e-17], + [1.66845776e-01, 2.50406418e-01, 8.34407094e-02], + [2.50431710e-01, 2.50272401e-01, 0.00000000e+00], + [2.92084423e-01, 1.66939361e-01, 4.16950969e-02], + [3.75159395e-01, 4.20126079e-02, 8.34987860e-02], + [0.00000000e+00, 1.66823233e-01, 3.33871723e-01], + [1.25356191e-01, 8.32949110e-02, 2.92040307e-01], + [5.00670742e-01, 0.00000000e+00, 0.00000000e+00], + [4.16702871e-02, 2.08657305e-01, 2.50365535e-01], + [1.25339526e-01, 1.25302060e-01, 2.50077643e-01], + [1.66899020e-01, 2.08653871e-01, 1.25135349e-01], + [8.36862581e-02, 2.91827437e-01, 1.25207517e-01], + [1.24805981e-01, 3.75879513e-01, 0.00000000e+00], + [1.66872545e-01, 2.92155472e-01, 4.16746454e-02], + [4.59023931e-01, 0.00000000e+00, 4.16951103e-02], + [1.66931731e-01, 0.00000000e+00, 3.33779060e-01], + [4.16960614e-02, 3.75638025e-01, 8.34530303e-02], + [4.16547298e-02, 2.50465933e-01, 2.08568876e-01]]), 'CV': None, 'executeTime': 0.4803190231323242, 'nfev': 45500, 'gd': 0.00019904744477661055, 'igd': 0.020607102400585026, 'hv': 0.8416981101036072, 'spacing': 0.00025115688906644323, 'startTime': '2022-01-09 15h-27m-33s', 'endTime': '2022-01-09 15h-27m-54s'} \ No newline at end of file diff --git a/geatpy/testbed/soea_test/main.py b/geatpy/testbed/soea_test/main.py new file mode 100644 index 00000000..dd03070c --- /dev/null +++ b/geatpy/testbed/soea_test/main.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +import geatpy as ea # import geatpy + +if __name__ == '__main__': + # 问题对象 + problem = ea.benchmarks.Ackley(30) + # 构建算法 + algorithm = ea.soea_DE_rand_1_bin_templet(problem, + ea.Population(Encoding='RI', NIND=20), + MAXGEN=1000, # 最大进化代数。 + logTras=1) # 表示每隔多少代记录一次日志信息,0表示不记录。 + algorithm.mutOper.F = 0.5 # 差分进化中的参数F + algorithm.recOper.XOVR = 0.2 # 差分进化中的参数Cr + # 求解 + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=True, saveFlag=True, dirName='result') + print(res) diff --git a/geatpy/testbed/soea_test/result/Best Objective Value Trace Plot.svg b/geatpy/testbed/soea_test/result/Best Objective Value Trace Plot.svg new file mode 100644 index 00000000..5b23ce26 --- /dev/null +++ b/geatpy/testbed/soea_test/result/Best Objective Value Trace Plot.svg @@ -0,0 +1,1492 @@ + + + + + + + + + 2022-01-09T12:07:55.908720 + image/svg+xml + + + Matplotlib v3.3.4, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geatpy/testbed/soea_test/result/Trace Plot.svg b/geatpy/testbed/soea_test/result/Trace Plot.svg new file mode 100644 index 00000000..7f6b8a5a --- /dev/null +++ b/geatpy/testbed/soea_test/result/Trace Plot.svg @@ -0,0 +1,1851 @@ + + + + + + + + + 2022-01-09T12:07:54.310941 + image/svg+xml + + + Matplotlib v3.3.4, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geatpy/testbed/soea_test/result/algorithm info.txt b/geatpy/testbed/soea_test/result/algorithm info.txt new file mode 100644 index 00000000..c5f1be63 --- /dev/null +++ b/geatpy/testbed/soea_test/result/algorithm info.txt @@ -0,0 +1 @@ +{'Algorithm Name': 'DE/rand/1/bin', 'Algorithm MAXGEN': 1000, 'Algorithm MAXTIME': None, 'Algorithm MAXEVALS': None, 'Algorithm trappedValue': 0, 'Algorithm maxTrappedCount': 1000} \ No newline at end of file diff --git a/geatpy/testbed/soea_test/result/optPop/Chrom.csv b/geatpy/testbed/soea_test/result/optPop/Chrom.csv new file mode 100644 index 00000000..cae90912 --- /dev/null +++ b/geatpy/testbed/soea_test/result/optPop/Chrom.csv @@ -0,0 +1 @@ +1.475186172698949562e-09,-7.001637426292977011e-11,-2.587862875744894631e-09,-6.279855874797716903e-09,2.892229346573713522e-09,-1.396149349740257204e-08,5.615482241978756832e-09,3.902998340008097181e-09,1.324942838101899019e-08,1.401207480981079950e-09,3.924613501820291624e-09,-4.428269430484062161e-09,-3.416449321267405716e-09,6.906242535215901324e-09,1.112605311598462532e-08,4.968860959701790511e-09,1.333857146589515004e-08,-6.974799715644176020e-09,4.644514417428996888e-09,-1.572553392278275766e-10,-1.057993644795990778e-09,-1.119391830652194155e-09,-7.084006192416114756e-09,1.053721198908012741e-09,1.172387567283968477e-08,6.731360276600854522e-09,3.141005631411198937e-09,4.086116814995524878e-09,-4.058474354812909539e-09,-1.216213851737466353e-08 diff --git a/geatpy/testbed/soea_test/result/optPop/Encoding.txt b/geatpy/testbed/soea_test/result/optPop/Encoding.txt new file mode 100644 index 00000000..959bb74d --- /dev/null +++ b/geatpy/testbed/soea_test/result/optPop/Encoding.txt @@ -0,0 +1 @@ +RI \ No newline at end of file diff --git a/geatpy/testbed/soea_test/result/optPop/Field.csv b/geatpy/testbed/soea_test/result/optPop/Field.csv new file mode 100644 index 00000000..b7f16b0f --- /dev/null +++ b/geatpy/testbed/soea_test/result/optPop/Field.csv @@ -0,0 +1,3 @@ +-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01,-3.276800000000000068e+01 +3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01,3.276800000000000068e+01 +0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00 diff --git a/geatpy/testbed/soea_test/result/optPop/FitnV.csv b/geatpy/testbed/soea_test/result/optPop/FitnV.csv new file mode 100644 index 00000000..b9c55c5f --- /dev/null +++ b/geatpy/testbed/soea_test/result/optPop/FitnV.csv @@ -0,0 +1 @@ +2.208137317438740865e-08 diff --git a/geatpy/testbed/soea_test/result/optPop/ObjV.csv b/geatpy/testbed/soea_test/result/optPop/ObjV.csv new file mode 100644 index 00000000..8e51a98a --- /dev/null +++ b/geatpy/testbed/soea_test/result/optPop/ObjV.csv @@ -0,0 +1 @@ +2.726931569441148895e-08 diff --git a/geatpy/testbed/soea_test/result/optPop/Phen.csv b/geatpy/testbed/soea_test/result/optPop/Phen.csv new file mode 100644 index 00000000..cae90912 --- /dev/null +++ b/geatpy/testbed/soea_test/result/optPop/Phen.csv @@ -0,0 +1 @@ +1.475186172698949562e-09,-7.001637426292977011e-11,-2.587862875744894631e-09,-6.279855874797716903e-09,2.892229346573713522e-09,-1.396149349740257204e-08,5.615482241978756832e-09,3.902998340008097181e-09,1.324942838101899019e-08,1.401207480981079950e-09,3.924613501820291624e-09,-4.428269430484062161e-09,-3.416449321267405716e-09,6.906242535215901324e-09,1.112605311598462532e-08,4.968860959701790511e-09,1.333857146589515004e-08,-6.974799715644176020e-09,4.644514417428996888e-09,-1.572553392278275766e-10,-1.057993644795990778e-09,-1.119391830652194155e-09,-7.084006192416114756e-09,1.053721198908012741e-09,1.172387567283968477e-08,6.731360276600854522e-09,3.141005631411198937e-09,4.086116814995524878e-09,-4.058474354812909539e-09,-1.216213851737466353e-08 diff --git a/geatpy/testbed/soea_test/result/population info.txt b/geatpy/testbed/soea_test/result/population info.txt new file mode 100644 index 00000000..91831e20 --- /dev/null +++ b/geatpy/testbed/soea_test/result/population info.txt @@ -0,0 +1,15 @@ +{'Population Info': {'Type': 'Population', 'Population Encoding:': 'RI', 'Population ChromNum': 1, 'Population Field:': array([[-32.768, -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, + -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, + -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, + -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, + -32.768, -32.768], + [ 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, + 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, + 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, + 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, + 32.768, 32.768], + [ 0. , 0. , 0. , 0. , 0. , 0. , 0. , + 0. , 0. , 0. , 0. , 0. , 0. , 0. , + 0. , 0. , 0. , 0. , 0. , 0. , 0. , + 0. , 0. , 0. , 0. , 0. , 0. , 0. , + 0. , 0. ]]), 'Population size:': 20}} \ No newline at end of file diff --git a/geatpy/testbed/soea_test/result/problem info.txt b/geatpy/testbed/soea_test/result/problem info.txt new file mode 100644 index 00000000..1a43a108 --- /dev/null +++ b/geatpy/testbed/soea_test/result/problem info.txt @@ -0,0 +1,12 @@ +{'name': 'Ackley', 'M': 1, 'maxormins': array([1]), 'Dim': 30, 'varTypes': array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0]), 'lb': array([-32.768, -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, + -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, + -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, + -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, -32.768, + -32.768, -32.768]), 'ub': array([32.768, 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, + 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, + 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, 32.768, + 32.768, 32.768, 32.768, 32.768, 32.768, 32.768]), 'borders': array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1]])} \ No newline at end of file diff --git a/geatpy/testbed/soea_test/result/result info.txt b/geatpy/testbed/soea_test/result/result info.txt new file mode 100644 index 00000000..7619ff78 --- /dev/null +++ b/geatpy/testbed/soea_test/result/result info.txt @@ -0,0 +1,10 @@ +{'success': True, 'stopMsg': 'The algotirhm stepped because it exceeded the generation limit.', 'Vars': array([[ 1.47518617e-09, -7.00163743e-11, -2.58786288e-09, + -6.27985587e-09, 2.89222935e-09, -1.39614935e-08, + 5.61548224e-09, 3.90299834e-09, 1.32494284e-08, + 1.40120748e-09, 3.92461350e-09, -4.42826943e-09, + -3.41644932e-09, 6.90624254e-09, 1.11260531e-08, + 4.96886096e-09, 1.33385715e-08, -6.97479972e-09, + 4.64451442e-09, -1.57255339e-10, -1.05799364e-09, + -1.11939183e-09, -7.08400619e-09, 1.05372120e-09, + 1.17238757e-08, 6.73136028e-09, 3.14100563e-09, + 4.08611681e-09, -4.05847435e-09, -1.21621385e-08]]), 'ObjV': array([[2.72693157e-08]]), 'CV': None, 'executeTime': 0.28800177574157715, 'nfev': 20000, 'startTime': '2022-01-09 12h-07m-53s', 'endTime': '2022-01-09 12h-07m-57s'} \ No newline at end of file diff --git a/geatpy/testbed/tsp_test/main.py b/geatpy/testbed/tsp_test/main.py new file mode 100644 index 00000000..eae1b166 --- /dev/null +++ b/geatpy/testbed/tsp_test/main.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +import matplotlib.pyplot as plt +import numpy as np +import geatpy as ea # import geatpy + +if __name__ == '__main__': + # 实例化问题对象 + problem = ea.benchmarks.TSP('att48') + # 构建算法 + algorithm = ea.soea_studGA_templet(problem, + ea.Population(Encoding='P', NIND=100), + MAXGEN=1000, # 最大进化代数 + logTras=1) # 表示每隔多少代记录一次日志信息 + algorithm.mutOper.Pm = 0.5 # 变异概率 + # 求解 + saveDirName = 'result' + res = ea.optimize(algorithm, verbose=True, drawing=1, outputMsg=True, drawLog=False, saveFlag=True, dirName=saveDirName) + # 绘制路线图 + if res['success']: + print('最短路程为:%s' % res['ObjV'][0][0]) + print('最佳路线为:') + best_journey = np.hstack([res['Vars'][0, :], res['Vars'][0, 0]]) + for i in range(len(best_journey)): + print(int(best_journey[i]), end=' ') + print() + # 绘图 + plt.figure() + plt.plot(problem.places[best_journey.astype(int), 0], problem.places[best_journey.astype(int), 1], c='black') + plt.plot(problem.places[best_journey.astype(int), 0], problem.places[best_journey.astype(int), 1], 'o', c='black') + for i in range(len(best_journey)): + plt.text(problem.places[int(best_journey[i]), 0], problem.places[int(best_journey[i]), 1], + int(best_journey[i]), fontsize=15) + plt.grid(True) + plt.xlabel('x') + plt.ylabel('y') + plt.savefig(saveDirName + '/roadmap.svg', dpi=600, bbox_inches='tight') + plt.show() + else: + print('没找到可行解。') diff --git a/geatpy/testbed/tsp_test/result/Trace Plot.svg b/geatpy/testbed/tsp_test/result/Trace Plot.svg new file mode 100644 index 00000000..14a1b1a8 --- /dev/null +++ b/geatpy/testbed/tsp_test/result/Trace Plot.svg @@ -0,0 +1,3128 @@ + + + + + + + + + 2022-01-08T22:02:25.281343 + image/svg+xml + + + Matplotlib v3.3.4, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geatpy/testbed/tsp_test/result/algorithm info.txt b/geatpy/testbed/tsp_test/result/algorithm info.txt new file mode 100644 index 00000000..a31a5329 --- /dev/null +++ b/geatpy/testbed/tsp_test/result/algorithm info.txt @@ -0,0 +1 @@ +{'Algorithm Name': 'studGA', 'Algorithm MAXGEN': 1000, 'Algorithm MAXTIME': None, 'Algorithm MAXEVALS': None, 'Algorithm trappedValue': 0, 'Algorithm maxTrappedCount': 1000} \ No newline at end of file diff --git a/geatpy/testbed/tsp_test/result/optPop/Chrom.csv b/geatpy/testbed/tsp_test/result/optPop/Chrom.csv new file mode 100644 index 00000000..b6355c5d --- /dev/null +++ b/geatpy/testbed/tsp_test/result/optPop/Chrom.csv @@ -0,0 +1 @@ +4.700000000000000000e+01,4.100000000000000000e+01,2.800000000000000000e+01,1.000000000000000000e+00,2.500000000000000000e+01,3.000000000000000000e+00,3.400000000000000000e+01,4.400000000000000000e+01,9.000000000000000000e+00,2.300000000000000000e+01,3.100000000000000000e+01,3.800000000000000000e+01,2.000000000000000000e+01,1.200000000000000000e+01,2.400000000000000000e+01,1.300000000000000000e+01,2.200000000000000000e+01,1.000000000000000000e+01,4.600000000000000000e+01,1.900000000000000000e+01,1.100000000000000000e+01,1.400000000000000000e+01,3.200000000000000000e+01,4.500000000000000000e+01,1.700000000000000000e+01,3.500000000000000000e+01,2.900000000000000000e+01,4.200000000000000000e+01,1.600000000000000000e+01,2.600000000000000000e+01,1.800000000000000000e+01,3.600000000000000000e+01,5.000000000000000000e+00,2.700000000000000000e+01,6.000000000000000000e+00,4.300000000000000000e+01,3.000000000000000000e+01,3.700000000000000000e+01,7.000000000000000000e+00,0.000000000000000000e+00,8.000000000000000000e+00,3.900000000000000000e+01,2.000000000000000000e+00,2.100000000000000000e+01,1.500000000000000000e+01,4.000000000000000000e+01,3.300000000000000000e+01,4.000000000000000000e+00 diff --git a/geatpy/testbed/tsp_test/result/optPop/Encoding.txt b/geatpy/testbed/tsp_test/result/optPop/Encoding.txt new file mode 100644 index 00000000..675f43ab --- /dev/null +++ b/geatpy/testbed/tsp_test/result/optPop/Encoding.txt @@ -0,0 +1 @@ +P \ No newline at end of file diff --git a/geatpy/testbed/tsp_test/result/optPop/Field.csv b/geatpy/testbed/tsp_test/result/optPop/Field.csv new file mode 100644 index 00000000..a5fc6645 --- /dev/null +++ b/geatpy/testbed/tsp_test/result/optPop/Field.csv @@ -0,0 +1,3 @@ +0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00,0.000000000000000000e+00 +4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01,4.700000000000000000e+01 +1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00,1.000000000000000000e+00 diff --git a/geatpy/testbed/tsp_test/result/optPop/FitnV.csv b/geatpy/testbed/tsp_test/result/optPop/FitnV.csv new file mode 100644 index 00000000..ea6a49cf --- /dev/null +++ b/geatpy/testbed/tsp_test/result/optPop/FitnV.csv @@ -0,0 +1 @@ +1.825694505263894098e+04 diff --git a/geatpy/testbed/tsp_test/result/optPop/ObjV.csv b/geatpy/testbed/tsp_test/result/optPop/ObjV.csv new file mode 100644 index 00000000..e85a4d53 --- /dev/null +++ b/geatpy/testbed/tsp_test/result/optPop/ObjV.csv @@ -0,0 +1 @@ +3.472130532497073000e+04 diff --git a/geatpy/testbed/tsp_test/result/optPop/Phen.csv b/geatpy/testbed/tsp_test/result/optPop/Phen.csv new file mode 100644 index 00000000..b6355c5d --- /dev/null +++ b/geatpy/testbed/tsp_test/result/optPop/Phen.csv @@ -0,0 +1 @@ +4.700000000000000000e+01,4.100000000000000000e+01,2.800000000000000000e+01,1.000000000000000000e+00,2.500000000000000000e+01,3.000000000000000000e+00,3.400000000000000000e+01,4.400000000000000000e+01,9.000000000000000000e+00,2.300000000000000000e+01,3.100000000000000000e+01,3.800000000000000000e+01,2.000000000000000000e+01,1.200000000000000000e+01,2.400000000000000000e+01,1.300000000000000000e+01,2.200000000000000000e+01,1.000000000000000000e+01,4.600000000000000000e+01,1.900000000000000000e+01,1.100000000000000000e+01,1.400000000000000000e+01,3.200000000000000000e+01,4.500000000000000000e+01,1.700000000000000000e+01,3.500000000000000000e+01,2.900000000000000000e+01,4.200000000000000000e+01,1.600000000000000000e+01,2.600000000000000000e+01,1.800000000000000000e+01,3.600000000000000000e+01,5.000000000000000000e+00,2.700000000000000000e+01,6.000000000000000000e+00,4.300000000000000000e+01,3.000000000000000000e+01,3.700000000000000000e+01,7.000000000000000000e+00,0.000000000000000000e+00,8.000000000000000000e+00,3.900000000000000000e+01,2.000000000000000000e+00,2.100000000000000000e+01,1.500000000000000000e+01,4.000000000000000000e+01,3.300000000000000000e+01,4.000000000000000000e+00 diff --git a/geatpy/testbed/tsp_test/result/population info.txt b/geatpy/testbed/tsp_test/result/population info.txt new file mode 100644 index 00000000..af24232f --- /dev/null +++ b/geatpy/testbed/tsp_test/result/population info.txt @@ -0,0 +1,12 @@ +{'Population Info': {'Type': 'Population', 'Population Encoding:': 'P', 'Population ChromNum': 1, 'Population Field:': array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., + 0., 0., 0., 0., 0., 0., 0., 0., 0.], + [47., 47., 47., 47., 47., 47., 47., 47., 47., 47., 47., 47., 47., + 47., 47., 47., 47., 47., 47., 47., 47., 47., 47., 47., 47., 47., + 47., 47., 47., 47., 47., 47., 47., 47., 47., 47., 47., 47., 47., + 47., 47., 47., 47., 47., 47., 47., 47., 47.], + [ 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., + 1., 1., 1., 1., 1., 1., 1., 1., 1.]]), 'Population size:': 100}} \ No newline at end of file diff --git a/geatpy/testbed/tsp_test/result/problem info.txt b/geatpy/testbed/tsp_test/result/problem info.txt new file mode 100644 index 00000000..828756fa --- /dev/null +++ b/geatpy/testbed/tsp_test/result/problem info.txt @@ -0,0 +1,12 @@ +{'name': 'att48', 'M': 1, 'maxormins': array([1]), 'Dim': 48, 'varTypes': array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0]), 'lb': array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0]), 'ub': array([47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, + 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47]), 'borders': array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1], + [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1]])} \ No newline at end of file diff --git a/geatpy/testbed/tsp_test/result/result info.txt b/geatpy/testbed/tsp_test/result/result info.txt new file mode 100644 index 00000000..11f1355d --- /dev/null +++ b/geatpy/testbed/tsp_test/result/result info.txt @@ -0,0 +1,3 @@ +{'success': True, 'stopMsg': 'The algotirhm stepped because it exceeded the generation limit.', 'Vars': array([[47, 41, 28, 1, 25, 3, 34, 44, 9, 23, 31, 38, 20, 12, 24, 13, + 22, 10, 46, 19, 11, 14, 32, 45, 17, 35, 29, 42, 16, 26, 18, 36, + 5, 27, 6, 43, 30, 37, 7, 0, 8, 39, 2, 21, 15, 40, 33, 4]]), 'ObjV': array([[34721.30532497]]), 'CV': None, 'executeTime': 2.0355513095855713, 'nfev': 100000, 'startTime': '2022-01-08 22h-02m-22s', 'endTime': '2022-01-08 22h-02m-26s'} \ No newline at end of file diff --git a/geatpy/testbed/tsp_test/result/roadmap.svg b/geatpy/testbed/tsp_test/result/roadmap.svg new file mode 100644 index 00000000..32bfe555 --- /dev/null +++ b/geatpy/testbed/tsp_test/result/roadmap.svg @@ -0,0 +1,1147 @@ + + + + + + + + + 2022-01-08T22:02:26.521746 + image/svg+xml + + + Matplotlib v3.3.4, https://matplotlib.org/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/geatpy/visualization/ParCoordPlotter.py b/geatpy/visualization/ParCoordPlotter.py new file mode 100644 index 00000000..d4f34e8a --- /dev/null +++ b/geatpy/visualization/ParCoordPlotter.py @@ -0,0 +1,136 @@ +# -*- coding: utf-8 -*- + +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.animation as animation + + +class ParCoordPlotter: + """ + ParCoordPlotter: 绘制平行坐标图。 + + 属性: + Dimension : int - 数据点的维度。它必须等于add(points)中points列数(points为一个2D的Numpy ndarray数组)。 + + xtickList : list - 存储着平行坐标图横坐标数据的列表。 + + grid : bool - 控制是否绘制网格。 + + legend : bool - 控制是否绘制图例。 + + title : str - 图片标题。 + + coordLabels : list - 存储着各个坐标轴名称的列表。 + + saveName : str - 保存图片的文件名(不含文件格式后缀。保存的文件为.svg格式) + 当缺省或为None时,不保存图片。 + + """ + + def __init__(self, Dimension, xtickList=None, grid=True, legend=True, title=None, coordLabels=None, saveName=None): + if title is None: + title = 'ParCoordPlot' + if coordLabels is None: + coordLabels = ['Dimension Number', 'Value'] + self.Dimension = Dimension + self.xtickList = xtickList + self.grid = grid + self.legend = legend + self.title = title + self.coordLabels = coordLabels + self.saveName = saveName + self.data_set = [] # 存储用于绘图的数据,每次调用addPoints,都会往data_set里添加一组绘图数据。 + self.params_set = [] # 存储所有的绘图参数。其每个元素是一个dict,格式为:{'marker': xxx, 'objectsize': xxx, 'color': xxx, 'alpha': xxx, 'label': xxx}。 + self.plots_set = [] # 存储图形中的所有图形对象。 + self.history = [] # 用于在绘制动画时保存历史数据。 + self.fig = None + self.ax = None + + def add(self, points, marker='-', objectSize=2, color='blue', alpha=1.0, label=None): + """ + 用于添加一组点到图形中。输入参数points的每一行表示每个点的坐标值。 + 当输入参数points只有一行,或者是1D的Numpy ndarray一维数组时,只添加一个点。 + objectSize控制点的大小以及线的粗细。 + """ + + if points is None: + return + if not isinstance(points, np.ndarray): + raise RuntimeError('Error in ParCoordPlotter.py: The type of the points must be numpy ndarray. (points必须是Numpy ndarray类型。)') + if points.ndim == 1: + points = np.array([points]) + if points.shape[1] != self.Dimension: + raise RuntimeError( + 'Error in ParCoordPlotter.py: The length of the points must be equal to Dimension if its dimension is 1. (points是1维时,其长度必须等于Dimension。)') + elif points.ndim == 2: + if points.shape[0] == 0: + return + if points.shape[1] != self.Dimension: + raise RuntimeError( + 'Error in ParCoordPlotter.py: The number of the column of the points must be equal to Dimension if its dimension is 2. (' + 'points是2维时,其列数必须等于Dimension。)') + self.data_set.append(points) + self.params_set.append({'marker': marker, 'objectsize': objectSize, 'color': color, 'alpha': alpha, 'label': label}) + self.history += [{'data_set': self.data_set, 'params_set': self.params_set}] + + def draw(self): + # 开始绘制 + if self.fig is None and self.ax is None: + self.fig, self.ax = plt.subplots() # 生成一块画布和创建绘图区域 + for idx, data in enumerate(self.data_set): + params = self.params_set[idx] + x = np.tile(np.arange(1, data.shape[1] + 1).reshape(-1, 1), (1, data.shape[0])) + _data = data.T + self.ax.plot(x[:, 0], _data[:, 0], params['marker'], markersize=params['objectsize'], linewidth=params['objectsize'], color=params['color'], alpha=params['alpha'], label=params['label']) + plot = self.ax.plot(x, _data, params['marker'], markersize=params['objectsize'], linewidth=params['objectsize'], color=params['color'], alpha=params['alpha']) + self.plots_set.append(plot) + self.ax.set_xlabel(self.coordLabels[0]) + self.ax.set_ylabel(self.coordLabels[1]) + if self.xtickList is not None: + plt.xticks(np.arange(1, len(self.xtickList) + 1), self.xtickList) + if self.title is not None: + self.ax.set_title(self.title) + if self.legend: + plt.legend() + plt.grid(self.grid) + plt.draw() + + def refresh(self): + if self.fig and self.ax: + plt.pause(1/24) + self.ax.cla() + self.data_set = [] + self.params_set = [] + self.plots_set = [] + + def show(self): + if self.saveName is not None: + self.fig.savefig(self.saveName + '.svg', dpi=300, bbox_inches='tight') + plt.show() + + def createAnimation(self, fps=6): + """ + 该函数根据self.history记录的数据,绘制动画并保存到文件中。 + fps表示每秒钟绘制多少帧。 + """ + def update(i, plotObject): + plotObject.ax.cla() + plotObject.data_set = plotObject.history[i]['data_set'] + plotObject.params_set = plotObject.history[i]['params_set'] + plotObject.draw() + if len(self.history) > 0: + if self.fig is None and self.ax is None: + self.fig, self.ax = plt.subplots() # 生成一块画布和创建绘图区域 + print('Creating gif...') + anim = animation.FuncAnimation(self.fig, update, frames=len(self.history), fargs=(self, )) + anim.save(self.title + '.gif', fps=fps) + print('gif has been created.') + + def close(self): + plt.close() + for item in self.history: + item.clear() + self.history = [] + self.data_set = [] + self.params_set = [] + self.plots_set = [] diff --git a/geatpy/visualization/PointScatter.py b/geatpy/visualization/PointScatter.py new file mode 100644 index 00000000..a1600bd3 --- /dev/null +++ b/geatpy/visualization/PointScatter.py @@ -0,0 +1,149 @@ +# -*- coding: utf-8 -*- + +import numpy as np +import matplotlib.pyplot as plt +from mpl_toolkits.mplot3d import Axes3D +import matplotlib.animation as animation + + +class PointScatter: + """ + PointScatter: 绘制2维或3维散点图。 + + 属性: + Dimension : int - 数据点的维度。它必须等于add(points)中points列数(points为一个2D的Numpy ndarray数组)。 + + grid : bool - 控制是否绘制网格。 + + legend : bool - 控制是否绘制图例。 + + title : str - 图片标题。 + + coordLabels : list - 存储着各个坐标轴名称的列表。 + + saveName : str - 保存图片的文件名(不含文件格式后缀。保存的文件为.svg格式) + 当缺省或为None时,不保存图片。 + + """ + + def __init__(self, Dimension, grid=True, legend=True, title=None, coordLabels=None, saveName=None): + if title is None: + title = 'ParCoordPlot' + if coordLabels is None: + coordLabels = ['F1', 'F2', 'F3'] + # check Dimension + if Dimension != 2 and Dimension != 3: + raise RuntimeError('Error in PointScatter.py: M must be 2 or 3. (M 必须为2或3。)') + self.Dimension = Dimension + self.grid = grid + self.legend = legend + self.title = title + self.coordLabels = coordLabels + self.saveName = saveName + self.data_set = [] # 存储用于绘图的数据,每次调用addPoints,都会往data_set里添加一组绘图数据。 + self.params_set = [] # 存储所有的绘图参数。其每个元素是一个dict,格式为:{'marker': xxx, 'objectsize': xxx, 'color': xxx, 'alpha': xxx, 'label': xxx}。 + self.plots_set = [] # 存储图形中的所有图形对象。 + self.history = [] # 用于在绘制动画时保存历史数据。 + self.fig = None + self.ax = None + + def add(self, points, marker='o', objectSize=5, color='blue', alpha=1.0, label=None): + """ + 用于添加一组点到图形中。输入参数points的每一行表示每个点的坐标值。 + 当输入参数points只有一行,或者是1D的Numpy ndarray一维数组时,只添加一个点。 + objectSize控制点的大小以及线的粗细。 + """ + if points is None: + return + if not isinstance(points, np.ndarray): + raise RuntimeError('Error in PointScatter.py: The type of the points must be numpy ndarray. (points必须是Numpy ndarray类型。)') + if points.ndim == 1: + points = np.array([points]) + if points.shape[1] != self.Dimension: + raise RuntimeError( + 'Error in PointScatter.py: The length of the points must be equal to Dimension if its dimension is 1. (points是1维时,其长度必须等于Dimension。)') + elif points.ndim == 2: + if points.shape[0] == 0: + return + if points.shape[1] != self.Dimension: + raise RuntimeError( + 'Error in PointScatter.py: The number of the column of the points must be equal to Dimension if its dimension is 2. (' + 'points是2维时,其列数必须等于Dimension。)') + self.data_set.append(points) + self.params_set.append({'marker': marker, 'objectsize': objectSize, 'color': color, 'alpha': alpha, 'label': label}) + self.history += [{'data_set': self.data_set, 'params_set': self.params_set}] + + def draw(self): + # 开始绘制 + if self.Dimension == 2: + if self.fig is None and self.ax is None: + self.fig, self.ax = plt.subplots() # 生成一块画布和创建绘图区域 + for idx, data in enumerate(self.data_set): + params = self.params_set[idx] + plot = self.ax.plot(data[:, 0], data[:, 1], params['marker'], markersize=params['objectsize'], linewidth=params['objectsize'], color=params['color'], alpha=params['alpha'], label=params['label']) + self.plots_set.append(plot) + self.ax.set_xlabel(self.coordLabels[0]) + self.ax.set_ylabel(self.coordLabels[1]) + elif self.Dimension == 3: + if self.fig is None and self.ax is None: + self.fig = plt.figure() # 生成一块画布 + self.ax = Axes3D(self.fig) # 创建绘图区域 + self.ax.view_init(elev=30, azim=45) # 旋转 + for idx, data in enumerate(self.data_set): + params = self.params_set[idx] + plot = self.ax.plot(data[:, 0], data[:, 1], data[:, 2], params['marker'], markersize=params['objectsize'], color=params['color'], alpha=params['alpha'], label=params['label']) + self.plots_set.append(plot) + self.ax.set_xlabel(self.coordLabels[0]) + self.ax.set_ylabel(self.coordLabels[1]) + self.ax.set_zlabel(self.coordLabels[2]) + if self.title is not None: + self.ax.set_title(self.title) + if self.legend: + plt.legend() + plt.grid(self.grid) + plt.draw() + + def refresh(self): + if self.fig and self.ax: + plt.pause(1/24) + self.ax.cla() + self.data_set = [] + self.params_set = [] + self.plots_set = [] + + def show(self): + if self.saveName is not None: + self.fig.savefig(self.saveName + '.svg', dpi=300, bbox_inches='tight') + plt.show() + + def createAnimation(self, fps=6): + """ + 该函数根据self.history记录的数据,绘制动画并保存到文件中。 + fps表示每秒钟绘制多少帧。 + """ + def update(i, plotObject): + plotObject.ax.cla() + plotObject.data_set = plotObject.history[i]['data_set'] + plotObject.params_set = plotObject.history[i]['params_set'] + plotObject.draw() + if len(self.history) > 0: + if self.fig is None and self.ax is None: + if self.Dimension == 2: + self.fig, self.ax = plt.subplots() # 生成一块画布和创建绘图区域 + elif self.Dimension == 3: + self.fig = plt.figure() # 生成一块画布 + self.ax = Axes3D(self.fig) # 创建绘图区域 + self.ax.view_init(elev=30, azim=45) # 旋转 + print('Creating gif...') + anim = animation.FuncAnimation(self.fig, update, frames=len(self.history), fargs=(self, )) + anim.save(self.title + '.gif', fps=fps) + print('gif has been created.') + + def close(self): + plt.close() + for item in self.history: + item.clear() + self.history = [] + self.data_set = [] + self.params_set = [] + self.plots_set = [] diff --git a/history.txt b/history.txt new file mode 100644 index 00000000..f6da6018 --- /dev/null +++ b/history.txt @@ -0,0 +1,49 @@ +Version History + +2022.1.9 : v2.7.0 - A well improved and similar version. + || +2020.10.18 : v2.6.0 - An enhanced version. + || +2020.5.30 : v2.5.1 - A cumulative update. + || +2020.4.18 : v2.5.0 - A revolutionary update. + || +2020.2.9 : v2.4.0 - A more feature-rich version. + || +2020.1.14 : v2.3.0 - A more improved version. + || +2019.10.1 : v2.2.3 - A cumulative performance update. + || +2019.8.29 : v2.2.2 - Added T_ENS and oop recombination & mutation operators. + || +2019.8.20 : v2.2.1 - Sped up the core and add new templates. + || +2019.8.10 : v2.2.0 - Support evoluating with hybrid encodings. + || +2019.8.8 : v2.1.1 - Sped up the core and fixed some BUGs + || +2019.7.28 : v2.1.0 - An update of Geatpy2, which is simpler and multifunction. + || +2019.6.25 : v2.0.0 - A new design of Geatpy, which is simpler, faster and stronger. + || +2018.11.15 : v1.1.5 - Updated the kernel and performed better. + || +2018.11.3 : v1.1.4 - Fixed BUGs and added new tutorials. + || +2018.10.25 : v1.1.3 - Updated algorithm templets. + || +2018.10.21 : v1.1.2 - Fixed BUGs and rebuilded mut* functions. + || +2018.10.18 : v1.1.0 - A revolutionary Update! Added new design of a new data structure : 'LegV' and refactored the kernel. + || +2018.10.3 : v1.0.7 - Essential Updates! Porforming better in solving constrained optimization problems. + || +2018.9.21 : v1.0.6 - Dealed with copyright issues. + || +2018.8.26 : v1.0.4 - Updated algorithm templets. + || +2018.8.23 : v1.0.3 - Updated some algorithms of multi-objective optimization. + || +2018.8.23 : v1.0.2 - Debugged some BUGs. + || +2018.8.21 : v1.0.1 - Original version. \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..abe42c64 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +numpy>=1.17.0 +matplotlib>=3.0.0 \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..37d5f1bf --- /dev/null +++ b/setup.py @@ -0,0 +1,83 @@ +# -*- coding: utf-8 -*- +# This is a list of files to install Geatpy +# +# Geatpy is a free toolbox: you can redistribute it and/or modify as you want. +# +# Geatpy is distributed in the hope that it will be useful for the genetic +# and evolutionary algorithm, you can get the tutorial from http://www.geatpy.com +# +# If you want to donate to it, please email geatpy@163.com + +import os +import sys +import shutil +import platform +import numpy as np +import setuptools +from Cython.Build import cythonize +from setuptools import setup + +LONG_DESCRIPTION = "Geatpy--The Genetic and Evolutionary Algorithms Toolbox for Python. http://www.geatpy.com" + +kwargs = dict(name = "geatpy", + version = "2.7.0", + description = "Geatpy is a high-performance Genetic and Evolutionary Algorithms toolbox for Python.", + author = "Geatpy Team", + author_email = "geatpy@163.com", + url = "http://www.geatpy.com", + packages=setuptools.find_packages(), + include_package_data = True, # Enabled list file: MANIFEST.in + install_requires=[ + 'numpy>=1.17.0', + 'matplotlib>=3.0.0', + ], + platforms='any', + classifiers = [ + 'Development Status :: 5 - Production/Stable', + 'Topic :: Software Development', + 'Topic :: Scientific/Engineering', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Topic :: Scientific/Engineering :: Artificial Intelligence', + 'License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + ], + long_description = LONG_DESCRIPTION, + zip_safe = False, +) + +dest_path = 'geatpy/core/' +source_path = '_core/' + +def findAndCopy(path): + for files in os.listdir(path): + name = os.path.join(path, files) + if os.path.isfile(name): + shutil.copy(name, dest_path + files) + +# delete the exist files +def findAndDel(path): + for files in os.listdir(path): + name = os.path.join(path, files) + if os.path.isfile(name): + os.remove(name) + +# copy the core files +if os.path.exists(dest_path) == False: + os.makedirs(dest_path) +versionName = sys.version.split()[0].split('.') +versionName = versionName[0] + '.' + versionName[1] +core_path = source_path + platform.system() + '/lib' + platform.architecture()[0][:2] + '/v' + versionName +findAndDel(dest_path) +findAndCopy(core_path) + +try: + setup(include_dirs=[np.get_include()],ext_modules=cythonize("build/build.pyx"),language="c", **kwargs), +except Exception: + setup(**kwargs)