gurobi

Pulp.pulpTestAll() test failed, too many values to unpack

亡梦爱人 提交于 2019-12-10 18:24:23
问题 My OS is window 7, Pulp version is 1.6.1, gurobi version is 7.0.1. gurobipy can be successfully imported. pulp.solvers.GUROBI did pass the test, so I could use gurobi. However pulp.solvers.CPLEX_CMD failed. Here is the error message: pulp.pulpTestAll() Testing zero subtraction Testing inconsistant lp solution Testing continuous LP solution Testing maximize continuous LP solution Testing unbounded continuous LP solution Testing Long Names Testing repeated Names Testing zero constraint Testing

How to resolve ImportError in Gurobi?

删除回忆录丶 提交于 2019-12-10 17:13:25
问题 I am trying to run this example given in gurobi's example model. I am using python 3.5 with gurobi 7.0.2. When I run the code, I get the following error. Traceback (most recent call last): File "test.py", line 1, in <module> from gurobipy import * File "/if5/wua4nw/anaconda3/lib/python3.5/site-packages/gurobipy/__init__.py", line 1, in <module> from .gurobipy import * ImportError: libgurobi70.so: cannot open shared object file: No such file or directory I have Gurobi installed at /if5/wua4nw

Graph coloring Gurobi constraints

我们两清 提交于 2019-12-10 11:49:06
问题 I'm trying to fix some constraints for the Graph coloring problem using networkx and gurobi. This is all the code that i wrote: import networkx as nx import gurobi as gb from itertools import combinations, chain import pygraphviz as pygv import os import matplotlib.pyplot as plt from IPython.display import SVG, display Creation of the graph, adding nodes and edges and two lists. G = nx.Graph() G.add_nodes_from ([1,2,3,4,5]) G.add_edge(1,2) G.add_edge(1,3) G.add_edge(1,4) G.add_edge(1,5) G.add

How to pass MIP gap parameter to Gurobi with PULP

自闭症网瘾萝莉.ら 提交于 2019-12-08 09:14:35
问题 How to pass MIP gap parameter to Gurobi with PULP? I tried: prob.solve(GUROBI_CMD(epgap = 0.9)) No luck I used this wiki for all my failed attempts 回答1: Looking at the code, i would assume, that you have to give the arguments as defined in gurobi's docs (these are then passed when calling gurobi's cli), compatible with pulp's function-signature. prob.solve(GUROBI_CMD(options=['MIPGap=0.9'])) But i probably recommend using the python-interface if you got gurobipy working (read gurobi's docs).

sparse matrix LP problems in Gurobi / python

你。 提交于 2019-12-08 03:02:47
问题 I am trying to solve an LP problem represented using sparse matrices in Gurobi / python. max c′ x, subject to A x = b, L &leq; x &leq; U where A is a SciPy linked list sparse matrix of size ~1000 2 . Using the code model = gurobipy.Model() rows, cols = len(b), len(c) for j in range(cols): model.addVar(lb=L[j], ub=U[j], obj=c[j]) model.update() vars = model.getVars() S = scipy.sparse.coo_matrix(A) expr, used = [], [] for i in range(rows): expr.append(gurobipy.LinExpr()) used.append(False) for

print constraints Gurobi Python

一曲冷凌霜 提交于 2019-12-07 14:16:03
问题 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 example, if S={1,3,4} and V= {1,2,3,4,5,6} , then, my constraint will be x[1,2]+x[1,5]+x[1,6]+x[3,2]+x[3,5]+x[3,6]+x[4,2]+x[4,5]+x[4,6]>=2 I want this constraint to be preinted on the screen. Can someone please help me to do it? 回答1: There is no

TypeError: unsupported operand type(s) for +: 'generator' and 'generator'

痞子三分冷 提交于 2019-12-06 07:22:46
I have a problem with adding three expressions in my objective function. I used quicksum to build each expression. However, when I try to add them together I get an error that I cannot use +/- operands on class 'generator'. Here is the last part of my code: # the shipping cost expression expr_sc = [] for j in J: for k in K: expr_sc.append(quicksum(r_jk[(j, k)]*x[(i, j, k)]) for i in I) m.setObjective((quicksum(item_rev) for item_rev in expr_rev) - ((quicksum(item_pc) for item_pc in expr_pc) + (quicksum(item_sc) for item_sc in expr_sc)), GRB.MAXIMIZE) Update: here is the actual problem that I

Microsoft Solver Foundation for semi-integer

耗尽温柔 提交于 2019-12-06 03:53:56
Is it possible to use the MSF api to specify a variable as semi-integer ( V = 0 , or a <= V <= b )? The following is an example in LP_Solve that uses the "sec" and "int" keywords to indicate the variables are semi-continuous and integer. max: 0.5 Q1 + 0.55 Q2 ; Q1 >= 5; Q1 <= 10 ; Q2 >= 5; Q2 <= 10; Q1 + Q2 <= 10; sec Q1,Q2 ; int Q1,Q2 ; Something similar in MSF would be nice. I note that it is possible to call a Gurobi Plugin DLL within MSF however I cannot find any place in that api to be able to set the type of the variable correctly (I think Gurobi calls it the VTYPE), so I assume it is

print constraints Gurobi Python

為{幸葍}努か 提交于 2019-12-05 21:56:01
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 example, if S={1,3,4} and V= {1,2,3,4,5,6} , then, my constraint will be x[1,2]+x[1,5]+x[1,6]+x[3,2]+x[3,5]+x[3,6]+x[4,2]+x[4,5]+x[4,6]>=2 I want this constraint to be preinted on the screen. Can someone please help me to do it? There is no built-in function to do this. Your best option is to call Model.write() to export the model as an LP file.

Graph coloring with intervals Gurobi constraints

家住魔仙堡 提交于 2019-12-02 14:01:15
问题 I'm trying to fix some constraints for the Graph coloring problem using networkx and gurobi. For each i ∈ V, we define the following set of intervals. Each interval [l,u] ∈ Ii represents a possible pair of minimum color l and maximum color u for the set of edges incident to vertex i. Also, for each k∈K , we represent the set of intervals for vertex i ∈ V which include color k by : Intervals variable This is all the code that i wrote: import networkx as nx import gurobi as gb from itertools