Skip to content
Prev 139518 / 398506 Next

Optimization with constraint.

Andreas Klein <klein82517 <at> yahoo.de> writes:
In optimization problems, very often you have to replace an equality by two
inequalities, that is you replace  x1 + x2 = 1  with

    min f(x1,x2)= (x1)^2 + (x2)^2
    s.t.  x1 + x2 >= 1
          x1 + x2 <= 1

The problem with your example is that there is no 'interior' starting point for
this formulation while the documentation for constrOptim requests:

    The starting value must be in the interior of the feasible region,
    but the minimum may be on the boundary.

You can 'relax', e.g., the second inequality with  x1 + x2 <= 1.0001 and use
(1.00005, 0.0) as starting point, and you will get a solution:
$par
    [1] 0.5000232 0.4999768
    $value
    [1] 0.5
    [...]
    $barrier.value
    [1] 9.21047e-08

where the accuracy of the solution is certainly not excellent, but the solution
is correctly fulfilling  x1 + x2 = 1.