Ignore:
Timestamp:
Feb 15, 2010 5:13:14 PM (10 years ago)
Author:
wehart
Message:

Adding a hack to detect whether CBC has compiled-in support for
AMPL *.nl files.

This really mucks with the test semantics... :(

Location:
coopr.plugins/trunk/coopr/plugins/mip
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • coopr.plugins/trunk/coopr/plugins/mip/CBCplugin.py

    r2348 r2349  
    99#  _________________________________________________________________________
    1010
     11__all__ = ['CBC', 'MockCBC']
    1112
    1213import os
     
    1920import pyutilib.common
    2021import pyutilib.component.core
     22import pyutilib.subprocess
    2123import mockmip
     24
     25cbc_compiled_with_asl=None
     26
     27def configure():
     28    global cbc_compiled_with_asl
     29    if cbc_compiled_with_asl is None:
     30        cbc = CBC()
     31        if not cbc.executable() is None:
     32            results = pyutilib.subprocess.run(cbc.executable()+" dummy -AMPL")
     33            if not cbc_compiled_with_asl is None:
     34                raise IOError
     35            cbc_compiled_with_asl = not ('No match for AMPL' in results[1])
     36        else:
     37            cbc_compiled_with_asl = False
     38
    2239
    2340class CBC(SystemCallSolver):
     
    3653        #
    3754#        self._valid_problem_formats=[ProblemFormat.nl, ProblemFormat.cpxlp, ProblemFormat.mps]
    38         self._valid_problem_formats=[ProblemFormat.cpxlp, ProblemFormat.nl, ProblemFormat.mps]       
     55        self._valid_problem_formats=[ProblemFormat.cpxlp, ProblemFormat.mps]       
     56        if cbc_compiled_with_asl:
     57            self._valid_problem_formats.append(ProblemFormat.nl)
    3958        self._valid_result_formats={}
    4059        self._valid_result_formats[ProblemFormat.cpxlp] = [ResultsFormat.soln]
    41         self._valid_result_formats[ProblemFormat.nl] = [ResultsFormat.sol]       
     60        if cbc_compiled_with_asl:
     61            self._valid_result_formats[ProblemFormat.nl] = [ResultsFormat.sol]       
    4262        self._valid_result_formats[ProblemFormat.mps] = [ResultsFormat.soln]
    4363
     
    5676       # in CBC, the results format is defined by the problem format;
    5777       # you can't vary them independently.
    58        if self._problem_format is ProblemFormat.nl:
     78       if cbc_compiled_with_asl and self._problem_format is ProblemFormat.nl:
    5979          self._results_format = ResultsFormat.sol
    6080       else:
     
    97117                problem_filename_prefix = tmp[0]
    98118
     119        #if not cbc_compiled_with_asl:
     120            #self._results_format = ResultsFormat.soln
     121            #self.results_reader = None
    99122        if self._results_format is ResultsFormat.sol:
    100123           self.soln_file = problem_filename_prefix+".sol"
  • coopr.plugins/trunk/coopr/plugins/mip/__init__.py

    r2215 r2349  
    1313
    1414from PICO import PICO, MockPICO
    15 from CBC import CBC, MockCBC
     15from CBCplugin import CBC, MockCBC
    1616from GLPK import GLPK, MockGLPK
    1717from CPLEX import CPLEX, MockCPLEX
     
    2020
    2121pyutilib.component.core.PluginGlobals.pop_env()
     22
     23#   
     24# Interrogate the CBC executable to see if it recognizes the -AMPL flag
     25#   
     26import CBCplugin
     27CBCplugin.configure()
     28
Note: See TracChangeset for help on using the changeset viewer.