楼主: 任无为
4529 9

请问怎样求一个表达式的最大值??急!! [推广有奖]

  • 0关注
  • 0粉丝

已卖:273份资源

讲师

32%

还不是VIP/贵宾

-

威望
0
论坛币
2852 个
通用积分
83.2976
学术水平
3 点
热心指数
5 点
信用等级
2 点
经验
82832 点
帖子
170
精华
0
在线时间
742 小时
注册时间
2008-10-24
最后登录
2025-8-1

20周年荣誉勋章

楼主
任无为 发表于 2009-12-14 03:10:10 |AI写论文
5论坛币
我想求一个表达式的最大可能结果
比如说要求
MAX : 3X+5Y+8Z
约束条件为:
   X>0  Y>0   Z>0
   X+Y<3
   XZ<9等条件

这个例子是我随便编的,大概就是这种情况
请问碰到这种问题该用什么软件,要怎么做?
谢谢了!!





PS:不知道这种问题该发到哪个版块,如果不合适,请管理员帮忙转移到合适的版块
但请勿删帖,因为我真的是急着知道这个问题的答案
谢谢!!

最佳答案

htslchy 查看完整内容

用lingo解得结果如下: Global optimal solution found. Objective value: 1.052572 Infeasibilities: 0.000000 Total solver iterations: 0 Variable Value Reduced Cost X41 0.000000 0.7200000E-02 ...
关键词:表达式 最大值 约束条件 max 表达 最大值

本帖被以下文库推荐

平常心!!平常心!!
Whoever saves one life,saves the world entirel!

沙发
htslchy 发表于 2009-12-14 03:10:11
用lingo解得结果如下:
Global optimal solution found.
  Objective value:                              1.052572
  Infeasibilities:                              0.000000
  Total solver iterations:                             0

                       Variable           Value        Reduced Cost
                            X41        0.000000           0.7200000E-02
                            X42        0.000000           0.5800000E-02
                            X43        1.041841            0.000000
                            X24        0.000000           0.1931936E-01
                            X05        0.000000           0.3927188E-01
                            X01        0.000000           0.7501255E-02
                            X02        0.000000           0.6042677E-02
                            X03        1.000000            0.000000
                            X04        0.000000           0.1971939E-01
                            X11        0.000000           0.7424779E-02
                            X12        0.000000           0.5981072E-02
                            X13        1.010300            0.000000
                            X14        0.000000           0.1951835E-01
                            X21        0.000000           0.7349084E-02
                            X22        0.000000           0.5920095E-02
                            X23        1.020706            0.000000
                            X31        0.000000           0.7274160E-02
                            X32        0.000000           0.5859740E-02
                            X33        1.031219            0.000000
                            Row    Slack or Surplus      Dual Price
                              1        1.052572            1.000000
                              2        0.000000            1.052572
                              3        0.000000            1.041841
                              4        0.000000            1.031219
                              5        0.000000            1.020706
                              6        0.000000            1.010300
源程序:
max=1.0031*x41+1.0045*x42+1.0103*x43+1.0119*x24+1.0133*x05;
     x01+x02+x03+x04+x05<=1;
     x11+x12+x13+x14-1.0031*x01-1.0045*x02-1.0103*x03<=0;
     x21+x22+x23+x24-1.0031*x11-1.0045*x12-1.0103*x13<=0;
     x31+x32+x33-1.0031*x21-1.0045*x22-1.0103*x23-1.0119*x04<=0;
     x41+x42+x43-1.0031*x31-1.0045*x32-1.0103*x33-1.0119*x14<=0;
已有 1 人评分经验 论坛币 收起 理由
胖胖小龟宝 + 10 + 10 热心帮助其他会员

总评分: 经验 + 10  论坛币 + 10   查看全部评分

藤椅
为你拭泪 发表于 2009-12-14 04:43:57
编写个程序就行了  这个蛮简单
昨日西风凋碧树,独上高楼,望尽天涯路

板凳
任无为 发表于 2009-12-14 12:18:45
用什么软件?
怎么编程序?
平常心!!平常心!!
Whoever saves one life,saves the world entirel!

报纸
wngbaq 发表于 2009-12-14 12:30:33
可以用matlab软件

可以试一下 fmincon 这个命令
该命令的用法可以查一下matlab的帮助.

下面这个材料可能对你有些帮助.

http://gjb.nclg.com.cn/shuxuejianmo/2_2.doc
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
任无为 + 1 + 1 + 1 谢谢指教!

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

心慈行孝,何需努力看经;意恶损人,空读如来一藏.

地板
任无为 发表于 2009-12-15 00:31:12
谢谢LS!我想求这样的式子



约束条件为  :




请问程序应该怎么编?
我太笨了,一时间学不会Matlab
谢谢了!!
平常心!!平常心!!
Whoever saves one life,saves the world entirel!

7
mjsnoopy 发表于 2009-12-15 04:18:21
would you pls send the whole question here? you just pick up part of this, I cannot see the relationship between (X01, X02, X03, X04, X05 ... X41, X42, X43, X44, X45), you need to send the whole matrix to solve it
已有 1 人评分学术水平 热心指数 信用等级 收起 理由
任无为 + 1 + 1 + 1 谢谢帮助!

总评分: 学术水平 + 1  热心指数 + 1  信用等级 + 1   查看全部评分

LIVE,and let LIVE

8
任无为 发表于 2009-12-18 17:48:47
我不是很清楚怎么去表达他们之间的关系
这个式子是用来求投资组合的最大化收益的
X(i,j)中i表示投资期,j表示投资的品种
X(i,j)就表示第i期投资于第j种产品的资金
一共有5种产品可选择,总投资期限5期(不是每种产品都投资5期,可重复持有)
不知道这样表达能不能让LS明白
谢谢LS!
平常心!!平常心!!
Whoever saves one life,saves the world entirel!

9
mjsnoopy 发表于 2009-12-19 15:14:10
hi~
I used to use R to solve this kind of problem.
I can give you some hint here (cause I don't have your data, so I can't write the program for you):
once you installed R, follow the steps here: packages -> install packages -> select cran -> download "quadprog", then click packages -> load package -> "quadprog"
then in the R console type in: help(solve.QP), then press "Enter"
you'll get a help file of R.
like:
solve.QP(Dmat, dvec, Amat, bvec, meq=0, factorized=FALSE)
Dmat: matrix appearing in the quadratic function to be minimized.
dvec: vector appearing in the quadratic function to be minimized.
Amat: matrix defining the constraints under which we want to minimize the quadratic function.
bvec: vector holding the values of b_0 (defaults to zero).
meq: the first ‘meq’ constraints are treated as equality constraints, all further as inequality constraints (defaults to 0).
factorized: logical flag: if ‘TRUE’, then we are passing R^(-1) (where D = R^T R) instead of the matrix D in the argument ‘Dmat’.
Follow the instruction, apply to your data, then you'll find the answer~
Good Luck
LIVE,and let LIVE

10
mjsnoopy 发表于 2009-12-19 15:34:18
in your question you have to move all the right-side non-constant variables to the left-side to solve your problem. otherwise you cannot do it by "solve.QP" function.
LIVE,and let LIVE

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-22 03:48