楼主: zhyizzq
3830 6

[有偿编程] 人大经济论坛还有人才么?——求函数的最大值优化问题 [推广有奖]

  • 0关注
  • 0粉丝

初中生

38%

还不是VIP/贵宾

-

威望
0
论坛币
344 个
通用积分
0
学术水平
-5 点
热心指数
-5 点
信用等级
-5 点
经验
12 点
帖子
9
精华
0
在线时间
17 小时
注册时间
2010-9-26
最后登录
2013-3-15

楼主
zhyizzq 在职认证  发表于 2012-8-3 15:06:10 |AI写论文
50论坛币
2N)Z]Z9]%[H)E}L{B_MPRPS.jpg

关键词:人大经济论坛 人大经济 经济论坛 经济论 最大值 优化 最大值
已有 1 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
Xaero -100 -100 -5 -5 -5 要提问好好提问。用这种侮辱所有网友的语气.

总评分: 经验 -100  论坛币 -100  学术水平 -5  热心指数 -5  信用等级 -5   查看全部评分

沙发
3生石 在职认证  发表于 2012-8-4 01:08:40
属于有约束的非线性规划问题
首先编写目标函数(取原函数的相反数):
function f=myfun(x)
f=-(2-0.9*x(1))*(200-10*x(2))*0.4*(1-(3-x(1))/(0.9*(x(2)-x(1))))...
    +0.9*x(1)*(200-10*x(2))*0.25*0.4^2*(1-(3-x(1))/(0.9*(x(2)-x(1))))^2;
再编写非线性约束函数:
function [c,ceq]=nl(x)
c=[];
ceq=(200-20*x(2)+10*x(1))*0.4^2*0.25*(0.9*(x(2)-x(1))-(3-x(1)))+0.2*0.4*(3-x(1));
最后写出线性约束:
A=[-1 -9];
b=-30;
写出上下界:
lb=[0;3];
ub=[20/9;20];
设定一个初始值:
x0=[2 4];
最后优化:
[x,fval,exitflag]=fmincon(@myfun,x0,A,b,[],[],lb,ub,@nl)
已有 1 人评分学术水平 热心指数 收起 理由
woodlee + 1 + 1 精彩帖子

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

藤椅
zhyizzq 在职认证  发表于 2012-8-4 09:35:55
3生石 发表于 2012-8-4 01:08
属于有约束的非线性规划问题
首先编写目标函数(取原函数的相反数):
function f=myfun(x)
很感谢你的帮助……可是按照你的程序运行时,出现以下错误:
>> A=[-1 -9];
b=-30;
lb=[0;3];
ub=[20/9;20];
x0=[2 4];
[x,fval,exitflag]=fmincon(@myfun,x0,A,b,[],[],lb,ub,@nl)
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 260
??? Error using ==> fmincon
FMINCON cannot continue because user supplied objective function failed with the following error:
Error using ==> feval
Undefined command/function 'myfun'.
不知道问题出在哪里……麻烦你了

板凳
3生石 在职认证  发表于 2012-8-4 10:11:31
myfun nl 两个函数分别存在两个m文件中,我运行没问题,祝你好运   

报纸
zhyizzq 在职认证  发表于 2012-8-4 10:13:55
3生石 发表于 2012-8-4 10:11
myfun nl 两个函数分别存在两个m文件中,我运行没问题,祝你好运
你的matlab是哪个版本?还有,你算的结果是多少?非常感谢你哦

地板
3生石 在职认证  发表于 2012-8-4 10:20:02
2012a最新版本的,我运行也有点问题,不知道是不是你的约束条件有问题,你再请教高人吧
Warning: The default trust-region-reflective algorithm does not solve problems with the
constraints you have specified. FMINCON will use the active-set algorithm instead. For
information on applicable algorithms, see Choosing the Algorithm in the documentation.
> In fmincon at 486

No feasible solution found.

fmincon stopped because the size of the current search direction is less than
twice the default value of the step size tolerance but constraints are not
satisfied to within the default value of the constraint tolerance.

<stopping criteria details>


x =

    2.2328    3.0746


fval =

   -0.0059


exitflag =

    -2

7
zhyizzq 在职认证  发表于 2012-8-4 10:22:00
3生石 发表于 2012-8-4 10:20
2012a最新版本的,我运行也有点问题,不知道是不是你的约束条件有问题,你再请教高人吧
Warning: The defa ...
还是非常感谢你!

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-3 12:22