linear-programming

“Too many indices” big matrix vector length issue in R

[亡魂溺海] 提交于 2020-01-17 08:55:03
问题 Hello and thanks in advance. I'm using Rx64 version 3.1.2 on a Windows Server and have a file-backed big matrix generated from the package bigmemory that I'm trying to use in a linear programming problem. The matrix is 7062 rows by 364520 columns for a total of 2574240240 entries (of integers). When I run the line for the linear program, I get the following error: Error in GetElements.bm(x, i, j) : Too many indices (>2^31-1) for extraction. That number, 2147483647, from what I read is the

How to perform Integer Linear Programming in Apache Commons Math

狂风中的少年 提交于 2020-01-17 08:16:12
问题 The org.apache.commons.math3.optim.linear package in Apache Commons Math Library allows Linear Optimization but the returned values are double. Is there any way to perform Integer Linear Programming using this library? I tried googling but there seems to be no mention of ILP anywhere. Alternatively, is there any other Java library that can do ILP? please not that I need to run this on android so SCPSolver, GLPK, Or-tools. etc. are not possible. Thanks in advance. 回答1: As this question and

Linear Programming with Big Matrix - Still having memory problems

只愿长相守 提交于 2020-01-17 04:25:30
问题 Hello everyone and thanks in advance! I've had a bit of an interesting journey with this problem. Here I figured out how to create a file-backed big matrix using the bigmemory package. This 7062 row by 364520 column matrix is the constraint matrix in a linear programming problem I'm trying to solve using the Rsymphony package. The code is below and the constraint matrix is called mat : Rsymph <- Rsymphony_solve_LP(obj ,mat[1:nrow(mat),1:ncol(mat)] ,dir ,rhs ,types="B",max=F, write_lp=T)

Set up linear programming optimization in R using LpSolve?

僤鯓⒐⒋嵵緔 提交于 2020-01-15 10:16:09
问题 I have this optimization problem where I am trying to maximize column z based on a unique value from column X, but also within a constraint that each of the unique values picked of X added up column of Y most be less than (in this example) 23. For example, I have this sample data: d=data.frame(x=c(1,1,1,2,2,2,3,3,3),y=c(9,7,5,9,7,5,9,7,5),z=c(25,20,5,20,10,5,10,5,3)) Which looks like this: X Y Z 1 1 9 25 2 1 7 20 3 1 5 5 4 2 9 20 5 2 7 10 6 2 5 5 7 3 9 10 8 3 7 5 9 3 5 5 The result should

Converting conditional constraints to linear constraints in Linear Programming

↘锁芯ラ 提交于 2020-01-13 13:13:00
问题 I have two variables: x>= 0 and y binary (either 0 or 1), and I have a constant z >= 0. How can I use linear constraints to describe the following condition: If x = z then y = 1 else y = 0. I tried to solve this problem by defining another binary variable i and a large-enough positive constant U and adding constraints y - U * i = 0; x - U * (1 - i) = z; Is this correct? 回答1: Really there are two classes of constraints that you are asking about: If y=1 , then x=z . For some large constant M ,

Converting conditional constraints to linear constraints in Linear Programming

让人想犯罪 __ 提交于 2020-01-13 13:12:01
问题 I have two variables: x>= 0 and y binary (either 0 or 1), and I have a constant z >= 0. How can I use linear constraints to describe the following condition: If x = z then y = 1 else y = 0. I tried to solve this problem by defining another binary variable i and a large-enough positive constant U and adding constraints y - U * i = 0; x - U * (1 - i) = z; Is this correct? 回答1: Really there are two classes of constraints that you are asking about: If y=1 , then x=z . For some large constant M ,

Converting conditional constraints to linear constraints in Linear Programming

十年热恋 提交于 2020-01-13 13:11:48
问题 I have two variables: x>= 0 and y binary (either 0 or 1), and I have a constant z >= 0. How can I use linear constraints to describe the following condition: If x = z then y = 1 else y = 0. I tried to solve this problem by defining another binary variable i and a large-enough positive constant U and adding constraints y - U * i = 0; x - U * (1 - i) = z; Is this correct? 回答1: Really there are two classes of constraints that you are asking about: If y=1 , then x=z . For some large constant M ,

Trying to find a pure python integer linear programming solver with inequalities

守給你的承諾、 提交于 2020-01-13 06:47:21
问题 I have a program written in App Engine (python) and I want to use an integer linear programming solver in it. All solvers I could find seems to be written partly in C, so I would imagine they won't work in App Engine. Anyone knows of a pure python library that solves integer linear programming with inequalities? I managed to find this http://projects.scipy.org/scipy/ticket/1252 but it seems that it doesn't deal with inequalities. 回答1: This seems to do the trick: http://labix.org/python

how can I minimize the distance from a given input distribution?

大城市里の小女人 提交于 2020-01-06 06:46:40
问题 I have a list of customers and each of them can be "activated" in four different ways: n= 1000 df = pd.DataFrame(list(range(0,n)), columns = ['Customer_ID']) df['A'] = np.random.randint(2, size=n) df['B'] = np.random.randint(2, size=n) df['C'] = np.random.randint(2, size=n) each customer can be activated either on "A" or on "B" or on "C" and only if the Boolean related to the type of activation is equal to 1. In input i have the count of the final activations. es: Target_A = 500 Target_B =

Best linearization for p-dispersion (maxmin) problem?

元气小坏坏 提交于 2020-01-06 03:53:05
问题 Partially related to my other question here. In my case the 'original' aim was to choose n=50 objects out of N=292, such that the sum of all pairwise distances between the chosen objects is maximized (maxsum or p-dispersion sum). Thanks to the users who provided advice, I did some further reading, and now I understand that the problem is indeed quadratic in its simplest form, and a solver like CPLEX may be able to solve it. However, this article by Kuby points out that the maxsum results does