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
3
votes
1 answer

How to use absolute value in python pulp objective function?

I am trying to use absolute value in the objective function. I want to minimize the absolute value of the following equation |(m[i] - (x1 * a1[i] + x2 * a2[i] + x3 * a3[i])| I tried the following from pulp import LpVariable, LpProblem, lpSum,…
iselim
  • 309
  • 3
  • 8
3
votes
1 answer

Python / Pandas / PuLP optimization on a column

I'm trying to optimize a column of data in a Pandas dataframe. I've looked through past posts but couldn't find one that addressed the issue of optimizing values in a column in a dataframe. This is my first post and relatively new to coding so…
FlettnerRocks
  • 49
  • 1
  • 4
3
votes
1 answer

Pulp Killer sudoku - check choices are distinct for choice of variables

I am trying to solve killer Sudoku using Python linear optimization library, Pulp. https://en.wikipedia.org/wiki/Killer_sudoku Here is my attempt so far, adding a constraint that each row must add up to 45. import pulp prob = pulp.LpProblem("Sudoku…
oli5679
  • 1,709
  • 1
  • 22
  • 34
3
votes
1 answer

"int object is not callable" error using PuLP code

I'm just learning how the PuLP library works, which is a linear programming solver. The code I'm using was found here: LINK. It solves the following optimization problem (in this case, using binary variables x_{ij}): This is the code from the…
3
votes
1 answer

Python: All Solvers Are Unavailable in PuLP Module

I have some code that solves an LP using the PuLP module, and it worked when using a 64-bit windows machine. Now I am trying to run the same code on a Raspberry Pi 4 using Raspbian. Creating the objective function and the constraints works fine, but…
Ken Bassett
  • 58
  • 1
  • 7
3
votes
2 answers

Constrained Optimization of battery scheduling in microgrid

Given inputs such as electricity consumption, generation from solar panel, price, (All at a given time t), we have a battery, and we want to evaluate how much it should (dis)/charge at any given time. The Problem can be formulated as follows: Pt =…
usman Farooq
  • 151
  • 1
  • 12
3
votes
2 answers

How to configure PuLP to call GLPK solver

I am using the PuLP library in Python to solve an MILP problem. I have run my problem successfully with the default solver (CBC). Now I would like to use PuLP with another solver (GLPK). How do I set up PuLP with GLPK? I have done some research…
johnwolf1987
  • 10,603
  • 3
  • 14
  • 17
3
votes
2 answers

PuLP and OR-Tools Alternatives

I currently have a MIP model formulated in Gurobi's python API, but recently I've been looking into tools such as PuLP and OR-Tools that allow me to build a model and feed it to multiple different optimizers. One feature of Gurobi used extensively…
jacob
  • 255
  • 3
  • 11
3
votes
2 answers

How to set Gurobi parameter in Pulp

I am using Pulp with Python to specify an LP problem. I want to solve this using Gurobi. The following does work: prob.solve(pulp.GUROBI_CMD()) However, now I want to specify a MIP Gap. This should be a parameter of the Gurobi solver according to…
Jordi
  • 361
  • 1
  • 4
  • 14
3
votes
1 answer

How to add GLPK solver on pulp, python

I'd like to know how to add GLPK solver step by step on pulp, python. I have installed python (v=3.6.5), pulp (v=1.6.8). I get the result as below when I executed pulp.pulpTestAll(). Testing zero subtraction Testing inconsistant lp solution …
mhiro216
  • 91
  • 2
  • 6
3
votes
1 answer

PuLP: Objective Function: Adding multiple lpSum in a loop

I am trying to use PuLp for a Blending problem with different Elements (Iron, Mercury..). But instead of max/min some profit/cost I need to maximize the utilization of my constraints. So in Excel I had something like this (in pseudocode): max Sum…
JanB
  • 179
  • 2
  • 2
  • 10
3
votes
2 answers

Error disallowing the optimal solution using Python Pulp

I have the following optimization problem: subject to where = {0,1} (binary variables). When I implement this in Pulp as: from pulp import * x1 = pulp.LpVariable('x1', cat=LpBinary) x2 = pulp.LpVariable('x2', cat=LpBinary) x3 =…
RobinHood
  • 377
  • 4
  • 20
3
votes
1 answer

How to show the dual of a (primal) linear program defined in pulp

First question on Stack overflow... love this website... I am using PuLP on Python. Based on inputting variables, an objective function, and constraints, I am trying to view the dual variables/values that are associated with the optimal solution of…
3
votes
1 answer

AttributeError: 'module' object has no attribute 'DefaultRoutingSearchParameters'

I have installed the ortools exactly as mentioned in this link. After that, I copied vehicle routing problem from the documentation and tried to execute.I am using python 2.7.12 in my system. I ended up with the below error: >>python or_test.py …
Neelesh I
  • 415
  • 1
  • 5
  • 14
3
votes
1 answer

Python PuLP "Overwriting previously set objective." and __dummy = None

I have built a pretty complex MIP in Python PuLP. Obviously a bit too complex for me. When I run it it gives the following Warning: UserWarning: Overwriting previously set objective. warnings.warn("Overwriting previously set objective.") The…
Axel
  • 2,545
  • 2
  • 18
  • 30