Skip to content

Commit

Permalink
new usage
Browse files Browse the repository at this point in the history
  • Loading branch information
blankjul committed Apr 26, 2019
1 parent 2d3d10f commit 7210465
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 32 deletions.
50 changes: 22 additions & 28 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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'
]
)

Expand Down

0 comments on commit 7210465

Please sign in to comment.