matlab中二次规划的问题,matlab中二次规划的问题 100

2020-11-22 05:01:15 字数 6265 阅读 6226

1楼:匿名用户

没有上下文,只给这么个**片段,除非碰巧有熟悉这段**的,否则,绝大多数人没办法帮你。

matlab二次规划问题

2楼:兔子和小强

这个优化目标不是二次型、约束也不是线性约束,无法用quadprog求解,可以考虑用fmincon来解。

新建个mycon.m文件,里面的内容是:

function[c,ceq]=mycon(x)

u=[3.60.8288.38.33.95.5]';

l=[2.60.7177.37.32.95.0]';

%25个不等式约束

c=[27-x(1)*x(2)^2*x(3);

397.5-x(1)*x(2)^2*x(3)^2;

1.93*x(4)^3-x(2)*x(3)*x(6)^4;

1.93*x(5)^3-x(2)*x(3)*x(7)^4;

sqrt((745*x(4)/x(2)/x(3))^2+16.9e6)-110*x(6)^3;

sqrt((745*x(5)/x(2)/x(3))^2+157.5e6)-85*x(7)^3;

x(2)*x(3)-40;

x(1)-12*x(2);

5*x(2)-x(1);

x-u;

l-x;

1.5*x(6)+1.9-x(4);

1.1*x(7)+1.9-x(5)];

%等式约束

ceq=;

end调用的程序是:

%%最优化目标函数f

f=@(x)0.7854*x(1)*x(2)^2*(3.3333*x(3)^2+14.

9334*x(3)-43.0934)-1.508*x(1)*(x(6)^2+x(7)^2)+7.

477*(x(6)^3+x(7)^3)+0.7854*(x(4)*x(6)^2+x(5)*x(7)^2);

x=fmincon(f,ones(7,1),,,,,,,@mycon,optimset('display','off'))

f(x)

解出来的值与你的最终答案基本一样,除了x(5)=7.7以外。

你所贴的最终答案是错的,如果x(5) = 7.3,那么g25约束无法满足。

3楼:匿名用户

约束条件非线性,quadprog做不了吧

这些啥意思? g8(x) ----- : g9(x)

matlab求解二次规划问题 5

4楼:匿名用户

题主给出的用matlab求解二次规划问题,运行结果总是求lambda负无穷大,x,y近于零。分析和运行题主的**,其根本的错误是缺少lambda变量的下限值,应该为vlb=[0;0;0];再一个问题没有利用x+y=7的等式条件,应该可以这样来补充,aeq=[1,1,0];beq=[7];

纠正上述错误,后运行可以得到如下的解。

k1 = 3.0071 %x

k2 = 3.9929 %y

k3 = 0.995 %λ

fval = -13.016

matlab 求解二次规划

5楼:匿名用户

lingo的确可以解二次规划,如果想让某变量x只能取值0-1的话,用@bin(x)即可

我写个最简单的例子

--------------------------------

min x1^2+3*x2-x3+4*x^2

s.t. x1+x2-x3-x4>0

x1*x2=-6

x1>3

x2∈r

x3>=0

x4∈-----------------------------------

lingo程序的写法(最简单的写法)

-----------------------------------

model:

min=x1^2+3*x2-x3-4*x4^2;

x1+x2-x3-x4>0;

x1*x2=-6;

x1>3;

@free(x2);! 感叹号后面的是说明语句。lingo默认变量均为非负的。free表示该变量无约束范围。

@bin(x4);!bin表示该变量为0-1变量。

end------------------------------------

运行后即可得到解答。

关于lingo更进一步的用法请参阅相关教程,这里从略。

6楼:匿名用户

是整数规划?

lingo不是解线性规划的么?

能把问题说的清楚些么?

matlab有个最优化工具箱(optimization tools),里面有个单独解二次规划的模块。

二次规划是np-hard问题,一般来讲,变量超过一定尺度(14个)就不能在有限的时间内解决了。

请大神帮忙用matlab解一下二次规划问题,谢谢

7楼:我行我素

可这样:

f=@(x)-702.5*x(1)*x(2)-750*x(1)*x(4)-625*x(2)*x(3)-350*x(2)*x(4);

a=[700,450,0,0;0,0,762.5,525];b=[200;150];

aeq=[1,1,0,0;0,0,1,1];beq=[1;1];lb=zeros(4,1);[x,f]=fmincon(f,ones(4,1)*0.5,a,b,aeq,beq,lb)

结果是:

x =0.1392

0.8608

0.0000

1.0000

f =-489.8553

也就是,x1=0.1392,x2=0.8608,y1=0,y2=1,maxf=489.8553

急求一份用matlab求解二次规划问题的**。

8楼:匿名用户

楼上正解,不过用doc+quadprog或者helpwin+quarprog界面更好。

以下是help+quadprog得到的用法,英文不懂的查字典…

采纳吧~少年~

我最近在研究matlab的并行计算~哦吼吼

quadprog quadratic programming.

x=quadprog(h,f,a,b) attempts to solve the quadratic programming problem:

min 0.5*x'*h*x + f'*x subject to: a*x <= b

xx=quadprog(h,f,a,b,aeq,beq) solves the problem above while additionally

satisfying the equality constraints aeq*x = beq.

x=quadprog(h,f,a,b,aeq,beq,lb,ub) defines a set of lower and upper

bounds on the design variables, x, so that the solution is in the

range lb <= x <= ub. use empty matrices for lb and ub

if no bounds exist. set lb(i) = -inf if x(i) is unbounded below;

set ub(i) = inf if x(i) is unbounded above.

x=quadprog(h,f,a,b,aeq,beq,lb,ub,x0) sets the starting point to x0.

x=quadprog(h,f,a,b,aeq,beq,lb,ub,x0,options) minimizes with the default

optimization parameters replaced by values in the structure options, an

argument created with the optimset function. see optimset for details.

used options are display, diagnostics, tolx, tolfun, hes**ult, largescale,

maxiter, precondbandwidth, typicalx, tolpcg, and maxpcgiter. currently,

only 'final' and 'off' are valid values for the parameter display ('iter'

is not available).

x=quadprog(hinfo,f,a,b,aeq,beq,lb,ub,x0,options,p1,p2,...) passes the

problem-dependent parameters p1,p2,... directly to the hmfun function

when optimset('hes**ult',hmfun) is set. hmfun is provided by the user.

pass empty matrices for a, b, aeq, beq, lb, ub, xo, options, to use the

default values.

[x,fval]=quadprog(h,f,a,b) returns the value of the objective function at x:

fval = 0.5*x'*h*x + f'*x.

[x,fval,exitflag] = quadprog(h,f,a,b) returns an exitflag that describes the

exit condition of quadprog. possible values of exitflag and the corresponding

exit conditions are

1 quadprog converged with a solution x.

3 change in objective function value **aller than the specified tolerance.

4 local minimizer found.

0 maximum number of iterations exceeded.

-2 no feasible point found.

-3 problem is unbounded.

-4 current search direction is not a direction of descent; no further

progress can be made.

-7 magnitude of search direction became too **all; no further progress can

be made.

[x,fval,exitflag,output] = quadprog(h,f,a,b) returns a structure

output with the number of iterations taken in output.iterations,

the type of algorithm used in output.algorithm, the number of conjugate

gradient iterations (if used) in output.cgiterations, a measure of first

order optimality (large-scale method only) in ouput.firstorderopt, and the

exit message in output.message.

[x,fval,exitflag,output,lambda]=quadprog(h,f,a,b) returns the set of

lagrangian multipliers lambda, at the solution: lambda.ineqlin for the

linear inequalities a, lambda.eqlin for the linear equalities aeq,

lambda.lower for lb, and lambda.upper for ub.

二次根式的几何意义如何理解,二次根式的几何意义

1楼 执著着的快乐 二次根式 的简单性质和几何意义 1 a 0 0 双重非负性 2 2 a a 0 任何一个非负数都可以写成一个数的平方的形式 3 c a 2 b 2表示直角三角形内,斜边等于两直角边的平方和的根号,即勾股定理推论。 二次根式的几何意义 2楼 袁楽 1 任何一个数都可以写成一个数的平...

二次根式的注意事项

1楼 匿名用户 1 二次根式具有双重非负性,符号表示为 a 0,a 0。 2 二次根式加减时要注意是同类二次根式相加减。 3 二次根式乘除时要注意是被开方数相乘除。 4 二次根式在计算和化简时要注意正负性和取值范围,如 1 a a ,然后根据正负性去除绝对值符号。 2 在分母或除数上出现字母时,注意...

二次求导等于零的几何意义是什么,二次求导等于零的几何意义是什么比如说二阶求导Y‘’

1楼 午后蓝山 是拐点,就是凸凹转换点。 2楼 就是拐点。可以理解为加速度由正变负或由负变正的点。 3楼 匿名用户 拐点。就是转换的地方。 二次求导等于零的几何意义是什么比如说二阶求导y 4楼 为你写歌金牛 二阶导数,是原函数导数的导数,将原函数进行二次求导。一般的,函数y f x 的导数y f x...