Changeset 3079
- Timestamp:
- Oct 11, 2010 11:54:31 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
coopr.plugins/trunk/coopr/plugins/mip/GUROBI.py
r2664 r3079 10 10 11 11 import os 12 import sys 12 13 import re 13 14 from coopr.opt.base import * … … 27 28 import time 28 29 29 # TODO: CHECK IF IT IS ILMLicensedSystemCallSolver30 30 class GUROBI(ILMLicensedSystemCallSolver): 31 31 """The GUROBI LP/MIP solver … … 63 63 self._capabilities = pyutilib.misc.Options() 64 64 self._capabilities.linear = True 65 self._capabilities.quadratic = True 65 66 self._capabilities.integer = True 67 self._capabilities.sos1 = True 68 self._capabilities.sos2 = True 66 69 67 70 # … … 69 72 # 70 73 def warm_start_capable(self): 74 71 75 return False 72 76 73 77 def executable(self): 74 executable = pyutilib.services.registered_executable("gurobi.sh") 78 79 if sys.platform == "win32": 80 executable = pyutilib.services.registered_executable("gurobi.bat") 81 else: 82 executable = pyutilib.services.registered_executable("gurobi.sh") 75 83 if executable is None: 76 84 pyutilib.component.core.PluginGlobals.env().log.error("Could not locate the 'gurobi' executable, which is required for solver %s" % self.name) … … 80 88 81 89 def create_command_line(self,executable,problem_files): 90 82 91 # 83 92 # Define log file … … 96 105 # Write the GUROBI execution script 97 106 # 107 108 # NOTE: the gurobi shell is independent of Coopr python virtualized environment, so any 109 # imports - specifically that required to get GUROBI_RUN - must be handled explicitly. 98 110 self.gurobi_script_file_name = pyutilib.services.TempfileManager.create_tempfile(suffix = '.gurobi.script') 99 111 gurobi_script_file = open(self.gurobi_script_file_name,'w') 100 112 gurobi_script_file.write("import sys\n") 101 113 gurobi_script_file.write("from gurobipy import *\n") 102 gurobi_script_file.write("sys.path.append(\'/home/claird/Research/CooprWork/coopr/src/coopr.plugins/coopr/plugins/mip\')\n") 114 # NOTE: The gurobi plugin and GUROBI_RUN.py live in the same directory. 115 gurobi_script_file.write("sys.path.append("+"\""+os.path.dirname(__file__)+"\""+")\n") 103 116 gurobi_script_file.write("from GUROBI_RUN import *\n") 104 117 gurobi_script_file.write("gurobi_run(\""+self._problem_files[0]+"\",\""+self.soln_file+"\")\n") … … 109 122 # user if we're keeping files around. 110 123 if self.keepFiles: 111 print "Solver script file =" +self.gurobi_script_file_name124 print "Solver script file: '%s'" % self.gurobi_script_file_name 112 125 113 126 # … … 118 131 119 132 def process_logfile(self): 133 120 134 return ILMLicensedSystemCallSolver.process_logfile(self) 121 135 122 136 def process_soln_file(self,results): 137 123 138 # check for existence of the solution file 124 139 # not sure why we just return - would think that we … … 173 188 results.solution.insert(soln) 174 189 175 # todo: 176 # is this necessary???? 177 # return ILMLicensedSystemCallSolver.process_soln_file(self,results) 178 179 pyutilib.services.register_executable(name="gurobi.sh") 190 if sys.platform == "win32": 191 pyutilib.services.register_executable(name="gurobi.bat") 192 else: 193 pyutilib.services.register_executable(name="gurobi.sh")
Note: See TracChangeset
for help on using the changeset viewer.