Questions tagged [python]

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

66 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7 votes
0 answers
109 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
810 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
378 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
144 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
0 answers
110 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
139 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
96 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
62 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
  • 425
4 votes
0 answers
227 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
84 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
1 answer
72 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
  • 7,664
3 votes
0 answers
39 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
85 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
107 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,239
3 votes
0 answers
229 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
69 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
585 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
92 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
175 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
0 answers
65 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
96 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
  • 7,664
2 votes
1 answer
80 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
  • 181
2 votes
0 answers
128 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
520 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
252 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
128 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
484 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,636
2 votes
0 answers
265 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
94 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,607
2 votes
0 answers
145 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
1 vote
0 answers
31 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? Thanks
Mansour's user avatar
  • 11
1 vote
1 answer
205 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
  • 471
1 vote
0 answers
151 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
173 views

Apply Benders decomposition approach in CPLEX with python while using docplex class

I am new to cplex with python. I want to solve a problem using the Benders decomposition approach. Where I want to use UserCutCallback and LazyConstraintCallback. I am writing code in script format (...
Mohammad Samiullah's user avatar
1 vote
0 answers
111 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
48 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
39 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
36 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
133 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
406 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
462 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
72 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.M's user avatar
  • 377
1 vote
0 answers
257 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
303 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
265 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
1 vote
0 answers
92 views

MLE application with gekko in python

I want to implement MLE (Maximum likelihood estimation) with gekko package in python. Suppose that we have a DataFrame that ...
Shayan's user avatar
  • 125
1 vote
0 answers
155 views

Optimization Multiple Constraints

I am trying to solve a linear algebra problem: an optimization problem and I am using CVXOPT. I've split the problem into 3 components In its simplest form, The general formulation for CVXOPT is \...
Marco_sbt's user avatar
  • 173
1 vote
0 answers
429 views

How do I define multiple indices for the same set in python? (using CPLEX to solve a MILP)

I am using docplex in Python to solve a MILP and I am having some trouble defining the indices and sets of my model. I want to translate $w,v,a\in W$ into Python. In this case, $W$ is a set, and $w, v$...
mnm23's user avatar
  • 11
1 vote
0 answers
126 views

How can I set the solution of gurobi to be a multiple of 10 instead of all integers?

For example, the solution for gurobi has two solutions, as follows: [10,20,50,70] [55,79,30,80] I only want to output solutions that contain only multiples of 10. The sample example as follow: ...
Zying's user avatar
  • 57
1 vote
0 answers
205 views

Solver issue? Xpress (slp) - Nonlinear - Python - Pyomo

I tried solving my model with xpress: pip install xpress And then in the model: ...
PM0087's user avatar
  • 111