Questions tagged [python]

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

Filter by
Sorted by
Tagged with
-4
votes
2answers
75 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 <...
5
votes
1answer
137 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 ...
-4
votes
0answers
29 views

How can I 2 terms in the objective function with sigma over each term in pywraplp library in OR tools

I am having 2 terms in my objective function based on the below objective function. Please guide me on how can I formalize it in OR tools? I tried the below way but it only considers the second term ...
0
votes
1answer
72 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 ...
1
vote
0answers
53 views

Deploying Models with GCP [migrated]

Is there a recommended architecture/design to run models using (Google Cloud Platform)GCP? This is what I currently have A data model and associated data in relational tables in BigQuery A model ...
4
votes
1answer
119 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$.
-3
votes
1answer
93 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.
2
votes
1answer
228 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: ...
2
votes
1answer
39 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. ...
2
votes
1answer
46 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 ...
2
votes
0answers
74 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=...
1
vote
1answer
360 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 &...
6
votes
3answers
1k 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, ...
4
votes
0answers
84 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:...
5
votes
3answers
317 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. ...
2
votes
1answer
74 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 ...
7
votes
1answer
215 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 ...
7
votes
1answer
229 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 ...
4
votes
1answer
73 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): ...
8
votes
2answers
619 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 ...
1
vote
0answers
104 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 ...
3
votes
1answer
141 views

Bin Packing with CP Solver

[ [0,5], [0,4], [1,6], [2,4], [3,6], [3,2], [4,5], [5,5], [6,4], [7,3], [8,2], [8,3], [9,5], [10,3]] ...
4
votes
2answers
234 views

Any transformation of constraints during Cplex's LP problem export?

We are exporting a optimization problem from matrices to LP format using Cplex. ...
1
vote
0answers
27 views

How to count the number of Stale variables in Pyomo?

How to check if a variable is Stale or not? How to count them? For example let's have a variable like instance.x[i] (i in instance.i set). Let's assume some of ...
0
votes
0answers
115 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..!
3
votes
1answer
61 views

Nurse Rostering Code with custom constraints Not Working

Could someone please check this code. I modified constraints as : No. of nurses - 10 Max No. of nurses in Morning/Afternoon/Evening Shifts - 3/4/2 Max no. of shifts in a week per nurse - 5 ...
9
votes
2answers
462 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 ...
1
vote
0answers
36 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 ...
1
vote
1answer
321 views

Conditional constraints in PuLP

I have the following optimization model using PuLP. ...
2
votes
1answer
85 views

Is there any solver intended specifically for integer and binary variables alone on the optimization model other than solvers for MIP, MILP?

Any solvers which can be integrated in python where we can quickly solve if we have integer and binary variables alone in our model other than normal solvers for MIP, MILP?
1
vote
1answer
58 views

Print Intermediate Solutions of Scheduling Problem and tackling FLAGS in jupyter notebook

I tried this code and it goes on and I'm clueless when it'll end so I manually interrupt it. Is there any way we can see intermediate solutions that are feasible solutions and can we limit time or ...
1
vote
1answer
61 views

Calculating the Obj Value manually in Gurobi

I have been working on the problem on Facility Location Problem with Gurobi using the example provided by the Gurobi team. ...
2
votes
0answers
101 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:/...
2
votes
1answer
104 views

Violation of specific constraint in Pulp

I have successfully implemented a program where I allocate N truck drivers to M gathering hubs for each one of the days of the ...
2
votes
1answer
74 views

Variable vector violates upper and lower bounds when I hit iteration limit

I have an application where I want to monitor the variables over time. I declare all the variables in my model like this: ...
13
votes
5answers
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 ...
1
vote
0answers
76 views

Optimisation Multiple Constraints

I am trying to solve a linear algebra problem: an optimisation problem and I am using CVXOPT. I've split the problem into 3 components In its simplest form, The general formulation for CVXOPT is \...
0
votes
1answer
142 views
0
votes
1answer
201 views

Gurobi: How to define constraints that can accept multiple different values? [duplicate]

I have a question about Gurobi. How do I define a constraint that can accept multiple different values? For example, a sample constraint is shown as follows: ...
1
vote
0answers
94 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$...
1
vote
1answer
116 views

How to make the solution of linear programming within the specified elements [duplicate]

The constraint value of a variable must be an element of the specified list.A simple example is shown as follow,in which the value of the...
1
vote
1answer
60 views

gurobipy.GurobiError: Second argument should be a list of Var

The following error was encountered when using LinExpr in gurobi: ...
1
vote
2answers
204 views

How to make the elements of the solution of gurobi belong to the elements of the specified list?

If I want to use the elements of the list as the range of the solution, like list1 = [10,20,50,60,30],and the elements of the solution must belong to the elements of the list The sample example as ...
1
vote
0answers
75 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: ...
2
votes
1answer
162 views

Obtaining solver timings from Pyomo

I would like to seek some advice on the following: I am currently using Pyomo to generate my MILP model in Pyomo and solve it using Gurobi, respectively. As the solution process is iterative, I would ...
1
vote
0answers
69 views

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

I tried solving my model with xpress: pip install xpress And then in the model: ...
2
votes
1answer
219 views

Capacitated Maximum Coverage Location Problem, Python and Gurobi

I am building a variant of the maximum coverage location model and want to limit the amount of points that each "facility" can cover. I am using Gurobi optimization . I have tried using the ...
1
vote
1answer
139 views

How to display results of 2-dimensional Pyomo variables in a pandas dataframe

I would like to create a pandas dataframe from the results (and the parameters) of an optimization problem and create a csv file out of it. In my previous example (1-dimensional case) I have just one ...
2
votes
1answer
201 views

Find multiple solutions using pyomo and gurobi

I am solving a MILP using Gurobi and Pyomo. I would like to obtain as many optimal solutions as possible. Here is what I have so far: ...

1
2 3 4 5