Minimizing a function using the BFGS method

I can not minimize it using the fminunc function. While respecting that both alpha and beta values are between 0 and 1. Thanks!

回答(1 个)

John D'Errico
John D'Errico 2016-7-7
编辑:John D'Errico 2016-7-7
You cannot do so using BFGS either. However, you COULD use FMINCON to do so. And if you have fminunc, then you have fmincon.
So what is the point of this question? In fact, you have no question here that I see. Writing your own tools for something when you already have professionally written tools to do the same thing is just a waste of time.

8 个评论

Hello John, When I try to minimize the function with the following code :
>> x0 = [0,0];
>> A=[1,0];
>> b=[0];
>> Aeq=[0,1];
>> beq=0;
>> x = fmincon(mFunction,x0,A,b,Aeq,beq)
the compiler gives me the following error
Error using mFunction (line 41)
Not enough input arguments.
x = fmincon(@(x)mFunction(x(1),x(2)),x0,A,b,Aeq,beq)
Best wishes
Torsten.
Thanks so much Torsten! it works wonderfully.
That just means you did not use fmincon properly, as shown how by Torsten.
You are right Jhon. I think I made a mistake at the initial point. What do you think?
Can you enlighten me your answer John? Thanks!
Torsten showed you how to do it.
You made a mistake in not formulating your function properly. First, an optimizer passes in a vector of unknowns. Your function has TWO arguments, two unknowns. So Torsten showed you that the function needs to be passed its arguments properly.
Next, when you call it like this:
x = fmincon(mFunction,x0,A,b,Aeq,beq)
MATLAB does not understand that you want to pass a function to fmincon. It sees the function and tries to evaluate it instead. So Torsten showed you how to use a function handle.
Thanks Jhon for your help!

请先登录,再进行评论。

类别

标签

提问:

2016-7-7

编辑:

2016-7-8

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by