Using minFunc package

I am using the fminunc MATLAB function to solve my optimization problem. I want to try the minFunc package:

http://www.di.ens.fr/~mschmidt/Software/minFunc.html

When using fminunc, I defined a function funObj.m that gives me an objective value and gradient at any point "x". It also accepts several external inputs, for example, {a, b, c}, which are matrices. So the function prototype looks like this:

function [objVal,G] = funObj(x,a,b,c)

I want to use the same setting in the minFunc package. From the examples, I decided that this should work:

options.Method='lbfgs';
f = @(x)funObj(x,a,b,c);
x = minFunc(f,x_init,options);

But when I call this path, I get an error:

Error using funObj
Too many output arguments.

What is the correct way to call minFunc for my case?

** EDIT: , , minFunc. , a * (b-x) ^ 2, a, b - , x - . MATLAB :

function obj = testFunc(x,a,b)
obj = a*(b-x)^2;

fminunc ( MATLAB) :

f = @(x)testFunc(x,a,b);
x = fminunc(f,x_init);

x = 10. , minFunc?

+4
2

" , minFunc , , 'numDiff' 1 ( ) 2 ( )."

, . .

+4

. , :

minFunc(@testFunc, x_init, a, b, c)

MATLAB . , f = @(x)testFunc(x,a,b); . minFunc , a, b c x_init. , .

0

Source: https://habr.com/ru/post/1535968/


All Articles