source: trunk/coopr/opt/parallel/local.py @ 1768

Last change on this file since 1768 was 1768, checked in by wehart, 11 years ago

Rework of Coopr to use the new PyUtilib? package decomposition.

NOTE: to use Coopr with this update, we need to work with a new version of coopr_install.

File size: 2.0 KB
Line 
1#  _________________________________________________________________________
2#
3#  Coopr: A COmmon Optimization Python Repository
4#  Copyright (c) 2008 Sandia Corporation.
5#  This software is distributed under the BSD License.
6#  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
7#  the U.S. Government retains certain rights in this software.
8#  For more information, see the Coopr README.txt file.
9#  _________________________________________________________________________
10
11
12__all__ = []
13
14from manager import *
15from solver import *
16
17
18class SolverManager_Serial(AsynchronousSolverManager):
19
20    def clear(self):
21        """
22        Clear manager state
23        """
24        AsynchronousSolverManager.clear(self)
25        self._ah_list = []
26        self._opt = None
27
28    def _perform_queue(self, ah, *args, **kwds):
29        """
30        Perform the queue operation.  This method returns the ActionHandle,
31        and the ActionHandle status indicates whether the queue was successful.
32        """
33        if 'opt' in kwds:
34            self._opt = kwds['opt']
35            del kwds['opt']
36        if self._opt is None:
37            raise ActionManagerError, "Undefined solver"
38        self.results[ah.id] = self._opt.solve(*args, **kwds)
39        ah.status = ActionStatus.done
40        self._ah_list.append(ah)
41        return ah
42
43    def _perform_wait_any(self):
44        """
45        Perform the wait_any operation.  This method returns an
46        ActionHandle with the results of waiting.  If None is returned
47        then the ActionManager assumes that it can call this method again.
48        Note that an ActionHandle can be returned with a dummy value,
49        to indicate an error.
50        """
51        if len(self._ah_list) > 0:
52            return self._ah_list.pop()
53        return ActionHandle(error=True, explanation="No queued evaluations available in the 'local' solver manager, which only executes solvers synchronously")
54
55
56SolverManagerRegistration("serial", SolverManager_Serial)
Note: See TracBrowser for help on using the repository browser.