Questions tagged [python]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
138 views

How to put this restriction using Gurobi in python

I am doing an optimization problem for the filling and extraction of a warehouse. One of the constraints is that the filling volume cannot exceed a given limit for one day: For example, on the 3rd of ...
user avatar
  • 27
2 votes
1 answer
105 views

How to formulate cumulative sum of LpVariable in Pulp Python

I have a Multiple product LP optimization problem in which the product(B1,B2,D) will be received in variable quantity with respect to date column. The Optimizer should LP variable Output as Assy Out ...
user avatar
6 votes
2 answers
2k views

Python vs C++ performance on Discrete Optimization

Are there any useful resources to compare the performance of python and c++ languages in algorithms dedicated to solving discrete optimization problems?
user avatar
  • 347
2 votes
1 answer
81 views

Passing exact number of allocations as constraint to pyomo in a sourcing problem

I am solving a sourcing allocation optimization problem. Here I have let's say two brands. Each brand has a raw material demand across the 3 plants (Demand in kg) Brand 1 Brand2 Plant 1 3000 2000 ...
user avatar
1 vote
1 answer
74 views

Modeling constraints in gurobi

$$\max \lbrace 0, q_i \rbrace \le L^r_i \le \min \lbrace Q^r,Q^r+q_i \rbrace \quad \forall i\in N,r\in R$$ I am not sure if this type of question is allowed here but I am stuck at modeling this ...
user avatar
  • 429
0 votes
0 answers
62 views

Decision whether to serve the current table now or skip it

Can the following problem be formulated as a LP/IP problem, where an agent (waiter) that has just arrived at a certain table has to decide whether to visit that table now, or skip the current table ...
user avatar
1 vote
0 answers
32 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 ...
user avatar
  • 179
1 vote
1 answer
24 views

dual cycle data generation

I want to generate 2x6 dataframe which represents a rack to optimizing a dual cycle in optimizing warehouse.Half of this dataframe are filled with storage items and the other half is with retrieval ...
user avatar
  • 151
-4 votes
1 answer
28 views

MIP gives out zero as best solution when trying to optimize MIP model for flexible job-hop

I have implemented an existing MIP Model into python with the python-mip solver and somehow I only get '0' as a solution to my minimization problem. What could be the problem? I am fairly new to LP ...
user avatar
3 votes
3 answers
2k views

Python to Excel

Using DOcplex module an optimization problem is solved. There are many decision variables in the solution, for the validation of the mathematical model I want to check them. How can I write the ...
user avatar
  • 151
2 votes
1 answer
94 views

opposite of no_overlap constraint in docplex for CP

I am using python for CP solving. I would like to know if there is constraint that does the opposite of no_overlap. This will be like overlap(interval, arr, n) interval - single interval variable arr -...
user avatar
1 vote
0 answers
61 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 ...
user avatar
1 vote
1 answer
70 views

OR-Tools Cost Function Integration

I am modeling a problem similar to the job shop problem (tasks with start times, duration, and predecessors) and my objective is to minimize the makespan, with Python and OR-Tools. start[i] is an ...
user avatar
  • 11
0 votes
1 answer
54 views

Cplex 12.10 and python

Does cplex 12.10 support python 3.8? I cannot install setup.py file. I think only 3.7 and 3.6 are supported.
user avatar
  • 151
1 vote
0 answers
78 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 ...
user avatar
3 votes
2 answers
343 views

Simple example of finding Hamiltonian path using Google OR-Tools?

I'd like to test how good/fast OR-Tools is in finding hamiltonian paths on some (big) directed graphs. But I can't find simple enough (for me) examples. Something like these ones (or even simpler), ...
user avatar
5 votes
1 answer
136 views

Constraints like "max(column a + column b) == 2" are not DCP

I am struggling with the following constraint on a minimization problem cvx.max(z[:, i] + z[:, j]) == 2 where z is a Boolean ...
user avatar
  • 533
2 votes
1 answer
145 views

Can docplex solve a mixed integer quadratic programming (MIQP) problem?

I am trying to solve a mixed integer quadratic programming (MIQP) problem. The objective function contains the product of two continuous decision variables, some of constraints are non-linear too. I ...
user avatar
  • 151
2 votes
0 answers
109 views

SLSQP vs Trust Region Constrained Algorithms

I have gone through scipy constrained algos explanation, however, not much is mentioned about the differences, pros and cons of the 'trust-const' and 'slsqp' methods. I particularly wanted to know ...
user avatar
  • 129
7 votes
1 answer
376 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 ...
user avatar
  • 414
4 votes
2 answers
113 views

Compute Irreducible Infeasible Set (IIS) in Pyomo

I am using Pyomo together with Gurobi (and other solvers such as cbc). I am trying to compute an Irreducible Infeasible Set (ISS). In Pyomo documentation, ...
user avatar
  • 414
1 vote
0 answers
116 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 ...
user avatar
2 votes
0 answers
88 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 ...
user avatar
  • 414
4 votes
1 answer
81 views

Edit .NL files to reformulate problem instances

I would like to run a solvers comparison on several instances of MINLPLib. I can get the .NL files for each instance. Now, I would like to reformulate several instances and I need to edit the .NL ...
user avatar
  • 59
1 vote
1 answer
214 views

Pyomo: Check if solution exists and if not solve other problem

I am using pyomo with gurobi (and other solvers) to solve some optimization programs. Sometimes these programs don't have a solution and throw an error such as ...
user avatar
  • 414
1 vote
1 answer
288 views

Pulp Python - How to define a constraint with different indexes of variables

I am new to modeling LP with Pulp in Python and I need some help with defining a constraint with multiple variables with different indexes. Please see below. The constraint is defined on A, B, C ...
user avatar
0 votes
2 answers
135 views

sensitivity analysis in python + Docplex

I want to do a sensitivity analysis for the following problem. I know how to add new variables or constraints, but I do not know how I can change the right-hand side (RHS) of the constraint. ...
user avatar
  • 17
3 votes
1 answer
506 views

Complicated constraint with logical operators in PuLP

I have an optimization problem that I am trying to solve with PuLP. All the variables are Booleans. The variables that are "selected" will be true, all others false. Objective function is ...
user avatar
  • 33
1 vote
0 answers
53 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 ...
user avatar
  • 347
3 votes
1 answer
432 views

How to retrieve the variable's value in DOCplex

I am trying to write a simple optimization problem by using DOCPLEX. I am pretty new on python+DO and What I have tried to do is: ...
user avatar
  • 5,705
0 votes
1 answer
102 views

Gurobi Environment should be Common or Unique for concurrent optimization problems?

Thanks for the amazing performance of Gurobi. Actually we are using Gurobi Cloud (via its python binding - Gurobipy) for our optimization requirements. Due to our ...
user avatar
  • 430
1 vote
1 answer
84 views

Circuit constraint respecting the order of the next n jobs / jobs on each machine starting at 0

I am working on a scheduling problem in OR-Tools using the CP-SAT solver. I'm working with python but I managed to rebuild this solution as starting point: Optimal way to ensure optional intervals are ...
user avatar
5 votes
1 answer
83 views

How to transfer an optimization problem written with GUROBI (in python) in a grammar that can be readily solved with another solver?

Trying to use an opensource optimization tool in python (having used only gurobi for years) I see that the whole code (representing the optimization problem in pythonic language) must be written ...
user avatar
-3 votes
2 answers
473 views

No value for uninitialized NumericValue object

I'm working on an optimization model in python with the pyomo library. However I'm getting an error message in python that I cannot seem to understand. The code and error message is below. My code is <...
user avatar
6 votes
1 answer
306 views

Python "Coffee Shop Scheduling Problem" - Scheduling Lunches/Breaks

I'm working on an employee scheduling program in python. Having never done this before, I've been researching different libraries that can be used to accomplish the task. Unfortunately, none of the ...
user avatar
  • 63
0 votes
1 answer
128 views

How to solve the following linear programming problem using Gurobi (or at least python)?

For an optional ungraded assignment (see it as a complex problem that won't be graded, more to test our skills and knowledge) I was given the following problem. It is not as straightforward as all the ...
user avatar
4 votes
1 answer
165 views

Python library to solve nonlinear problems

What is the best python library to solve nonlinear problems? PuLP can solve only linear problems like $\max15000Z_7 + 350D_{73}Z_7 - 15000Z_8 + 350D_{86}Z_8$.
user avatar
-3 votes
1 answer
118 views

Heuristic Algorithms Implementation

As a new python learner, I'm supposed to implement either GENETIC ALGORITHM or TABU SEARCH. Which one would be easier for me? Both of them are constructed for the same problem.
user avatar
  • 45
2 votes
1 answer
272 views

How to professionally write a constraint, where some variables take certain values of index and some variables should not take some values of index

I am using Pyomo's concrete model to model a MILP mathematical model, coming from multiproduct pipeline scheduling. Some of our continuous variables are: ...
user avatar
  • 103
2 votes
1 answer
55 views

Constraint raises DCP Error

I have defined a problem which will minimize the cost of to run a pump. That is defined as the objective of the problem. ...
user avatar
2 votes
1 answer
80 views

Can we take the constraints from one model and plug them into the other model in pyomo?

I am implementing data-driven robust optimization methodology introduced in this article in python. Somewhere of the method, I need to use pyomo for each constraint whose parameters are uncertain to ...
user avatar
  • 103
1 vote
0 answers
165 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=...
user avatar
  • 99
1 vote
1 answer
1k views

No executable found for solver 'ipopt

I know that there are some questions concerning this type of error, for example, this link. I first installed the latest version of ipopt through command line into my Pyomo environment and got the &...
user avatar
  • 103
6 votes
3 answers
2k views

Traveling Salesman Problem: How to avoid symmetry?

I solved a Traveling Salesman Problem (TSP) by the cutting plane method, i.e. adding violated sub-tour constraints until the LP relaxation is a tour. Now, I am realizing that, in this symmetric TSP, ...
user avatar
4 votes
0 answers
180 views

Announcing OptaPy - a new open source constraint solver for Python (feedback welcome)

[Not sure if this counts as a proper question, but I've seen a few similar "new solver" announcements in the past, so I 'll take my chances.] A new constraint solver for Python has been born:...
user avatar
5 votes
3 answers
417 views

Minimizing cost of transportation and storage of items

I am looking for an optimization algorithm to minimize the cost of transportation and storage cost in warehouse. Let's assume the following table gives us the weekly forecast of Demand. ...
user avatar
  • 205
2 votes
1 answer
109 views

A lexicographic objective function

I am trying to solve a multi-objective vehicle routing problem, I want to implement a lexicographic objective function, I have already defined a function for each objective. if someone has an idea of ...
user avatar
  • 347
7 votes
1 answer
271 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 ...
user avatar
  • 191
8 votes
1 answer
330 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 ...
user avatar
  • 99
4 votes
1 answer
79 views

In pyomo, any reason for using "model.<nameofvariable>" throughout the code instead of doing "<nameofvariable> = model.<nameofvariable>" and using it?

The question is a bit self explanatory I believe, but just to give a simple example (this is not the entire model of course): ...
user avatar
  • 159

1
2 3 4 5