Questions tagged [lpsolve]

lp_solve is a free linear (integer) programming solver. The solver is a callable library written in ANSI C.

lp_solve is a free (see LGPL for the GNU lesser general public license) linear (integer) programming solver based on the revised simplex method and the Branch-and-bound method for the integers.

lp_solve solves pure linear, (mixed) integer/binary, semi-continuous and special ordered sets (SOS) models.

It can also be called as a library from different languages like C, VB, .NET, Delphi, Excel, Java, ... It can also be called from AMPL, MATLAB, O-Matrix, Scilab, Octave, R via a driver program. lp_solve is written in ANSI C and can be compiled on many different platforms like linux and WINDOWS.

More details, including an FAQ, and an intro to lp_solve can be found here.

271 questions
1
vote
2 answers

How to speed up linear programming problem solution?

I have the following problem. I have n (typically n = 1000) data points (integers from {1,2,3}, so there are a lot of repeting numbers) and a real number d. I have to choose k
treskov
  • 328
  • 1
  • 4
  • 17
1
vote
1 answer

R lpSolve setting constraints (fantasy football related)

I am trying to solve linear optimization problem. I have 100 players with score and price for each player. My goal is to select 11 players and to maximize possible score while staying within budget (83 in this example). Code below solve this…
1
vote
2 answers

lp_solve return uniform solution

Can lp_solve return a unifrom solution? (Is there a flag or something that will force this kinf of behavior?) Say that I have this: max: x + y + z + w; x + y + z + w <= 100; Results in: Actual values of the variables: x …
user17477528
1
vote
1 answer

lpSolve to solving an integer programming problem

Solving an integer programming problem with R, the model is: # variables: x1, x2, x3 max z = 25000x1 + 18000x2 + 31000x3 s.t.: x1 + x2 + x3 = 100 5000x1 + 11000x2 + 7000x3 <= 700000 x1 >= 10 x2 >= 10 x3 >= 10 x1, x2, x3 є {0,1} In R, I have…
Mark K
  • 8,767
  • 14
  • 58
  • 118
1
vote
0 answers

How to form an LP based clustering problem in R?

Trying to form an LP-based clustering problem in R with binary variables. sample dataset: set.seed(123) id<- seq(1:50) lon <- rnorm(50, 88.5, 0.125) lat <- rnorm(50, 22.4, 0.15) demand <- round(runif(50, min=20, max=40)) df<- data.frame(id, lon,…
Shibaprasadb
  • 1,307
  • 1
  • 7
  • 22
1
vote
1 answer

How do I add a dependency constraint in LPsolve with binary variables

I am using the Java wrapper for LPsolve and I have a cost function with the traditional initial fixed cost + operating costs in the cost function How can I add this constraint that if y_i = 0, p_i must also be zero (with y_i being the initial…
1
vote
1 answer

Linear optimization in R, Stigler diet problem

Has anyone tried to replicate The Stigler Diet problen in R? So far this is what I have: library(lpSolve) library(linprog) # where d is the nutrients data frame found in the above link f.obj_ <- d$`1939 price (cents) ` f.con_ <- matrix(c(…
Antarqui
  • 467
  • 6
  • 18
1
vote
1 answer

LpSolve R conditional constraint

I am trying to answer the following ILP where the objective is to maximize the type of patients operated, while only 2 different types can be operated at most. max 310x1 + 400x2 + 500x3 + 500x4 + 650x5 + 800x6 + 850x7 subject to 1.8x1 + 2.8x2 +…
Sam
  • 13
  • 2
1
vote
1 answer

R: How to solve the following linear programming problem

I'm interested in solving the following linear programming problem. In this toy example, the second constraint tells me that x1 <= -1, that is, x1 must be negative, so the minimum value of x1 should be negative. Using lpSolveAPI, I coded up this…
Adrian
  • 9,229
  • 24
  • 74
  • 132
1
vote
1 answer

R: In lpSolveAPI, how do I change the objective function from minimization to maximization?

library(lpSolveAPI) my.lp <- make.lp(nrow = 3, ncol = 2) set.column(my.lp, 1, c(1, 1, 2)) set.column(my.lp, 2, c(3, 1, 0)) set.objfn(my.lp, c(1, 0)) set.constr.type(my.lp, rep("<=", 3)) set.rhs(my.lp, c(4, 2, 3)) set.bounds(my.lp, lower = c(-Inf,…
Adrian
  • 9,229
  • 24
  • 74
  • 132
1
vote
1 answer

Using lpSolve in R to Minimize Absolute Values in an Objective Function

I would like to set up a linear program (if it is possible, I'm not sure) to solve this problem in R: I want to minimize the function: abs(x1) + abs(x2) + abs(x3) + abs(x4) Constraints: x1 + x2 + x3 + x4 = 0 0.2x1 + 0.3x2 + 0.5x3 + 0.1x4 =…
Kevin
  • 107
  • 5
1
vote
1 answer

Using lpsolve to define constraint for the proportion over a subset of decision variables

I am making an lp solution but am stuck at defining constraints. Suppose I have 9 decision variables, {x1,x2...n} Suppose also I have a constraint that involves a subset of all decision variables: x1 / (x1+x2+x3) = 40/100 Then how can I write this…
JasTonAChair
  • 1,948
  • 1
  • 19
  • 31
1
vote
1 answer

Examples of LpSolve Implementation with Netlogo

I have searched extensively, but have been unable to find any code examples of where LpSolve has been implemented with Netlogo, which makes it a little hard as a first time user. Does anyone have any examples to provide some insights? I am familiar…
Simon Bush
  • 407
  • 2
  • 9
1
vote
1 answer

How to implement a binary constraint in LPSolve?

I am trying to solve an optimization problem by using linear programming. I have a list of products for which I know the content of multiple nutrients. The goal is then to find the combination of products that gives the closest solution to a certain…
Sven
  • 133
  • 1
  • 8
1
vote
0 answers

Many optimal solution using lpSolve in R

I am running a lp optimization using lpSolve package. The $solution value show me only one result, but I know there are more than one optimal solution. How can I collect the others solutions?