help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help in using nonlin_min


From: Hitesh Harnal
Subject: Help in using nonlin_min
Date: Wed, 14 Dec 2016 08:25:36 -0500

hi,
I am new to Octave, having just completed machine learning course on coursera. It's a great tool, thanks for building it! 
I wanted to clarify if I am using the nonlin_min correctly. I have written a trivial example below where the objective is to minimize sum of elements of vector. Constraint is that sum of squares of elements is more than zero.

%========
function [val gradient_val] = f_obj(x)
   val = sum(x);
   grad_val = ones(length(x),1);
end
%========
function [val gradient_val] = constraint(x)
  val = sumsq(x);
  grad_val = x.*2;
end
%========
x_init = ones(10,1);
X_opt = nonlin_min(@(x)f_obj(x), x_init, optimset("inequc", {@(x)constraint(x)}));

Can you please tell if this is the correct syntax for using nonlin_min? In particular will gradients that I have as the second output of f_obj and constraint functions will get used by nonlin_min? 

I have struggled past few days trying to find the right syntax and more examples, so will appreciate the help.

Thanks,
Hitesh

reply via email to

[Prev in Thread] Current Thread [Next in Thread]