Skip to main content

Questions tagged [python]

For questions about solving Operations Research problems using the Python programming language.

Filter by
Sorted by
Tagged with
0 votes
1 answer
45 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 ...
Shwing's user avatar
  • 13
0 votes
0 answers
40 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][...
Beau Ryan's user avatar
0 votes
0 answers
29 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 ...
Sham's user avatar
  • 1
0 votes
0 answers
21 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 ...
Mohammad Samiullah's user avatar
1 vote
0 answers
84 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 ...
CangWangu's user avatar
1 vote
2 answers
53 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 ...
John Donald's user avatar
1 vote
0 answers
58 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. ...
Mohammad Samiullah's user avatar
0 votes
1 answer
98 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\...
BasicUser's user avatar
  • 101
0 votes
0 answers
54 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: ...
Dan's user avatar
  • 1
2 votes
1 answer
163 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....
TTY's user avatar
  • 245
1 vote
1 answer
104 views

Unique values constraint in Pulp

Can we directly model following constraint in pulp x != y as following: ...
mufassir's user avatar
  • 211
1 vote
0 answers
37 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. ...
CangWangu's user avatar
0 votes
0 answers
104 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 ...
CangWangu's user avatar
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,...
Jayit Ghosh's user avatar
1 vote
1 answer
93 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 ...
Erel Segal-Halevi's user avatar
1 vote
2 answers
75 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 ...
j x's user avatar
  • 111
-1 votes
2 answers
171 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 ...
138 Aspen's user avatar
  • 197
0 votes
1 answer
167 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 ...
Caleb O's user avatar
  • 13
3 votes
1 answer
900 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 ...
Yiyuan Chen's user avatar
5 votes
3 answers
620 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 ...
7824238's user avatar
  • 151
3 votes
1 answer
200 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 ...
Amir Hosseini's user avatar
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?
Geoffrey De Smet's user avatar
1 vote
1 answer
209 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 ...
user avatar
0 votes
2 answers
102 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 ...
Jigeli's user avatar
  • 11
1 vote
0 answers
108 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 ...
mathlete42's user avatar
1 vote
1 answer
81 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 ...
mdslt's user avatar
  • 615
-2 votes
2 answers
97 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 ...
IsalanOnkar's user avatar
1 vote
0 answers
271 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,...
independentvariable's user avatar
0 votes
0 answers
154 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 ...
Bhavya Budhia's user avatar
2 votes
1 answer
315 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 ...
CangWangu's user avatar
2 votes
1 answer
513 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 ...
Cbhihe's user avatar
  • 123
0 votes
1 answer
86 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 ...
CangWangu's user avatar
0 votes
0 answers
56 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 ...
Andreas K's user avatar
0 votes
3 answers
536 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/...
Erin Walter's user avatar
2 votes
0 answers
38 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$. ...
Thiha Aung's user avatar
1 vote
1 answer
606 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 ...
BSplitter's user avatar
  • 145
2 votes
1 answer
243 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 ...
jam123's user avatar
  • 21
1 vote
1 answer
125 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 ...
Mohammad Samiullah's user avatar
1 vote
0 answers
76 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 ...
user760900's user avatar
1 vote
1 answer
157 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 ...
E. Fischer's user avatar
0 votes
0 answers
97 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 ...
Adri's user avatar
  • 11
0 votes
0 answers
36 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 ...
ABDE's user avatar
  • 1
1 vote
0 answers
53 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 ...
Brannon's user avatar
  • 900
2 votes
1 answer
113 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
0 votes
1 answer
111 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, ...
Last_Mile's user avatar
1 vote
2 answers
224 views

Efficient ways to do pairwise/multiplicative variables in integer linear programming on PuLP / Python

I'm trying to formulate an LP that is in essence a variant of the sudoku problem, and I've repurposed the code from https://coin-or.github.io/pulp/CaseStudies/a_sudoku_problem.html. The differences ...
Riezz's user avatar
  • 41
1 vote
1 answer
133 views

Set optimality gap for each goal objective in FICO XPRESS

FICO XPRESS recently released a feature that supports multi-objective optimization. While it allows you to define a tolerance per objective (aka how much you can relax the previous objective), I am ...
user4168715's user avatar
1 vote
1 answer
241 views

Are there any hidden differences in OR-Tools' default parameters for a MIP model in Python vs C++?

or-tools-discuss cross post here. As a disclaimer -- I am very aware that OR-Tools' Python code are just wrappers around their C++ source code. I'm just getting an odd discrepancy between a model ...
gjgutier545's user avatar
0 votes
1 answer
84 views

how the number of employees affects the married employee scheduling problem

My scheduling problem has a specific pattern of 2 days of work followed by 2 days off. Additionally, there is a week off after every 4 weeks of work. The scheduling matrix (P) has five different ...
abdula smith's user avatar
0 votes
0 answers
66 views

How do I implement this convex problem in CVXPY?

I am looking to implement the following optimization problem in CVXPY. $$ \max _{x_t} x_t' \mu - \frac{\gamma}{2} x'_t \Sigma x_t - x'_t\Lambda \Delta x_t $$ where $\Delta x_t := x_t - x_{t-1}$ and $\...
Lydia's user avatar
  • 1

1
2 3 4 5
8