Re: [R] Bad optimization solution

From: Berwin A Turlach <>
Date: Tue, 08 May 2007 12:10:25 +0800

G'day Paul,

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

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


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....


        Berwin mailing list PLEASE do read the posting guide 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 Please read the posting guide before posting to the list.