Problem minimizing with sqp Classic List Threaded 5 messages Open this post in threaded view
|

Problem minimizing with sqp

 I need to minimize a function of two variables. It looks like sqp is the sort of function I should use for that.As a test to make sure I was using the function properly, I put in the following paraboloid:f = @(v) 2*v(1).^3 + 3*v(2).^4;[x, obj, info, iter, nf, lambda] = sqp([1,3],f)was given the resultx =  -1.1753e+11   1.7162e+08Clearly this is completely wrong - the minimum of the function f is at (0,0)! Have I done something wrong here or is it a bug?- Brett Green
Open this post in threaded view
|

RE: Problem minimizing with sqp

 Brett, From: Help-octave [mailto:help-octave-bounces+allen.windhorn=[hidden email]] On Behalf Of Brett Green > I need to minimize a function of two variables. It looks like sqp is the > sort of function I should use for that. > As a test to make sure I was using the function properly, I put in the > following paraboloid: > f = @(v) 2*v(1).^3 + 3*v(2).^4; > [x, obj, info, iter, nf, lambda] = sqp([1,3],f) > was given the result > x = >   -1.1753e+11 >    1.7162e+08 > Clearly this is completely wrong - the minimum of the function f is at (0,0)! > Have I done something wrong here or is it a bug? Look carefully, it's not a paraboloid.  And the minimum isn't at [0,0] -- f([0,0]) = 0 -- because at [-2,0] the value is -2, which is less than 0. Maybe you meant to restrict the values of x to >0, in which case you need a constraint function?  Or maybe the exponent 3 of x(1) is meant to be 4? Regards, Allen
Open this post in threaded view
|

RE: Problem minimizing with sqp

 In reply to this post by BGreen Brett, Sorry, I meant to say: ...because at [-1,0] the value is -2, which is less than 0. Regards, Allen
 In reply to this post by BGreen On Fri, Jul 12, 2019 at 3:52 PM Brett Green <[hidden email]> wrote:I need to minimize a function of two variables. It looks like sqp is the sort of function I should use for that.As a test to make sure I was using the function properly, I put in the following paraboloid:f = @(v) 2*v(1).^3 + 3*v(2).^4;[x, obj, info, iter, nf, lambda] = sqp([1,3],f)was given the resultx =  -1.1753e+11   1.7162e+08Clearly this is completely wrong - the minimum of the function f is at (0,0)! Have I done something wrong here or is it a bug?- Brett Green if you tryf = @(v) abs(2*(v(1)-1).^3) + 3*v(2).^4;[x, obj, info, iter, nf, lambda] = sqp([1,3],f)it finds a minimum!!! at +1-- DAS How embarrassing... I had put a parabola there earlier, changed it to experiment, left for a meeting, and had forgotten about the change by the time I returned.Thank you both for pointing that out! I'm relieved that it was something so simple.- Brett GreenOn Fri, Jul 12, 2019 at 5:26 PM Doug Stewart <[hidden email]> wrote:On Fri, Jul 12, 2019 at 3:52 PM Brett Green <[hidden email]> wrote:I need to minimize a function of two variables. It looks like sqp is the sort of function I should use for that.As a test to make sure I was using the function properly, I put in the following paraboloid:f = @(v) 2*v(1).^3 + 3*v(2).^4;[x, obj, info, iter, nf, lambda] = sqp([1,3],f)was given the resultx =  -1.1753e+11   1.7162e+08Clearly this is completely wrong - the minimum of the function f is at (0,0)! Have I done something wrong here or is it a bug?- Brett Green if you tryf = @(v) abs(2*(v(1)-1).^3) + 3*v(2).^4;[x, obj, info, iter, nf, lambda] = sqp([1,3],f)it finds a minimum!!! at +1-- DAS 