Questions tagged [python]

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

79 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7 votes
0 answers
118 views

What distuingishes a model-and-run framework solver from a programmatic solver?

I am looking for examples to understand what kind of benefits a model-and-run framework solver offers that a more programmatic solver doesn't do or doesn't do as well. What distinguishes a model-and-...
Geoffrey De Smet's user avatar
7 votes
0 answers
858 views

Having trouble with objective function in Python: "GurobiError: Variable not in model". What else could I try?

I am trying to figure out how I can write this objective function into python using Gurobi. I have to minimize the sum of the product of three dictionary's values. The reason I am confused is that ...
Jacob Myer's user avatar
6 votes
0 answers
436 views

How to make constraints satisfy disciplined convex programming guidelines?

How do I turn my convex constraints (described below) into constraints that are DCP so that I can solve them in CVXPy? Is there some ``cheat sheet'' of standard tricks? I'm trying to implement the ...
Dupin's user avatar
  • 61
5 votes
0 answers
199 views

How to use interpolation for problem parameters in Pyomo

I'm working on my first Pyomo DAE project to teach myself how to use it for trajectory optimization. I have generated an atmosphere lookup table with density and speed of sound as a function of ...
machalot's user avatar
5 votes
1 answer
122 views

Changing a parameter while branching in SCIP

I use pyscipopt. I know how to add constraints while branching using handlers (kind of), but now I want also to change some parameters. I imagine is similar, but couldn’t found an example. What I want ...
orpanter's user avatar
  • 517
5 votes
0 answers
120 views

Reduce overhead Gurobi Python getting and setting attributes

I am using Gurobi 9.5.1 in Python 3.10. In the context of column generation I request the duals of the master problem and set them in the objective of the subproblem. This is done repeated times. <...
rllb's user avatar
  • 51
5 votes
0 answers
149 views

How to handle constraints in docplex to states the relation between two variables?

I am using docplex.cp and I need to state the following constraint: $$\sum_{c}(X_p{_w}_{cj}+X_{p+1}{_{w'}}_{cj+1})\leqslant T_w{_{w'}}_{,jj+1} + 1$$ Knowing that the binary variables are: $X_p{_w}_{...
campioni's user avatar
  • 1,133
4 votes
0 answers
141 views

How to invoke a solution pool and access all the solutions in cplex using PYOMO ? this is the structure of my pyomo code

...
Prachi Patki's user avatar
4 votes
0 answers
257 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 ...
newbie's user avatar
  • 81
4 votes
0 answers
86 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 ...
Divyam Aggarwal's user avatar
3 votes
0 answers
71 views

Pygmo2: What is the point of evolving an archipelago in a loop if number of generations already set in algo

I want to solve a multi-objective problem with nsga2 or moead taking advantage of the parallelism available in pygmo library. I have seen a very nice example on github posted below. However I am not ...
Sophie's user avatar
  • 31
3 votes
0 answers
87 views

Minimize total cost to buy unique products over timespan

I am looking for some guidance on how to better state my problem formally and practically (e.g., relevant Python libraries). Let's assume I have a set of $X$ unique products to buy. I have $Y$ days in ...
M2FKXY's user avatar
  • 31
3 votes
0 answers
136 views

Proving convexity for a function with summation and integer variable

I would like to show that the function $f$ is convex in $\rho\in [0,1)$ under $s\in \mathbb{Z}^+$. When I use Sympy packages of Python to find $\displaystyle\frac{\partial^2 f(\rho)}{d\rho^2}$. I get ...
tcokyasar's user avatar
  • 1,249
3 votes
0 answers
320 views

Add Variables in Bulk for ortools

I am using the Python ortools to solve large LPs where the number of variables and constraints are in the hundred thousands ($10^5$). Surprisingly, it takes longer ...
Zachzhao's user avatar
  • 131
3 votes
0 answers
87 views

PuLP Python: How to linearize an inequality involving an integer variable

I am working on a Copper payables problem where the objective function is to maximise the sum of copper payable over a time period, T. The total amount of payable tonnes i.e. what the customer will ...
cmp's user avatar
  • 327
3 votes
0 answers
782 views

How can I see the engine log when solving a LP using pulp (python)?

I wonder which command should I use to see how the steps the pulp solver is doing when solving a linear program.
Pep's user avatar
  • 39
3 votes
0 answers
101 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 ...
Joep's user avatar
  • 101
3 votes
0 answers
192 views

Power of variable or tools

I'm working with OR Tools in Python and I need to define the objective function an expression of the variables. In particular, the objective function is $$\frac{c_j}{1.7^{s_j}}$$ with $c_j$ ...
Clopen's user avatar
  • 131
2 votes
1 answer
142 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
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
2 votes
0 answers
197 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
2 votes
1 answer
162 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,642
2 votes
1 answer
142 views

Control load per trip in multi trip VRP in ORTools

I have implemented multitrip VRP in ortools (To be specific, solved CVRPTW with virtual depots). Maximum number of trips per vehicle is limited to 2. I want to put a hard constraint that load carried ...
mufassir's user avatar
  • 201
2 votes
0 answers
206 views

OR constraint in Gurobi - Python

I'm new to Gurobi in Python and I am wondering if there is way to code the following constraints: 1- $\sum x_i =0$ for all $i\in A$ OR for all $i \in B$ where A and B are distinch sets of integers ...
M.Badaoui's user avatar
  • 185
2 votes
0 answers
938 views

Add lower and upper bounds on decision variables in Pyomo

I have the following optimization model in pyomo: ...
Telso's user avatar
  • 21
2 votes
0 answers
268 views

Pyomo + Cplex - OSError: [Errno 22] Invalid argument

I am trying to get Cplex working with pyomo. I have followed Cplex installation instructions has explained here: Downloading and setting up CPLEX for Pyomo However when calling Cplex via pyomo I get ...
Meth's user avatar
  • 424
2 votes
0 answers
138 views

Multiple Depot/Crew Office Bus Driver Scheduling Modelling

I'm working on Bus Driver Schedule with multiple add-on constraints that are complex and hence trying to figure out how this can be achieved. Reference of Bus Driver Scheduling using OR-Tools:- https:/...
Brainiac's user avatar
2 votes
0 answers
654 views

How to assign a single value to Pyomo parameter without a dictionary

I would like to assign a single value to a paramter that depends on a created set in Pyomo. I have the following code: ...
PeterBe's user avatar
  • 1,632
2 votes
0 answers
292 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 ...
Milovan's user avatar
  • 21
2 votes
0 answers
109 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? ...
user3680510's user avatar
  • 3,645
2 votes
0 answers
166 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 ...
HABIL BHAGAT's user avatar
2 votes
1 answer
387 views

MIQP — CVXPY unable to treat summation of variables as a variable

I have a quadratic integer programming assignment problem. The goal is to assign riders seats on a bus such that distance between any two riders is maximized; however, the importance of each objective ...
jbuddy_13's user avatar
  • 519
1 vote
0 answers
58 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
0 answers
141 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
1 vote
0 answers
42 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
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
1 vote
0 answers
39 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
  • 131
1 vote
0 answers
57 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
1 vote
0 answers
300 views

Resetting Pyomo model after computation

I am aware that the types provided by pyomo are immutable and often cause issues when we feed the same data twice in consecutive computations (e.g. when trying to solve an instance a couple of times) ...
Pia MiA's user avatar
  • 392
1 vote
0 answers
147 views

Profit Optimization in Python with Difficult Constraints to Maximize Net Revenue

I am currently trying to work on this problem that determines the best constraints on how to place these 'bids'- please see the second column in the screenshot: The ask at hand is to uncover a model ...
mty514's user avatar
  • 11
1 vote
0 answers
82 views

Pyomo error about evaluating value of 'ScalarParam' parameter

I'm trying to optimize a huge model, but here is a part of it capable of creating an understanding of my question: ...
Alexandre César Barbosa's user avatar
1 vote
0 answers
40 views

batch file for docplex

I have a mathematical model written in docplex python. For analysis, I have to generate different sized data with batch file which can be input for the problem. How can I generate this type of batch ...
GTek's user avatar
  • 307
1 vote
0 answers
40 views

Blended or hierarchical objectives if solving speed is more important

When optimizing a two objective task assignment problem, is it generally better to use blended objectives or hierarchical objectives if the speed to obtaining a near-optimal solution is more ...
Nyxynyx's user avatar
  • 179
1 vote
0 answers
151 views

How to see fix constraint violations found with IIS

I'm running a simple MCNF model to see if my network is balanced. I'm using Gurboi in Python and with the IIS I can see that there are 2 constraint violations making it infeasible. How do I fix these ...
Emma Kuttler's user avatar
1 vote
0 answers
661 views

How to eliminate large matrix coefficients and large RHS warning in Gurobi

I'm solving a large network flow problem using Gurobi to do Benders decomposition in Python. The imported .csvs contain values that typically fall in either zero, the range of [20,200], or with a ...
Emma Kuttler's user avatar
1 vote
0 answers
601 views

In DOcplex, how can I get value of variable for objective function before solved?

In terms of python based atypical math model as shown below, which is unlike nonlinear or quadratic form in my opinion, I have difficulty in accessing value of variable before optimization as ...
Nam-kyoung Lee's user avatar
1 vote
0 answers
76 views

Meaning of zeros in the column best bound in docplex?

I am trying to solve a large-scale MIP problem in docplex(python). I give to the model a MIP start solution, I remark that after 20 hours, the best integer still the cost of the MIP start and the best ...
Nada.S's user avatar
  • 409
1 vote
0 answers
299 views

Problem with Piecewise constraint in Gurobi

I am facing a problem in my model with piecewise constraints that is making my one of the decision variables equal to zero for every value. My objective function is: \begin{equation} \min \sum_{t=...
salidi's user avatar
  • 99
1 vote
0 answers
378 views

Adding sequence constraints to the assignment problem- Python

This is an online assignment problem and yet can be considered as an assignment problem with a sequence. Assume that workers are coming into the system sequentially and I want to assign a task to them ...
Dr. Turkuaz's user avatar
1 vote
0 answers
303 views

Set Covering and Column Generation

I need some set covering and column generation examples in OR-Tools python. If anyone can provide or direct me to some resources that would be great..!
user3237357's user avatar