pulp

Linear Programming (Simplex LP) PuLP?

寵の児 提交于 2019-12-18 17:28:08
问题 In Python only, and using data from a Pandas dataframe, how can I use PuLP to solve linear programming problems the same way I can in Excel? How much budget should be allocated to each Channel under the New Budget column so we maximize the total number of estimated successes? I'm really looking for a concrete example using data from a dataframe and not really high-level advice. Problem Data Setup Channel 30-day Cost Trials Success Cost Min Cost Max New Budget 0 Channel1 1765.21 9865 812 882

How to fix constraints for allocation optimisation in PuLP python

末鹿安然 提交于 2019-12-14 03:12:53
问题 Background: I am trying to allocate customers Ci to financial advisers Pj. Each customer has a policy value xi. I'm assuming that the number of customers (n) allocated to each adviser is the same, and that the same customer cannot be assigned to multiple advisers. Therefore each partner will have an allocation of policy values like so: P1=[x1,x2,x3] , P2=[x4,x5,x6], P3=[x7,x8,x9] I am trying to find the optimal allocation to minimise dispersion in fund value between the advisers. I am

How to add Logical constraints in PuLP

偶尔善良 提交于 2019-12-12 02:42:40
问题 I am trying to solve FLP using PuLP. I want to add logical constraint for variable value. I have LpVariable f and C is list of LpVariables . I want to add f to the constraint of problem and which depends on values of c[i]. Below is code snippet > prob = LpProblem("The MILP problem", LpMinimize) Added 1st constraint : prob += lpSum(c[i] for i in range (len(c))) == 2 Now I want to add following constraint: if`lpSum(c[i] for i in range (len(c))) > 1: ` prob += f == 1 else: prob += f == 0 prob +=

Relating constraints with objective in PULP

ⅰ亾dé卋堺 提交于 2019-12-11 21:29:43
问题 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 time used to finish demand. I have demand, time taken by each tech, list of techs etc. in separate dataframes. I am able to find the number of exams to minimize the objective, however I wish to add a constraint of maximum number of techs to be used as 8. I added some binary variables to add the condition, however I am not able to relate it with the

Importing Python Module “Pulp” on Amazon AWS Lambda

为君一笑 提交于 2019-12-11 15:16:41
问题 I have been trying to import python module "Pulp" to the Amazon AWS Lambda but getting an error. Pulp is an optimization module which can be installed using pip ("pip install pulp") but as in AWS Lambda I'm not sure how to install it so I zipped everything along with Lambda Function from my local machine and uploaded it to AWS Lambda. The error which I received:- "Attempted relative import in non-package: ValueError Traceback (most recent call last): File "/var/task/lambda_function.py", line

Python PuLP Beginner Constraint lists

孤者浪人 提交于 2019-12-11 04:46:51
问题 I am a beginner in Python. I am using PuLP to solve a minimization problem for a Renewable Energy System (PV + Wind + Battery). My system uses timesteps (24h, per hour). My question is how can I create a list in the constraints that collects the state of charge of the battery, as well as the inlet and outlet of it (variables that change value each timestep). In mathlab I have seen people use "eye", but here in PuLP I am not sure how can be done. Any help would be very well appreciated. Here

I there a way to specify two constraints for the same variable when using Puthon PuLP for a linear program

做~自己de王妃 提交于 2019-12-11 04:46:47
问题 I was wondering if there is a way two have a variable with two different constraints when using Python PuLP. prob += lpSum([evaptwohundredF[i] * component_vars[i] for i in name]) >= 30.0000, "evaptwohundredFrequirement" prob += lpSum([evaptwohundredF[i] * component_vars[i] for i in name]) <=70.0000, "evaptwohundredFrequirement" This is an example fo what i would want where the same variable has two constraints so >= 30 and <= 70, but the problem is that i get an error which says 'pulp

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

Use mod function in a constraint using Python Pulp

岁酱吖の 提交于 2019-12-10 12:16:39
问题 I am writing a LpProblem and I need to create a constraint where the sum of some variables is multiples of 100... 100, 200, 300... I am trying the next expressions using mod(), round() and int() but none works because they don't support LpAffineExpression. probl += lpSum([vars[h] for h in varSKU if h[2] == b]) % 100 == 0 probl += lpSum([vars[h] for h in varSKU if h[2] == b]) / 100 == int(lpSum([vars[h] for h in varSKU if h[2] == b]) / 100) probl += lpSum([vars[h] for h in varSKU if h[2] == b]

How do I specify multiple variable constraints using Integer Programming in PuLP?

时光总嘲笑我的痴心妄想 提交于 2019-12-10 11:39:09
问题 I am trying to solve the Bin Packing Problem using the Integer Programming Formulation in Python PuLP. The model for the problem is as follows: I have written the following Python Code using the PuLP library from pulp import * #knapsack problem def knapsolve(bins, binweight, items, weight): prob = LpProblem('BinPacking', LpMinimize) y = [LpVariable("y{0}".format(i+1), cat="Binary") for i in range(bins)] xs = [LpVariable("x{0}{1}".format(i+1, j+1), cat="Binary") for i in range(items) for j in