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
23 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
63 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
  • 575
-2 votes
2 answers
57 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
69 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
67 views

Detect presolve status in pulp model

Hi 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
222 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
122 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
52 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
54 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
180 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
34 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
104 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
  • 113
2 votes
1 answer
192 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
43 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
0 votes
0 answers
28 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
89 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
74 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
26 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
  • 892
2 votes
1 answer
80 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
72 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
139 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
  • 21
1 vote
1 answer
81 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
0 votes
1 answer
92 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
83 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
61 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
78 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
272 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
153 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
216 views

How to use the at() method in Pyomo

I am using Pyomo and I have the following lines ...
PeterBe's user avatar
  • 1,632
0 votes
3 answers
170 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
150 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
120 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
0 votes
0 answers
37 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
  • 121
2 votes
2 answers
93 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
207 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,380
5 votes
3 answers
274 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 vote
0 answers
55 views

Which Python package is suitable for finding the optimal non dominated set in multiobjective optimization?

I would like to know how to use pyhon or Cplex or both for finding the whole optimal pareto front for a biobjective mixed integer linear programming problem?
Mansour's user avatar
  • 11
2 votes
1 answer
135 views

Using networkx predecessors in Pyomo initialize method

I am working on the directed graph by using the Networkx package and what I need is to use its predecessors' method on an optimization model. Let's say, there exists a directed graph with just $12$ ...
A.Omidi's user avatar
  • 8,380
0 votes
1 answer
102 views

Optimal blending of gasoline via LP

...
N_ote's user avatar
  • 11
1 vote
4 answers
178 views

Multi-period Inventory Balance in Gurobipy

I would like to get the inventory balance in the oponed facility $\text{C}$ such that, the Inventory at time $t$ is equal to the previous one, plus the inflow minus the outflow. I have tried to create ...
Abde's user avatar
  • 81
2 votes
3 answers
236 views

How to represent the objective function of the Weapon Target Assignment problem in CVXPY?

I am trying to use CVXPY to analyse a problem and the objective function for this problem involves calculating a product and a sum as per the problem description below (taken from a draft paper I am ...
BRavos's user avatar
  • 29
0 votes
0 answers
62 views

Gurobi-Python, unmet demand of customers

I would like to capture the unmet demand by modeling the following constraint with two decision variables. where $QU_{wc}$ is the unmet demand and $QW_{wc}$ the shipped amount of products. I model the ...
Abde's user avatar
  • 81
0 votes
2 answers
157 views

Modelling with Gurobi-Python a Supply Chain Problem

I would like to write the following simple model in GurobiPy, which is part of many terms that's belongs to the objective function, I assumed that I have three suppliers are selected and three ...
Abde's user avatar
  • 81
0 votes
0 answers
89 views

Multi-Scenario Gurobi Python Output

I have an lp and am trying to solve multiple scenarios at once. One of my scenarios is infeasible though this is not the issue. For some reason, when I print m.status, both solutions have a status of ...
TroyE219's user avatar
  • 105
2 votes
2 answers
339 views

I want to solve an optimization problem with nonlinear piecewise objective function (I tried Pyomo with "ipopt" solver but I had an error)

I want to solve an optimization problem where the objective function is the summation of nonlinear, piecewise functions in the decision variables q_i's such that when a decision variable q_i < 1, ...
3bod's user avatar
  • 21
3 votes
1 answer
181 views

Converting continuous variable dict to binary variables in python docplex

I am solving a problem using linear relaxation at the initial phase. Hence, I need continuous variables at the beginning. Then I need to convert some continuous variables to binary and solve the same ...
user avatar
2 votes
1 answer
239 views

Implementing a MINLP problem in Pyomo: giving an infeasible solution

I'm trying to implement a MINLP problem which is described in a previous post here: How do we formulate a problem where the decision variable has an index that is also a decision variable? The only ...
Steven01123581321's user avatar
0 votes
0 answers
53 views

Creating a simple class in python for doing simulation of MDP

I am currently learning Python and doing object-oriented programming. I am trying to create a simulation for MDP. My problem statement is: "I have four stages of process. Each stage has two ...
Margi Shah's user avatar
2 votes
1 answer
91 views

Grid search for optimization problem

Suppose you wanted to solve the following optimization problem: $$\inf_{a \geq 0}\sup_{b \geq 0}\dfrac{(a^2 + 1)(a + b)}{2a + b} + \dfrac{b}{a + b} - ab,$$ where $a, b$ are scalars. How would you use ...
Nico Konrad's user avatar

1
2 3 4 5
8