Questions tagged [python]
For questions about solving Operations Research problems using the Python programming language.
404
questions
0
votes
1
answer
57
views
Free solver for large LP with warm start and shadow prices
Please advise me a free solver for large linear programming problems that
supports warm start
can calculate shadow prices simultaneously solving the LP problem
has Python interface
I considered GLOP ...
0
votes
0
answers
55
views
Fastest way to solve many systems of integral equations using python
I have a Pandas dataframe that looks like the following:
...
0
votes
0
answers
46
views
Could I use numpy.arrays to represent the chromosome when solve Job scheduling in GA
I'm trying to solve a Job scheduling problem using a Rank-Based Encoding genetic algorithm that I envision encoding like this:
Represent the chromosome as an m x n matrix, each row of the array ...
2
votes
1
answer
60
views
How can I create a python program that organizes CSV into combinations?
I was directed to this forum by the users at stack overflow as they informed me it didnt fit there.
Im trying to create a program that would input a csv file with two lists of plate thicknesses, in ...
2
votes
0
answers
103
views
Which OR communities would welcome in a new open source solver for Python?
We've just announced Timefold Solver for Python, a new open source (apache license) solver for Python. We'd love to get some feedback on it's user experience. It's all being build in the open.
So I am ...
0
votes
1
answer
94
views
How to write conditional constraints and sum the result in Linear Programming in Python?
I want to use the sum of a series of linear expressions as objective and constraints. These linear expressions are chosen to be included or not based on some conditions. I can achieve it in Excel ...
0
votes
0
answers
58
views
Need help for the python scheduling code
I'm working on a Python application using PuLP for optimization, and I'm having trouble ensuring that only one material is produced on a given day.
The constraint prob += pulp.lpSum(production_flag[m][...
0
votes
0
answers
31
views
Spectral clustering with laplacian matrix eigenvector
I want to separate a given graph in $k$ clusters with the laplacian matrix ($L = D-A$ where $D$ is the degree matrix and $A$ the adjacency matrix).
How can the eigenvectors of $L$ be used, along with ...
0
votes
0
answers
46
views
Getting solution status as Unknown status value in callback (lazyconstraints) for docplex with Python to solve MILP
from docplex.mp.model import Model
from cplex.callbacks import LazyConstraintCallback
from docplex.mp.callbacks.cb_mixin import *
p_id is the list of lists of customers,
n is the set of vehicles,
dth ...
1
vote
0
answers
91
views
what should I do to avoid scipy.minimize solver from computing infeasible models as much as possible
Python==3.9.5, scipy==1.13.0
My model has some variable coefficients in each round of calculation. for example, for a four-dimensional decision variable ...
1
vote
2
answers
61
views
Improve a heuristic to solve the MS-RCPSP
I'm currently working on developing a heuristic to tackle the multi-skill resource constrained project scheduling problem (MS-RCPSP). I'd greatly appreciate any suggestions or modifications you may ...
1
vote
0
answers
89
views
Getting error in callback (lazy constraints) for docplex with Python to solve MILP
I am trying to use lazy constraints to solve my MILP problem. The details are given as follows.
...
0
votes
1
answer
139
views
Minimal example using MOSEK API in python
I want to solve (simplified version)
\begin{equation*}
\begin{aligned}
& \underset{}{\text{find}} & & X\in\mathbb{S}^{n}_{+}, x \in \mathbb{R}^{m}, \nu \in \mathbb{R}, \lambda\...
0
votes
0
answers
85
views
Linear sum assignment, but with ranked assignments?
Let's say I have 5 tasks that I have to assign to 5 agents, with a cost matrix:
...
2
votes
1
answer
329
views
CPLEX 20.1.0.0 and python version 3.10
I am trying to develop in python 3.10, and locally I have cplex 20.1.0.0 installed. It appears to me that the python interface cplex only supports python version 3....
1
vote
1
answer
134
views
Unique values constraint in Pulp
Can we directly model following constraint in pulp
x != y
as following:
...
1
vote
0
answers
49
views
Could scipy.optimize.minimize be suitable for multi-objectives?
The current model is built using the manner of scipy.optimize.minimize, and now the business needs to transform the model into a multi-objective optimization model. ...
0
votes
0
answers
107
views
Need Help for building two constraints in MIP model
Really need help for building two constraints with MIP model, I have written the required information and variable information on the diagram below.
The way I think of it now is to use two ...
0
votes
0
answers
33
views
Shipment Allocation using Pulp
I am trying to create a model where each shipment must be allocated to a route to minimize the freight cost. I am a complete newbie at LP Optimization.
Explanation of dataset:
Every destination (D1,...
1
vote
1
answer
128
views
A tool for finding integer solutions to linear systems
I have a system of linear equations $A x = 0$, where $A$ is an integer matrix, and I want to find a non-zero solution, if it exists. In that case, a rational solution exists. Multiplying by the common ...
1
vote
2
answers
78
views
How to maximise black-box function defined on a subset of integers, with access to its derivative?
The basic form of my problem is as follows. Let $S = \{ 1, 2, ..., 30 \}$. I have an integer-valued function $f$, whose argument is an integer-valued vector $\vec{x} \in S^{200}$. I also know that ...
-1
votes
2
answers
202
views
How to describe nonlinear programming in gurobipy?
The optimization task
The optimization task concerned here is:
A square matrix $A\in \mathbb{R^{5\times 5}}$ satisfies the condition: the elements of the first row all are 1, the elements of the ...
0
votes
1
answer
259
views
PuLP is ignoring constraints, and setting everything to 0 for minimization problem
I have a multi-objective optimization problem I am trying to solve with competing objectives. I am trying to model a network of industrial businesses which can share wastewater rather than sending it ...
3
votes
1
answer
1k
views
Scipy.optimize can't get correct answer when objective is Piecewise Linear Function and Equality Constraint
I'm encountering a puzzling issue with SciPy's minimize function in a constrained optimization problem. My objective is to optimize a piecewise linear function with ...
5
votes
3
answers
626
views
Algorithm needed to find optimum area of 2-dimensional data set
The python script depicted below generates the following toy data set.
I need to determine the values for $x_{min}$, $x_{max}$, $y_{min}$, $y_{max}$ describing a rectangular area where the sum over ...
3
votes
1
answer
227
views
Implementing Logic-based Benders decomposition on a single search tree
Currently, I am working on a scheduling problem and trying to approach it by the logic-based Benders decomposition method. Theoretically, I have everything, i.e., the master and sub problem(s), the ...
8
votes
3
answers
2k
views
When are Jupyter Notebooks used to solve optimization problems in Operations Research?
When is it useful to solve an optimization problem inside a Jupyter Notebook?
When is it not?
What are the advantages/disadvantages?
1
vote
1
answer
301
views
Creating a decision variable that is the sum of other variables in PuLP
I'm trying to represent the following problem with PuLP:
A car factory needs to maximize profit with an X amount of car models. Each car model has an individual profit and a manufacturing limit, and ...
0
votes
2
answers
117
views
Extracting a sequence as a decision variable from a matrix (PuLP)
I am solving a sequencing problem x[i][j], i.e. a binary matrix indicating that product i is followed by ...
1
vote
1
answer
180
views
pyinstaller and Pyomo and also SCIP
I would like to package (using pyinstaller) my optimizer program that uses Pyomo and SCIP. I keep getting ...
1
vote
1
answer
84
views
Partially modify LHS of a constraint set?
I have implemented a column generation algorithm in Gurobi in Python. The most computationally expensive aspect of this algorithm is the reconstruction of the master problem when a column is added (or ...
-2
votes
2
answers
102
views
Is there existing code for the set partitioning formulation of routing problems?
The set partitioning formulation of routing problems is pretty well-accepted as perhaps the best exact method to solve routing problems. However, these methods are difficult to implement as many ...
1
vote
0
answers
369
views
MOSEK via fusion vs API vs CVXPY
In Python, I would like to solve a collection of problems, that are all solvable via MOSEK's conic optimization solvers (ExpCone, SOCP, etc.)
I have tried CVXPY. I get very robust and reliable results,...
0
votes
0
answers
194
views
Detect presolve status in pulp model
I am running a model using pulp CBC and have few constraints in the model that may make the model infeasible if wrong input is given to the model.
I can see while my model runs that in case of ...
2
votes
1
answer
333
views
Gurobipy MILP model comes infeasible yet can't compute IIS because "the model is feasible"
I build a MILP model by Pyomo and use Gurobi 9.0.3 as solver.
When the model comes infeasible, I try to use pyomo.contrib.iis.iis.write_iis
to compute infeasible ...
2
votes
1
answer
862
views
Non-proprietary (Python friendly) alternatives to Cplex and Gurobi
I have implemented a pure binary integer combinatorial optimization routine within a Python module (importing gurobipy), and experimented with relaxing a few ...
0
votes
1
answer
95
views
Question about IIS output in Pyomo, Gurobipy
These days I try to build a Gurobipy optimization model by Pyomo and I met a problem about outputing IIS file.
I use
...
0
votes
0
answers
57
views
Optimization for a capacity problem
I have a csv file with a table with 5 columns: dueDateTime, cover, phone, simcard, tablet.
This file has the amount of items for cover, phone, simcard, tablet.
I have the size of the items:
we have ...
0
votes
3
answers
705
views
Starting with HiGHS
I have been messing about with HiGHS and trying to get a hang of its capability.
Here is an example of a simple model from their github repo
https://github.com/ERGO-Code/HiGHS/blob/master/examples/...
2
votes
0
answers
39
views
I need help with finding a library or tutorial to parallel optimize given a black box function, assuming it's convex
I have a black box function to optimize with respect to 1-D input,$\beta$, and I also have other inputs, which I don't need to optimize, say (x,y). So, I need to optimize f($\beta$, x,y) over $\beta$. ...
1
vote
1
answer
818
views
How to get hypervolume calculation for Pareto Front in python?
I hope that this Stack Exchange channel is the right place for this.
I'm trying to analyze a multiobjective optimization problem. I'm wanting to use the hypervolume calculation to benchmark the ...
2
votes
1
answer
272
views
Quadratic optimisation with $\ell_1$ constraints with CVXPY
Crossposted on Mathematics SE
I seek to minimize a convex quadratic objective subject to linear and $\ell_1$-based equality constraints. When I turn to CVXPY, an error is raised indicating that it ...
1
vote
1
answer
149
views
How to obtain nodes count and nodes left in docplex (using CPLEX 12.20 and Python 3.8)
I solving a MILP problem as given below using Python 3.8 and CPLEX 12.20. I want to obtain the number of nodes and nodes left. The details of the codes are as follows:
n_xvars=2
n_yvars=2
#Create ...
1
vote
0
answers
103
views
Handling Variable Division in CVXPY for Calculating Annualized Rate of Change
I am working with a dataset that contains multiple entries for different IDs across various years. Some IDs might have a gap of years between entries. My goal is to solve an optimization problem using ...
1
vote
1
answer
197
views
Non integer linear objective in or-tools CP-SAT
It seems that or-tools' CP-SAT solvers allows for non-integer coefficients in a linear objective expression. Am I correct, or is it just that the solver doesn't check for integrity and rounds the ...
0
votes
0
answers
101
views
Transforming a quadratic constraint into a linear constraint
I have a problem with a quadratic constraint and I want to transform it into a linear constraint. This would help to reduce the computational time of my problem.
Following constraint should be ...
0
votes
0
answers
38
views
Error while using subgradient method to update lagrange multipliers
I am trying to implemet the subgradient method in Lagragian relaxation to update the multiplier lamda which has three dimension, I have ecountered an Except error, it looks the is bugs in the code. it ...
1
vote
0
answers
58
views
explain Givens rotation chain for maintaining Cholesky factorization
I'm attempting to implement the dual face algorithm from Pan's book chapter 22 (https://link.springer.com/book/10.1007/978-981-19-0147-8).
The part in question is pasted here:
Can you please explain ...
2
votes
1
answer
125
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 ...
0
votes
1
answer
112
views
Interpret the formulation of a pricing model in crowdshipping
I am trying to run the pricing model from the paper "Designing pricing and compensation schemes by integrating matching and routing models for crowd-shipping systems" on python with Gurobi, ...