Skip to main content

Questions tagged [pulp]

Questions relevant to the PuLP modelling framework in Python

Filter by
Sorted by
Tagged with
13 votes
2 answers
635 views

"Out of the box" Mixed Integer Programming Heuristics

I currently have a complex Mixed Integer Program (a sort of vehicle routing problem variant, with multiple vehicle types and without assigned pickup -> delivery routes, among other complications) ...
blahblah4252's user avatar
11 votes
1 answer
1k views

Change coefficient in PuLP

Once a model is implemented in PuLP, how do you change a coefficient (e.g., $a_{ij}$, $b_i$ or $c_j$) of a program of the from $\min\{c^{\top}x: Ax=b, x\geq0\}$? Specifically: How to update ...
Daniel Duque's user avatar
  • 1,355
10 votes
1 answer
14k views

How do I access the value of a variable in PuLP?

In Python's PuLP package, how can I get the value of a decision variable? For example, if I declare a variable— ...
LarrySnyder610's user avatar
8 votes
1 answer
1k views

Read an LP/MPS file in the PuLP

I was trying to read a MPS file by using the PuLP package in the Python, but I can't find any related documents on it. Does ...
A.Omidi's user avatar
  • 9,046
7 votes
0 answers
156 views

Why does PuLP call copy for addition and how can I avoid it?

Using a for loop to append terms to an expression seems to be much faster than summing a group of terms all at once. Constructing the expression using a for loop uses __iadd__, which does not include ...
Charles Fox's user avatar
6 votes
1 answer
3k views

How to call HiGHS solver from python PuLP MIP?

I have a large MIP built with PuLP in python, and want to utilize the HiGHS Solver. However, PuLP does not have the option to use HiGHS as a solver. One option I am aware of would be to use PuLP to ...
Mason's user avatar
  • 525
6 votes
1 answer
922 views

Python "Coffee Shop Scheduling Problem" - Scheduling Lunches/Breaks

I'm working on an employee scheduling program in python. Having never done this before, I've been researching different libraries that can be used to accomplish the task. Unfortunately, none of the ...
t25's user avatar
  • 63
6 votes
1 answer
675 views

Advanced Heuristics for MIP vehicle routing problem in PuLP

I am currently trying to speed up an MIP. An approach I was considering was to implement a cut callback heuristic with PuLP (one which rounds relaxed integer variables greater than .9 to 1). ...
ctyler9's user avatar
  • 63
5 votes
1 answer
138 views

How to transfer an optimization problem written with GUROBI (in python) in a grammar that can be readily solved with another solver?

Trying to use an opensource optimization tool in python (having used only gurobi for years) I see that the whole code (representing the optimization problem in pythonic language) must be written ...
Makis Karasavvidis's user avatar
5 votes
1 answer
139 views

CBC stalling after approximately 10 seconds

I'm using CBC with PuLP to solve a small unit commitment problem. I'm finding that with certain combinations of input parameters, CBC simply stalls. With other input parameters, it solves, usually ...
Daniel's user avatar
  • 51
4 votes
2 answers
766 views

Python Pulp - LpMinimize Not Returning Expected Output - Scheduling Problem

I'm working on my first pulp model and something isn't going quite right. It looks like it's close, but for some reason it is not respecting one of my constraints... It's a scheduling problem and I am ...
t25's user avatar
  • 63
4 votes
2 answers
2k views

Scheduling optimisation constraint on consecutive shifts & consecutive night shifts (`python`)

I am trying to write a program to schedule a team of 8 individuals into shifts. I want to know how to model that every individual must get at least one night shift break, and must not work two ...
Tommy Lees's user avatar
4 votes
1 answer
1k views

How to convert static variables into arrays for use with PuLP

I have the following code in Python and PuLP which uses static variables. I want to know how to solve the problem by converting all of the LpVariable parts into an array, as well as the constraints. ...
Vasco V.'s user avatar
4 votes
2 answers
742 views

Output of binary variable greater than one

I am working on a shipping demurrage problem that uses a binary variable to denote the date a specific vessel can be loaded (I have been kindly helped by Wesley on OR before with this). I am confident ...
cmp's user avatar
  • 327
4 votes
1 answer
722 views

Subtour elimination implementation (DFJ) using Python (PULP). While loop never exits

The simple test problem I'm trying to implement is \begin{align} \min &\quad c_{ij}x_{ij} \\ \text{s.t} &\quad \\ &\quad \sum_{j\in N}x_{ij} = 1, \quad i\in N\\ &\quad \sum_{i\...
Parseval's user avatar
  • 207
4 votes
1 answer
456 views

Understanding reduced costs and dual values

I have a headache regarding calculating the reduced costs of a linear program. I am using Pulp for modelling and CBC for solving. What I do is, I model a linear programming problem based on a rhs ...
Djames's user avatar
  • 1,143
4 votes
1 answer
824 views

PuLP Transport Problem - How to add outcomes of decision variables together

I am working on a rail scheduling problem that moves product from a production plant to a storage facility to satisfy demand. I am new to PuLP so finding this difficult to understand why this isn't ...
cmp's user avatar
  • 327
3 votes
1 answer
4k views

Complicated constraint with logical operators in PuLP

I have an optimization problem that I am trying to solve with PuLP. All the variables are Booleans. The variables that are "selected" will be true, all others false. Objective function is ...
Jesse's user avatar
  • 33
3 votes
2 answers
269 views

Binary Integer Programming Problem - Enforce Zeros on Certain Groups

I'm working on a binary integer programming problem using pulp. I have a vector X = [x_1, x_2, x_3, . . . , x_n]. I have enforced a number of simple constraints. I ...
user16668649's user avatar
3 votes
2 answers
1k views

Pulp problem gets the right objective value but fails to find the minimal solution

I converted an excel solver problem to Pulp. However, while the pulp program calculates the objective function value correctly, it doesn't arrive at the right answer. I can't figure out what is wrong ...
Murtaza's user avatar
  • 39
3 votes
2 answers
2k views

How to generate multiple solutions to linear program in Python?

I recently posted a question here where I had written some Pyomo code to solve a simple linear program, however I feel the Operations Research platform is perhaps a better fit for this question. My ...
Jwem93's user avatar
  • 333
3 votes
2 answers
181 views

Find all pivots that the simplex algorithm visited, i.e., the intermediate solutions, using Python

For my research, I am interested in finding the trajectory outlined by the pivots along the way of optimizing an LP problem, but I only know how to use Python PuLP to obtain the optimal solution. Is ...
Miya's user avatar
  • 31
3 votes
1 answer
730 views

How do I turn off preprocessing in pulp?

there is an inbuilt preprocessing in CBC solver , which affects the optimality of my solution , I get the optimal output by turning this off in command prompt . How do I turn this off using pulp ?
21vs's user avatar
  • 489
3 votes
2 answers
680 views

Designing a multi-commodity network flow optimizer

I'm trying to solve multi commodity multi source network flow optimization problem using Python-PuLP. Here is how my problem looks like: The numbers on the arcs represent the order of priority a ...
themlchic's user avatar
3 votes
1 answer
806 views

How to set these constraints in a linear optimization problem (PuLP)?

I am trying to implement an employee (nurse) scheduling problem and seek some advice on how to implement a specific constraint.The problem is as follows: There is a set of employees and days (both ...
Joep's user avatar
  • 101
3 votes
2 answers
304 views

Simple Integer Optimization Problem: docplex CP model works but equivalent PuLP+CBC model is infeasible?

I have an integer optimization problem with one constraint per decision variable and no objective function. It can be coded and solved using docplex, however I am ...
SlowLoris's user avatar
  • 145
3 votes
1 answer
429 views

Multi period inventory / reordering MILP in PULP

I'm trying to optimize reorder quantities for $n$ products over $m$ periods in PuLP. The total reorder quantity should fill a container. I've never worked with multiple periods before, and I can't get ...
Jan's user avatar
  • 83
3 votes
1 answer
200 views

Assignment Problem - Students and teachers

I ran across this problem at work and I'm sure that we can optimize it with OR. I have $n(T) = 4$ teachers and $n(S) = 7$ students that should have a weekly individual class. If a student $s$ has a ...
nickh's user avatar
  • 133
3 votes
1 answer
299 views

Warm starting a LP problem with PuLP and Gurobi

I have a set of many similar linear programs (LP). All these LPs have the same objective function, and almost all constraints are the same. The only difference is for one linear constraint $f(x)=a_{i}$...
Quentin PLOUSSARD's user avatar
3 votes
1 answer
1k views

How to formulate cumulative sum of LpVariable in Pulp Python

I have a Multiple product LP optimization problem in which the product(B1,B2,D) will be received in variable quantity with respect to date column. The Optimizer should LP variable Output as Assy Out ...
SrinivasaRamanujam N's user avatar
3 votes
0 answers
93 views

PuLP Python: How to linearize an inequality involving an integer variable

I am working on a Copper payables problem where the objective function is to maximise the sum of copper payable over a time period, T. The total amount of payable tonnes i.e. what the customer will ...
cmp's user avatar
  • 327
3 votes
0 answers
909 views

How can I see the engine log when solving a LP using pulp (python)?

I wonder which command should I use to see how the steps the pulp solver is doing when solving a linear program.
Pep's user avatar
  • 39
3 votes
0 answers
106 views

Constraint equivalence in PuLP

I'm working on an optimization problem in PuLP and I have to enforce a daily minimum of shifts and a daily maximum of assigned shifts. I have the following constraints to ensure each day has a minimum ...
Joep's user avatar
  • 101
2 votes
2 answers
467 views

Find the list with the fewest elements whose cumulative sum reaches threshold

I have a question with which I am stuck and would be very grateful for help: I have multiple lists of non-negative numerical values (all of the same length) I want to find the list with the lowest <...
birnbaum's user avatar
  • 151
2 votes
3 answers
1k views

Any Idea why PuLP is ignoring binary variables?

When I solve the following code, the binaries for the lines_selection variable is not respected by PuLP. Can anyone please point me out to the reason why this could ...
lalsriv's user avatar
  • 21
2 votes
1 answer
688 views

How to enforce this specific constraint in PuLP?

I am trying to implement an employee (nurse) scheduling problem and seek some advice on how to implement a specific constraint.The problem is as follows: There is a set of employees and days (both ...
Joep's user avatar
  • 101
2 votes
1 answer
599 views

Violation of specific constraint in Pulp

I have successfully implemented a program where I allocate N truck drivers to M gathering hubs for each one of the days of the ...
azal's user avatar
  • 153
2 votes
1 answer
319 views

Representing Date Variables in Pulp

I am working on an optimisation problem that involves minimising shipping demurrage. I am struggling to model how to represent the difference, (x-y) between dates where the ship is ready to be loaded ...
cmp's user avatar
  • 327
2 votes
1 answer
2k views

Defining Objective Function in PuLP

I have a binary variable $X_{ijk}$ which I have defined as the following : ...
Alphanerd's user avatar
2 votes
1 answer
569 views

Pulp Python: How to formulate a time-based variable for shipping demurrage

I am working on a shipping optimisation problem that aims to minimise demurrage charges as a result of low/insufficient inventory. I have daily vessel requirement (sales) data in the format ...
cmp's user avatar
  • 327
2 votes
1 answer
118 views

How to linearize the multiplication by a binary decision variable?

I am currently optimizing a hydrogen production chain. I am optimizing the production regime, and the size of the required wind, solar and the electrolyser. For every hour of the year, the production ...
KlaasR's user avatar
  • 23
2 votes
1 answer
1k views

How can I assign an initial value to a variable in PuLP?

I am trying to solve a production problem and right now I need to assign an initial value to the inventory, and that value is given. This is my definition of the inventory variable: ...
wymbo's user avatar
  • 21
2 votes
1 answer
92 views

Split variables into groups, each constrained to hold a specific number of variables, while optimizing group sums towards specific values

I have a number of variables each assigned an integer value. I need to split these variables in three groups with a predefined number of variables going into each group while optimizing towards ...
Hjalte's user avatar
  • 121
2 votes
0 answers
132 views

Seeking help in pulp scheduling problem

I have successfully implemented a program where I allocate N truck drivers to M gathering hubs for each one of the days of the ...
azal's user avatar
  • 153
1 vote
3 answers
94 views

PuLP ensure first and last choice

I have an assignment problem where I have $N$ locations and $M$ dates for each location, and the goal is to choose $K$ location-date pairs that maximize revenue. There are a number of constraints, for ...
3Li's user avatar
  • 35
1 vote
1 answer
2k views

Conditional constraints in PuLP

I have the following optimization model using PuLP. ...
gernworm's user avatar
  • 151
1 vote
2 answers
1k views

Pulp: slack variable to identify & measure extent infeasible in supply problem

I am currently modelling a supply problem that attempts to optimise a rail schedule which moves products from a production plant, to a warehouse to satisfy sales. The model is working fine (thanks in ...
cmp's user avatar
  • 327
1 vote
1 answer
465 views

How to save log file from pulp , log including algorithms used by the solver?

How to save log file from pulp , log including algorithms used by the solver ? while this is printed in the python IDE console, looking to save it as a txt file .
21vs's user avatar
  • 489
1 vote
2 answers
493 views

PuLp is ignoring all of the constraints given to it

I am trying to solve a portfolio optimization problem using PuLP where given a dictionary of stock tickers and their returns for the day, returns a set of weights for each stock such that portfolio ...
Josh Smith's user avatar
1 vote
2 answers
234 views

How can I formulate an objective function that minimises the number of items required to solve a problem

I am currently trying to solve a problem where I need to minimise transport cost through the choice of vehicle (and how many of each choice) subject to a given demand. The problem: There are currently ...
cmp's user avatar
  • 327