0
f <- matrix(NA, nrow = (s+m), ncol = (N+1))

for (j in 1:N){
  f.obj = c(1, rep(0,N))
  f.dir <- c(rep("<=", (m+s)))
  df.dir <- c(rep(">=", (m+s)))
  f.rhs <- c(rep(0,s), as.numeric(df[j,1:m]))
  
  for (r in (1:s)){
    f[r,1] = (df[j,(m+r)])
    f[r, 2:(N+1)] = (-df[,(m+r)])
  }
  for (i in (1:m)){
    f[(s+i),1:(N+1) ] = c(0, as.numeric(unlist(df[,i])))
  }
  if (j==1){
    z <- lp("max",f.obj,f, f.dir, f.rhs, scale = 0, compute.sens = F )
    e1 <- print(z$objval)
    l1 <- print(z$solution)
  }

How to get values of objval and solutions for n DMUs if n = 45. df is a dataframe with 45 rows, 6 columns ( inputs, i from 1:4, outputs, r from 5:6)

I want to get objval and solutions for n DMUs in single loop.

Phil
  • 7,287
  • 3
  • 36
  • 66

0 Answers0