linear-programming

Set up linear programming code in Matlab to obtain vertices in 4D or higher dimensions

戏子无情 提交于 2019-12-22 18:07:04
问题 Suppose I have a point cloud given in 4D space, which can be set up arbitrarily dense. These points will lie on the surface of a polytope, which is an unknown object at this point. (Just to provide some unhelpful visualization, here is a rather arbitrary projection of the point cloud which I have given - i.e. plotting the first 3 columns of the 100000x4 array): My goal is to obtain the vertices of this polytope, and one of my numerous attempts to get those was computing the convex hull of the

Find exact solutions to Linear Program

这一生的挚爱 提交于 2019-12-22 10:28:37
问题 I need to find an exact real solution to a linear program (where all inputs are integers). It is important that the solver also outputs the solutions as rational numbers, ideally without doing any intermediate steps with floating point numbers. GLPK can do exact arithmetic, but cannot display the solutions as rational numbers (i.e. I get 0.3333 for 1/3). I could probably attempt to guess which number is meant by that, but that seems very fragile. I was unable to find an LP solver that can do

Python Pandas self join for merge cartesian product to produce all combinations and sum

谁说我不能喝 提交于 2019-12-21 20:17:17
问题 I am brand new to Python, seems like it has a lot of flexibility and is faster than traditional RDBMS systems. Working on a very simple process to create random fantasy teams. I come from an RDBMS background (Oracle SQL) and that does not seem to be optimal for this data processing. I made a dataframe using pandas read from csv file and now have a simple dataframe with two columns -- Player, Salary: ` Name Salary 0 Jason Day 11700 1 Dustin Johnson 11600 2 Rory McIlroy 11400 3 Jordan Spieth

Optimization problem in Python

匆匆过客 提交于 2019-12-21 18:36:09
问题 I need to solve a problem. I have 5 devices. They all have 4 kind of I/O types. And there is a target input/output combination. At first step, I want to find all combinations among the devices so that the total I/O number of selected devices are all equal or greater than the target values. Let me explain: # Devices=[numberof_AI,numberof_AO,numberof_BI,numberof_BO,price] Device1=[8,8,4,4,200] Device1=[16,0,16,0,250] Device1=[8,0,4,4,300] Device1=[16,8,4,4,300] Device1=[8,8,2,2,150] Target=[24

Optimisation/knapsack algorithm with multiple contraints in JavaScript

限于喜欢 提交于 2019-12-21 06:40:12
问题 I'm looking for a solution to the knapsack problem where multiple constraints are in place. Say our knapsack has a maximum weight of 30kg and we have a set of 100 objects, each with a weight and each with a benefit. These objects could look like this: { name: 'water bottle', weight: 2, benefit: 5 }, { name: 'potatoes', weight: 10, benefit: 6 } Finding the combination of objects with the highest benefit within the maximum weight is simple enough. Here is a nodeJS plugin showing how it can be

Optimisation/knapsack algorithm with multiple contraints in JavaScript

自作多情 提交于 2019-12-21 06:40:06
问题 I'm looking for a solution to the knapsack problem where multiple constraints are in place. Say our knapsack has a maximum weight of 30kg and we have a set of 100 objects, each with a weight and each with a benefit. These objects could look like this: { name: 'water bottle', weight: 2, benefit: 5 }, { name: 'potatoes', weight: 10, benefit: 6 } Finding the combination of objects with the highest benefit within the maximum weight is simple enough. Here is a nodeJS plugin showing how it can be

Fantasy football linear programming in R with RGLPK

被刻印的时光 ゝ 提交于 2019-12-21 04:12:13
问题 long time listener first time caller to S.O... I am asking a question that has been asked very similarly before, however I don't believe I am smart enough to decipher how to implement the solution, for this I apologize. Here is the link to the question I found: Constraints in R Multiple Integer Linear Programming I am maxing over my projected fantasy points(FPTS_PREDICT_RF), subject to a 50,000 salary cap, while minimizing a 'risk' calculation that I have came up with. Now, the problem lies

Why solving Knapsack problem is not considered as linear programming?

心不动则不痛 提交于 2019-12-21 03:49:30
问题 Why isn't the knapsack problem included under the category of linear programming algorithms in spite of the fact that the Knapsack problem statement seems similar to the problems in linear programming ? 回答1: Knapsack can be written as an integer linear programming program. Unlike normal linear programming, this problem requires that variables in the solution are integers. Linear programming is known to be solvable in polynomial time, while integer linear programming is NP-complete. Exercise

Sparse constrained linear least-squares solver

放肆的年华 提交于 2019-12-20 20:19:12
问题 This great SO answer points to a good sparse solver for Ax=b , but I've got constraints on x such that each element in x is >=0 an <=N . Also, A is huge (around 2e6x2e6) but very sparse with <=4 elements per row. Any ideas/recommendations? I'm looking for something like MATLAB's lsqlin but with huge sparse matrices. I'm essentially trying to solve the large scale bounded variable least squares problem on sparse matrices: EDIT: In CVX: cvx_begin variable x(n) minimize( norm(A*x-b) ); subject

Port MATLAB bounding ellipsoid code to Python

南笙酒味 提交于 2019-12-20 12:16:23
问题 MATLAB code exists to find the so-called "minimum volume enclosing ellipsoid" (e.g. here, also here). I'll paste the relevant part for convenience: function [A , c] = MinVolEllipse(P, tolerance) [d N] = size(P); Q = zeros(d+1,N); Q(1:d,:) = P(1:d,1:N); Q(d+1,:) = ones(1,N); count = 1; err = 1; u = (1/N) * ones(N,1); while err > tolerance, X = Q * diag(u) * Q'; M = diag(Q' * inv(X) * Q); [maximum j] = max(M); step_size = (maximum - d -1)/((d+1)*(maximum-1)); new_u = (1 - step_size)*u ; new_u(j