0

I am solving a TSP with an academic Gurobi licence and and I pretty much used the following code for my solution.(from gurobi itself) https://gurobi.github.io/modeling-examples/traveling_salesman/tsp.html About 25 minutes after I start running I get the following error:

File "...", line 109, in <module>
m.optimize(subtourelim)
File "src\gurobipy\model.pxi", line 864, in gurobipy.Model.optimize
gurobipy.GurobiError 

That's the method subtourelim I implemented which maybe is the origin of the problem because it is the only input in m.optimize(subtourelim).

 def subtourelim(model, where):
    if where == GRB.Callback.MIPSOL:
        # make a list of edges selected in the solution
        vals = model.cbGetSolution(model._vars)
        selected = gp.tuplelist((i, j) for i, j in model._vars.keys()
                             if vals[i, j] > 0.5)
        # find the shortest cycle in the selected edge list
        tour = subtour(selected)
        if len(tour) < len(Kundenliste):
            # add subtour elimination constr. for every pair of cities in subtour
            model.cbLazy(gp.quicksum(model._vars[i, j] for i, j in combinations(tour, 2))
                         <= len(tour)-1)

But I am wondering because I just copied the code example (from the link above). Others who have an gurobipy.GurobiError have a more specific explanation of what exactly went wrong. (like "model too large for academic licence") What could be the reason for this error?

2 Answers2

0

Does the error happen when the number of points is small(like 20)? If not,maybe it is the problem of license.

韩擎天
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 03 '22 at 07:21
0

Thanks for your help guys but I had some infeasibilities in my model and they may have causes this error.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 05 '22 at 07:39