Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare v.0.4.0 #223

Merged
merged 29 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6f8844f
Update base classes to inherit from ABC (#218)
ljvmiranda921 Aug 14, 2018
ad86b71
Remove environments module (#217)
ljvmiranda921 Aug 14, 2018
2472ed2
Remove `_func` in single_obj function names (#222)
jarcelao Aug 14, 2018
eb05142
Merge branch 'master' into development
ljvmiranda921 Aug 14, 2018
85952da
Merge branch 'master' into development
ljvmiranda921 Aug 15, 2018
f9dc37c
Add fmt comments for black (#229)
whzup Aug 17, 2018
0ad254d
Add reporter module (#227)
ljvmiranda921 Aug 19, 2018
0f7d9d1
Add cost function decorator (#226)
whzup Aug 20, 2018
5961ea4
Fix plotters documentation (#236)
ljvmiranda921 Aug 31, 2018
db1d922
Merge branch 'master' into development
ljvmiranda921 Sep 14, 2018
bf0d11c
Fix missing init_pos parameter in create_swarm (#249)
dfhljf Sep 14, 2018
277d9c0
Refactor GeneralOptimizer if-else hierarchy (#232)
ljvmiranda921 Sep 10, 2018
ad80287
Refactor test abstractions (#240) (#241)
ljvmiranda921 Sep 12, 2018
0b36637
Add pytest-cov config file
ljvmiranda921 Sep 13, 2018
569c8a7
Add isort configuration
ljvmiranda921 Sep 29, 2018
a359feb
Fix merge conflict in .coveragerc
ljvmiranda921 Oct 3, 2018
e5d7d93
Add init_pos in Optimizer docstrings
ljvmiranda921 Oct 3, 2018
32cb893
Update test on decorators
ljvmiranda921 Oct 3, 2018
c289bdd
Fix docstring in Star topology
ljvmiranda921 Oct 4, 2018
f7e376a
Merge branch 'development' into refactor/general
ljvmiranda921 Oct 20, 2018
7e4d04c
Merge pull request #246 from ljvmiranda921/refactor/general
ljvmiranda921 Oct 20, 2018
aed0dca
Fix bug in topologies (#253)
whzup Jan 28, 2019
2f56cf5
Add new targets for Makefile
ljvmiranda921 Jan 28, 2019
ff4558e
Use venv instead of env
ljvmiranda921 Jan 28, 2019
48b8042
Use pip-tools for creating dependencies
ljvmiranda921 Jan 28, 2019
20e88a9
Update setup.py to read directly from requirements
ljvmiranda921 Jan 28, 2019
c5a5157
Add requirements files to MANIFEST.in
ljvmiranda921 Jan 28, 2019
77e3fcd
Remove py34 support
ljvmiranda921 Jan 29, 2019
2bafd39
Update HISTORY.rst
ljvmiranda921 Jan 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[report]
exclude_lines =
pragma: no cover
@abc.abstractmethod
pos = init_pos
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ __pycache__/

# Distribution / packaging
.Python
env/
venv/
build/
develop-eggs/
dist/
Expand Down Expand Up @@ -68,4 +68,4 @@ target/
.python-version

# Vagrant folder
.vagrant
.vagrant
5 changes: 5 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[settings]
skip=test_plotters.py
import_heading_stdlib=Import standard library
import_heading_firstparty=Import from pyswarms
import_heading_thirdparty=Import modules
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ language: python
python:
- 3.6
- 3.5
- 3.4
script: tox
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.md
include requirements.txt
include requirements-dev.txt

recursive-include tests *
recursive-exclude * __pycache__
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ BROWSER := python -c "$$BROWSER_PYSCRIPT"
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

build: venv requirements.txt
venv/bib/pip-sync

dev: venv requirements-dev.txt
venv/bib/pip-sync requirements-dev.txt

clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts


Expand Down Expand Up @@ -85,3 +91,13 @@ dist: clean ## builds source and wheel package

install: clean ## install the package to the active Python's site-packages
python setup.py install

venv:
python3 -m venv venv
venv/bin/pip3 install pip-tools

requirements.txt: requirements.in
venv/bin/pip-compile -o requirements.txt --no-header --no-annotate requirements.in

requirements-dev.txt: requirements-dev.in
venv/bin/pip-compile -o requirements-dev.txt --no-header --no-annotate requirements-dev.in
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interaction with swarm optimizations. Check out more features below!

* **Free software:** MIT license
* **Documentation:** https://pyswarms.readthedocs.io.
* **Python versions:** 3.4 and above
* **Python versions:** 3.5 and above

## Features

Expand Down Expand Up @@ -101,7 +101,7 @@ import pyswarms as ps

Suppose we want to find the minima of `f(x) = x^2` using global best
PSO, simply import the built-in sphere function,
`pyswarms.utils.functions.sphere_func()`, and the necessary optimizer:
`pyswarms.utils.functions.sphere()`, and the necessary optimizer:

```python
import pyswarms as ps
Expand All @@ -111,7 +111,7 @@ options = {'c1': 0.5, 'c2': 0.3, 'w':0.9}
# Call instance of PSO
optimizer = ps.single.GlobalBestPSO(n_particles=10, dimensions=2, options=options)
# Perform optimization
best_cost, best_pos = optimizer.optimize(fx.sphere_func, iters=100, verbose=3, print_step=25)
best_cost, best_pos = optimizer.optimize(fx.sphere, iters=100, verbose=3, print_step=25)
```
```s
>>> 2017-10-03 10:12:33,859 - pyswarms.single.global_best - INFO - Iteration 1/100, cost: 0.131244226714
Expand Down Expand Up @@ -170,7 +170,7 @@ options = {
# n_selection_iters is the number of iterations to run the searcher
# iters is the number of iterations to run the optimizer
g = RandomSearch(ps.single.LocalBestPSO, n_particles=40,
dimensions=20, options=options, objective_func=fx.sphere_func,
dimensions=20, options=options, objective_func=fx.sphere,
iters=10, n_selection_iters=100)

best_score, best_options = g.search()
Expand Down Expand Up @@ -202,7 +202,7 @@ from pyswarms.utils.plotters import plot_cost_history
# Set-up optimizer
options = {'c1':0.5, 'c2':0.3, 'w':0.9}
optimizer = ps.single.GlobalBestPSO(n_particles=50, dimensions=2, options=options)
optimizer.optimize(fx.sphere_func, iters=100)
optimizer.optimize(fx.sphere, iters=100)
# Plot the cost
plot_cost_history(optimizer.cost_history)
plt.show()
Expand All @@ -216,7 +216,8 @@ We can also plot the animation...
from pyswarms.utils.plotters.formatters import Mesher
from pyswarms.utils.plotters.formatters import Designer
# Plot the sphere function's mesh for better plots
m = Mesher(func=fx.sphere_func)
m = Mesher(func=fx.sphere_func,
limits=[(-1,1), (-1,1)])
# Adjust figure limits
d = Designer(limits=[(-1,1), (-1,1), (-0.1,1)],
label=['x-axis', 'y-axis', 'z-axis'])
Expand All @@ -225,7 +226,7 @@ d = Designer(limits=[(-1,1), (-1,1), (-0.1,1)],
In 2D,

```python
plot_contour(pos_history=optimizer.pos_history, mesher=m, mark=(0,0))
plot_contour(pos_history=optimizer.pos_history, mesher=m, designer=d, mark=(0,0))
```

![Contour](https://i.imgur.com/H3YofJ6.gif)
Expand Down
6 changes: 4 additions & 2 deletions docs/api/_pyswarms.utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ functionalities.

.. toctree::

pyswarms.utils.decorators
pyswarms.utils.functions
pyswarms.utils.search
pyswarms.utils.plotters
pyswarms.utils.environments
pyswarms.utils.reporter
pyswarms.utils.search

7 changes: 7 additions & 0 deletions docs/api/pyswarms.utils.decorators.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pyswarms.utils.decorators package
=================================

.. automodule:: pyswarms.utils.decorators
:members:
:undoc-members:
:show-inheritance:
17 changes: 0 additions & 17 deletions docs/api/pyswarms.utils.environments.rst

This file was deleted.

10 changes: 10 additions & 0 deletions docs/api/pyswarms.utils.reporter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pyswarms.utils.reporter package
================================

.. automodule:: pyswarms.utils.reporter.reporter
:members:
:undoc-members:
:show-inheritance:
:private-members:
:special-members: __init__

Loading