Questions tagged [python]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

Need Help for building two constrains, MIP model

Really need help for building two constrains 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 identifiers ...
CangWangu's user avatar
0 votes
0 answers
26 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
73 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
73 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
146 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
126 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
758 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
617 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
2 votes
1 answer
161 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
154 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
94 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
74 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
0 votes
0 answers
28 views

Need exercises to learn the Gurobi python package syntax

as I am trying to learn the Gurobi package, I did successfully try to implement some mathematical models. I want more and wish to have some exercises containing the Obj fun solution and the variables ...
applethal's user avatar
1 vote
1 answer
79 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
84 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
201 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
121 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
270 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
287 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
67 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
2 answers
339 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
35 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
410 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
236 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
99 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
57 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
126 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
93 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
33 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
51 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
101 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
198 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
115 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
179 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
62 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 votes
1 answer
85 views

How do I translate the following constraint for gurobi py?

I successfully worked on the problem with following model in Excel, but I have a problem translating it into Python. This is the proposed way to code the problem form the book: ...
Wangcincay's user avatar
0 votes
0 answers
575 views

VRP - Clarke and Wright implementation in python unable to find routes

Here's my attempt to implement the clarke and wright algorithm with the following constraints: maximum truck capacity, maximum distance traveled by a truck. The algorithm takes a distance matrix to ...
user.mokho's user avatar
3 votes
2 answers
197 views

Simplest Quadratic Programming algorithm for teaching

Can anyone recommend a straightforward quadratic programming (QP) algorithm suitable for an undergraduate engineering class? I'm interested in finding an algorithm that they can easily grasp and ...
Walton P. Coutinho's user avatar
0 votes
1 answer
287 views

How to use the at() method in Pyomo

I am using Pyomo and I have the following lines ...
PeterBe's user avatar
  • 1,642
0 votes
3 answers
199 views

Using PULP to model machines in a factory

Complete revision: I have all 4 machines that can run in positive and negative directions which results in 2 outputs: $ P_1 = \begin{cases} -390 \le P_1 \le -300 & \text{for neg mode}\\ 0 &...
sino's user avatar
  • 1
2 votes
0 answers
226 views

Pyomo Terminal Condition: other

I have written a huge optimization code in pyomo. The code serves for any planning horizon. The variables are indexed in time (t). When I set t to have 365 days, the termination condition is feasible/...
Alex's user avatar
  • 21
1 vote
1 answer
178 views

Python and GLPK to solve Linear programming problem (infeasible solution)

I'm using Python and the GLPK Solver to find recommendations for an infeasible problem. I'm optimizing for price, and this is the problem data: Define problem data foods = ['Food 0', 'Food 1', 'Food 2'...
Joao Branco's user avatar
1 vote
0 answers
41 views

Why does changing this one thing in the Primal Effective Capacity Heuristic improve the solutions it generates for the MDK problem?

For a long-done project presentation, I implemented the Primal Effective Capacity (PECH) Heuristic to look for initial greedy solutions for the Multidimensional Knapsack (MDK) problem in Python. I ...
Miss Mae's user avatar
  • 143
2 votes
2 answers
109 views

Small negative decision variable returned in Gurobipy model

I have a multi-period model in gurobipy with 7 types continuous decision variables and 1 type of binary (Thousands indexed total). The model solves properly and the solution has passed many validation ...
TroyE219's user avatar
  • 105
3 votes
1 answer
300 views

Solver options in Pyomo as long as using the NEOS solvers

I am working on a scheduling problem that is already coded in Pyomo. To solve the problem, I have used the NEOS solver, CPLEX. Now, to test and run some of the instances, I need to call some CPLEX ...
A.Omidi's user avatar
  • 8,882
5 votes
3 answers
442 views

What are my options for exact linear programming solvers in python3 that work as of April 2023?

So a while back I had asked this question: Is there a Linear Programming Library that natively supports fractions instead of floating point arithmetic? And basically the overwhelming consensus was ...
Sidharth Ghoshal's user avatar

1
2 3 4 5
8