linear-programming

How to formulate LP for shortest path problems?

↘锁芯ラ 提交于 2019-12-08 11:37:09
问题 I'm trying to understand how the LP formulation for shortest path problem works. However I'm having trouble understanding constraints. Why does this formulation work? http://ie.bilkent.edu.tr/~ie400/Lecture8.pdf I'm having trouble understanding how the constraints work at pages 15 and 17. I got the main idea and I understand how and why x should take some values but I did not understand how the whole system works in terms of math. Can someone explain? In the exam, I am supposed to be able to

Mixed Integer Programming - Warehouse Location (Python + GLPK)

六月ゝ 毕业季﹏ 提交于 2019-12-08 07:57:55
问题 I am relatively new in optimizationa nd I am trying to optimize a problem (from a pas class in Coursera, 2 years ago) about Warehouse Location. The problem is, its been more than 6 hours and its still running on an instance with 100 warehouses and 1000 customers. The problem is the following. I have a set of warehouses that I can either open or not. Opening each of them has a cost s_w. Also, they all have a maximum capcity, cap_w. On the other side, there is a bunch of clients, all of them

scipy.optimize with SLSQP. 'Singular matrix C in LSQ subproblem'

﹥>﹥吖頭↗ 提交于 2019-12-08 07:12:46
问题 I'm trying to minimize a dot product of 2 vectors but it doesn't work and I have no idea why. Can someone please help me? I have a matrix c of this form: c = [[c11, c12, c13, c14, c15], [c21, c22, c23, c24, c25]] I want to get a matrix p of this form: p = [[p11, p12, p13, p14, p15], [p21, p22, p23, p24, p25]] I want to maximize this value : c11*p11 + c12*p12 +c13*p13 + c14*p14 + c15*p15 + c21*p21 + c22*p22 +c23*p23 + c24*p24 + c25*p25 To get that I convert the c and p to 1-D vector and do the

Constraints in R Multiple Integer Linear Programming

≯℡__Kan透↙ 提交于 2019-12-08 06:22:06
问题 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,

sparse matrix LP problems in Gurobi / python

你。 提交于 2019-12-08 03:02:47
问题 I am trying to solve an LP problem represented using sparse matrices in Gurobi / python. max c′ x, subject to A x = b, L ≤ x ≤ U where A is a SciPy linked list sparse matrix of size ~1000 2 . Using the code model = gurobipy.Model() rows, cols = len(b), len(c) for j in range(cols): model.addVar(lb=L[j], ub=U[j], obj=c[j]) model.update() vars = model.getVars() S = scipy.sparse.coo_matrix(A) expr, used = [], [] for i in range(rows): expr.append(gurobipy.LinExpr()) used.append(False) for

Fox-Goat-Cabbage Transportation

纵然是瞬间 提交于 2019-12-07 18:30:03
问题 My question is about an old transportation problem -- carrying three items across a river with a boat only capable of tranferring one item at a time. A constraint is certain items cannot be left together, such as the cabbage with the goat, wolf with the goat etc. This problem should be solveable using Integer programming, or another optimization approach. The cost function is all items being on the other side of the river, and the trips required to get there could be the output from Simplex (

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

。_饼干妹妹 提交于 2019-12-07 16:43:17
问题 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

Linear Programming - variable that equals the sign of an expression

萝らか妹 提交于 2019-12-07 12:58:25
问题 I am trying to write a linear program and need a variable z that equals the sign of x-c, where x is another variable, and c is a constant. I considered z = (x-c)/|x-c| . Unfortunately, if x=c, then this creates division by 0. I cannot use z=x-c, because I don't want to weight it by the magnitude of the difference between x and c. Does anyone know of a good way to express z so that it is the sign of x-c? Thank you for any help and suggestions! 回答1: You can't model z = sign(x-c) exactly with a

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

大城市里の小女人 提交于 2019-12-07 12:46:14
问题 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)

Find the Discrete Pair of {x,y} that Satisfy Inequality Constriants

走远了吗. 提交于 2019-12-07 05:30:42
问题 I have a few inequalities regarding {x,y} , that satisfies the following equations: x>=0 y>=0 f(x,y)=x^2+y^2>=100 g(x,y)=x^2+y^2<=200 Note that x and y must be integer. Graphically it can be represented as follows, the blue region is the region that satisfies the above inequalities: The question now is, is there any function in Matlab that finds every admissible pair of {x,y} ? If there is an algorithm to do this kind of thing I would be glad to hear about it as well. Of course, one approach