From 7210465f8d5e1d68cdd086a02811b07353396b01 Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 26 Apr 2019 16:07:31 -0400 Subject: [PATCH] new usage --- README.rst | 50 ++++++++++++++++++++++---------------------------- setup.py | 10 ++++++---- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/README.rst b/README.rst index 1c05ae3bd..ff9ea6d6e 100644 --- a/README.rst +++ b/README.rst @@ -70,35 +70,29 @@ However, for instance executing NSGA2: .. code:: python + from pymoo.optimize import minimize + from pymoo.algorithms.nsga2 import nsga2 + from pymoo.util import plotting + from pymop.factory import get_problem - import numpy as np - - from pymoo.optimize import minimize - from pymoo.util import plotting - from pymop.factory import get_problem - - # create the optimization problem - problem = get_problem("zdt1") - pf = problem.pareto_front() - - res = minimize(problem, - method='nsga2', - method_args={'pop_size': 100}, - termination=('n_gen', 200), - pf=pf, - save_history=True, - disp=True) - - plot = True - if plot: - plotting.plot(pf, res.F, labels=["Pareto-front", "F"]) - - # set true if you want to save a video - animate = False - if animate: - from pymoo.util.plotting import animate as func_animtate - H = np.concatenate([e.pop.get("F")[None, :] for e in res.history], axis=0) - func_animtate('%s.mp4' % problem.name(), H, problem) + # load a test or define your own problem + problem = get_problem("zdt1") + + # get the optimal solution of the problem for the purpose of comparison + pf = problem.pareto_front() + + # create the algorithm object + method = nsga2(pop_size=100, elimate_duplicates=True) + + # execute the optimization + res = minimize(problem, + method, + termination=('n_gen', 200), + pf=pf, + disp=True) + + # plot the results as a scatter plot + plotting.plot(pf, res.F, labels=["Pareto-Front", "F"]) diff --git a/setup.py b/setup.py index fe064e020..dbe5b9a74 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ def get_extension_modules(): url=__url__, python_requires='>3.3', author_email="blankjul@egr.msu.edu", - description="Multi-Objective Optimization Algorithms", + description="Multi-Objective Optimization in Python", long_description=readme(), license='Apache License 2.0', keywords="optimization", @@ -32,16 +32,18 @@ def get_extension_modules(): include_package_data=True, platforms='any', classifiers=[ - 'Development Status :: Production/Stable', + 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: Apache License', 'Operating System :: OS Independent', + 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', - 'Topic :: Optimization :: Multi-objective Optimization', + 'Topic :: Scientific/Engineering', + 'Topic :: Scientific/Engineering :: Artificial Intelligence', + 'Topic :: Scientific/Engineering :: Mathematics' ] )