Questions tagged [pulp]

PuLP is a linear programming module for Python.

PuLP is a linear programming module, written in Python. PuLP supports multiple open-source (e.g. the Coin-OR suite) and commercial solvers (e.g. Gurobi, CPLEX).

The Coin-OR suite with the integer solver CBC is included with the Python package.

Further reading

913 questions
-1
votes
1 answer

Any effective solver to solve selection problem with constraints

I am working on a package selection problem. I have to put a constraint on the final result, like ‘top3 brands among selected products should account for less than 50%’. I try to implement that on Pulp. But it seems CBC solver do not support such…
Cino
  • 83
  • 1
  • 7
-1
votes
1 answer

Sort array using Mixed integer constraints

Assume that I have X = X_1....x_n Variables and I want to build variables Y = Y_1...Y_n using constraints such that the elements of Y are the sorted elements of X. For example when n = 2 Y_1 = min(X_1,X_2) Y_2 = max(X_1,X_2) this can be achieved…
-1
votes
1 answer

Why is my iterating through a dictionary causing a TypeError when I call the value of the objective function

When I run the following code: for key,value in before_yield_ts.items(): print(key,value) Before this block of code: # The result of the objective function is here final_amount_ts = value (prob_ts.objective) print ("Total",…
user15795580
-1
votes
1 answer

Demand optimization planning using PULP

Need help in solving a demand-optimiztion planning for factories. Factories have Machines which can make one or more Products in it. Each Product takes time to make 1 unit which is known as 'Cycle-Time'. So, to make 10 units of product/component on…
-1
votes
1 answer

Formulating equations in Pulp Python

I'm trying to formulate the following equations: 25, 28, 29, 30 & 31, with Pulp in Python using dictionaries that include LpVariable, with the objective to minimize the end to end latency of a transmission from one network node to node. i index…
Arnauinez
  • 7
  • 3
-1
votes
1 answer

how can we solve the linear equation with pulp python with range conditonal constraint

I am having objective function with pre-decided objective value, but want to know the values of decision variable for that objective function. from pulp import LpMaximize, LpProblem, LpStatus, lpSum, LpVariable, LpConstraint constraints =['0 <=…
SKP
  • 151
  • 16
-1
votes
1 answer

Solving Model with pulp python

I have been struggling with solving the following problem: I have some values stored in variable returns, and I want to multiply them by a weight (x_vars)in order to make the sum of the products and obtain the value of the variable target_return. As…
arodrisa
  • 300
  • 4
  • 17
-1
votes
2 answers

Converting a string value of a dictionary inside another dictionary into int value

I am using PulP to solve a linear programming problem. I am having the following error in the objective function: TypeError: list indices must be integers or slices, not str My objective function is prob +=…
-1
votes
1 answer

Prediction models, Objective functions and Optimization in Python

How do we define objective functions while doing optimization in Python. We have defined Prediction models separately. Next step is to bring objective functions from prediction models (Gradient boosting, Random forest , Linear regression etc) and…
suresh hp
  • 11
  • 1
  • 2
-1
votes
1 answer

Optimization using pulp python

Trying to write an optimization code using pulp. From the given dataset i want to 5 items which in sum maximize the value whereas having constraints as 2 items having color blue, 2 items having color yellow and a random item But instead by using the…
-1
votes
1 answer

Using Python optimization function with only integer inputs

I am solving a minimization problem in Python that allocates packet capacities over the edges of a graph in a way that the loss of packets throughout the network/graph is minimum. Packets are generated at nodes following a Poisson Distribution . The…
-1
votes
2 answers

How to use initial solution in pulp (python)

Community, I have the next problem I want to do a improvement heuristic (Fix and Optimize) and I need to use the initial solution to start, my problem is MIP having binary and continuous variables. I asked him how I would do to use the previous…
Juan S. P.
  • 31
  • 5
-1
votes
1 answer

Add quantity as a constrain in the blending optimization problem

I´m replicating this example of the blending problem: https://www.coin-or.org/PuLP/CaseStudies/a_blending_problem.html With the following data: import pulp from pulp import * import pandas as pd food = ["f1","f2","f3","f4"] KG =…
Luis Ramon Ramirez Rodriguez
  • 9,591
  • 27
  • 102
  • 181
-1
votes
1 answer

Create constraint in Python Pulp to limit consecutive streak of 1s to 1

I would like to add a constraint to my optimization problem that I am building using pulp. The constraint should count the number of "streaks" of non-zero numbers, i.e., [1,1,1,1,0] = 1 because there us 1 group of 1s [1,1,1,0,1] = 2 because there…
-1
votes
1 answer

Python Pulp - Avoiding Duplicated Entries In Solution

Thanks ahead for your time! I have the following data: Name Group ID Grade Bill A 1 89 Jill A 2 70 Bob A 3 99 Chad A 4 5 Molly B 5 12 Bill …
1 2 3
60
61