r******n 发帖数: 351 | 1 用 fmincon 优化
x = fmincon(&myfun,x0,[],[],[],[],[],[],&mycon)
非线性的约束条件做成函数.
function [c,ceq] = mycon(x)
c = ... % Compute nonlinear inequalities at x.
ceq = x(1)+x(2)-b % Compute nonlinear equalities at x.
现在的问题是,这个约束条件mycon里有一个需要不断改变的参数b。怎么能把这个参数
从外面传到这个约束条件的函数mycon里面。 |
|
r******n 发帖数: 351 | 2 Good point. 但是如何在fmincon 中调用mycon?
x = fmincon(&myfun,x0,[],[],[],[],[],[],&mycon(b)) ?
我试过了,好像不行 |
|
a****f 发帖数: 944 | 3 I want to minimize the energy E=f(p;...). p is a vector containing a set of
parameters.
I set initial values of each element in p based on some prior knowledge.
Then I use fmincon to find the optimal p that minimizes E.
Some elements in p are constrained in a range so I set the constraints
according to the syntax of fmincon.
The result is, the elements in p without constraints do not change (the same
as initial values), the elements that are initially in their constraints do
not change either, o |
|
l*****i 发帖数: 3929 | 4 More likely your own problem than fmincon. You should read the help document
s very carefully.
Or, set display='iter' in fmincon options and see what's happening.
of
same
do
some |
|
n**o 发帖数: 11 | 5 I need to minimize f = F(X,Y,Z), subject to two conditions
1) maximizing G(X,Y,Z) w.r.t Z (I can not diferientiate G(Z).)
and 2) f(X,Z) = 0.
It is easy to implement the second condition using fmincon in matlab. but have no idea about the first condition. finmincon does not has such a constrain condition. any suggestion? thanks a lot
******************* script?
[] = fmincon(@minF, initials(x0,y0,z0), [] .. @constr)
function minF()
F = F(X,Y,Z);
function constr
how to maximize G(Z) in the constra... 阅读全帖 |
|
b***k 发帖数: 2673 | 6 ☆─────────────────────────────────────☆
iambear (iambear) 于 (Wed Sep 10 14:09:47 2008) 提到:
像那种linprog的example,就是把linprog中的目标距阵改成fmincon中的objective
function就好了,别的都一样的.那还要linprog干嘛呢,用linprog有什么好处么? 而且
感觉linprog算得很慢,是不是算法不同啊
☆─────────────────────────────────────☆
QL365 (QL) 于 (Wed Sep 10 14:28:37 2008) 提到:
fmincon will become very slow for high dimensional problem, where linear
programing is supposed to be able to solve for high dimensional problem (say
, in the scale of thousnads of var |
|
a***m 发帖数: 74 | 7 Greetings!
My function evaluation sometimes generate complex numbers when I use fmincon
, fminsearch, and fminunc. The optimizations stop or won't converge. Why
this could happen? Can I dump the imaginary part to continue the routine?
Any experience to share?
Many Thanks. |
|
k*****l 发帖数: 59 | 8 u can add parameters at the end of this function.
fmincon(@OBJFUN,x0,A,B,Aeq,Beq,VLB,VUB,@NONLCON,OPTIONS,P1,P2,...); |
|
o****r 发帖数: 57 | 9 function [c,ceq] = mycon(x,b)
......
fmincon(@mycon,[x0]........,b) |
|
a****f 发帖数: 944 | 10 When you do energy minimization problems, do you use built-in matlab
function or write your own gradient descent method ( or other methods)?
I use matlab function fmincon for a constrained optimization problem, but
the parameters don't change at all after optimization, except those that did
not satisfy the constraints are changed to meet the constraints.
Does anyone know the reason? |
|
f******k 发帖数: 297 | 11 try fminbnd or fmincon. fminsearch solves the unconstrained optimization
problem. you can provide gradient and/or Hessian if you are using fmincon.
The
is |
|
|
l*******y 发帖数: 4006 | 13 (f-x)^2+(g-y)^2, 丢到matlab里面 fmincon
问题是拟合的标准是什么, 是不是convex。 不是的话, 胡扯的可能性大 |
|
a*****e 发帖数: 176 | 14 新手问题。
用的fmincon函数,有33个未知数,program运行了大约半个小时,
出现
Maximum number of function evaluations exceeded;
increase OPTIONS.MaxFunEvals.
给的解,就是我设定的initial value
显然不对的。
一般这个option都set成多少啊?
是不是这么多未知数,一般都需要运行很长时间? |
|
a*****e 发帖数: 176 | 15 I am using the function fmincon. I need to supply a constraint function.
I have a bunch of constraint function to test. How can I make a loop over
these function?
I know how to loop over numbers, but do not know how to loop over function.
Thanks very much. |
|
a***m 发帖数: 74 | 16 Greetings!
I use fminsearch and fmincon in matlab to estimate parameters for a GARCH
model. The solution is not reliable: for example different initial values
result in different solutions, sometimes the optimization wouldn't be
reached. Because I need to estimate GARCH model for different sets of data,
it is impossible for me to debug or tweak solve for each dataset. I wonder
if there are better approach tothe problem. Any suggestions are welcome.
Many thanks! |
|
a***m 发帖数: 74 | 17 thanks, I am trying the GARCH toolbox now.
From the manual, it uses fmincon function too. |
|
d*****1 发帖数: 1837 | 18 because matlab optimization toolbox sucks |
|
o*****s 发帖数: 1445 | 19 I have a code like the following. But it is a linear constrained optimization
code. I want to solve nonlinear optimization. How can I change it? I knew
fmincon in matlab. Thanks a lot.
% [xmin,lambdamin,fxmin]=dnewtonlip('f','g',A,b,x0,tol)
%
% Given a function 'f', its gradient 'g', a feasible x0, and
% linear inequality constraints Ax>=b, use a discrete Newton method
% to minimize f, ending at a point xk, with
%
% |f(xk)-f(xk-1)| < tol*(1+|f(xk)|)
%
function [xmin,lambdamin,fxmin]=dn |
|
Y****e 发帖数: 7 | 20 用fmincon算3
个parameters,每3个都是对一个方程作最小化,3个parameter都限制在[0,1]内,有一
系列的方程(上千个。。),每一个都要输出这3个parameters。但是用matlab中的fminc
on语句算出的parameter很多都在边界点上,但是教授说在0,1上的都不可能是global
min只是local
min,他不希望看到在边界点上的取值。。怎么样才能让这些parameter在[0,1]内取到最
值点呢?
而且不可能对这一系列方程只取一个uniform initial value,怎么取uniform initial
value都有些点parameters在边界上。。。还有不太能用速度太慢的算法求,例如不能用g
a。
哪位大侠知道怎么设定option,或者这么设一个penalty
function让他不可能取值在0,1上吗(比如说值取到1就自动重取)?但是这样一个penal
ty function可能要花很多时间,或者根本不能converge。。。怎么办啊~~~急死了~~~
小弟出来乍到,不胜感激啊~~~~ |
|
|
|
j**u 发帖数: 6059 | 23 ☆─────────────────────────────────────☆
jzxu (自然) 于 (Thu Feb 8 10:21:30 2007) 提到:
发信人: lzmaths (飞刀), 信区: Mathematics
标 题: 问个matlab的问题
发信站: BBS 未名空间站 (Wed Feb 7 23:15:04 2007)
怎么求一个函数 f(x) 在区间[a,b]的最大值?
有没有直接的命令?
Thanks
☆─────────────────────────────────────☆
longhei ($$$$$$$$$$$$) 于 (Thu Feb 8 10:23:11 2007) 提到:
optimization toolbox
fmincon etc...
☆─────────────────────────────────────☆
jzxu (自然) 于 (Thu Feb 8 10:33:12 2007) 提到:
en.就像这样,不论难度,回答问题有包子,当然每天限10个,呵呵。
☆──────────── |
|
|
l*****a 发帖数: 119 | 25 search "nested function" in the help document. |
|
|
Y********x 发帖数: 322 | 27 There is a command called Bintprog in Matlab. But it seems
it does not support user-defined objective function. I mean
the ojbective function required in its form is just a
coefficients vector. Other optimization commands in Matlab
such as fmincon all support user-defind obj. ftn. I have a
kind of complex objective function and would like to define
it as a separate function. Anyone knows how to handle this? |
|
l***e 发帖数: 10 | 28 Hi, All:
I came up with an optimization problem min f(x)= 1/2 x' H x- abs(x) subject
to -c<=x<=c, and sum(x)=0. Here, H is a matrix, x is vector, c is bound.
It looks like quadratic programming. But not really.
I tried the "fmincon" in the optimzation toolbox of Matlab, but it can't
find a statisfactory solution. The problem is not convex ( I think), but
some optimization method should reach a good minima.
Anyone can help? Please! If anyone can solve this, it could be used in a
wonderful |
|
l*****i 发帖数: 3929 | 29 linprog
quadprog
fmincon |
|
|
|
b**********g 发帖数: 2012 | 32 非线性 约束的优化问题
用matlab的fmincon速度太慢了,精度也
大家有啥推荐的优化工具包吗
tomlab的snopt之类的能搞到免费的吗
要了一个dido的试用版,可惜只能搞4阶的2个输入最多的系统 |
|
l*****i 发帖数: 3929 | 33 你要是不把问题描述得更详细一些,恐怕没人能给你任何建议...
did |
|
j**u 发帖数: 6059 | 34 matlab的优化做的其实挺好的,你可能需要仔细看看manual。
did |
|
a****f 发帖数: 944 | 35 Thank you.
I tried and it only ran 2 iterations before it was terminated. The 'max
constraint' value was -6.9 in both iterations. directional derivative and
first-order optimality are both 0. Is this normal?
What does max constraint mean? should it be close to 0 at the final
iteration? I used inequality constraint, something like Ax
document |
|
Y****e 发帖数: 7 | 36 小弟在用matlab编garch(1,1)variance forecast的程序,
用fmincon算3 个parameters,每3个都是对一个garch(1,1)方程的variance作最小化
,3个parameter中两个都限制在(0,1)内,有一 系列的方程(上千个。。),每一个
都要输出这3个parameters。但是用matlab中的fminc on语句算出的parameter很多都在边
界点上,但是教授说在0,1上的都不可能是global min只是local min,他不希望看到在
边界点上的取值。。怎么样才能让这些parameter在(0,1)内取到最 值点呢?
而且不可能对这一系列方程只取一个uniform initial value,怎么取uniform initial
value都有些点parameters在边界上。。。还有不太能用速度太慢的算法求,例如不能用g
a。
哪位大侠知道怎么设定option,或者这么设一个penalty
function让他不可能取值在0,1上吗(比如说值取到1就自动重取)?但是这样一个penal
ty function可能要花很多 |
|
|
g*******g 发帖数: 46 | 38 mMaple 也有此功能
maple还有一个附带的工具包,叫 globle optimization toolbox
据他们吹很牛
matlab, fmincon |
|
j**u 发帖数: 6059 | 39 发信人: longhei ($$$$$$$$$$$$), 信区: Computation
标 题: Re: 问个matlab的问题 (转载)
发信站: BBS 未名空间站 (Thu Feb 8 10:23:11 2007), 转信
optimization toolbox
fmincon etc... |
|
e*******s 发帖数: 62 | 40 我的问题用了matlab 里面的fmincon
然后设了一些nonlinear的constraints, 居然能解,
明天再线性搜索一下,看看结果对不对
下面的意思是说找到解了吧?
Optimization terminated: first-order optimality measure less
than options.TolFun and maximum constraint violation is less
than options.TolCon.
exitflag =
1
First order optimality conditions were satisfied to the specified tolerance. |
|
|
f*********n 发帖数: 148 | 42 我对基于二阶导数的最优化算法牛顿法和基于一阶导数的算法例如共轭梯度法很熟悉。
一般认为,使用牛顿法会比基于一阶导数的算法例如共轭梯度法在很多情况下都好一些
,例如更快、更准确、更稳定。(https://cn.mathworks.com/help/optim/ug/fmincon
-interior-point-algorithm-with-analytic-hessian.html?requestedDomain=www.
mathworks.com, "When you supply a Hessian, you may obtain a faster, more
accurate solution to a constrained minimization problem.").
我的问题是,在具体什么情况下,牛顿法比基于一阶导数的算法更好?什么情况下,它
们差不多?
我看了很多书也没明白。
请您回答的时候,顺便提供参考文献。谢谢! |
|
l**********r 发帖数: 1745 | 43 选课?有意思,正好我一直以来都有这个疑问,就多说两句。
呵呵,我上了15门课(一门是自己选的去audit的,不用付钱的也没有学分的,但是该
做的作业和项目我都做了,期中考试也是考了的,期末吗,老师说你不用考了,已经可
以直接给你证书了,他比较喜欢我,觉得我聪明。其他学生除了给学分,也都有这么个
证书的,呵呵,我也挺喜欢那个老师的,是欧洲的一个prof来我们这边visiting的),
so what?
仔细想想,能用到我phd期间的项目中的,有1门?两门?打个比方,上了数值分析,告
诉你怎么矩阵分解,解线性方程组(?), who cares,我又用不着,用了那么一丁点
symbolic的东东,MATHCAD全部搞定;上了工程优化,告诉你有A方法,B方法,C方法,
各自的优势劣势,who cares,我的项目中MATLAB 的 fmincon 全部搞定;学了xx控制,
yy控制,who cares,我的项目中也用不上;学了xx-dynamics,who cares,它说的是东
,我搞的是西;学了科学计算,怎么解微分方程,各种算法,who cares, MATLAB全部
搞定;学了FEM,我... 阅读全帖 |
|
i*****r 发帖数: 1302 | 44 oops...还是fmincon是吧,我以为只能做二次的... |
|
|
i*****r 发帖数: 1302 | 46 非线性等式限制ceq有多个怎么表示法?
[c,ceq] = ....
c=...
ceq=[a;
b;
c]
是这样么? |
|
|
K****n 发帖数: 5970 | 48 也不用揪理论了,多换几个初值,用fmincon之类的,有一组函数optimization
toolbox? |
|
|
|