We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ASL Sover Version Check Timeout Increase
## Summary

Increase the subprocess timeout in the ASL solver version check. 

### Rationale

This may be an odd use case, but I have Windows batch files wrapping solvers running in WSL, so I can use solvers built for Linux on Windows.  It seems to take a bit longer to return with the version info.  The version returns fine with the longer timeout when I tested it with Ipopt.  I'm not sure exactly what the best number is but 6 seconds seems to work for me.

### Description

<!-- Describe the solution you'd like and the alternatives you have considered. -->


### Additional information
<!-- Add any other context about the feature request here. -->



<!-- If you want to ask a question (how to use Pyomo, what it can do, etc.), please refer to our [online documentation](https://github.com/Pyomo/pyomo#getting-help) on ways to get help. -->

ASL Sover Version Check Timeout Increase
## Summary

Increase the subprocess timeout in the ASL solver version check. 

### Rationale

This may be an odd use case, but I have Windows batch files wrapping solvers running in WSL, so I can use solvers built for Linux on Windows.  It seems to take a bit longer to return with the version info.  The version returns fine with the longer timeout when I tested it with Ipopt.  I'm not sure exactly what the best number is but 6 seconds seems to work for me.

### Description

<!-- Describe the solution you'd like and the alternatives you have considered. -->


### Additional information
<!-- Add any other context about the feature request here. -->



<!-- If you want to ask a question (how to use Pyomo, what it can do, etc.), please refer to our [online documentation](https://github.com/Pyomo/pyomo#getting-help) on ways to get help. -->


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pyomo/solvers/plugins/solvers/ASL.py`
Content:
```
1 #  ___________________________________________________________________________
2 #
3 #  Pyomo: Python Optimization Modeling Objects
4 #  Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC
5 #  Under the terms of Contract DE-NA0003525 with National Technology and 
6 #  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain 
7 #  rights in this software.
8 #  This software is distributed under the 3-clause BSD License.
9 #  ___________________________________________________________________________
10 
11 
12 import os
13 import subprocess
14 
15 from pyomo.common import Executable
16 from pyomo.common.errors import ApplicationError
17 from pyomo.common.collections import Bunch
18 from pyomo.common.tempfiles import TempfileManager
19 
20 from pyomo.opt.base import ProblemFormat, ResultsFormat
21 from pyomo.opt.base.solvers import _extract_version, SolverFactory
22 from pyomo.opt.solver import SystemCallSolver
23 from pyomo.core.kernel.block import IBlock
24 from pyomo.solvers.mockmip import MockMIP
25 from pyomo.core import TransformationFactory
26 
27 import logging
28 logger = logging.getLogger('pyomo.solvers')
29 
30 
31 @SolverFactory.register('asl', doc='Interface for solvers using the AMPL Solver Library')
32 class ASL(SystemCallSolver):
33     """A generic optimizer that uses the AMPL Solver Library to interface with applications.
34     """
35 
36 
37     def __init__(self, **kwds):
38         #
39         # Call base constructor
40         #
41         if not 'type' in kwds:
42             kwds["type"] = "asl"
43         SystemCallSolver.__init__(self, **kwds)
44         self._metasolver = True
45         #
46         # Setup valid problem formats, and valid results for each problem format.
47         # Also set the default problem and results formats.
48         #
49         self._valid_problem_formats=[ProblemFormat.nl]
50         self._valid_result_formats = {}
51         self._valid_result_formats[ProblemFormat.nl] = [ResultsFormat.sol]
52         self.set_problem_format(ProblemFormat.nl)
53         #
54         # Note: Undefined capabilities default to 'None'
55         #
56         self._capabilities = Bunch()
57         self._capabilities.linear = True
58         self._capabilities.integer = True
59         self._capabilities.quadratic_objective = True
60         self._capabilities.quadratic_constraint = True
61         self._capabilities.sos1 = True
62         self._capabilities.sos2 = True
63 
64     def _default_results_format(self, prob_format):
65         return ResultsFormat.sol
66 
67     def _default_executable(self):
68         #
69         # We register the ASL executables dynamically, since _any_ ASL solver could be
70         # executed by this solver.
71         #
72         if self.options.solver is None:
73             logger.warning("No solver option specified for ASL solver interface")
74             return None
75         if not self.options.solver:
76             logger.warning(
77                 "No solver option specified for ASL solver interface")
78             return None
79         executable = Executable(self.options.solver)
80         if not executable:
81             logger.warning(
82                 "Could not locate the '%s' executable, which is required "
83                 "for solver %s" % (self.options.solver, self.name))
84             self.enable = False
85             return None
86         return executable.path()
87 
88     def _get_version(self):
89         """
90         Returns a tuple describing the solver executable version.
91         """
92         solver_exec = self.executable()
93         if solver_exec is None:
94             return _extract_version('')
95         try:
96             results = subprocess.run([solver_exec, "-v"],
97                                      timeout=2,
98                                      stdout=subprocess.PIPE,
99                                      stderr=subprocess.STDOUT,
100                                      universal_newlines=True)
101             return _extract_version(results.stdout)
102         except OSError:
103             pass
104         except subprocess.TimeoutExpired:
105             pass
106 
107     def available(self, exception_flag=True):
108         if not super().available(exception_flag):
109             return False
110         return self.version() is not None
111 
112     def create_command_line(self, executable, problem_files):
113         assert(self._problem_format == ProblemFormat.nl)
114         assert(self._results_format == ResultsFormat.sol)
115         #
116         # Define log file
117         #
118         solver_name = os.path.basename(self.options.solver)
119         if self._log_file is None:
120             self._log_file = TempfileManager.\
121                              create_tempfile(suffix="_%s.log" % solver_name)
122 
123         #
124         # Define solution file
125         #
126         if self._soln_file is not None:
127             # the solution file can not be redefined
128             logger.warning("The 'soln_file' keyword will be ignored "
129                            "for solver="+self.type)
130         fname = problem_files[0]
131         if '.' in fname:
132             tmp = fname.split('.')
133             fname = '.'.join(tmp[:-1])
134         self._soln_file = fname+".sol"
135 
136         #
137         # Define results file (since an external parser is used)
138         #
139         self._results_file = self._soln_file
140 
141         #
142         # Define command line
143         #
144         env=os.environ.copy()
145         #
146         # Merge the PYOMO_AMPLFUNC (externals defined within
147         # Pyomo/Pyomo) with any user-specified external function
148         # libraries
149         #
150         if 'PYOMO_AMPLFUNC' in env:
151             if 'AMPLFUNC' in env:
152                 env['AMPLFUNC'] += "\n" + env['PYOMO_AMPLFUNC']
153             else:
154                 env['AMPLFUNC'] = env['PYOMO_AMPLFUNC']
155 
156         cmd = [executable, problem_files[0], '-AMPL']
157         if self._timer:
158             cmd.insert(0, self._timer)
159         #
160         # GAH: I am going to re-add the code by Zev that passed options through
161         # to the command line. Setting the environment variable in this way does
162         # NOT work for solvers like cplex and gurobi because the are looking for
163         # an environment variable called cplex_options / gurobi_options. However
164         # the options.solver name for these solvers is cplexamp / gurobi_ampl
165         # (which creates a cplexamp_options and gurobi_ampl_options env variable).
166         # Because of this, I think the only reliable way to pass options for any
167         # solver is by using the command line
168         #
169         opt=[]
170         for key in self.options:
171             if key == 'solver':
172                 continue
173             if isinstance(self.options[key], str) and \
174                (' ' in self.options[key]):
175                 opt.append(key+"=\""+str(self.options[key])+"\"")
176                 cmd.append(str(key)+"="+str(self.options[key]))
177             elif key == 'subsolver':
178                 opt.append("solver="+str(self.options[key]))
179                 cmd.append(str(key)+"="+str(self.options[key]))
180             else:
181                 opt.append(key+"="+str(self.options[key]))
182                 cmd.append(str(key)+"="+str(self.options[key]))
183 
184         envstr = "%s_options" % self.options.solver
185         # Merge with any options coming in through the environment
186         env[envstr] = " ".join(opt)
187 
188         return Bunch(cmd=cmd, log_file=self._log_file, env=env)
189 
190     def _presolve(self, *args, **kwds):
191         if (not isinstance(args[0], str)) and \
192            (not isinstance(args[0], IBlock)):
193             self._instance = args[0]
194             xfrm = TransformationFactory('mpec.nl')
195             xfrm.apply_to(self._instance)
196             if len(self._instance._transformation_data['mpec.nl'].compl_cuids) == 0:
197                 # There were no complementarity conditions
198                 # so we don't hold onto the instance
199                 self._instance = None
200             else:
201                 args = (self._instance,)
202         else:
203             self._instance = None
204         #
205         SystemCallSolver._presolve(self, *args, **kwds)
206 
207     def _postsolve(self):
208         #
209         # Reclassify complementarity components
210         #
211         mpec=False
212         if not self._instance is None:
213             from pyomo.mpec import Complementarity
214             for cuid in self._instance._transformation_data['mpec.nl'].compl_cuids:
215                 mpec=True
216                 cobj = cuid.find_component_on(self._instance)
217                 cobj.parent_block().reclassify_component_type(cobj, Complementarity)
218         #
219         self._instance = None
220         return SystemCallSolver._postsolve(self)
221 
222 
223 @SolverFactory.register('_mock_asl')
224 class MockASL(ASL,MockMIP):
225     """A Mock ASL solver used for testing
226     """
227 
228     def __init__(self, **kwds):
229         try:
230             ASL.__init__(self,**kwds)
231         except ApplicationError: #pragma:nocover
232             pass                        #pragma:nocover
233         MockMIP.__init__(self,"asl")
234         self._assert_available = True
235 
236     def available(self, exception_flag=True):
237         return ASL.available(self,exception_flag)
238 
239     def create_command_line(self,executable, problem_files):
240         command = ASL.create_command_line(self,
241                                           executable,
242                                           problem_files)
243         MockMIP.create_command_line(self,
244                                     executable,
245                                     problem_files)
246         return command
247 
248     def executable(self):
249         return MockMIP.executable(self)
250 
251     def _execute_command(self,cmd):
252         return MockMIP._execute_command(self,cmd)
253
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pyomo/solvers/plugins/solvers/ASL.py b/pyomo/solvers/plugins/solvers/ASL.py
--- a/pyomo/solvers/plugins/solvers/ASL.py
+++ b/pyomo/solvers/plugins/solvers/ASL.py
@@ -94,7 +94,7 @@
             return _extract_version('')
         try:
             results = subprocess.run([solver_exec, "-v"],
-                                     timeout=2,
+                                     timeout=5,
                                      stdout=subprocess.PIPE,
                                      stderr=subprocess.STDOUT,
                                      universal_newlines=True)

{"golden_diff": "diff --git a/pyomo/solvers/plugins/solvers/ASL.py b/pyomo/solvers/plugins/solvers/ASL.py\n--- a/pyomo/solvers/plugins/solvers/ASL.py\n+++ b/pyomo/solvers/plugins/solvers/ASL.py\n@@ -94,7 +94,7 @@\n             return _extract_version('')\n         try:\n             results = subprocess.run([solver_exec, \"-v\"],\n-                                     timeout=2,\n+                                     timeout=5,\n                                      stdout=subprocess.PIPE,\n                                      stderr=subprocess.STDOUT,\n                                      universal_newlines=True)\n", "issue": "ASL Sover Version Check Timeout Increase\n## Summary\r\n\r\nIncrease the subprocess timeout in the ASL solver version check. \r\n\r\n### Rationale\r\n\r\nThis may be an odd use case, but I have Windows batch files wrapping solvers running in WSL, so I can use solvers built for Linux on Windows.  It seems to take a bit longer to return with the version info.  The version returns fine with the longer timeout when I tested it with Ipopt.  I'm not sure exactly what the best number is but 6 seconds seems to work for me.\r\n\r\n### Description\r\n\r\n<!-- Describe the solution you'd like and the alternatives you have considered. -->\r\n\r\n\r\n### Additional information\r\n<!-- Add any other context about the feature request here. -->\r\n\r\n\r\n\r\n<!-- If you want to ask a question (how to use Pyomo, what it can do, etc.), please refer to our [online documentation](https://github.com/Pyomo/pyomo#getting-help) on ways to get help. -->\r\n\nASL Sover Version Check Timeout Increase\n## Summary\r\n\r\nIncrease the subprocess timeout in the ASL solver version check. \r\n\r\n### Rationale\r\n\r\nThis may be an odd use case, but I have Windows batch files wrapping solvers running in WSL, so I can use solvers built for Linux on Windows.  It seems to take a bit longer to return with the version info.  The version returns fine with the longer timeout when I tested it with Ipopt.  I'm not sure exactly what the best number is but 6 seconds seems to work for me.\r\n\r\n### Description\r\n\r\n<!-- Describe the solution you'd like and the alternatives you have considered. -->\r\n\r\n\r\n### Additional information\r\n<!-- Add any other context about the feature request here. -->\r\n\r\n\r\n\r\n<!-- If you want to ask a question (how to use Pyomo, what it can do, etc.), please refer to our [online documentation](https://github.com/Pyomo/pyomo#getting-help) on ways to get help. -->\r\n\n", "before_files": [{"content": "#  ___________________________________________________________________________\n#\n#  Pyomo: Python Optimization Modeling Objects\n#  Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC\n#  Under the terms of Contract DE-NA0003525 with National Technology and \n#  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain \n#  rights in this software.\n#  This software is distributed under the 3-clause BSD License.\n#  ___________________________________________________________________________\n\n\nimport os\nimport subprocess\n\nfrom pyomo.common import Executable\nfrom pyomo.common.errors import ApplicationError\nfrom pyomo.common.collections import Bunch\nfrom pyomo.common.tempfiles import TempfileManager\n\nfrom pyomo.opt.base import ProblemFormat, ResultsFormat\nfrom pyomo.opt.base.solvers import _extract_version, SolverFactory\nfrom pyomo.opt.solver import SystemCallSolver\nfrom pyomo.core.kernel.block import IBlock\nfrom pyomo.solvers.mockmip import MockMIP\nfrom pyomo.core import TransformationFactory\n\nimport logging\nlogger = logging.getLogger('pyomo.solvers')\n\n\n@SolverFactory.register('asl', doc='Interface for solvers using the AMPL Solver Library')\nclass ASL(SystemCallSolver):\n    \"\"\"A generic optimizer that uses the AMPL Solver Library to interface with applications.\n    \"\"\"\n\n\n    def __init__(self, **kwds):\n        #\n        # Call base constructor\n        #\n        if not 'type' in kwds:\n            kwds[\"type\"] = \"asl\"\n        SystemCallSolver.__init__(self, **kwds)\n        self._metasolver = True\n        #\n        # Setup valid problem formats, and valid results for each problem format.\n        # Also set the default problem and results formats.\n        #\n        self._valid_problem_formats=[ProblemFormat.nl]\n        self._valid_result_formats = {}\n        self._valid_result_formats[ProblemFormat.nl] = [ResultsFormat.sol]\n        self.set_problem_format(ProblemFormat.nl)\n        #\n        # Note: Undefined capabilities default to 'None'\n        #\n        self._capabilities = Bunch()\n        self._capabilities.linear = True\n        self._capabilities.integer = True\n        self._capabilities.quadratic_objective = True\n        self._capabilities.quadratic_constraint = True\n        self._capabilities.sos1 = True\n        self._capabilities.sos2 = True\n\n    def _default_results_format(self, prob_format):\n        return ResultsFormat.sol\n\n    def _default_executable(self):\n        #\n        # We register the ASL executables dynamically, since _any_ ASL solver could be\n        # executed by this solver.\n        #\n        if self.options.solver is None:\n            logger.warning(\"No solver option specified for ASL solver interface\")\n            return None\n        if not self.options.solver:\n            logger.warning(\n                \"No solver option specified for ASL solver interface\")\n            return None\n        executable = Executable(self.options.solver)\n        if not executable:\n            logger.warning(\n                \"Could not locate the '%s' executable, which is required \"\n                \"for solver %s\" % (self.options.solver, self.name))\n            self.enable = False\n            return None\n        return executable.path()\n\n    def _get_version(self):\n        \"\"\"\n        Returns a tuple describing the solver executable version.\n        \"\"\"\n        solver_exec = self.executable()\n        if solver_exec is None:\n            return _extract_version('')\n        try:\n            results = subprocess.run([solver_exec, \"-v\"],\n                                     timeout=2,\n                                     stdout=subprocess.PIPE,\n                                     stderr=subprocess.STDOUT,\n                                     universal_newlines=True)\n            return _extract_version(results.stdout)\n        except OSError:\n            pass\n        except subprocess.TimeoutExpired:\n            pass\n\n    def available(self, exception_flag=True):\n        if not super().available(exception_flag):\n            return False\n        return self.version() is not None\n\n    def create_command_line(self, executable, problem_files):\n        assert(self._problem_format == ProblemFormat.nl)\n        assert(self._results_format == ResultsFormat.sol)\n        #\n        # Define log file\n        #\n        solver_name = os.path.basename(self.options.solver)\n        if self._log_file is None:\n            self._log_file = TempfileManager.\\\n                             create_tempfile(suffix=\"_%s.log\" % solver_name)\n\n        #\n        # Define solution file\n        #\n        if self._soln_file is not None:\n            # the solution file can not be redefined\n            logger.warning(\"The 'soln_file' keyword will be ignored \"\n                           \"for solver=\"+self.type)\n        fname = problem_files[0]\n        if '.' in fname:\n            tmp = fname.split('.')\n            fname = '.'.join(tmp[:-1])\n        self._soln_file = fname+\".sol\"\n\n        #\n        # Define results file (since an external parser is used)\n        #\n        self._results_file = self._soln_file\n\n        #\n        # Define command line\n        #\n        env=os.environ.copy()\n        #\n        # Merge the PYOMO_AMPLFUNC (externals defined within\n        # Pyomo/Pyomo) with any user-specified external function\n        # libraries\n        #\n        if 'PYOMO_AMPLFUNC' in env:\n            if 'AMPLFUNC' in env:\n                env['AMPLFUNC'] += \"\\n\" + env['PYOMO_AMPLFUNC']\n            else:\n                env['AMPLFUNC'] = env['PYOMO_AMPLFUNC']\n\n        cmd = [executable, problem_files[0], '-AMPL']\n        if self._timer:\n            cmd.insert(0, self._timer)\n        #\n        # GAH: I am going to re-add the code by Zev that passed options through\n        # to the command line. Setting the environment variable in this way does\n        # NOT work for solvers like cplex and gurobi because the are looking for\n        # an environment variable called cplex_options / gurobi_options. However\n        # the options.solver name for these solvers is cplexamp / gurobi_ampl\n        # (which creates a cplexamp_options and gurobi_ampl_options env variable).\n        # Because of this, I think the only reliable way to pass options for any\n        # solver is by using the command line\n        #\n        opt=[]\n        for key in self.options:\n            if key == 'solver':\n                continue\n            if isinstance(self.options[key], str) and \\\n               (' ' in self.options[key]):\n                opt.append(key+\"=\\\"\"+str(self.options[key])+\"\\\"\")\n                cmd.append(str(key)+\"=\"+str(self.options[key]))\n            elif key == 'subsolver':\n                opt.append(\"solver=\"+str(self.options[key]))\n                cmd.append(str(key)+\"=\"+str(self.options[key]))\n            else:\n                opt.append(key+\"=\"+str(self.options[key]))\n                cmd.append(str(key)+\"=\"+str(self.options[key]))\n\n        envstr = \"%s_options\" % self.options.solver\n        # Merge with any options coming in through the environment\n        env[envstr] = \" \".join(opt)\n\n        return Bunch(cmd=cmd, log_file=self._log_file, env=env)\n\n    def _presolve(self, *args, **kwds):\n        if (not isinstance(args[0], str)) and \\\n           (not isinstance(args[0], IBlock)):\n            self._instance = args[0]\n            xfrm = TransformationFactory('mpec.nl')\n            xfrm.apply_to(self._instance)\n            if len(self._instance._transformation_data['mpec.nl'].compl_cuids) == 0:\n                # There were no complementarity conditions\n                # so we don't hold onto the instance\n                self._instance = None\n            else:\n                args = (self._instance,)\n        else:\n            self._instance = None\n        #\n        SystemCallSolver._presolve(self, *args, **kwds)\n\n    def _postsolve(self):\n        #\n        # Reclassify complementarity components\n        #\n        mpec=False\n        if not self._instance is None:\n            from pyomo.mpec import Complementarity\n            for cuid in self._instance._transformation_data['mpec.nl'].compl_cuids:\n                mpec=True\n                cobj = cuid.find_component_on(self._instance)\n                cobj.parent_block().reclassify_component_type(cobj, Complementarity)\n        #\n        self._instance = None\n        return SystemCallSolver._postsolve(self)\n\n\n@SolverFactory.register('_mock_asl')\nclass MockASL(ASL,MockMIP):\n    \"\"\"A Mock ASL solver used for testing\n    \"\"\"\n\n    def __init__(self, **kwds):\n        try:\n            ASL.__init__(self,**kwds)\n        except ApplicationError: #pragma:nocover\n            pass                        #pragma:nocover\n        MockMIP.__init__(self,\"asl\")\n        self._assert_available = True\n\n    def available(self, exception_flag=True):\n        return ASL.available(self,exception_flag)\n\n    def create_command_line(self,executable, problem_files):\n        command = ASL.create_command_line(self,\n                                          executable,\n                                          problem_files)\n        MockMIP.create_command_line(self,\n                                    executable,\n                                    problem_files)\n        return command\n\n    def executable(self):\n        return MockMIP.executable(self)\n\n    def _execute_command(self,cmd):\n        return MockMIP._execute_command(self,cmd)\n", "path": "pyomo/solvers/plugins/solvers/ASL.py"}], "after_files": [{"content": "#  ___________________________________________________________________________\n#\n#  Pyomo: Python Optimization Modeling Objects\n#  Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC\n#  Under the terms of Contract DE-NA0003525 with National Technology and \n#  Engineering Solutions of Sandia, LLC, the U.S. Government retains certain \n#  rights in this software.\n#  This software is distributed under the 3-clause BSD License.\n#  ___________________________________________________________________________\n\n\nimport os\nimport subprocess\n\nfrom pyomo.common import Executable\nfrom pyomo.common.errors import ApplicationError\nfrom pyomo.common.collections import Bunch\nfrom pyomo.common.tempfiles import TempfileManager\n\nfrom pyomo.opt.base import ProblemFormat, ResultsFormat\nfrom pyomo.opt.base.solvers import _extract_version, SolverFactory\nfrom pyomo.opt.solver import SystemCallSolver\nfrom pyomo.core.kernel.block import IBlock\nfrom pyomo.solvers.mockmip import MockMIP\nfrom pyomo.core import TransformationFactory\n\nimport logging\nlogger = logging.getLogger('pyomo.solvers')\n\n\n@SolverFactory.register('asl', doc='Interface for solvers using the AMPL Solver Library')\nclass ASL(SystemCallSolver):\n    \"\"\"A generic optimizer that uses the AMPL Solver Library to interface with applications.\n    \"\"\"\n\n\n    def __init__(self, **kwds):\n        #\n        # Call base constructor\n        #\n        if not 'type' in kwds:\n            kwds[\"type\"] = \"asl\"\n        SystemCallSolver.__init__(self, **kwds)\n        self._metasolver = True\n        #\n        # Setup valid problem formats, and valid results for each problem format.\n        # Also set the default problem and results formats.\n        #\n        self._valid_problem_formats=[ProblemFormat.nl]\n        self._valid_result_formats = {}\n        self._valid_result_formats[ProblemFormat.nl] = [ResultsFormat.sol]\n        self.set_problem_format(ProblemFormat.nl)\n        #\n        # Note: Undefined capabilities default to 'None'\n        #\n        self._capabilities = Bunch()\n        self._capabilities.linear = True\n        self._capabilities.integer = True\n        self._capabilities.quadratic_objective = True\n        self._capabilities.quadratic_constraint = True\n        self._capabilities.sos1 = True\n        self._capabilities.sos2 = True\n\n    def _default_results_format(self, prob_format):\n        return ResultsFormat.sol\n\n    def _default_executable(self):\n        #\n        # We register the ASL executables dynamically, since _any_ ASL solver could be\n        # executed by this solver.\n        #\n        if self.options.solver is None:\n            logger.warning(\"No solver option specified for ASL solver interface\")\n            return None\n        if not self.options.solver:\n            logger.warning(\n                \"No solver option specified for ASL solver interface\")\n            return None\n        executable = Executable(self.options.solver)\n        if not executable:\n            logger.warning(\n                \"Could not locate the '%s' executable, which is required \"\n                \"for solver %s\" % (self.options.solver, self.name))\n            self.enable = False\n            return None\n        return executable.path()\n\n    def _get_version(self):\n        \"\"\"\n        Returns a tuple describing the solver executable version.\n        \"\"\"\n        solver_exec = self.executable()\n        if solver_exec is None:\n            return _extract_version('')\n        try:\n            results = subprocess.run([solver_exec, \"-v\"],\n                                     timeout=5,\n                                     stdout=subprocess.PIPE,\n                                     stderr=subprocess.STDOUT,\n                                     universal_newlines=True)\n            return _extract_version(results.stdout)\n        except OSError:\n            pass\n        except subprocess.TimeoutExpired:\n            pass\n\n    def available(self, exception_flag=True):\n        if not super().available(exception_flag):\n            return False\n        return self.version() is not None\n\n    def create_command_line(self, executable, problem_files):\n        assert(self._problem_format == ProblemFormat.nl)\n        assert(self._results_format == ResultsFormat.sol)\n        #\n        # Define log file\n        #\n        solver_name = os.path.basename(self.options.solver)\n        if self._log_file is None:\n            self._log_file = TempfileManager.\\\n                             create_tempfile(suffix=\"_%s.log\" % solver_name)\n\n        #\n        # Define solution file\n        #\n        if self._soln_file is not None:\n            # the solution file can not be redefined\n            logger.warning(\"The 'soln_file' keyword will be ignored \"\n                           \"for solver=\"+self.type)\n        fname = problem_files[0]\n        if '.' in fname:\n            tmp = fname.split('.')\n            fname = '.'.join(tmp[:-1])\n        self._soln_file = fname+\".sol\"\n\n        #\n        # Define results file (since an external parser is used)\n        #\n        self._results_file = self._soln_file\n\n        #\n        # Define command line\n        #\n        env=os.environ.copy()\n        #\n        # Merge the PYOMO_AMPLFUNC (externals defined within\n        # Pyomo/Pyomo) with any user-specified external function\n        # libraries\n        #\n        if 'PYOMO_AMPLFUNC' in env:\n            if 'AMPLFUNC' in env:\n                env['AMPLFUNC'] += \"\\n\" + env['PYOMO_AMPLFUNC']\n            else:\n                env['AMPLFUNC'] = env['PYOMO_AMPLFUNC']\n\n        cmd = [executable, problem_files[0], '-AMPL']\n        if self._timer:\n            cmd.insert(0, self._timer)\n        #\n        # GAH: I am going to re-add the code by Zev that passed options through\n        # to the command line. Setting the environment variable in this way does\n        # NOT work for solvers like cplex and gurobi because the are looking for\n        # an environment variable called cplex_options / gurobi_options. However\n        # the options.solver name for these solvers is cplexamp / gurobi_ampl\n        # (which creates a cplexamp_options and gurobi_ampl_options env variable).\n        # Because of this, I think the only reliable way to pass options for any\n        # solver is by using the command line\n        #\n        opt=[]\n        for key in self.options:\n            if key == 'solver':\n                continue\n            if isinstance(self.options[key], str) and \\\n               (' ' in self.options[key]):\n                opt.append(key+\"=\\\"\"+str(self.options[key])+\"\\\"\")\n                cmd.append(str(key)+\"=\"+str(self.options[key]))\n            elif key == 'subsolver':\n                opt.append(\"solver=\"+str(self.options[key]))\n                cmd.append(str(key)+\"=\"+str(self.options[key]))\n            else:\n                opt.append(key+\"=\"+str(self.options[key]))\n                cmd.append(str(key)+\"=\"+str(self.options[key]))\n\n        envstr = \"%s_options\" % self.options.solver\n        # Merge with any options coming in through the environment\n        env[envstr] = \" \".join(opt)\n\n        return Bunch(cmd=cmd, log_file=self._log_file, env=env)\n\n    def _presolve(self, *args, **kwds):\n        if (not isinstance(args[0], str)) and \\\n           (not isinstance(args[0], IBlock)):\n            self._instance = args[0]\n            xfrm = TransformationFactory('mpec.nl')\n            xfrm.apply_to(self._instance)\n            if len(self._instance._transformation_data['mpec.nl'].compl_cuids) == 0:\n                # There were no complementarity conditions\n                # so we don't hold onto the instance\n                self._instance = None\n            else:\n                args = (self._instance,)\n        else:\n            self._instance = None\n        #\n        SystemCallSolver._presolve(self, *args, **kwds)\n\n    def _postsolve(self):\n        #\n        # Reclassify complementarity components\n        #\n        mpec=False\n        if not self._instance is None:\n            from pyomo.mpec import Complementarity\n            for cuid in self._instance._transformation_data['mpec.nl'].compl_cuids:\n                mpec=True\n                cobj = cuid.find_component_on(self._instance)\n                cobj.parent_block().reclassify_component_type(cobj, Complementarity)\n        #\n        self._instance = None\n        return SystemCallSolver._postsolve(self)\n\n\n@SolverFactory.register('_mock_asl')\nclass MockASL(ASL,MockMIP):\n    \"\"\"A Mock ASL solver used for testing\n    \"\"\"\n\n    def __init__(self, **kwds):\n        try:\n            ASL.__init__(self,**kwds)\n        except ApplicationError: #pragma:nocover\n            pass                        #pragma:nocover\n        MockMIP.__init__(self,\"asl\")\n        self._assert_available = True\n\n    def available(self, exception_flag=True):\n        return ASL.available(self,exception_flag)\n\n    def create_command_line(self,executable, problem_files):\n        command = ASL.create_command_line(self,\n                                          executable,\n                                          problem_files)\n        MockMIP.create_command_line(self,\n                                    executable,\n                                    problem_files)\n        return command\n\n    def executable(self):\n        return MockMIP.executable(self)\n\n    def _execute_command(self,cmd):\n        return MockMIP._execute_command(self,cmd)\n", "path": "pyomo/solvers/plugins/solvers/ASL.py"}]}