def _glpk_representation(self): self.update() with TemporaryFilename(suffix=".glpk") as tmp_file_name: glp_write_prob(self.problem, 0, tmp_file_name) with open(tmp_file_name) as tmp_file: glpk_form = tmp_file.read() return glpk_form
def _glpk_representation(self): self.update() with TemporaryFilename(suffix=".glpk") as tmp_file_name: glp_write_prob(self.problem, 0, tmp_file_name) with open(tmp_file_name) as tmp_file: glpk_form = tmp_file.read() return glpk_form
def _glpk_representation(self): with tempfile.NamedTemporaryFile(suffix=".glpk", delete=True) as tmp_file: tmp_file_name = tmp_file.name glp_write_prob(self.problem, 0, tmp_file_name) with open(tmp_file_name) as tmp_file: glpk_form = tmp_file.read() return glpk_form
def _glpk_representation(self): self.update() with TemporaryFilename(suffix=".glpk") as tmp_file_name: code = glp_write_prob(self.problem, 0, tmp_file_name) if code != 0: raise Exception("GLPK could not successfully create the GLPK file.") with open(tmp_file_name, "r") as tmp_file: glpk_form = tmp_file.read() return glpk_form
def _glpk_representation(self): self.update() with TemporaryFilename(suffix=".glpk") as tmp_file_name: code = glp_write_prob(self.problem, 0, tmp_file_name) if code != 0: raise Exception("GLPK could not successfully create the GLPK file.") with open(tmp_file_name, "r") as tmp_file: glpk_form = tmp_file.read() return glpk_form
def _glpk_representation(self): tmp_file = tempfile.mktemp(suffix=".glpk") glp_write_prob(self.problem, 0, tmp_file) glpk_form = open(tmp_file).read() return glpk_form
def write_lp_glpk(self, filename): '''write the lp in GLPK format''' if glpk.glp_write_prob(self.lp, 0, filename) != 0: raise RuntimeError('Error saving GLPK-format LP to {}'.format(filename))