Questions tagged [python]

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

Filter by
Sorted by
Tagged with
-2
votes
0answers
37 views

Optimized Production Planning & Scheduling

I want to create an optimized schedule and production to meet demand of four different buyers. I am starting with Pulp but not able to account for continuous production variable and discrete dispatch ...
1
vote
0answers
22 views

New to Inventory Theory: How to calculate Cycle & Safety Stock

I have been asked to calculate cycle and safety stock levels for one of our business units. I have very little/no knowledge on the subject of inventory theory so would like to ask what a reasonable ...
0
votes
0answers
96 views

Resource constrained LP problem

I am working on Diet Allocation problem. Where we need to provide food piece for protein deficiency. The data is as below: ...
1
vote
0answers
41 views

CPLEX keeps restarting in Pyomo

I tried running my model by adding the following settings to CPLEX. ...
2
votes
1answer
44 views

How to display the range of coefficients in docplex log?

A typical gurobi log can have a section where it shows the range of coefficients. Something like: ...
1
vote
1answer
75 views

How to balance the workload of teachers in OR-Tools (maximization of the minimum)

I am very new to optimization and OR-Tools. I am trying to solve a very simple question. Let's assume that we have $n$ students. Each student needs to be assigned to only one teacher as a supervisor. ...
3
votes
2answers
94 views

Decision variable transformation in Gurobi

I'm trying to find a way of setting the values of a binary MVar object (which is my decision variable) of size n to {-1,1}. Right now I have a vector that can either take values 0 or 1 (due to binary ...
3
votes
1answer
55 views

View of Constraints and Decision Variables in Pyomo

I have just attempted to construct my first Pyomo model. However, I was unable to locate any documentation that shows how to view constraints, decision variables. As my model is big, I need to see ...
3
votes
1answer
117 views

CPLEX Python API Manual with References

I am currently attempting to code a model using the Python API. However, the IBM Site seems to not have one that is similar in formating and content depth such as those for C++ or Java (examples and ...
5
votes
2answers
176 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 ...
1
vote
1answer
50 views

How to get detail about 'OptimizationStatus.ERROR' in MIP module in Python?

I am using MIP (Mixed Integer Programming) module in Python to solve one of my optimization problems. for some of the scenarios, model returns "ERROR" (OptimizationStatus.ERROR) status after ...
4
votes
2answers
182 views

Output of binary variable greater than one

I am working on a shipping demurrage problem that uses a binary variable to denote the date a specific vessel can be loaded (I have been kindly helped by Wesley on OR before with this). I am confident ...
3
votes
1answer
83 views

Pyomo: Help setting up my model

I have been working with a model for the past couple of weeks, but I am not sure what am I doing wrong as every time Pyomo returns that is infeasible or ...
5
votes
3answers
164 views

How can I optimize this integer programming constraint problem without running out of memory?

I am trying to run this constraint problem but the memory runs out, $$S_{i}$$ are 1975 Students that need to be assigned to one of 188 teacher assistants classes, each teacher assistant has to chose a ...
2
votes
1answer
103 views

Representing Date Variables in Pulp

I am working on an optimisation problem that involves minimising shipping demurrage. I am struggling to model how to represent the difference, (x-y) between dates where the ship is ready to be loaded ...
1
vote
1answer
64 views

Pyomo: Struggling to get a constraint to work

I am trying to model an Electric Vehicle scheduling to minimise the electricity bill. Of course, the EV will only be able to charge every time that is plugged into a charging station (i.e. it cannot ...
3
votes
2answers
499 views

Fast algorithm for Transportation Problem in Python?

Transportation Problem can be solved with simplex algorithm, but it's time demanding. I'm wondering if there exist a specific Python-implemented algorithm with low complexity. Thanks
1
vote
2answers
194 views

Downloading and setting up CPLEX for Pyomo

I have just installed Anaconda and am intending to use Spyder as it is able to display variable, parameter values for debugging. After which, I am planning to use Pyomo to code my MIP model and invoke ...
1
vote
1answer
104 views

Pulp Python: How to formulate a time-based variable for shipping demurrage

I am working on a shipping optimisation problem that aims to minimise demurrage charges as a result of low/insufficient inventory. I have daily vessel requirement (sales) data in the format ...
5
votes
2answers
110 views

Priority List Constraint

I used the Vehicle Routing Problem example that has the objective of minimizing total distance traveled for each vehicle. Suppose that each order to pick up for each vehicle at each node has a ...
2
votes
0answers
88 views

Gurobi is unable to give an optimal solution even when it exists

I am trying to solve Logarithmic Fuzzy Preference Programming (LFPP) for criteria weight evaluation, based on fuzzy comparisons between criteria, and I am solving it with Gurobi in Python 2.7. It is a ...
1
vote
2answers
80 views

Pulp: slack variable to identify & measure extent infeasible in supply problem

I am currently modelling a supply problem that attempts to optimise a rail schedule which moves products from a production plant, to a warehouse to satisfy sales. The model is working fine (thanks in ...
4
votes
3answers
298 views

Branch and bound algorithm programming code

I want to solve an integer programming problem using the branch and bound method, but I'm having trouble finding the programming code. From what I saw, almost all algorithms use it for traveling ...
25
votes
7answers
8k 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 ...
2
votes
0answers
52 views

Efficient way to do user rescaling of variable in Gurobi

Is there a better way than the code below to the rescaling of variable in a model after the model has been build with Gurobi? Like some build in function or a direct manipulation of the column object? ...
4
votes
1answer
67 views

Adding a hard and soft upper bound constraint of number of locations to visit (VRP)

I went through the Vehicle Routing Problem example and was able to replicate it. On the example, there is a constraint added for vehicle maximum distance as shown below: ...
0
votes
1answer
129 views

How to solve knapsack problem with simulated annealing?

I was going through the course contents of Optimization with Metaheuristics in Python in udemy , where they have solved a quadratic assignment problem using Simulated annealing in python , i was ...
8
votes
3answers
833 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 ...
4
votes
0answers
87 views

Does anyone have the criss cross algorithm programming code to solve linear programming problems?

I have a project that requires programming code for the simplex algorithm and criss-cross algorithm. The purpose of this project is to compare the two methods. I've tried to find it, but the ...
4
votes
2answers
95 views

Suggest me good books to learn heuristics to solve Operations Research problems using python

Suggest me some good books with implementation of heuristics using python to solve operations research problems
10
votes
3answers
429 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 (...
3
votes
0answers
31 views

Constraint equivalence in PuLP

I'm working on an optimization problem in PuLP and I have to enforce a daily minimum of shifts and a daily maximum of assigned shifts. I have the following constraints to ensure each day has a minimum ...
4
votes
1answer
123 views

How to set these constraints in a linear optimization problem (PuLP)?

I am trying to implement an employee (nurse) scheduling problem and seek some advice on how to implement a specific constraint.The problem is as follows: There is a set of employees and days (both ...
3
votes
0answers
62 views

Problem related to machine's performance while solving an LP-relaxation of a set-covering problem using the Column Generation

PS: I am familiar with performance variability encountered while solving large-scale MIPs. My question may not be explicitly related to it but maybe to the inefficiency of python packages. I have ...
2
votes
0answers
65 views

Branch-and-Price: return gap using SCIP

I implemented a branch-and-price tree in python. I would like to stop the process after 5 hours and return the gap in % between the best integer solution found so far and the optimal solution. How ...
2
votes
1answer
59 views

How to enforce this specific constraint in PuLP?

I am trying to implement an employee (nurse) scheduling problem and seek some advice on how to implement a specific constraint.The problem is as follows: There is a set of employees and days (both ...
4
votes
1answer
79 views

How to make a copy of a Gurobi model in Python?

Suppose I have made a Gurobi model in Python model = Model(), defined variables, constraints, objective function, and solved it. However, I want to make a deepcopy ...
4
votes
1answer
115 views

PuLP Transport Problem - How to add outcomes of decision variables together

I am working on a rail scheduling problem that moves product from a production plant to a storage facility to satisfy demand. I am new to PuLP so finding this difficult to understand why this isn't ...
33
votes
13answers
8k 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 ...
3
votes
1answer
153 views

Convexity Analysis

For the following function, I am testing the convexity in $\lambda$. All parameters are in $\mathbb{R}^+$. $$\frac{\left(- \lambda \left(b + \frac{p}{\beta}\right) + 1\right) \left(\left(1 + \frac{p}{...
8
votes
1answer
131 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 ...
6
votes
1answer
129 views

Advanced Heuristics for MIP vehicle routing problem in PuLP

I am currently trying to speed up an MIP. An approach I was considering was to implement a cut callback heuristic with PuLP (one which rounds relaxed integer variables greater than .9 to 1). ...
2
votes
0answers
48 views

How to solve an LPP with summation

Up until this point I have only solved simple LPP problems with maybe 2 to 3 variables that looked like this, using pen and paper. I need to solve This Problem using Simplex, Dual Simplex, Big M and ...
3
votes
2answers
113 views

Rotated Second-Order Cone Constraints in docplex

I have programmed the model in here using Gurobi 9.0 in Python 3.7. To ensure playing within the boundaries of the licensing, I am trying to program it using CPLEX where we have broader flexibility ...
4
votes
1answer
144 views

How to read a solution file (.sol) in cplex python API?

I've been to trying to read a .sol file in cplex python API before solving the problem but couldn't find any command to do so. There are analogous commands for this ...
4
votes
1answer
42 views

Inputting logical constraints into a binary programming model in Gurobi

I am very new to Gurobi and OR in general (I'm in my first class for it now), so apologies if this is a very obvious answer. For a project in that class, I am generating a flight schedule for a ...
3
votes
1answer
68 views

Logical operation on an array in DOCplex

Here is a simple example of logical operation in docplex taken from here. Code below works fine. ...
9
votes
2answers
597 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. ...
8
votes
2answers
604 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 ...
5
votes
1answer
311 views

How to run MOSEK solver in CVXOPT

I have written a small code to do a simple min variance optimisation using CVXOPT, you can see the whole code below By using solvers.qp(P, q, G, h, A, b) in CVXOPT ...