I have the following linear goal programming problem that I'm trying to solve using R
:
I tried formulating using R
in the following matrix format:
Below is the reproducible example:
library("lpSolve")
a <- matrix(c(1,2,5,
1/2,1,3,
1/5,1/3,1),nrow=3,byrow=T)
f.obj <- c(rep(1,6),rep(0,3))
f.cons <- matrix(c(c(1,-1,0,0,0,0,1,-1,0,
0,0,1,-1,0,0,1,0,-1,
0,0,0,0,1,-1,0,1,-1,
1,0,0,0,0,0,0,0,0,
0,1,0,0,0,0,0,0,0,
0,0,1,0,0,0,0,0,0,
0,0,0,1,0,0,0,0,0,
0,0,0,0,1,0,0,0,0,
0,0,0,0,0,1,0,0,0,
0,0,0,0,0,0,1,0,0,
0,0,0,0,0,0,0,1,0,
0,0,0,0,0,0,0,0,1)
),nrow=12,byrow=T)
f.dir <- c(rep("=",3),rep(">",9))
f.rhs <- c(c(log(a[1,2]),log(a[1,3]),log(a[2,3])),rep(0,9))
g <- lp ("min", f.obj, f.cons, f.dir, f.rhs)
g$solution
> g$solution
[1] 0.1823216 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000 1.6094379 1.0986123 0.0000000
Below are my questions:
- The solution is incorrect ? Is there anything that I formulated is incorrect ?
- How can I formulate for an
nxn
matrix usingR
for the above goal programming.
- How can I formulate for an