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
53 votes
15 answers
14k views

Are Python and Julia used for optimization in industry?

I am giving a small computer exercise that aims at teaching students the basics of a modelling language to model small optimization problems. So far I have been using the modelling language GAMS as ...
PeterBe's user avatar
  • 1,652
33 votes
12 answers
15k views

MATLAB vs. Python in industry

I am a beginning PhD student in math, and I would like to focus on optimization. I am learning programming for the first time, and I have written out some rudimentary optimization algorithms in both ...
Blue's user avatar
  • 603
18 votes
5 answers
15k views

Which Python package is suitable for multiobjective optimization

I would like to start using Python for modelling and solving optimization problems. I would like to use both single-objective problems and multi-objective problems with a multidimensional objective ...
PeterBe's user avatar
  • 1,652
14 votes
4 answers
4k views

YALMIP-like modeling environment in Python

What are the handiest optimization parsers out there? Is COIN-OR's PyPy being used actively? I am currently trying to do an optimization project in Python, but I am used to using MATLAB + YALMIP ...
independentvariable's user avatar
14 votes
4 answers
2k views

How to model a mixed-integer linear programming formulation in Python using Gurobi?

I can remember that I spent some time in understanding how to formulate my first model. So I aimed at presenting a complete model here, wishing to save some time for students or researchers needing it....
Mostafa's user avatar
  • 2,104
13 votes
5 answers
2k views

What are technologies or libraries which greatly improve the speed or ease of use for delivering of OR software?

There are many great technologies/libraries out there to improve the speed and quality of implementing and deploying OR applications. However in my experience I "stumbled" upon many of them ...
user3680510's user avatar
  • 3,655
13 votes
3 answers
7k views

How to find all vertices of a polyhedron

I have a convex polyhedron given by a set of linear inequalities, for example: $$ x_1 \geq 0,~~ x_2 \geq 0, ~~x_3\geq 0 \\ x_1+x_2\leq 1,~~ x_2+x_3\leq 1,~~ x_3+x_1\leq 1 $$ I want to list all the ...
Erel Segal-Halevi's user avatar
12 votes
3 answers
4k views

Settings for a faster solution of a MILP (GUROBI, python)

Using GUROBI with python. When solving a MILP, I notice that the incumbent is very early (25sec) at the optimal point but the best bound is so slow to fall (maximization problem) that it takes ages (...
Makis Karasavvidis's user avatar
11 votes
2 answers
223 views

Are there examples of spatially explicit MIP problems?

Disclosure: I am an MSc student in economics, but not an expert by any means in OR. I am trying to model a spatial MIP problem of an invasive species similar to this academic paper, however, my ...
GrayLiterature's user avatar
11 votes
3 answers
4k views

Python API and CPLEX

Note: See the EDIT below for one possible solution. I apologize if this is not appropriate but I don't really have anywhere else to turn. I was hoping that someone would be able to post how they ...
GrayLiterature's user avatar
11 votes
1 answer
1k views

Change coefficient in PuLP

Once a model is implemented in PuLP, how do you change a coefficient (e.g., $a_{ij}$, $b_i$ or $c_j$) of a program of the from $\min\{c^{\top}x: Ax=b, x\geq0\}$? Specifically: How to update ...
Daniel Duque's user avatar
  • 1,355
11 votes
1 answer
971 views

Termination Criteria of Solver in Pyomo

I am solving a nonlinear optimization problem using Pyomo with Ipopt as solver. The solver exits with the status: EXIT: Optimal Solution Found. This I can cross ...
chupa_kabra's user avatar
  • 1,485
11 votes
1 answer
2k views

Simulation in Python

What is the most common package for discrete-event simulation in the OR community? I have found SimPy package.
Junior MIP's user avatar
11 votes
1 answer
755 views

How to solve the Cumulative Traveling Salesman Problem using or-tools in python?

The objective of the Cumulative Traveling Salesman Problem (CTSP) is to minimize the sum of arrival times at customers, instead of the total travelling time. This is different than minimizing the ...
Sebastián Quintero's user avatar
10 votes
4 answers
2k views

Integer programming problem with simple quadratic objective function in Python

I have $n$ objects that need to be divided among $k$ groups. Each group must receive at least $5$ objects. In addition, the percentage of objects in group $i$ should be as close as possible to $p_i$ ...
Rohit Pandey's user avatar
10 votes
2 answers
827 views

Modeling and solvers

I have just started to dive into OR world on my work. Currently we are using GAMS with Gurobi but some of us have strong programming background and would like to have more programmatic approach to OR. ...
aurelije's user avatar
  • 203
10 votes
2 answers
2k views

Implementing solvers with Object Oriented Programming

I would like to know what are some best practices in designing a solver implementation with Object Oriented Programming. We have implemented a solver with procedural programming paradigm, using python,...
naveen divakaran's user avatar
10 votes
2 answers
564 views

Significant bias introduced into simple simulation

This question has been asked on Cross Validated Introduction Service is allocated to an infinite source of customers i.e. there is always a service in progress. The duration of the $i^{th}$ service ...
Dylan Solms's user avatar
10 votes
1 answer
14k views

How do I access the value of a variable in PuLP?

In Python's PuLP package, how can I get the value of a decision variable? For example, if I declare a variable— ...
LarrySnyder610's user avatar
10 votes
1 answer
2k views

Floating points in OR-Tools

I'm trying to solve an RCPSPDc model (maximizing the net present value instead of a makespan). The objective function is: $\sum\limits_{j \in \text{Tasks}} e^{-\theta\cdot s_{j}}\cdot p_{j}$, where $...
Diego R. Troncoso's user avatar
10 votes
2 answers
3k views

How to get GAMS's solvers to work from Pyomo?

I want to run a model written in Pyomo language with CPLEX solver of GAMS. However I get the following error: ...
rgholizadehr's user avatar
9 votes
2 answers
838 views

Softwares for Operations Research. Is Excel Outdated or Useless for the OR industry?

I am looking over for softwares recommendation in Introduction to Operations Research Hillier 11th, there are tens of options for learn and apply OR theory using software. I normally check how much ...
rubengavidia0x's user avatar
9 votes
4 answers
2k views

Open Source MILP software for Python with user-friendly API to define the optimization problem

Following the accepted answer to Assignment problem where assignments must be done sequentially I would like to write a Python script which can solve the problem defined there. It's a Mixed Integer ...
DeltaIV's user avatar
  • 255
9 votes
3 answers
2k views

Open source MILP solver for quick “good enough” solution

I have a problem that I have already posted elsewhere in OR.stack, but the question is focused around a large binary MILP (about 1 million decision variables). Ultimately, I am more time constrained ...
S moran's user avatar
  • 335
9 votes
3 answers
5k views

Can I use 'SCIP' solver for PYOMO?

I have an MINLP problem to solve where I was initially using 'ipopt' solver but the solution was not sticking to 'binary/boolean/integer' domain type for a variable. I am not sure which free solver ...
Nikita Agrawal's user avatar
9 votes
2 answers
227 views

When should I use a solver for IP and MIP and can I just use a library from Python, R, Matlab, etc...?

Are there any rules of thumb for figuring out when you need to use a solver like Gurobi or CPLEX, and when you can just solve you problems directly with a Python, R, or Matlab package? Is it just a ...
Skander H.'s user avatar
  • 2,139
9 votes
2 answers
3k views

Reading an LP/MPS file using Pyomo software

I would like to know is it possible to read an LP/MPS file into the Pyomo software and solve the problem? If so, how can I do that?
A.Omidi's user avatar
  • 8,960
9 votes
2 answers
2k views

Is there a way to view added constraints in Gurobi (Python)?

I should note that I am very new to Gurobi so apologies if this is obvious. I am working on a project for a class to maximize profit on a theoretical flight network by deciding which routes to fly at ...
Noah M's user avatar
  • 131
9 votes
2 answers
815 views

Common structures in Gurobi - Python

I'm new to Gurobi in Python and I was wondering if someone knows how to code some common structures of linear constraints. I'm trying to understand how you'll code something like the following ...
SantiagoAm16's user avatar
9 votes
1 answer
618 views

TSP problem: traveller does not visit all nodes - Google OR-tools

Context: I am dealing with a kind of scheduling problem, in which I have a set of tasks and machines. All tasks must be assigned to machines (not necessary all of them). In addition to that, I must ...
campioni's user avatar
  • 1,133
9 votes
1 answer
388 views

pyomo - pass time limit to NEOS

I am sending a pretty complex Pyomo MINLP to NEOS using Couenne. I'm getting an error message that the solve time is too long (sorry, I don't have it still in my Python console). Is there a way to set ...
Ralph's user avatar
  • 371
9 votes
1 answer
2k views

Pyomo: Looping Over A Variable Method

I am trying to extract my variable values into unique lists so that I can pass them to a panadas dataframe and eventually export the dataframe to Excel after I solve my model. The idea is to have the ...
GrayLiterature'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
8 votes
3 answers
1k views

Maximize assigned tasks to each worker

In a scheduling problem I want to assign the maximum number of tasks to one worker before assigning it to another. For example, if I have $10$ tasks and $2$ workers, the best assignment would be $(10, ...
Stradivari's user avatar
  • 1,414
8 votes
1 answer
761 views

Creating a Continuous Decision Variable between 0 and 1 in Python-MIP Interface

This task appears to be harder than it seems to me. I want to create a continuous variable $x \in [0,1]$. To test this, I did use the open-source Python-MIP interface which uses the CBC-Solver out ...
Georgios's user avatar
  • 1,193
8 votes
2 answers
6k views

Python does not identify the academic version of CPLEX

Python does not identify the academic version of CPLEX. I am using Linux, Ubuntu. I have Python 3.6. I installed CPLEX studio 12.9 (academic version installed via the file ...
Mostafa's user avatar
  • 2,104
8 votes
1 answer
575 views

Using the values of variable in the objective function before optimizing

I am facing a problem to multiply a term in objective function. My objective function is : \begin{equation} \min \sum_{t=1}^\top p_{t} \cdot (1+r) \cdot y_{t} \end{equation} where $p$ is the ...
salidi's user avatar
  • 99
8 votes
1 answer
759 views

Travelling salesman problem with given number of locations to visit

There's a great example here of how to find a solution to the travelling salesman problem: ...
ignoring_gravity's user avatar
8 votes
1 answer
187 views

Specific filter on the set using Python

I'm trying to write an optimization model using an open-source solver's Python API. I'm new to use Python. The model objective function is as follows: \begin{equation} \sum_{k=1}^{K} \sum_{j=1}^{n}\...
A.Omidi's user avatar
  • 8,960
8 votes
1 answer
439 views

Why is Gurobi output in Pyomo returning floating-point values rather than optimal integer solution?

I am hoping someone will be able to point me in the direction of why I am experiencing floating-point outputs rather than simply model.X = [15,15] and model.Z = [15,5] as solutions to this model? Note ...
Jwem93's user avatar
  • 333
8 votes
2 answers
4k views

How can I add this conditional constraint to my model in Python?

I am creating an optimization model with 2 sets of binary decision variables. The first, site, is regarding which of 380 cities to place manufacturing sites in, and ...
Jacob Myer's user avatar
8 votes
1 answer
1k views

Read an LP/MPS file in the PuLP

I was trying to read a MPS file by using the PuLP package in the Python, but I can't find any related documents on it. Does ...
A.Omidi's user avatar
  • 8,960
8 votes
2 answers
3k views

Gurobi's "Out of memory" error without exhausting the RAM?

I wrote a branch-and-price algorithm in Python 2.7 which solves several small LP and MIP models by Gurobi 8.1 in each node. The algorithm runs fine at first, it produces both lower bound and upper ...
Mehdi's user avatar
  • 683
8 votes
1 answer
247 views

Heuristic Search Planning Tree Leading to Worse TSP Solutions than Naive Greedy

I'm doing a Traveling Salesman Problem (TSP) homework for a coursera optimization course. My first attempt was a regular naive greedy approach, from each point, moving to the closest node (that hadn't ...
Max Power's user avatar
7 votes
4 answers
3k views

Python vs. compiled languages in OR research using metaheuristics

In many articles that use metaheuristics to solve optimization problems, the programming language of choice is C++. For example, the following two articles present state-of-the-art metaheuristics to ...
Leon Lan's user avatar
  • 185
7 votes
3 answers
1k views

Finding a solution to a linear program with a small number of zeros

It is known that, in a linear program with $k$ constraints, there exists a basic feasible solution in which at most $k$ variables are non-zero. How can I find such a solution? Is there a polynomial-...
Erel Segal-Halevi's user avatar
7 votes
3 answers
502 views

Profit Maximization LP and Incentives Scenarios

I wrote a profit maximization LP with inventory, component usage, production, and machine hours constraints. When I optimize the model, it solves as expected. When applied towards a business case, ...
TroyE219's user avatar
  • 105
7 votes
1 answer
1k views

Problem is infeasible with Gurobi, feasible with cbc (but can't access objective value)

I am solving a MILP with cbc and gurobi (via pyomo). Gurobi states that the model is infeasible. As to cbc the solver status states that a feasible and optimal solution is found, but then it fails to ...
Meth's user avatar
  • 424
7 votes
1 answer
509 views

Can docplex (module for Constraint Programming optimizer CPLEX for Python) read .lp or .mps file?

I want to solve a problem with docplex.cp (module for Constraint Programming optimizer CPLEX for Python), and the problem is available in ...
Mostafa's user avatar
  • 2,104
7 votes
1 answer
224 views

DOCPLEX: tips to manipulate data input (binary parameter)

I am coding a MIP problem in docplex and I would like to ask for some tips. I would like to input a binary parameter that states a compatibility relation: I have a set of characteristics $H$ to be ...
campioni's user avatar
  • 1,133

1
2 3 4 5
8