[R] Optimization

Berwin A Turlach berwin at maths.uwa.edu.au
Wed Jul 18 03:26:58 CEST 2007


G'day Moshe,

On Tue, 17 Jul 2007 17:32:52 -0700 (PDT)
Moshe Olshansky <m_olshansky at yahoo.com> wrote:

> This is partially true since both the function to be
> maximized and the constraint are non-linear. 

I am not sure what your definition of non-linear is, but in my book,
and I believe by most mathematical/statistical definitions, the
objective function is linear.

The only non-linearity comes in through the second constraint.

> One may substitute 1-x1-x2 for x3 and use (let say) Lagrange
> multipliers to get two non-linear equations with 2
> unknowns for which there should be a function solving
> them. 

Why would you want to use Lagrange multipliers?  Isn't that a bit of an
overkill?  Once you substitute 1-x1-x2 for x3 in the second constraint,
you have a quadratic equations in x1 and x2.  So for any given value of
x1 you can solve for x2 (or for any given value of x2 you can solve for
x1).  They still teach how to solve quadratic equations at school,
don't they? ;-)

> Then you must find the points where the
> constraint function intersects with the triangle
> {x1>=0,x2>=0,x1+x2<=1}, which is easier (for each of
> the 3 edges you get a non-linear equation in one
> variable).

Even easier.  Take an x1 between 0 and 1.  If for that x1 the quadratic
equation in x2 has no real solution, then x1 is not feasible.
Otherwise find the values of x2 that solve the equation.  Use each of
these values together with x1 to calculate corresponding values of x3.
Then check these tuples for feasibility.  If they are feasible,
evaluate the objective function and return the tuple with the larger
function value.

All the calculations outlined in the paragraph above are easily
implemented in R, e.g. the function polyroot() returns the roots of a
polynomial.

Cheers,

	Berwin

=========================== Full address =============================
Berwin A Turlach                            Tel.: +65 6515 4416 (secr)
Dept of Statistics and Applied Probability        +65 6515 6650 (self)
Faculty of Science                          FAX : +65 6872 3919       
National University of Singapore     
6 Science Drive 2, Blk S16, Level 7          e-mail: statba at nus.edu.sg
Singapore 117546                    http://www.stat.nus.edu.sg/~statba



More information about the R-help mailing list