Opened 2 years ago

Closed 2 years ago

#28206 closed defect (fixed)

py3: fix str vs bytes issues with gurobi

Reported by: dcoudert Owned by:
Priority: major Milestone: sage-8.9
Component: linear programming Keywords:
Cc: Merged in:
Authors: David Coudert Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 86f5bde (Commits, GitHub, GitLab) Commit: 86f5bde90b7c4fc90fbe1b4d73c179733352088a
Dependencies: Stopgaps:

Status badges

Description

sage: G = graphs.PetersenGraph()
sage: G.maximum_average_degree(solver='gurobi')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-04247347e38e> in <module>()
----> 1 G.maximum_average_degree(verbose=Integer(1), solver='gurobi')

/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/graphs/graph.py in maximum_average_degree(self, value_only, solver, verbose)
   4901         for u,v in g.edge_iterator(labels=False):
   4902             fuv = frozenset((u, v))
-> 4903             p.add_constraint(one[fuv] - 2 * d[u], max=0)
   4904             p.add_constraint(one[fuv] - 2 * d[v], max=0)
   4905 

/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/numerical/mip.pyx in sage.numerical.mip.MIPVariable.__getitem__ (build/cythonized/sage/numerical/mip.c:20224)()
   3000         zero = self._p._backend.zero()
   3001         name = self._name + "[" + str(i) + "]" if self._name else None
-> 3002         j = self._p._backend.add_variable(
   3003             lower_bound=self._lower_bound,
   3004             upper_bound=self._upper_bound,

/Users/dcoudert/sage3/sage/local/lib/python3.7/site-packages/sage/numerical/backends/gurobi_backend.pyx in sage.numerical.backends.gurobi_backend.GurobiBackend.add_variable (build/cythonized/sage/numerical/backends/gurobi_backend.c:3149)()
    166             name = "x_"+str(self.ncols())
    167 
--> 168         c_name = name
    169 
    170         if upper_bound is None:

TypeError: expected bytes, str found

Change History (3)

comment:1 Changed 2 years ago by dcoudert

  • Branch set to public/linear_programming/28206_gurobi
  • Commit set to 86f5bde90b7c4fc90fbe1b4d73c179733352088a
  • Status changed from new to needs_review

I have not (yet) identified other issues with gurobi (version 8.0.1).


New commits:

86f5bdetrac #28206: fix str vs bytes issue in gurobi backend with py3

comment:2 Changed 2 years ago by chapoton

  • Reviewers set to Frédéric Chapoton
  • Status changed from needs_review to positive_review

ok, looks good enough.

comment:3 Changed 2 years ago by vbraun

  • Branch changed from public/linear_programming/28206_gurobi to 86f5bde90b7c4fc90fbe1b4d73c179733352088a
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.