linear-programming

Constraints in R Multiple Integer Linear Programming

别来无恙 提交于 2019-12-07 02:26:25
I am working on some code in R to optimize my fantasy football lineup but I am having some difficulty with one constraint. I basically have a list of players, their position, expected points, and cost. Roster must include: 1 QB 2 RB 2 WR 1 TE 1 FLEX (either a RB, WR, or TE) Total cost under $200 My issue is that my code wants to pick the FLEX position as player it already selected as a WR, RB or TE. Here is the code I am using, I have a table that I imported with columns for player, position, points, and cost. In the table, any RB, WR, or TE is duplicated with the position as FLEX. I tried to

Linear Programming library for iOS

随声附和 提交于 2019-12-06 22:14:40
问题 I am looking for an iOS library that enables solving LP, IP, BIP, MIP for an application I am developing. I've found GLPK but have no idea how to compile it for iOS, and after searching the web for some time, I did not find anything interesting... I'd appreciate if someone can help me how to compile GLPK for iOS or either knows of some open source LP solver for iOS. 回答1: I used GMP (GNU Multiple Precision Arithmetic Library) for iOS development, what is basically a C based static library for

Simplex in z3 via for-all

ぃ、小莉子 提交于 2019-12-06 16:16:44
问题 A very similar questions were asked on SO already, but I couldn't find answer to the following problem. A linear maximization problem can be easily stated using for-all quantifier: obj = f(x) AND \forall x . Ax <= b => f(x) <= obj The queries like above can be posed to z3. Consequently I want to ask whether z3 is smart enough to recognize an LP problem when it sees one and will it apply a simplex method to eliminate a for-all quantifier? I did a few experiments and it seemed to work, but I

How do I specify multiple variable constraints using Integer Programming in PuLP?

旧巷老猫 提交于 2019-12-06 14:53:44
I am trying to solve the Bin Packing Problem using the Integer Programming Formulation in Python PuLP. The model for the problem is as follows: I have written the following Python Code using the PuLP library from pulp import * #knapsack problem def knapsolve(bins, binweight, items, weight): prob = LpProblem('BinPacking', LpMinimize) y = [LpVariable("y{0}".format(i+1), cat="Binary") for i in range(bins)] xs = [LpVariable("x{0}{1}".format(i+1, j+1), cat="Binary") for i in range(items) for j in range(bins)] #minimize objective nbins = sum(y) prob += nbins print(nbins) #constraints prob += nbins >

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

若如初见. 提交于 2019-12-06 11:14:09
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 point cloud. The problem here was that the number of resulting vertices differed with the specified

Solving a linear program in case of an equality constraint

爷,独闯天下 提交于 2019-12-06 08:17:19
问题 I had asked a question, which can be found here : Computing the optimal combination And had been suggested Linear programming. I have looked up Linear programming and the Simplex method. But all the examples that I have come across have inequality constraints which are converted into equalities using slack variables. The simplex method then interchanges the basic and the non basic variables to obtain an optimal solution. But my problem is : minimize : x1 + x2 + ... + xn subject to : a1*x1 +

Find exact solutions to Linear Program

此生再无相见时 提交于 2019-12-06 03:54:24
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 this kind of thing. Is there one? Performance is not a huge issue; my problems are very small. (I did

scipy.optimize.minimize (COBYLA and SLSQP) ignores constraints initiated within for loop

给你一囗甜甜゛ 提交于 2019-12-06 03:43:53
I'm using scipy.optimize.minimize to solve a complex reservoir optimization model (SQSLP and COBYLA as the problem is constrained by both bounds and constraint equations). There is one decision variable per day (storage), and releases from the reservoir are calculated as a function of change in storage, within the objective function. Penalties based on releases and storage penalties are then applied with the goal of minimizing penalties (the objective function is a summation of all penalties). I've added some constraints within this model to limit the change in storage to the physical system

Get multiple solutions for 0/1-Knapsack MILP with lpSolveAPI

China☆狼群 提交于 2019-12-06 02:26:07
Reproducable Example: I described a simple 0/1-Knapsack problem with lpSolveAPI in R , which should return 2 solutions: library(lpSolveAPI) lp_model= make.lp(0, 3) set.objfn(lp_model, c(100, 100, 200)) add.constraint(lp_model, c(100,100,200), "<=", 350) lp.control(lp_model, sense= "max") set.type(lp_model, 1:3, "binary") lp_model solve(lp_model) get.variables(lp_model) get.objective(lp_model) get.constr.value((lp_model)) get.total.iter(lp_model) get.solutioncount(lp_model) Problem: But get.solutioncount(lp_model) shows that there's just 1 solution found: > lp_model Model name: C1 C2 C3

Converting conditional constraints to linear constraints in Linear Programming

假装没事ソ 提交于 2019-12-06 01:59:56
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? Really there are two classes of constraints that you are asking about: If y=1 , then x=z . For some large constant M , you could add the following two constraints to achieve this: x-z <= M*(1-y) z-x <= M*(1-y) If y=1 then these