pulp

How to make solverstudio (pulp and cbc) report out conflict constraints in case of infeasble?

笑着哭i 提交于 2020-01-05 04:25:10
问题 I am using solverstudio (pulp and cbc). How to make the solver report out the conflict constraints? Thank you. 回答1: If your problem is infeasible, then technically ALL of your constraints are in conflict. However, for whatever intermediate solution was found before the solver returned Infeasible, you can try this to see which constraints were violated: for c in lp.constraints.itervalues(): if not c.valid(0): print c.name, c.value() 来源: https://stackoverflow.com/questions/43861880/how-to-make

How to use a variable as a divisor in PuLP

二次信任 提交于 2020-01-02 07:42:23
问题 I was trying to resolve a LP problem with a constraint that is calculated by dividing variable A by variable B. The simple version of the problem is as below: The product is made by two materials (A and B) % of A should be greater than 50% % of B should be less than 40% Total amount of A and B are 100 Objective: What's the minimum amount of A? The code is like: from pulp import * prob = LpProblem('Simple problem', LpMinimize) x = LpVariable('x', 0, None, 'Integer') y = LpVariable('y', 0, None

PuLP very slow when adding many constraints

牧云@^-^@ 提交于 2019-12-30 03:27:04
问题 I'm trying to use PuLP, but it is taking 50 seconds to add 4000 constraints (with 67 variables). Solving the problem only takes a fraction of a second. We want to use PuLP to easily test several solvers on a large set of problems. Should it be taking PuLP this long? Using PyGLPK directly takes only a fraction of second including both setup and solving, so I hope not. What can I do to improve the efficiency of this step in PuLP? Update My constraints matrix is very sparse, and I was able to

MIP using PULP not approaching result

萝らか妹 提交于 2019-12-25 03:44:17
问题 I am trying to solve a MIP problem. I am trying to find the number of exams to be done by each tech on a date for a week by minimizing the total number of techs used. I have demand, time taken by each tech, list of techs etc. in separate dataframes. Initially, I was using the cost function as minimizing the total time used to finish demand which @kabdulla helped me solve, linkhere! Now, with the new cost function, the script gets stuck and doesn't seem to converge and I am not able to

Pulp add constraint that at least one LpAffineExpression is equal to one

↘锁芯ラ 提交于 2019-12-25 00:13:35
问题 Say I have a PuLP model defined as thus: model = pulp.LpProblem('',pulp.LpMaximize) And I have added an objective function (it does not matter) Now I have a list of LpAffineExpression objects: lps = [l1, l2, l3, ...] I want to add to the model the constraint that one of these LpAffineExpression evaluates to 1. How would I do so? Essentially what I'm looking for is the syntactically correct way to do the following: model += (l1 == 1 OR l2 == 1 OR l3 == 1 OR ...) Note that I do not know how

How to apply conditional constraints to Python Pulp function

冷暖自知 提交于 2019-12-24 23:37:13
问题 I'm setting up a linear optimization using Pulp in Python. I would like to set up a conditional constrain to the problem. Like, I want to Maximize the profit of a factory. For the cost of the material, the first 1000 units cost $5 each, any more unit cost $3. For example, if the factory order 1100 units, total cost will be 1000*5+100*3. I have a list of material: material_list , a dictionary of benchmark for the materials: benchmark_dic={material_a: 1000, material_b:2000 ....} , a dictionary

Linear optimization with PuLP, additional condition on variables

你说的曾经没有我的故事 提交于 2019-12-24 09:28:17
问题 I have to solve an integer linear optimization problem in Python with pulp. I solved the basic problem and now I have to add additional constraints. Is anybody who can help me with adding the condition with a logical indicator? The logical restriction is: B>5 if A>20 Here is my code: from pulp import * prob = LpProblem("The Optimization Problem", LpMaximize) A = LpVariable("A", 0, 100) B = LpVariable("B", 0, 200) C = LpVariable("C", 0, 100) R1 = LpVariable("R1", 0) R2 = LpVariable("R2", 0) R1

PulpSolverError: PuLP: Error while trying to execute glpsol in Python 2.7

戏子无情 提交于 2019-12-23 16:03:18
问题 I'm running PuLP on OS X via a iPython notebook and Python 2.7. glpk is installed using brew install homebrew/science/glpk and PuLP is installed via pip install pulp . However I'm getting the error in Python: --------------------------------------------------------------------------- PulpSolverError Traceback (most recent call last) <ipython-input-15-689fef0dd94f> in <module>() 1 # Solve the problem ----> 2 status = prob.solve(GLPK(msg=0)) 3 /Users/x/anaconda/envs/data/lib/python2.7/site

Binary integer programming with PULP using vector syntax for variables?

梦想与她 提交于 2019-12-22 09:56:12
问题 New to the python library PULP and I'm finding the documentation somewhat unhelpful, as it does not include examples using lists of variables. I've tried to create an absolutely minimalist example below to illustrate my confusion. import pulp IDENTIFIERS = ['A','B','C','D','E'] PRICES = dict( zip( IDENTIFIERS, [100.0, 99.0, 100.5, 101.5, 200.0 ] ) ) n = len( IDENTIFIERS ) x = pulp.LpVariable.dicts( "x", indexs = IDENTIFIERS, lowBound=0, upBound=1, cat='Integer', indexStart=[] ) prob = pulp

Can't find package on Anaconda Navigator. What to do next?

佐手、 提交于 2019-12-22 03:22:58
问题 I am trying to install "pulp" module in Anaconda Navigator's Environment tabs. But when I search in "All" packages I can't find it. It happened with other packages too. Is there any way to install my package to the desired environment? I tried to install it by opening a terminal in the environment, but I see that afterwards it won't show up in the list. What am I missing here? 回答1: Click Open terminal from environment Execute conda install keras in terminal mode 回答2: Download tar.gz file of