322 questions
2
votes
3
answers
125
views
Problem with a Lineup Optimizer due to players having multiple Positions
i have a list of Hitters in python with their name,projection and Positions
juan-soto 30.3773 ['OF']
kyle-tucker 44.0626 ['OF']
...
yordan-alvarez 32.510200000000005 ['CI', 'OF']
william-contreras 26....
1
vote
1
answer
202
views
Working with large parameters in an integer linear program using pulp
In pulp's documentation https://coin-or.github.io/pulp/guides/how_to_debug.html, it says that
Check the precision of the numbers. If you have very big numbers (with a high precision), this generally ...
0
votes
1
answer
144
views
Limit Coin-OR CLP variables to integers
I've created a small program using the java clp implementation https://github.com/quantego/clp-java.
Sometimes the solution returns decimals, which I don't want as the variables that I'm using are ...
3
votes
1
answer
81
views
Find nonnegative integer weights of integer inputs array for integer output, minimizing sum of weights
Problem: Given an array of integers inputs and an integer output, return an array of non-negative integers weights such that the sum of the element-wise product of inputs and weights equals output and ...
-1
votes
2
answers
70
views
PuLP: Constrain the number of distinct people that can work on a task
I have a LP/IP problem that I'm trying to solve using PuLP. It is the division of work amongst employees. The thing that I can't figure out is how to limit the engine to only plan 1 employee on an ...
0
votes
0
answers
92
views
About MATLAB intlinprog
I have a problem with MATLAB intlinprog. I have a problem about assigning worker types to jobs. Each job must assigned to one type of worker. The same type of worker can be assigned to different jobs. ...
0
votes
1
answer
111
views
Binary and Integer Program in Python
I have a binary/integer program that I am trying to solve using milp in Python. Below the image and below is the code I have so far. When I run it, I get
`bounds.lb` and `bounds.ub` must contain ...
0
votes
1
answer
580
views
Use min/max operator inside integer linear programming constraint
I have for example the following integer variables x1, x2, x3 and y1, y2, y3.
Is there a way to constrain them in the following ways?
For example:
min(x1, x2, x3) + min(y1, y2, y3) <= 100
or
max(...
1
vote
1
answer
96
views
Stuck formulating an adjacency constraint with pyomo
I'm trying to assign attributes into a 3 x 3 matrix based on an adjacency constraint, but I'm stuck formulating the adjacency constraint. I keep thinking I've got the answer, then when I try it the ...
1
vote
0
answers
87
views
Formulating a constraint with pyomo
I'm trying to array genes (elements) in a matrix (matrix_a) based on the restriction sites they have (attributes). Restriction sites are recognized by enzymes that cut the DNA at a specific site. This ...
2
votes
1
answer
120
views
Does the Order of Modeling Affect Computational Speed in Pulp for Integer Programming Problems?
I am currently solving an integer programming problem using Pulp. I am aware that the order of statements in Pulp modeling can affect the outcome of the computations. However, I am curious to know if ...
2
votes
2
answers
91
views
Gekko not solving Integer Programming Problem
I'm trying to use the integer programming option to find a magic square. The algorithm finds a solution if I remove the requirement the entries are unique. I can add up to six requirements for entries ...
0
votes
1
answer
143
views
PAO.Pyomo model sets two variables x and y to be unique
The background is I am trying to implement a bilevel optimization program using Python-based package for Adversarial Optimization (PAO), which is based on Pyomo. I am new to Pyomo, though I have used ...
0
votes
0
answers
344
views
How to implement non-zero count constraint for cvxpy in integer programming
I want to implement the constraint that the number of non-zero elements per row in x is less than 2.
constraint2 = cp.sum( x >= 0, 1) <= 2
but get the error TypeError: float() argument must be ...
0
votes
1
answer
138
views
Keeping count of variable occurence in google OR Tools
I'm playing around with OR Tools, just wondering if there is any way to hold the number of times a certain constraint is satisfied?
In this case, I'd like to keep track of the number of times my 'diff'...
0
votes
1
answer
92
views
Order elements in a matrix based on another matrix
I'd like to order an arbitrary number of elements into an arbitrarily shaped matrix (matrix_a) based on values in a binary matrix (element_map) that describes attributes of the elements. matrix_b ...
0
votes
1
answer
205
views
How to convert the following if-else conditions to Linear integer programming constraints?
if x ≥ 100,
then x -100 + p(x) ≤ 0;
else p(x) ≤ 0
p(x) is a linear function. We can add x ≥ 0 if it could make it easy.
I tried to make a binary variable z, if x ≥ 100, then z=1; else z=0. Then we got ...
0
votes
0
answers
75
views
How to define this complex labor rule as a constraint in MIP?
Im trying to define a complex labor rule as constraints in a MIP, solved with CPLEX.
My key decision variable is a binary x(i,j) indicating if shift i is assigned to employee j.
The labor rule is as ...
2
votes
1
answer
86
views
setting a lower bound constraint based on condition in gekko
I am trying to set up something similar to the facility location problem using gekko in python. I'm trying to minimize the distance between a set of facilities and corresponding counties while ...
0
votes
1
answer
94
views
Python, puLP, Multiplication variable with integer and assign it to some variable
In here I couldn't get calculations of y1,y2 and y3 when I try my code y1,y2 and y3 was not calculated. how can I fix this
from pulp import *
model = LpProblem("LineBalancing",LpMinimize)
...
0
votes
1
answer
105
views
Binary Integer Programming Problem - Enforce Zeros on Certain Groups
I'm working on a binary integer programming problem using pulp. I have a vector X = [x_1, x_2, x_3, . . . , x_n]. I have enforced a number of simple constraints. I have a bunch of groups in the data ...
1
vote
1
answer
463
views
Fast Convex Integer Non linear programming python solver
I have a convex non-linear integer program of the following form:
K is a fixed integer greater than 0. Betas are real numbers greater than zero.
Note that x is a positive integer and the function to ...
2
votes
2
answers
112
views
Linear integer programming in R?
I have a vector of 100 integers, x1, where each element of the vector is in [1, 7]. I want to find, using R, another vector of 100 elements, x2, also containing integers ranging from 1 to 7, that ...
1
vote
2
answers
253
views
Pulp Matching algorithm to replace greedy algo
I am trying to create a matching algorithm using pulp but the results for the sample data I'm getting are wrong as I think the function is flawed.
Sample data:
users = {
1: (5.0, 4.0, 1.0, 2, 1, 1)...
0
votes
2
answers
733
views
Python-MIP InterfacingError('Gurobi environment could not be loaded, check your license.')
I want to use Gurobi with python-mip. I run the following:
from mip import Model, GUROBI
Model("test_problem", solver_name=GUROBI)
I receive the following error: InterfacingError('Gurobi ...
1
vote
1
answer
86
views
Solving an equation such that the solution is inetger
I have an equation y*8.57E-7 = x with the constraints:
x>0
x should be an integer
y should be an integer
It might be solved with dynamic programming, but I am weak in analyzing it this way. For ...
0
votes
1
answer
100
views
Create all combinations satisfying a sum condition without expand.grid
I am using R to find the set of values that maximise a certain function (the function is given here by obj_fun). The problem is that for a large number of the parameter pD, I get an integer overflow ...
0
votes
3
answers
465
views
Trying to add a constraint to a Integer Linear Programming problem
Problem set: I have 3 different groups that need to be assigned to 6 different locations.
Objective: I need to minimize the unused space in each location.
Constraints:
For each location j, the sum of ...
0
votes
1
answer
157
views
Is pulp.lpDot(a,n) not equivalent to pulp.lpSum([a[i] * n[i] for i in range(N)])?
I have a decision variable vector n, and a is a constant vector. What confuses me is why lpDot(a,n) is not equivalent to lpSum([a[i] * n[i] for i in range(N)]) in a constraint?
Here is the code:
...
2
votes
1
answer
314
views
How to set Gurobi to stop after the objective value reaches a certain threshold in Julia?
I am trying to run a minimization problem for an MIP using Gurobi in Julia. I would like it to stop after it has found a solution that is below a certain threshold that I have set. I have found ways ...
0
votes
1
answer
282
views
Solving Knapsack Problem for large dataset using PULP library in Python
I have the below dataframe:
import itertools
import pandas as pd
import numpy as np
p1_values = np.arange(19, 29.1, 0.1)
p2_values = np.arange(23, 33.1, 0.1)
p3_values = np.arange(36, 46.1, 0.1)
...
1
vote
1
answer
237
views
Minimize AbsEquality rather than enforce in OrTools
I'm trying to solve the following using OR tools:
Given the following bags containing different colors of balls:
bag
red
blue
green
black
A
10
5
85
0
B
25
50
25
0
C
0
100
0
0
D
90
5
5
0
E
2
0
98
0
F
0
...
0
votes
0
answers
35
views
MILP - How to set variable to be absolute value of other variable [duplicate]
In a Milp, given an integer variable x, I would like to define a variable y which will be the absolute value of x.
y = |x|
x is bounded between [M, -M].
Is it even possible?
Thank you!
2
votes
2
answers
1k
views
How to use CP-SAT solver or other tools to find 3D arrays with constraints on rows, columns and tubes (representing school classes, terms and days)?
I will be grateful to anyone who can help me write some Python code to enumerate the 21×2×3 arrays, indexed with i, j and k, which are two-thirds filled with 0's and one-third filled with the values '...
1
vote
2
answers
1k
views
How to obtain multiple solutions of a binary LP problem using Google's OR-Tools in Python?
I am new to integer optimization. I am trying to solve the following large (although not that large) binary linear optimization problem:
max_{x} x_1+x_2+...+x_n
subject to: A*x <= b ; x_i is binary ...
1
vote
1
answer
2k
views
How to get all solutions for an integer program in ortools?
I am trying to get all solutions for a Mixed Integer program through ortools. I have two lists x and y of size 4. I want to get all solutions which satisfy sum(x) = 4 * sum(y). I created a function ...
1
vote
1
answer
442
views
How to write constraint with sum of absolutes in Integer Programming?
I found a solution for just one term here.
How can we formulate constraints of the form
|x1- a1| +|x2-a2| + .... + |xn - an| >= K
in Mixed Integer Linear Programming ?
0
votes
1
answer
169
views
Constraint 'feasibility_cut[1]' does not have a proper value. Found 'True'
I'm new to python and pyomo, so I would kindly appreciate your help,
I'm currently having trouble trying to add a constraint to my mathematical model in Pyomo, the problem is while I try to add the &...
0
votes
1
answer
141
views
lpSolve constraint for choices of start and length of shifts
I have a finite number of staff N, and I need to find an optimal schedule (using the least number of staff) meeting the demand
Hour of Day
Demand
0
d0
1
d1
...
...
23
d23
where the d0, d1, ..., d23 ...
0
votes
1
answer
253
views
Julia-Jump Integer Programming Optimization model: issue with multiplying matrix by vector
I have written an optimization model that has 3 binary decision variables that are all in matrix form (X[p,s], Y[a,s], and Z[a,p]). a=associate, p=process, and s=station.
I have encountered an issue ...
0
votes
1
answer
75
views
Truck Type (infinite number of them) vs Orders
The goal of the docplex model below is to choose the trucks with total minimum cost to fulfill all orders. I treat the truck type as 1 truck in the following code, but in fact, a truck type can have ...
-1
votes
1
answer
77
views
How can I order the basic solutions of a min cost flow problem according to their cost?
I was wondering if, given a min cost flow problem and an integer n, there is an efficient algorithm/package or mathematical method, to obtain the set of the
n-best basic solutions of the min cost flow ...
0
votes
0
answers
284
views
Fastest way to solve non-negative linear diophantine equations
Let A be a list of n lists of m non-negative integers, such that for all j there is i with A[i][j] nonzero. Let V be a list of m positive integers.
Question: What is the fastest way to find all the ...
0
votes
2
answers
372
views
Python Knapsack problem - using the average value of the selected items as a constraint?
I'm still relatively new to python so I'm having trouble figuring out how to accomplish a certain feat.
What I'm trying to do: I have an Excel file with two columns - Sell and margin. There could be a ...
2
votes
1
answer
863
views
How to convert the following if conditions to Linear integer programming constraints?
These are the conditions:
if(x > 0)
{
y >= a;
z <= b;
}
It is quite easy to convert the conditions into Linear Programming constraints if x were binary variable. But I am not finding ...
0
votes
1
answer
1k
views
How to Convert or Solve a Non-Linear Optimization Problem with Non-Linear Objective Function & Constraints
Overview
I am working on an order allocation problem with variable and fixed costs. The initial formulation of this problem was a linear optimization, but when fixed and variable costs were introduced,...
0
votes
0
answers
315
views
Building a stacking constraint in Pyomo for Daily Fantasy Sports
I am creating an integer program in Python using pyomo for Major League Baseball (MLB) daily fantasy. Given a lineup of 10 players (1 of each position plus 2 pitchers) and a salary cap, the program ...
0
votes
0
answers
300
views
ILP in poly-time?
Integer programming is said to be NP-complete. However, I think formulating a problem into ILP can't prove the problem to be NP-hard. Is there any example of problem that can be modeled into ILP but ...
0
votes
1
answer
212
views
GAMS Error in MIP Transportation Problem - Uncontrolled set entered as constant
I am trying to formulate an MIP model in which a transportation can be performed by available trains or new ship investments. My current code includes three tables: Monthly costs for trains, monthly ...
0
votes
1
answer
1k
views
CVXPY: Constraint Violation
I'm attempting to solve an optimization program in cvxpy. The issues is that the answer it returns violates the basic constraint that it was given. I've run this program before with success and ...