gurobi

Python: Optimization with Exponential Objective Function

Python: Optimization with Exponential Objective Function Question: I am working on assignment problems. So far, I have been using Gurobi via gurobipy. In my current problem, I have an objective function with an exponential term. In gurobipy this would be m.setObjective(ratings.prod(assign) ** 0.5, sense=GRB.MAXIMIZE) but ** (or pow()) is not supported in Gurobi. What are …

Total answers: 1

AttributeError: NoneType' object has no attribute 'split' when creating a mip model

AttributeError: NoneType' object has no attribute 'split' when creating a mip model Question: I am relatively new to this, but I wanted to do my first steps using Python-MIP, so I just tried to follow the first examples. But every time a just want to create a model the following error occurs: from mip import …

Total answers: 1

How to use Gurobi quicksum in Python to write this expression?

How to use Gurobi quicksum in Python to write this expression? Question: I am trying to figure out how to write this constraint for Gurobi in Python. for j in city: for i in frequency: c2 = m.addConstr(gp.quicksum(x[i,j]) <= 1, "c2") But I am getting this error and I am a bit confused why it …

Total answers: 1

Unable to open Gurobi license file.Why the start of path has '?'?

Unable to open Gurobi license file.Why the start of path has '?'? Question: Unable to open Gurobi license file.Why the start of path has ‘?’ ? File "srcgurobipygurobi.pxi", line 3575, in gurobipy.read File "srcgurobipygurobi.pxi", line 84, in gurobipy.gurobi.read File "srcgurobipygurobi.pxi", line 32, in gurobipy.gurobi._getdefaultenv File "srcgurobipyenv.pxi", line 62, in gurobipy.Env.__init__ gurobipy.GurobiError: Unable to open Gurobi …

Total answers: 1

How can I run a model multiple times changing the parameter value in pyomo?

How can I run a model multiple times changing the parameter value in pyomo? Question: I am working with a MIP model with multiple parameters and I’d like to test different scenarios (with different parameter values). I’ve created a df with the parameter values that need to be changed and did a loop where the …

Total answers: 1

per-element vector multiplication with gurobipy

per-element vector multiplication with gurobipy Question: The last line of this code fails: A = np.random.rand(d, d)*5.0 b = np.random.rand(d)*10.0 m = gp.Model() x = m.addMVar(d, name=’x’) y = m.addMVar(d, name=’y’, vtype=gp.GRB.BINARY) m.addConstr(A@x <= b) m.addConstr(A@x >= y*b) // error occurs here on y*b It gives this error for gurobipy version 9.5.1: File "src/gurobipy/mvar.pxi", line …

Total answers: 1

multiprocessing compatibility issue with Gurobi

multiprocessing compatibility issue with Gurobi Question: The following simple multiprocessing of a square function works fine: from multiprocessing import Pool class A(object): def square(self, x): return x * x def test(self): pool = Pool() result = pool.map(self.square, range(5)) return result But when I add an initialization of a Gurobi model in the class like this, …

Total answers: 1

print constraints Gurobi Python

print constraints Gurobi Python Question: I’m using Gurobi in Python and for a given set S I’m adding the constraint as follows: for i in S: m.addConstr(quicksum(x[i,j] for j in (set(V) – set(S))) >= 2) I want to print these constraints for each value of the sets S and V on the screen. For an …

Total answers: 4

Python passing callback function in a class

Python passing callback function in a class Question: I have to try to move from the non-class-based coding style into class-based coding style, but facing an issue. The optimize() function takes a callback function mycallback(). The code works perfectly fine in Non-class-based method, but when I moved it to class-based method, I got an error …

Total answers: 5