R中有错误的单纯形函数的基本示例 [英] A basic example of the simplex function in R with errors

查看:65
本文介绍了R中有错误的单纯形函数的基本示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好, 我对在R中无法解决但在Excel中无法解决的优化问题有疑问:

Good morning, I have a question to an optimization problem I can't solve in R but in Excel:

我想优化以下情况(物质和人员的运输):
x1航空公司可运送50吨物料和500人
x2航空公司可运输150吨物料和250人

I would like to optimize the following situation (Transportation of material and people):
Airline x1 can transport 50t of material and 500 people
Airline x2 can transport 150t of material and 250 people

50x1 + 150x2> = 900->最小物料运输900
500x1 + 250x2> = 2500->人员运输量2500

50x1 + 150x2 >= 900 -> Transportation of material min. 900
500x1 + 250x2 >= 2500 -> Transportation of people min. 2500

x1是一家航空公司,每次航班的航班费用为2500 x2是一家航空公司,每次航班的飞行成本为3500 费用应降到最低!

x1 is an airline with flight costs of 2500 per flight x2 is an airline with flight costs of 3500 per flight The costs should be minimized!

x1> = 0
x2> = 0

x1>=0
x2>=0

这是我在R中的解决方案(软件包"boot"中的功能单纯形):

Here is my solution in R (function simplex from the package "boot"):

library("boot")    
a <- c(2500, 3500)
A2 <- matrix(c(50, 150, 500, 250), ncol=2, nrow=2, byrow=TRUE)
b2 <- c(900, 2500)
simplex(a, A2 = A2, b2 = b2, maxi=FALSE)

我收到以下错误:
Fehler in Pivot(tableau,prow,pcol): Teilbereichszuweisungen中的NAs nicht zugelassen

I get the following error:
Fehler in pivot(tableau, prow, pcol) : NAs nicht zugelassen in Teilbereichszuweisungen

Excels Solver为我提供了确切的解决方案: x1 = 2.4和x2 = 5.2

Excels Solver gives me the exact solution: x1 = 2.4 and x2 = 5.2

我在R中的错误在哪里?我必须使用参数A2和b2,因为> = ... 谢谢您的帮助!

Where is my error in R? I have to use the arguments A2 and b2 because of >= ... Thank's for any help!

只是一个简短的扩展: 我使用以下语法从软件包"linprog"使用函数"solveLP"解决了给定的问题:

Just a short extension: I solved the given problem using the function "solveLP" from the package "linprog" using the following syntax:

solveLP(cvec = a, bvec = b, Amat = A, 
    maximum=FALSE, const.dir=c(">=",">="))

和:

A <- matrix(c(-50,-150,-500,-250),nrow=2,ncol=2,byrow=TRUE)
a <- c(2500, 3500)
b <- c(-900, -2500)
solveLP(a,b,A,maximum=FALSE)

仍然想知道为什么单纯形函数会给我这个错误?

Still wondering why the function simplex gives me this errors?

推荐答案

我不知道确切原因(因此这不是必不可少的解决方案).但是我知道,即使b1是一个很大的值,当您使用A1b1设置上限时,该错误也已解决.

I don't know an exact reason (so this isn't an essential solution). But I know the error is solved when you set an upper limit with A1 and b1 even if b1 is a enormous value.

simplex(a, A1 = c(1, 1), b1 = 1.0E+12, A2 = A2, b2 = b2, maxi = FALSE)

这篇关于R中有错误的单纯形函数的基本示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆