[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Constrained Nonlinear Optimization problem
From: |
Ben Abbott |
Subject: |
Re: Constrained Nonlinear Optimization problem |
Date: |
Fri, 02 May 2014 21:23:44 -0400 |
On May 2, 2014, at 9:18 PM, Ether Jones <address@hidden> wrote:
>
> On May 2, 2014, at 7:40 PM, Ether Jones wrote:
>
> Could someone please show me how to set up this problem in Octave?
>
> Maximize (x + y)
>
> Subject to constraints:
>
> 0 <= x <= 75
>
> 0 <= y <= 75
>
> 29.5 - sqrt(0.184*(x+y)^2 + x^2) = 0.0
>
> 45.5 - sqrt(0.184*(x+y)^2 + y^2) = 0.0
>
> I have solved it with Maxima, Python, AMPL, and Excel and get the following
> answer:
>
> x = 17.2
> y = 38.7
>
> But I'm having trouble setting it up in Octave
> Thank you.
>
>
> I should have made a few points clearer in my original post:
>
> I've read the documentation for sqp() in the Octave manual. I find it
> puzzling.
>
> I'm aware that maximization can be accomplished by making the objective
> function negative ( that's what I did for Python and Maxima, using Powell's
> COBYLA ).
>
> I'm an Octave newbie.
>
> This is not a homework problem (I'm in my 60's). It's a scaled-down example
> of a more complex engineering problem I am trying to solve.
>
> If someone would be willing to show how to transform/convert this example
> into the parameters that the Octave sqp() function requires it would be
> greatly appreciated.
Ok. My apologies. The code below solves the problem. If the syntax isn't
clear, feel free to ask for clarification.
phi = @(x) - sum (x);
lb = [0; 0];
ub = [75; 75];
h1 = @(x) 29.5 - sqrt (0.184 * sum (x)^2 + x(1)^2);
h2 = @(x) 45.5 - sqrt (0.184 * sum (x)^2 + x(2)^2);
h = @(x) [h1(x); h2(x)];
x0 = [1; 1];
x = sqp (x0, phi, [], h, lb, ub, 100, 1e-8)
Ben