Questions tagged [python]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
64 views

Generating a different optimal solution from CPLEX for each run

I recently chanced upon the idea of solution diversity through the setting of random seeds within CPLEX. However, the documentation page on the settings does not shed any light with regard to the ...
1
vote
1answer
468 views

Pyomo can't find solver

I am new to Pyomo and I have the following optimization problem (original transport problem by Dantzig): ...
2
votes
1answer
99 views

How to define constraints in Pyomo using sets and variables

I am trying to model the transportation problem of Dantzig in Pyomo (see the GAMS code here https://www.gams.com/latest/gamslib_ml/libhtml/gamslib_trnsport.html or the description here https://www....
3
votes
1answer
102 views

Why functions with arguments can be called without arguments in Pyomo

I have a question regarding pyomo. I have seen quite often, that for the definition of parameters, objectives and constraints, explicit functions are defined. These functions expect some arguments and ...
2
votes
1answer
92 views

Recommended python solver for an online optimization problem

I need to implement a load scheduling algorithm that involves solving an online optimisation problem from a research paper for my Real time systems course. This convex optimisation problem is setup ...
2
votes
1answer
87 views

Fixing the amount of variable in Gurobi - Python as a parameter for another model

I have solved a very simple mathematical model ( 2 variables) using Gurobi in Python and now I want to fix the amount of the variable in another model and solve it, for example, consider the variable $...
2
votes
1answer
110 views

Converting evolutionary optimization problem from Excel to Python

I've set up and successfully executed an evolutionary optimization in Excel, and now have a need to convert the problem to Python. differential_evolution() in the ...
4
votes
1answer
96 views

How to convert static variables into arrays for use with PuLP

I have the following code in Python and PuLP which uses static variables. I want to know how to solve the problem by converting all of the LpVariable parts into an array, as well as the constraints. ...
4
votes
1answer
100 views

Binary variables with multiple indices

I'm new to Cplex and I'm working with the python API. I have a variable $w^t_{iksm}$ and I could just find the binary_var_cube function which only accepts 3 indices. I'm then using this $w$ to define $...
2
votes
1answer
183 views

Error when defining variables in Pyomo

I just started to learn about Pyomo. In several tutorials it is stated that the command for creating a variable is just model.Variable = VAR(...). However, I get ...
2
votes
1answer
83 views

Formulating “more complicated” objectives in Python Gurobi

I am currently learning how to use Gurobi for Python using their official tutorial found here. In this example, they appear to formulate the objective by simply specifying a cost dictionary to the <...
1
vote
0answers
122 views

Doesn't Pyscipopt handle nonlinear objective functions?

I am trying to solve a large-scale nonlinear problem. Below is the objective function coded for pyscipopt. I have some loops over a list of tuples (r,p,s) in the list RouteTimeStop, and the only ...
5
votes
2answers
104 views

Solve nonlinear programming problems practically

In an exam, I studied Theoretical approaches to converting constrained minimum problems into unconstrained minimum problems. Specifically: KKT conditions Projection Gradient Descent Penalty and ...
4
votes
1answer
59 views

Greedy algorithms for assignment problems — prediction doesn't match simulation

I'm considering the following basic assignment problem: a group of $n$ people is to be assigned, in one-to-one fashion, a set of $n$ jobs. Write $C_{ij}$ for the cost incurred when person $i$ gets ...
1
vote
2answers
256 views

How to generate multiple solutions to linear program in Python?

I recently posted a question here where I had written some Pyomo code to solve a simple linear program, however I feel the Operations Research platform is perhaps a better fit for this question. My ...
5
votes
1answer
413 views

Python for OR: Which non-solver libraries do you use?

If you're programming OR challenges in Python, besides using mathematical optimization software (= constraint solvers), which other libraries do you often use? Maybe for mundane tasks such as data ...
1
vote
1answer
78 views

How can I formulate an objective function that minimises the number of items required to solve a problem

I am currently trying to solve a problem where I need to minimise transport cost through the choice of vehicle (and how many of each choice) subject to a given demand. The problem: There are currently ...
2
votes
1answer
92 views

Ordering Nodes of a graph according to their degree

In an undirected graph, I would like to order its nodes according to their degree. However, to do this I have to enter the edges of the graph first. When I do this, NetworkX in Python reads the nodes ...
2
votes
2answers
299 views

Cutting Stock Problem : Mixed Integer Programming

I am asked to solve the following problem: The problem: You were asked to repair a farm house with sheets of plywood. You were given thirty sheets of plywood. (each size = 10ft x 10ft) The house ...
3
votes
2answers
143 views

Google OR returning different values depending on language

Lately, I have been working on a CP-SAT model for solving multi-resource flexible job shop problems. I used the code (1) as an inspiration for building code (2) in Python which works well. Then I had ...
2
votes
0answers
82 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.
1
vote
1answer
201 views

Python, Google OR-Tools, OnlyEnforceIf() method

I am trying to solve a basic puzzle by using Google OR-Tools, this is my first try with OR-Tools and I am trying to learn. I completed almost everything and was ready to conclude the program until I ...
1
vote
0answers
57 views

Modeling the multiplication of two binary decision variables in undirected graph in python

In an undirected graph, I'm trying to model a constraint that forcing the optimizer to set an edge $(u,v)$ between two nodes to only exist (= $1$) if the two nodes have been selected to be $1$. The ...
1
vote
0answers
21 views

Implement geometric constraint using DOCplex

currently I'm working on a wind farm layout optimization problem. I found an appropriate model in literature (Fischetti et al.) and now I'm trying to reproduce it using the Python API of cplex with ...
1
vote
0answers
26 views

MILP formualtion for Two-level minimum dominating set (MDS) problem?

I'm working on an optimization problem which is kind of finding the minimum dominating set (MDS) or the minimum vertex set (MVS) in an undirected graph. given the MILP formulation for both problems, I ...
2
votes
1answer
66 views

Maximum bipartite matching with breakpoints in edge weight function

I am looking for an analogy to the problem I am facing or better yet a paper or even code. I have: Nodes from set A and B. Edges are from a single A to many B. I am framing a max bipartite matching ...
5
votes
1answer
91 views

Is the order of edges in graph is changing the optimization result?

I am solving an optimization problem using Pulp and NetworkX. The problem is similar to the Minimum Vertex Set (MVS) problem. I have noticed that the optimizer is Scanning the edges according to their ...
3
votes
1answer
75 views

Sum of links neighbors in a graph

I'm trying to model this constraint in an optimization problem using Pulp and NetworkX. Here is a piece of code I'm using. ...
3
votes
2answers
121 views

Summation of all links that contains nieghbors to certain node in Graph

I'm trying to model a constraint in Python using Pulp and networkX that is getting the sum of the edges that contain this node over all the nodes. The constraint can be like that: $$\sum_{m\in\cal N}...
3
votes
1answer
59 views

Python modeling for ILP Minimum Dominating Set (MDS)

I'm writing a code for solving the MDS problem, the problem is: \begin{align}\min&\quad\sum_{v\in V}y_v\\\text{s.t.}&\quad y_v+\sum_{(u,v)\in E}y_u\ge1\quad\forall v\in V\\&\quad y_v\in\{0,...
4
votes
1answer
306 views

MILP Minimum set Vertex cover coding by Python or MATLAB?

As a following up for my question for modeling a simple moded of the minimum set vertex cover problem, which is shown next. I would like to have your help in modeling this problem using Python or ...
2
votes
2answers
216 views

Pyomo + Ipopt. Speed Issue

I am using Pyomo + Ipopt as solver to solve a NLP problem. The problem is not extremely complex in terms of dimensionality and ...
7
votes
2answers
745 views

Can I use 'SCIP' solver for PYOMO?

I have an MINLP problem to solve where I was initially using 'ipopt' solver but the solution was not sticking to 'binary/boolean/integer' domain type for a variable. I am not sure which free solver ...
6
votes
1answer
282 views

Can GLPK be used to solve an optimal team selection problem?

My Problem I am quite new to optimisation, so any advice is appreciated. I am currently trying to solve a problem as follows: Given a pool of people, we want to create n teams such to find the optimal ...
1
vote
2answers
121 views

Issue with number of threads on Cplex

I'm solving a bunch of similar problems and I want to compare them. To do so, I need everything to run on one thread. Even by setting the number of threads to 1, the model still runs on 8 threads. Has ...
1
vote
1answer
100 views

Issues modeling portfolio optimization with rebalancing in gurobipy

I want to solve the following portfolio optimization problem by means of the Python API of Gurobi: \begin{align}\max_w&\quad w^\top\Pi\\\text{s.t.}&\quad w^\top\Sigma w=\sigma^{\rm target}\\&...
2
votes
0answers
86 views

How to set solver options in Pyomo with GAMS Python API?

Did anyone have experiences with Pyomo and GAMS as solver? I had looked into the pyomo documentation (GAMSShell Solver) and in the CPLEX Manuals, but doesnt find the correct syntax. My Code looks like:...
1
vote
1answer
112 views

Flexible Job Shop Problem with several resources per alternative - Ortools

It has been quite a journey for me to go from 0 to understanding the job shop (js) and the flexible job shop (fjs) examples given by Google's ORTOOLS team. Now the time has come for me to start ...
4
votes
1answer
162 views

Combinatorial Optimisation, Allocation problem

I am trying to solve a problem (in pyspark/ python) where I need to find two distinct values to allocate, and how to allocate them in a network of stores. The two distinct values can only be integer ...
1
vote
1answer
394 views

Mixed integer quadratic programming (MIQP) in CVXPY

There's something I don't understand about CVXPY's example on its MIQP use. It says that the algorithm returns a solution $x \in \mathbb{Z}^n$ but I thought in general the point of MIQP algorithms was ...
5
votes
1answer
255 views

Does pyomo support column generation?

I want to use column generation technique to solve cutting stock problem. Is there any other python modeling library that supports column generation?
4
votes
1answer
107 views

maximum number of BoolVar 's before or-tools is no longer feasible to use

The standard nurse scheduling problem which is used as an example for OR-Tools (see for example https://developers.google.com/optimization/scheduling/employee_scheduling) attempts to assign boolean ...
11
votes
3answers
4k views

Which Python package is suitable for multiobjective optimization

I would like to start using Python for modelling and solving optimization problems. I would like to use both single-objective problems and multi-objective problems with a multidimensional objective ...
-2
votes
1answer
173 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
117 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
51 views

CPLEX keeps restarting in Pyomo

I tried running my model by adding the following settings to CPLEX. ...
2
votes
1answer
153 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
124 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
174 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
232 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 ...