Re: [R] Bad optimization solution

From: Berwin A Turlach <berwin_at_maths.uwa.edu.au>
Date: Tue, 08 May 2007 12:10:25 +0800

G'day Paul,

On Mon, 7 May 2007 22:30:32 +0100
"Paul Smith" <phhs80_at_gmail.com> wrote:

> I am trying to perform the below optimization problem, but getting
> (0.5,0.5) as optimal solution, which is wrong;

Why?

As far as I can tell you are trying to minimize |x1-x2| where x1 and x2 are between 0 and 1. The minimal value that the absolute function can take is zero and any point (x1,x2)=(x,1-x) where x is between 0 and 1 will achieve this value and also respect the constraints that you have imposed. Hence, any such point, including (0.5,0.5) is a solution to your problem.

> the correct solution should be (1,0) or (0,1).

Why? Unless there are some additional constraint that you have not told optim() (and us) about, these are two possible solutions from an infinite set of solutions. As I said, any point of the form (x, 1-x) with x between 0 and 1 is a solution to your problem, unless I am missing something....

Cheers,

        Berwin



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 08 May 2007 - 04:21:08 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 08 May 2007 - 06:31:03 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.