source: projects/CooprNEOSPlugin/trunk/coopr/plugins/neos/NEOS.py @ 14

Last change on this file since 14 was 14, checked in by anonymous, 12 years ago

Importing CooprNEOSPlugin

File size: 1.8 KB
Line 
1
2__all__ = ['NEOSRemoteSolver']
3
4import re
5from coopr.opt.base import *
6from coopr.opt.results import *
7from coopr.opt.solver import *
8import pyutilib.services
9import pyutilib.misc
10import os
11
12
13class NEOSRemoteSolver(SystemCallSolver):
14    """A wrapper class for NEOS Remote Solvers"""
15
16    def __init__(self, **kwds):
17        SystemCallSolver.__init__(self, **kwds)
18        self._valid_problem_formats=[ProblemFormat.nl]
19        self._valid_result_formats = {}
20        self._valid_result_formats[ProblemFormat.nl] = [ResultsFormat.sol]
21        self._problem_format = ProblemFormat.nl
22        self._results_format = ResultsFormat.sol
23        self.solver_options=""
24        self.tmp_opt=None
25
26    def create_command_line(self,executable,problem_files):
27        """
28        Create the local *.sol and *.log files, which will be
29        populated by NEOS.
30        """
31        if self.log_file is None:
32           self.log_file = pyutilib.services.TempfileManager.create_tempfile(suffix=".neos.log")
33        if self.soln_file is None:
34           self.soln_file = pyutilib.services.TempfileManager.create_tempfile(suffix=".neos.sol")
35           self.results_file = self.soln_file           
36        return pyutilib.misc.Bunch(cmd="", log_file=self.log_file, env="")
37
38    def process_logfile(self):
39        """
40        This function creates and returns a SolverResults object that
41        is populated with data that is parsed from the solver output
42        provided by NEOS.
43        """
44        self.tmp_opt.soln_file = self.soln_file
45        self.tmp_opt.log_file = self.log_file
46        self.tmp_opt.results_file = self.results_file
47        return self.tmp_opt.process_logfile()
48
49    def process_other_data(self,results):
50        """
51        Process the *.sol file.
52        """
53        self.tmp_opt.process_other_data(results)
54
55    def executable(self):
56        return True
Note: See TracBrowser for help on using the repository browser.