source: coopr.misc/trunk/scripts/pyro_mip_server @ 1839

Revision 1839, 1.6 KB checked in by jwatson, 4 years ago (diff)

Fixed problem involving module naming in pyro_mip_server, associated with latest coopr package re-org. The pyro solver manager now works correctly.

  • Property svn:executable set to *
Line 
1#! /usr/bin/env python
2#
3# pyro_mip_server: A script that sets up a Pyro server for solving MIPs in
4#           a distributed manner.
5#
6#  _________________________________________________________________________
7#
8#  Coopr: A COmmon Optimization Python Repository
9#  Copyright (c) 2008 Sandia Corporation.
10#  This software is distributed under the BSD License.
11#  Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
12#  the U.S. Government retains certain rights in this software.
13#  For more information, see the FAST README.txt file.
14#  _________________________________________________________________________
15
16import os
17import sys
18from os.path import abspath, dirname
19sys.path.insert(0, dirname(dirname(abspath(__file__))))
20sys.path.append(".")
21
22import coopr.opt
23import pyutilib.pyro
24import sys
25import pyutilib.services
26import pickle
27import os.path
28
29
30class CooprMIPWorker(pyutilib.pyro.TaskWorker):
31
32    def process(self, data):
33        opt = coopr.opt.SolverFactory(data.opt)
34        if opt is None:
35            raise ValueError, "Problem constructing solver `"+data.opt+"'"
36
37        fname = os.path.split(data.filename)[1]
38        tfile = pyutilib.services.TempfileManager.create_tempfile(suffix=fname)
39        OUTPUT=open(tfile,'w')
40        print >>OUTPUT, data.file
41        OUTPUT.close()
42        print "Applying Solver",data.opt,"to solve problem",tfile
43        results = opt.solve(tfile, **data.kwds)
44        pyutilib.services.TempfileManager.clear_tempfiles()
45        results.write()
46        sys.stdout.flush()
47        return pickle.dumps(results)
48
49
50pyutilib.pyro.TaskWorkerServer(CooprMIPWorker, argv=sys.argv)
51
Note: See TracBrowser for help on using the repository browser.