I'm using the package and function lpsymphony::lpsymphony_solve_LP(obj, mat, dir, rhs, types, max)
to solve my linear programming problem.
And now I want to show that the restrictions in the argument mat
matter and therefore I solved this problem with only a subset of restrictions - only some rows of mat
are used to get the solution. And here the solution changes every time I reexecute.
Questions: Why there is no reproducibility and how can I solve this issue?!
But now let's have a look at my code:
# objective function
obj = rep(1, times = (196))
# other arguments
...
# first solution
set.seed(455)
res_231=lpsymphony_solve_LP(obj, mat[1:231,], dir[1:231], rhs[1:231], types = types, max = TRUE)
matrix(c(res_231$solution[29:56]),ncol=4,byrow=TRUE)
## [,1] [,2] [,3] [,4]
## [1,] 0 0 0 0
## [2,] 0 0 0 1
## [3,] 0 0 0 0
## [4,] 1 1 0 0
## [5,] 0 0 1 0
## [6,] 0 0 0 0
## [7,] 0 0 0 0
# second solution
set.seed(455)
res_231=lpsymphony_solve_LP(obj, mat[1:231,], dir[1:231], rhs[1:231], types = types, max = TRUE)
matrix(c(res_231$solution[29:56]),ncol=4,byrow=TRUE)
## [,1] [,2] [,3] [,4]
## [1,] 0 0 0 0
## [2,] 0 0 0 1
## [3,] 0 0 0 0
## [4,] 0 1 0 0
## [5,] 1 0 0 0 # difference in [5,1] compared to first solution
## [6,] 0 0 1 0 # difference in [6,3] compared to first solution
## [7,] 0 0 0 0
And an excerpt of the session info
session_info()
## version R version 4.1.0 (2021-05-18)
## ...
## lpsymphony * 1.20.0 2021-05-19 [1] Bioconductor (R 4.1.0)
Many thanks in advance!