Skip to content

Commit

Permalink
Merge pull request #368 from bluescarni/pr/ipy_fixes
Browse files Browse the repository at this point in the history
Another try at ipyparallel fixes
  • Loading branch information
bluescarni authored Dec 8, 2019
2 parents c7d6e89 + ac2f369 commit c4c673c
Show file tree
Hide file tree
Showing 14 changed files with 295 additions and 136 deletions.
19 changes: 18 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
version: 2

jobs:
bionic_gcc7_conda_py38:
docker:
- image: circleci/buildpack-deps:bionic
steps:
- checkout
- run:
name: Build and test
command: bash ./tools/circleci_bionic_gcc7_conda_py38.sh
bionic_gcc7_conda_py27:
docker:
- image: circleci/buildpack-deps:bionic
steps:
- checkout
- run:
name: Build and test
command: bash ./tools/circleci_bionic_gcc7_conda_py27.sh
bionic_gcc7_coverage:
docker:
- image: circleci/buildpack-deps:bionic
Expand Down Expand Up @@ -38,8 +54,9 @@ workflows:
version: 2
all_builds:
jobs:
- bionic_gcc7_conda_py38
- bionic_gcc7_conda_py27
- bionic_gcc7_coverage
- cosmic_gcc8_asan
- cosmic_clang7
- bionic_clang6_release

11 changes: 0 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ matrix:
packages:
- gcc-4.8
- g++-4.8
- env: PAGMO_BUILD="Python27"
dist: trusty
compiler: gcc
os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- env: PAGMO_BUILD="OSXDebug"
os: osx
osx_image: xcode6.4
Expand Down
1 change: 1 addition & 0 deletions ap_examples/test1.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ def fitness(self, a):
isl = pygmo.island(algo=ub, prob=py_udp(), size=20)
isl.evolve()
isl.wait_check()
pygmo.mp_island.shutdown_pool()
print("All good!")
1 change: 1 addition & 0 deletions ap_examples/test2.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ def evolve(self, pop):
isl = pygmo.island(algo=py_uda(), prob=ub, size=20)
isl.evolve()
isl.wait_check()
pygmo.mp_island.shutdown_pool()
print("All good!")
9 changes: 9 additions & 0 deletions doc/sphinx/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ New
- Implement the NSPSO algorithm
(`#314 <https://github.com/esa/pagmo2/pull/314>`__).

Changes
~~~~~~~

- **BREAKING**: the mechanism for managing the
interaction of an :class:`~pygmo.ipyparallel_island`
with an ipyparallel cluster has changed. Please refer
to the documentation for details
(`#368 <https://github.com/esa/pagmo2/pull/368>`__).

Fix
~~~

Expand Down
44 changes: 26 additions & 18 deletions doc/sphinx/docs/cpp/algorithms/nspso.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,32 @@ Non dominated sorting particle swarm optimization(NSPSO)

.. cpp:function:: void set_verbosity(unsigned level)

Sets the algorithm verbosity: sets the verbosity level of the screen ouput and of the log returned by ``get_log()`. *level* can be:
- 0: no verbosity.
- >0: will print and log one line each *level* generations.
Example (verbosity 1, where Gen, is the generation number, Fevals the number of function evaluations used; also, the ideal point of the current population follows cropped to its 5th component):
.. code-block:: c++
:linenos:
Gen: Fevals: ideal1: ideal2: ideal3: ideal4: ideal5: ... :
1 52 0.0586347 0.0587097 0.0586892 0.0592426 0.0614239
2 104 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
3 156 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
4 208 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
5 260 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
6 312 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
7 364 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
8 416 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
9 468 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
10 520 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
Sets the algorithm verbosity: sets the verbosity level
of the screen ouput and of the log returned by ``get_log()``.
*level* can be:

* 0: no verbosity.
* >0: will print and log one line each *level* generations.

Example (verbosity 1, where Gen, is the generation number,
Fevals the number of function evaluations used; also, the
ideal point of the current population follows cropped to its
5th component):

.. code-block:: c++
:linenos:

Gen: Fevals: ideal1: ideal2: ideal3: ideal4: ideal5: ... :
1 52 0.0586347 0.0587097 0.0586892 0.0592426 0.0614239
2 104 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
3 156 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
4 208 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
5 260 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
6 312 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
7 364 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
8 416 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
9 468 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778
10 520 0.00899252 0.00899395 0.00945782 0.0106282 0.0276778

.. cpp:function:: unsigned get_verbosity() const

Expand Down
1 change: 1 addition & 0 deletions pygmo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,7 @@ def get_serialization_backend():

def _cleanup():
mp_island.shutdown_pool()
ipyparallel_island.shutdown_view()
_cpp_cleanup()


Expand Down
22 changes: 14 additions & 8 deletions pygmo/_island_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,18 +612,24 @@ def run_basic_tests(self):
from . import ipyparallel_island
from copy import copy, deepcopy
from pickle import dumps, loads

ipyparallel_island.shutdown_view()
ipyparallel_island.shutdown_view()
ipyparallel_island.shutdown_view()

to = .5
isl = island(algo=de(), prob=rosenbrock(),
size=25, udi=ipyparallel_island())
ipyparallel_island.shutdown_view()
try:
isl = island(algo=de(), prob=rosenbrock(),
size=25, udi=ipyparallel_island(timeout=to))
ipyparallel_island.init_view(timeout=to)
except OSError:
return
isl = island(algo=de(), prob=rosenbrock(),
size=25, udi=ipyparallel_island(timeout=to))
isl = island(algo=de(), prob=rosenbrock(),
size=25, udi=ipyparallel_island(timeout=to + .3))
size=25, udi=ipyparallel_island())
self.assertEqual(isl.get_name(), "Ipyparallel island")
self.assertTrue(isl.get_extra_info() != "")
ipyparallel_island.shutdown_view()
isl.evolve(20)
isl.wait_check()
isl.evolve(20)
Expand All @@ -632,7 +638,7 @@ def run_basic_tests(self):

# Check the picklability of a problem storing a lambda.
isl = island(algo=de(), prob=_prob(lambda x, y: x + y),
size=25, udi=ipyparallel_island(timeout=to + .3))
size=25, udi=ipyparallel_island())
isl.evolve()
isl.wait_check()

Expand Down Expand Up @@ -668,9 +674,9 @@ def run_basic_tests(self):
return

# Check exception transport.
for _ in range(1000):
for _ in range(10):
isl = island(algo=de(), prob=_prob(
lambda x, y: x + y), size=2, udi=ipyparallel_island(timeout=to + .3))
lambda x, y: x + y), size=2, udi=ipyparallel_island())
isl.evolve()
isl.wait()
self.assertTrue("**error occurred**" in repr(isl))
Expand Down
Loading

0 comments on commit c4c673c

Please sign in to comment.