solu<-(function(x,y){
#          1,2,3,4,5,6,7,8,9
stn <-x #c(1,0,1,4,1,0,0,0,0)
obj <- c(0,c(30,60,90,150,225,375,675,1050,1800))
use <- c(1,c(2**c(0:(length(stn)-1))))
now <- c(0,stn)
msk <- c(0,c(rep(1,length(stn))))
library(Rsymphony)
mat <- matrix(c(msk,use), nrow = 2 , byrow = TRUE)
dir <- c("<=", "==")
rhs <- c(y,sum(use*(now)))
max <- TRUE
types <- rep("I",length(stn))
Rsymphony_solve_LP(obj, mat, dir, rhs, types = types, max = max)
})
solu(c(1,2,1,7,0,0,0,0,0),9)
 
附:
生成元素均为1的上三角型矩阵:
matrix(as.integer(upper.tri(diag(4),TRUE)),ncol=4)