I used lp solve to solve a linear programming equation and the solution gives a vector
> lp("max", obj, con, ineqs, rhs, all.int=TRUE,)$solution
[1] 5 0 13 11 4 0 1 11 0
which is fine, but I want each entry in this vector to be an integer between 1-9 and each integer to only be used once. e.g like what the vector looks like underneath.
[1] 3 4 8 9 2 5 1 6 7
Is there any way this can be done? Thank you in advance!
EDIT
This is the code I have used for the lp function
obj<-c(1,1,1,1,1,1,1,1,1)
con<-matrix(c(1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,1,0,1,1),nrow=5,byrow=TRUE)
ineqs<-c("=", "=", "=", "=", "=")
rhs<-c(45,20,17,27,15)
Basically what this does is it solves this optimisation problem for the 3x3 grid:
x1 x2 x3
x4 x5 x6
x7 x8 x9
Where the constraints are x1+x2+x4+x5=20, x2+x3+x5+x6=17, x4+x5+x7+x8=27, x5+x6+x8+x9=15, each x must be an integer between 1 and 9 and each x must be unique.