Ticket #255 (new defect)
ez_map2 fails for solvers
Reported by: | mmckerns | Owned by: | mmckerns |
---|---|---|---|
Priority: | minor | Milestone: | mystic-0.3a |
Component: | pathos | Keywords: | |
Cc: |
Description
ez_map2 fails for solvers. Throws traceback ending which includes:
File "./tmp-XBI61.py", line 3, in function_wrapper return function(_x) + penalty_function(_x) NameError: global name 'function' is not defined
Change History
comment:2 Changed 3 years ago by mmckerns
point of failure seems to stem from mystic.tools.wrap_penalty:
def wrap_penalty(function, penalty_function): """append a function call to a function object This is useful for binding a penalty function to a cost function; thus, the penalty will be evaluated at every cost function evaluation. """ def function_wrapper(x): _x = x[:] #XXX: trouble if x not a list or ndarray... maybe "deepcopy"? return function(_x) + penalty_function(_x) return function_wrapper
comment:3 Changed 18 months ago by mmckerns
Here is the traceback from Mpi(nodes, source=True).map:
>>> from mystic.solvers import * >>> def squared(x): ... return sum(xi**2 for xi in x) ... >>> from pyina.launchers import Mpi >>> p = Mpi(8, source=True).map >>> >>> solver = DifferentialEvolutionSolver2(3) >>> solver.SetMapper(p) >>> solver.Solve(squared) Traceback (most recent call last): File "/Users/mmckerns/bin/ezpool.py", line 4, in <module> __import__('pkg_resources').run_script('pyina==0.2a1.dev', 'ezpool.py') File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 534, in run_script self.require(requires)[0].run_script(script_name, ns) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1438, in run_script execfile(script_filename, namespace, namespace) File "/Users/mmckerns/lib/python2.7/site-packages/pyina-0.2a1.dev-py2.7.egg/EGG-INFO/scripts/ezpool.py", line 44, in <module> module = __import__(modname) File "/Users/mmckerns/dev/svn/mystic/mystic/tests/tmp2mqnbx.py", line 12, in <module> penalty_function = self._penalty = lambda x: 0.0 NameError: name 'self' is not defined Traceback (most recent call last): File "/Users/mmckerns/bin/ezpool.py", line 4, in <module> __import__('pkg_resources').run_script('pyina==0.2a1.dev', 'ezpool.py') File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 534, in run_script self.require(requires)[0].run_script(script_name, ns) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1438, in run_script execfile(script_filename, namespace, namespace) File "/Users/mmckerns/lib/python2.7/site-packages/pyina-0.2a1.dev-py2.7.egg/EGG-INFO/scripts/ezpool.py", line 44, in <module> module = __import__(modname) File "/Users/mmckerns/dev/svn/mystic/mystic/tests/tmp2mqnbx.py", line 12, in <module> penalty_function = self._penalty = lambda x: 0.0 NameError: name 'self' is not defined Traceback (most recent call last): File "/Users/mmckerns/bin/ezpool.py", line 4, in <module> __import__('pkg_resources').run_script('pyina==0.2a1.dev', 'ezpool.py') File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 534, in run_script self.require(requires)[0].run_script(script_name, ns) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1438, in run_script execfile(script_filename, namespace, namespace) File "/Users/mmckerns/lib/python2.7/site-packages/pyina-0.2a1.dev-py2.7.egg/EGG-INFO/scripts/ezpool.py", line 44, in <module> module = __import__(modname) File "/Users/mmckerns/dev/svn/mystic/mystic/tests/tmp2mqnbx.py", line 12, in <module> penalty_function = self._penalty = lambda x: 0.0 NameError: name 'self' is not defined Traceback (most recent call last): File "/Users/mmckerns/bin/ezpool.py", line 4, in <module> __import__('pkg_resources').run_script('pyina==0.2a1.dev', 'ezpool.py') File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 534, in run_script self.require(requires)[0].run_script(script_name, ns) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1438, in run_script execfile(script_filename, namespace, namespace) File "/Users/mmckerns/lib/python2.7/site-packages/pyina-0.2a1.dev-py2.7.egg/EGG-INFO/scripts/ezpool.py", line 44, in <module> module = __import__(modname) File "/Users/mmckerns/dev/svn/mystic/mystic/tests/tmp2mqnbx.py", line 12, in <module> penalty_function = self._penalty = lambda x: 0.0 NameError: name 'self' is not defined Traceback (most recent call last): File "/Users/mmckerns/bin/ezpool.py", line 4, in <module> __import__('pkg_resources').run_script('pyina==0.2a1.dev', 'ezpool.py') File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 534, in run_script self.require(requires)[0].run_script(script_name, ns) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1438, in run_script execfile(script_filename, namespace, namespace) File "/Users/mmckerns/lib/python2.7/site-packages/pyina-0.2a1.dev-py2.7.egg/EGG-INFO/scripts/ezpool.py", line 44, in <module> module = __import__(modname) File "/Users/mmckerns/dev/svn/mystic/mystic/tests/tmp2mqnbx.py", line 12, in <module> penalty_function = self._penalty = lambda x: 0.0 NameError: name 'self' is not defined Traceback (most recent call last): File "/Users/mmckerns/bin/ezpool.py", line 4, in <module> __import__('pkg_resources').run_script('pyina==0.2a1.dev', 'ezpool.py') File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 534, in run_script self.require(requires)[0].run_script(script_name, ns) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1438, in run_script execfile(script_filename, namespace, namespace) File "/Users/mmckerns/lib/python2.7/site-packages/pyina-0.2a1.dev-py2.7.egg/EGG-INFO/scripts/ezpool.py", line 44, in <module> module = __import__(modname) File "/Users/mmckerns/dev/svn/mystic/mystic/tests/tmp2mqnbx.py", line 12, in <module> penalty_function = self._penalty = lambda x: 0.0 NameError: name 'self' is not defined Traceback (most recent call last): File "/Users/mmckerns/bin/ezpool.py", line 4, in <module> __import__('pkg_resources').run_script('pyina==0.2a1.dev', 'ezpool.py') File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 534, in run_script self.require(requires)[0].run_script(script_name, ns) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1438, in run_script execfile(script_filename, namespace, namespace) File "/Users/mmckerns/lib/python2.7/site-packages/pyina-0.2a1.dev-py2.7.egg/EGG-INFO/scripts/ezpool.py", line 44, in <module> module = __import__(modname) File "/Users/mmckerns/dev/svn/mystic/mystic/tests/tmp2mqnbx.py", line 12, in <module> penalty_function = self._penalty = lambda x: 0.0 NameError: name 'self' is not defined Traceback (most recent call last): File "/Users/mmckerns/bin/ezpool.py", line 4, in <module> __import__('pkg_resources').run_script('pyina==0.2a1.dev', 'ezpool.py') File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 534, in run_script self.require(requires)[0].run_script(script_name, ns) File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources.py", line 1438, in run_script execfile(script_filename, namespace, namespace) File "/Users/mmckerns/lib/python2.7/site-packages/pyina-0.2a1.dev-py2.7.egg/EGG-INFO/scripts/ezpool.py", line 44, in <module> module = __import__(modname) File "/Users/mmckerns/dev/svn/mystic/mystic/tests/tmp2mqnbx.py", line 12, in <module> penalty_function = self._penalty = lambda x: 0.0 NameError: name 'self' is not defined =================================================================================== = BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES = PID 73982 RUNNING AT hilbert.local = EXIT CODE: 1 = CLEANING UP REMAINING PROCESSES = YOU CAN IGNORE THE BELOW CLEANUP MESSAGES ===================================================================================
comment:4 Changed 18 months ago by mmckerns
- Milestone changed from mystic-0.2a2 to mystic-0.3a
This is now a "somewhat deprecated" parallel map in pyina, and the above example does work for source=False, which is the default. This should be included as part of a test suite for solver interactions with pathos/pyina (see #210).
Note: See
TracTickets for help on using
tickets.
ez_map2 is equivalent to Mpi( nodes, source=True ).map... which exhibits similar defect