[R] Optimization inconsistencies

Hans W Borchers hwborchers at googlemail.com
Fri May 18 09:10:41 CEST 2012


peter dalgaard <pdalgd <at> gmail.com> writes:
> 
> On May 18, 2012, at 00:14 , Nathan Stephens wrote:
> 
> > I have a very simple maximization problem where I'm solving for the vector
> > x:
> > 
> > objective function:
> > w'x = value to maximize
> > 
> > box constraints (for all elements of w):
> > low < x < high
> > 
> > equality constraint:
> > sum(x) = 1
> > 
> > But I get inconsistent results depending on what starting values I. I've
> > tried various packages but none seem to bee the very solver in Excel. Any
> > recommendations on what packages or functions I should try?

Use the equality constraint to reduce the dimension of the problem by one.
Then formulate the inequality constraints and apply, e.g., constrOptim().
You can immediately write down and use the gradient, so method "L-BFGS-B" is
appropriate.

Because the problem is linear, there is only one maximum and no dependency
on starting values. 

If you had supplied some data and code (which packages did you try, and how?),
a more concrete answer would have been possible. My own test example worked
out of the box.

Hans Werner


> Sounds like a linear programming problem, so perhaps one of the packages 
> that are specialized for that? lpSolve looks like it should do it.
> 
> (As a general matter: There's nothing simple about constrained maximization 
> problems, and generic optimizers aren't really geared towards dealing with 
> large sets of constraints.)
> 
> > 
> > --Nathan



More information about the R-help mailing list