运筹学线性规划问题——R语言代码

运筹学线性规划问题——R语言代码

library(“lpSolve”)
f = c(3, 5)
a1 = c(1, 0)
a2 = c(0, 2)
a3 = c(3, 2)
a = rbind(a1,a2,a3)
a.dir = rep("<=", 3)
a.rhs = c(4, 12, 18)
solution = lp(“max”, f, a, a.dir, a.rhs, compute.sens = 1)
solution s o l u t i o n s o l u t i o n solution solution solutionsolutionduals #影子价格
solutionKaTeX parse error: Expected 'EOF', got '#' at position 19: …s.coef.from #̲f=c(3,5),在产品2的利…sens.coef.to #产品1的利润在(0,7.5)之间,最优解的答案不变

solutionKaTeX parse error: Expected 'EOF', got '#' at position 19: …ls.from #̲第二种产品的利润在(6,18)…duals.to

#all.bin = TRUE 0-1规划
#all.int = TRUE 整数规划

目标规划

p1 = 100000000000
p2 = 100000000
p3 = 10000
p4 = 1
library(“lpSolve”)
f = c(0, 0, p4, p1, p2, 0, 0, 5p3, 0, 3p3)
a1 = c(1, 2, -1, 1, 0, 0, 0, 0, 0, 0)
a2 = c(1, 2, 0, 0, -1, 1, 0, 0, 0, 0)
a3 = c(1, -2, 0, 0, 0, 0, -1, 1, 0, 0)
a4 = c(0, 1, 0, 0, 0, 0, 0, 0, -1, 1)
a = rbind(a1, a2, a3, a4)
a.dir = rep("=", 4)
a.rhs = c(6, 9, 4, 2)
solution_2 = lp(‘min’, f, a, a.dir, a.rhs)
solution_2$solution

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值