12
votes
How do I access the value of a variable in PuLP?
To get the value of the decision variable, you need to use the varValue property of the LpVariable, so:
...
10
votes
Accepted
Complicated constraint with logical operators in PuLP
Suppose your two arrays are indexed by $I$ and $J$, and let $x_i$ be the binary variable.
zero or one elements may be selected from first array:
$$\sum_{i\in I} x_i \le 1 \tag1$$
zero, one, or many ...
10
votes
"Out of the box" Mixed Integer Programming Heuristics
You can solve your model via the NEOS server which provides Gurobi, Cplex, and other solvers for free if it is the matter of not having a solver. I am not familiar with PuLP but I know it is easy to ...
10
votes
7
votes
Accepted
Read an LP/MPS file in the PuLP
According to PuLP's documentation, it seems that load_file function in PuLP's Amply class can only handle AMPL files with a ...
7
votes
Accepted
Find the list with the fewest elements whose cumulative sum reaches threshold
Your model basically reads as
$$
\begin{align*}
\min \quad n \quad \text{s.t.} \quad \sum_{k = 0}^{n} l_{i,k} \geq b_i \cdot \epsilon, \quad \sum_{i \in L} b_i = 1,
\end{align*}
$$
where $l_{i,k}$ is ...
7
votes
Accepted
How to call HiGHS solver from python PuLP MIP?
PuLP has an API for HiGHS but that version is not sent to pip yet.
For the time being, you should pip install PuLP from Github. See the command taken from their readme below. (ps. You might need to ...
6
votes
Accepted
How to set these constraints in a linear optimization problem (PuLP)?
The rule "works on Saturday implies works on Sunday" can be expressed as
$$(D_{i,6} \lor N_{i,6}) \implies (D_{i,7} \lor N_{i,7}),$$
which can be rewritten in conjunctive normal form as follows:
\...
6
votes
Accepted
How to enforce this specific constraint in PuLP?
In other words, you want to avoid a pattern of 010. As a logical proposition:
$$\neg (\neg V_{i,j} \land V_{i,j+1} \land \neg V_{i,j+2}),$$
which you can write in conjunctive normal form as:
$$V_{i,j}...
6
votes
Accepted
How do I turn off preprocessing in pulp?
You can use presolve parameter and can pass it to solver(CBC) using following statement (model is your problem object)
...
6
votes
Pulp problem gets the right objective value but fails to find the minimal solution
How do you define the "right" answer?
If the objective function value is computed correctly and reaches minimum value, then it is possible that the optimal solution is not unique, and that ...
5
votes
Accepted
Python "Coffee Shop Scheduling Problem" - Scheduling Lunches/Breaks
The model you linked in the question will do the job. You just set $a_{jt}=0$ if a worker on shift $j$ would be taking a break at time $t$.
5
votes
Accepted
Multi period inventory / reordering MILP in PULP
Some comments on your model:
you can remove constraints $\#1$ and $\#2$, as you have already defined the variables as non negative
the problem is infeasible, because the inventory is not a variable, ...
5
votes
Accepted
I'm trying to solve an OR problem written using pulp framework , with gurobi, in Linux , but I'm not able to solve it
The path in Linux has to point to the gurobi_cl binary, which is located in the bin folder. ...
5
votes
Accepted
Binary Integer Programming Problem - Enforce Zeros on Certain Groups
Let $G$ be the set of groups. For group $g\in G$, let $I_g$ be the set of indices $i$ in that group. Introduce binary decision variable $y_g$ to indicate whether $x_i=0$ for all $i\in I_g$. To ...
4
votes
Accepted
Representing Date Variables in Pulp
You don't want to create a variable representing a date in pulp. You want to utilize zero-one indicator variables for each option. In this case your options are the vessel-date combinations. Index the ...
4
votes
How to transfer an optimization problem written with GUROBI (in python) in a grammar that can be readily solved with another solver?
I think pySCIPOpt might be a good choice, provided you are willing to make minor changes to the code. The modelling interface is very similar to Gurobi and the underlying SCIP solver also supports ...
4
votes
Accepted
4
votes
Accepted
Violation of specific constraint in Pulp
Introduce linear constraints:
$$\sum_{\text{h}} z[\text{h}][\text{driver}] \le 1 \quad\text{for each driver}$$
4
votes
Scheduling optimisation constraint on consecutive shifts & consecutive night shifts (`python`)
There are certainly different ways of achieving what you want. Here is how I would proceed:
Start by predefining the set of all possible schedules which satisfy your constraints $2,3,4,6$. Although ...
4
votes
Accepted
How to convert static variables into arrays for use with PuLP
Your code is correct, you have used pulp.LpVariable.dicts correctly.
For better readability, it is often better to use dictionaries. So the idea is to convert your ...
4
votes
Accepted
How to generate multiple solutions to linear program in Python?
When I understand your question correctly you are not interested in the full solution space. In that case you can generate alternative optimal solutions by first solving your problem to optimality. ...
4
votes
Accepted
Python Pulp - LpMinimize Not Returning Expected Output - Scheduling Problem
First, it is confusing when you say
The final solution does not satisfy the workforce requirements for the
various time windows, it's substantially short. Only 5 shifts are
filled in total.
You do ...
4
votes
Designing a multi-commodity network flow optimizer
Question 1
You could simply use the priority function as the cost function on the arcs. This way, it is for example cheaper to ship a commodity to $D_1$ from $W_2$ ($1$ unit of cost per unit of flow) ...
4
votes
Accepted
Subtour elimination implementation (DFJ) using Python (PULP). While loop never exits
In constraint
...
4
votes
Any Idea why PuLP is ignoring binary variables?
You need to capitalize the first letter in the cat option:
...
3
votes
How to generate multiple solutions to linear program in Python?
Your problem does not have any objective function, so you do not have to use software to solve linear programs here. It is just a system of linear inequalities. (Of course, you still can use LP tools ...
3
votes
Accepted
Advanced Heuristics for MIP vehicle routing problem in PuLP
It is difficult to tell from this information. You need the examine the logs of the solver if your primal bound (how good are the solutions) or dual bound (how good is the relaxation) is not moving as ...
3
votes
"Out of the box" Mixed Integer Programming Heuristics
I have some experience in solving large-scale airline crew pairing combinatorial optimization problems (an NP-hard problem) with difficulty similar to vehicle routing problems. Yes, solving such ...
3
votes
CBC stalling after approximately 10 seconds
CBC does have its fair share of bugs, especially when it comes to proper termination.
If you are running in multithreaded mode try running in serial (or vice-versa), and see if that helps.
If you are ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pulp × 63python × 39
linear-programming × 28
optimization × 22
mixed-integer-programming × 16
modeling × 6
integer-programming × 6
solver × 4
constraint × 4
cbc × 4
gurobi × 3
scheduling × 3
pyomo × 3
binary-variable × 3
linearization × 2
constraint-programming × 2
vehicle-routing × 2
logical-constraints × 2
assignment-problem × 2
nonlinear-programming × 1
or-tools × 1
network-flow × 1
inventory × 1
heuristics × 1
facility-location × 1