Opened 3 years ago

Closed 3 years ago

#28206 closed defect (fixed)

py3: fix str vs bytes issues with gurobi

Reported by: David Coudert 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


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/ 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)

/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 =
   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())
--> 168         c_name = name
    170         if upper_bound is None:

TypeError: expected bytes, str found

Change History (3)

comment:1 Changed 3 years ago by David Coudert

Branch: public/linear_programming/28206_gurobi
Commit: 86f5bde90b7c4fc90fbe1b4d73c179733352088a
Status: newneeds_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 3 years ago by Frédéric Chapoton

Reviewers: Frédéric Chapoton
Status: needs_reviewpositive_review

ok, looks good enough.

comment:3 Changed 3 years ago by Volker Braun

Branch: public/linear_programming/28206_gurobi86f5bde90b7c4fc90fbe1b4d73c179733352088a
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.