lpsolve

Either-Or constraints in LPsolveAPI

我怕爱的太早我们不能终老 提交于 2019-12-11 06:24:01
问题 I'm currently writing a MIP in LPsolveAPI in R. The program itself is straightforward, but I can't find a way to write an either-or constraint without being able to directly call a new binary variable or the binary values on the lhs. Does LPsolveAPI not support this or am I missing something obvious? 回答1: The use of new binary variables is the standard way to model either-or-constraints in lp_solve. (LpSolveAPI is based on the lp_solve solver.). So you are not missing anything obvious. That

lpsolve - unfeasible solution, but I have example of 1

孤街醉人 提交于 2019-12-10 18:39:30
问题 I'm trying to solve this in LPSolve IDE: /* Objective function */ min: x + y; /* Variable bounds */ r_1: 2x = 2y; r_2: x + y = 1.11 x y; r_3: x >= 1; r_4: y >= 1; but the response I get is: Model name: 'LPSolver' - run #1 Objective: Minimize(R0) SUBMITTED Model size: 4 constraints, 2 variables, 5 non-zeros. Sets: 0 GUB, 0 SOS. Using DUAL simplex for phase 1 and PRIMAL simplex for phase 2. The primal and dual simplex pricing strategy set to 'Devex'. The model is INFEASIBLE lp_solve

How to augment lpsolve R optimization solution to run on a hadoop cluster?

醉酒当歌 提交于 2019-12-10 15:06:08
问题 I am using R lpsolve package to optimize my transportation model. My code runs fine but it takes a lot of time to run as I have huge number of nodes and paths. I am planning to run my code over hadoop cluster. Please guide me regarding changes that i need to make to my code. I think that running optimization over hadoop cluster might be impossible as we might end up with local minimums instead of the global minimum. I search internet for terms like "lpsolve hadoop" but didn't get anything

Find all alternative basic solutions using existing linear-programming tool

久未见 提交于 2019-12-10 13:50:22
问题 I have to find all basic solutions of some tiny linear-programming problems. Here's an example (in lp_solve format): max: x1 + x2; x1 + x2 <= 1; x1 <= 0.8; x2 <= 0.8; All 2 basic solutions: x1 = 0.2, x2 = 0.8 x1 = 0.8, x2 = 0.2 Of course there is a way of finding alternative solutions, but I really prefer using existing libraries instead of crafting my own simplex code. I'm using Python as my programming language, and hoping there's some method in lp_solve or GLPK's C API can do this. Thanks.

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

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

Setting up a linear optimizer with an “or” constraint

荒凉一梦 提交于 2019-12-04 14:48:03
问题 I have a big linear optimizer I'm running and need some help setting up the constraints to get what I want. It's hard for me to express it in words exactly (hence the vague post-title), so I've written an example, details: Select a total of 5 items, maximizing value and keeping the cost under 5k. Each item has 2 "types". They are either labeled type1 = A, B, C, D, or E, and either type2 = X or Y. 4 items must be type X, 1 must be type Y The below example works great, but I want to add two

Setting up a linear optimizer with an “or” constraint

耗尽温柔 提交于 2019-12-03 09:10:26
I have a big linear optimizer I'm running and need some help setting up the constraints to get what I want. It's hard for me to express it in words exactly (hence the vague post-title), so I've written an example, details: Select a total of 5 items, maximizing value and keeping the cost under 5k. Each item has 2 "types". They are either labeled type1 = A, B, C, D, or E, and either type2 = X or Y. 4 items must be type X, 1 must be type Y The below example works great, but I want to add two more constraints and I'm not really sure how to do it. The two other constraints: I want every

R lpsolve binary find all possible solutions

…衆ロ難τιáo~ 提交于 2019-11-27 08:15:42
问题 I have a linear programming problem. All variables are binary and I want to get all possible solutions.I know that I can set parameter num.bin.solns to provide multiple solutions. But is there any easy way to ask for all possible solutions? For example in below case I know that the maximum number of answers is 6. But if I don't know the maximum possible solutions then how can I set the num.bin.solns parameter such that it would return all possible solutions? library("lpSolve") A=matrix (c(1,1