linear-programming

Time limit for mixed integer programming with Python PuLP

你。 提交于 2021-02-19 03:34:06
问题 I've been using PuLP to solve a particular mixed integer linear program (MIP) I am interested in. However, as the problem size grows, PuLP is taking too long. I want to be able to run the solver for some time and terminate it prematurely if its taking to long and obtain the best feasible solution so-far computed. I have tried manually timing the solver out with signal, but the variables are all "None". I've looked at the documentation and PuLP does not seem to support this, though as I

How to use Continuous Variables for IF-THEN constraints on DOCPLEX (Python)?

随声附和 提交于 2021-02-10 14:27:43
问题 I'm using DOCPLEX to build up a Mixed Integer Linear Programming (MILP) problem which is then solved via CPLEX on Python. However, upon trying to solve the MILP problem using IF-THEN constraints, I receive the following error: DOcplexException: Model.if_then(), nbBus40 >= 3.0 is not discrete This is happening because I have declared nbbus40 variable to be continuous , as shown in the code below: from docplex.mp.model import Model mdl = Model(name='buses') nbbus40 = mdl.continuous_var(name=

How to use Continuous Variables for IF-THEN constraints on DOCPLEX (Python)?

[亡魂溺海] 提交于 2021-02-10 14:27:01
问题 I'm using DOCPLEX to build up a Mixed Integer Linear Programming (MILP) problem which is then solved via CPLEX on Python. However, upon trying to solve the MILP problem using IF-THEN constraints, I receive the following error: DOcplexException: Model.if_then(), nbBus40 >= 3.0 is not discrete This is happening because I have declared nbbus40 variable to be continuous , as shown in the code below: from docplex.mp.model import Model mdl = Model(name='buses') nbbus40 = mdl.continuous_var(name=

How to solve for multiple solutions to linear program in Python?

笑着哭i 提交于 2021-02-10 14:25:52
问题 I have some Pyomo code (see below) which produces one possible solution to the linear equation: 3a + 2b + 2c = 15 Where: -20 <= a <= 0 0 <= b <= 20 20 <= c <= 50 a, b, c are real numbers How could I rewrite the program to produce a random solution every time it is run? I am open to using Pulp as well. My Code: # Coefficients coeffs = [3,2,2] y_target = 15 # Define model and variables model = ConcreteModel() model.a = Var(bounds=(-20,0)) model.b = Var(bounds=(0,20)) model.c = Var(bounds=(20,50

inverted indicator constraint in gurobipy

こ雲淡風輕ζ 提交于 2021-02-10 09:52:19
问题 I am a beginner in gurobipy. I would like to add an inverted indicator constraint. Indicator constraint is nothing but depending on a binary variable a constraint does or does not hold. In gurobipy this is written as model.addConstr((x == 1) >> (y + z <= 5)) where x is a binary variable, y and z are integer variables. This statement says that if x is True then the constraint y+z <= 5 holds. But I would like to have an inverted constraint like this. If y+z <= 5 then x == 1. But gurobi does not

LP: postive reduced costs corresponding to positive variables?

谁说我不能喝 提交于 2021-02-08 06:16:38
问题 I have the next LP problem Maximize 1000 x1 + 500 x2 - 500 x5 - 250 x6 Subject To c1: x1 + x2 - x3 - x4 = 0 c2: - x3 + x5 = 0 c3: - x4 + x6 = 0 With these Bounds 0 <= x1 <= 10 0 <= x2 <= 15 0 <= x5 <= 15 0 <= x6 <= 5 By solving this problem with Cplex dual algorithm I get an optimal solution of 6250. But checking the reduced costs of the variables I get the next results Variable value reduced cost 1 10.0 500.0 1 0.0 -0.0 2 5.0 -0.0 3 5.0 -0.0 4 5.0 -0.0 5 5.0 250.0 Is it possible to have a

LP: postive reduced costs corresponding to positive variables?

心不动则不痛 提交于 2021-02-08 06:16:26
问题 I have the next LP problem Maximize 1000 x1 + 500 x2 - 500 x5 - 250 x6 Subject To c1: x1 + x2 - x3 - x4 = 0 c2: - x3 + x5 = 0 c3: - x4 + x6 = 0 With these Bounds 0 <= x1 <= 10 0 <= x2 <= 15 0 <= x5 <= 15 0 <= x6 <= 5 By solving this problem with Cplex dual algorithm I get an optimal solution of 6250. But checking the reduced costs of the variables I get the next results Variable value reduced cost 1 10.0 500.0 1 0.0 -0.0 2 5.0 -0.0 3 5.0 -0.0 4 5.0 -0.0 5 5.0 250.0 Is it possible to have a

Scipy - find bases of column space of matrix

杀马特。学长 韩版系。学妹 提交于 2021-02-07 13:23:42
问题 I'm trying to code up a simple Simplex algorithm, the first step of which is to find a basic feasible solution: Choose a set B of linearly independent columns of A Set all components of x corresponding to the columns not in B to zero. Solve the m resulting equations to determine the components of x. These are the basic variables. I know the solution will involve using scipy.linalg.svd (or scipy.linalg.lu ) and some numpy.argwhere / numpy.where magic, but I'm not sure exactly how. Does anyone

PyInstaller .exe file does nothing

此生再无相见时 提交于 2021-02-07 06:24:14
问题 After 3 days, I can't get a python program packaged into a .exe file. I've tried py2exe (which continuously missed modules), and PyInstaller. Here's the complicated part. My program uses a lot of additional installed modules (coopr, pyomo, openpyxl, glpk, cbc, pyutilib, numpy, etc.). These in turn import all kinds of other things, and I can't track it down (the PyInstaller warning log lists 676 lines of missing or potentially unneeded modules.) However, I've gotten (by adding imports of

PyInstaller .exe file does nothing

会有一股神秘感。 提交于 2021-02-07 06:23:09
问题 After 3 days, I can't get a python program packaged into a .exe file. I've tried py2exe (which continuously missed modules), and PyInstaller. Here's the complicated part. My program uses a lot of additional installed modules (coopr, pyomo, openpyxl, glpk, cbc, pyutilib, numpy, etc.). These in turn import all kinds of other things, and I can't track it down (the PyInstaller warning log lists 676 lines of missing or potentially unneeded modules.) However, I've gotten (by adding imports of