[R] Bad optimization solution

Berwin A Turlach berwin at maths.uwa.edu.au
Tue May 8 06:10:25 CEST 2007

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; 


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



More information about the R-help mailing list