Changeset 2266


Ignore:
Timestamp:
Feb 5, 2010 12:59:43 PM (10 years ago)
Author:
wehart
Message:

Adding an AMPL converter, which runs AMPL to convert *.mod files to *.nl (or *.mps).
This is needed because the current glpsol convert cannot handle nonlinear problems.

NOTE: this plugin will not gracefully handle situtations where the AMPL license
is already in use. I don't have access to a regular AMPL
installation to test this case.

Location:
coopr.plugins/trunk/coopr/plugins
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • coopr.plugins/trunk/coopr/plugins/converter/__init__.py

    r2201 r2266  
    1212pyutilib.component.core.PluginGlobals.push_env( 'coopr.opt' )
    1313
     14import ampl
    1415import glpsol
    1516import pico
  • coopr.plugins/trunk/coopr/plugins/converter/glpsol.py

    r2201 r2266  
    1818import pyutilib.subprocess
    1919import pyutilib.common
     20
    2021
    2122class GlpsolMIPConverter(ManagedSingletonPlugin):
  • coopr.plugins/trunk/coopr/plugins/converter/pico.py

    r2265 r2266  
    1919import pyutilib.common
    2020import pyutilib.subprocess
     21
    2122
    2223class PicoMIPConverter(ManagedSingletonPlugin):
  • coopr.plugins/trunk/coopr/plugins/converter/pyomo.py

    r2265 r2266  
    2020from pyutilib.component.executables import *
    2121import pyutilib.services
     22
    2223
    2324class PyomoMIPConverter(ManagedSingletonPlugin):
  • coopr.plugins/trunk/coopr/plugins/tests/mip/test_convert.py

    r2265 r2266  
    2424import xml
    2525import filecmp
     26import shutil
    2627
    2728
     
    139140        self.failUnlessFileEqualsBaseline(ans[0][0], currdir+"test3_convert.lp")
    140141
     142    def test_mod_nl1(self):
     143        """ Convert from MOD to NL """
     144        try:
     145           ans = coopr.opt.convert_problem( (currdir+"test3.mod",), None, [ProblemFormat.nl])
     146        except pyutilib.common.ApplicationError, err:
     147           if not pyutilib.services.registered_executable("ampl") is None:
     148              self.fail("Unexpected ApplicationError - ampl is enabled but not available: '%s'" % str(err))
     149           return
     150        except ConverterError, err:
     151           if not pyutilib.services.registered_executable("ampl") is None:
     152              self.fail("Unexpected ConverterError - ampl is enabled but not available: '%s'" % str(err))
     153           return
     154        self.failUnless(ans[0][0].endswith('.nl'))
     155        #self.failUnlessFileEqualsBinaryFile(ans[0][0], currdir+"test_mod_nl1.nl")
     156
     157    def test_mod_nl2(self):
     158        """ Convert from MOD+DAT to NL """
     159        try:
     160           ans = coopr.opt.convert_problem( (currdir+"test5.mod",currdir+"test5.dat"), None, [ProblemFormat.nl])
     161        except pyutilib.common.ApplicationError, err:
     162           if not pyutilib.services.registered_executable("ampl") is None:
     163              self.fail("Unexpected ApplicationError - ampl is enabled but not available: '%s'" % str(err))
     164           return
     165        except ConverterError, err:
     166           if not pyutilib.services.registered_executable("ampl") is None:
     167              self.fail("Unexpected ConverterError - ampl is enabled but not available: '%s'" % str(err))
     168           return
     169        self.failUnless(ans[0][0].endswith('.nl'))
     170        #self.failUnlessFileEqualsBaseline(ans[0][0], currdir+"test_mod_nl2.nl")
     171
    141172    def test_mock_lp1(self):
    142173        """ Convert from Pyomo to LP """
Note: See TracChangeset for help on using the changeset viewer.