Changeset 10884


Ignore:
Timestamp:
Nov 13, 2015 4:04:41 PM (4 years ago)
Author:
jdsiiro
Message:

Fix for running Gurobi on Windows: use '%r' to generate embedded strings
so that things like the backslash path separator are properly escaped.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyomo/trunk/pyomo/solvers/plugins/solvers/GUROBI.py

    r10409 r10884  
    263263        solution_filename = self._soln_file
    264264        warmstart_filename = self._warm_start_file_name
    265         if sys.platform == 'win32':
    266             problem_filename  = problem_filename.replace('\\', r'\\')
    267             solution_filename = solution_filename.replace('\\', r'\\')
    268             if self._warm_start_solve and \
    269                (warmstart_filename is not None):
    270                 warmstart_filename = warmstart_filename.replace('\\', r'\\')
    271265
    272266        # translate the options into a normal python dictionary, from a
     
    284278        script += "try:\n"
    285279        script += "  from gurobipy import *\n"
    286         script += "  sys.path.append('%s')\n" % os.path.dirname(__file__)
     280        script += "  sys.path.append(%r)\n" % os.path.dirname(__file__)
    287281        script += "  from GUROBI_RUN import *\n"
    288         script += "  gurobi_run%s\n" % str((problem_filename,
    289                                             warmstart_filename,
    290                                             solution_filename,
    291                                             self.options.mipgap,
    292                                             options_dict,
    293                                             self._suffixes))
     282        script += "  gurobi_run("
     283        for x in ( problem_filename,
     284                   warmstart_filename,
     285                   solution_filename,
     286                   self.options.mipgap,
     287                   options_dict,
     288                   self._suffixes ):
     289            script += "%r," % x
     290        script += ")\n"
    294291        script += "except ImportError:\n"
    295292        script += "  pass\n"
Note: See TracChangeset for help on using the changeset viewer.