Re: [R] Constrained optimization

From: Paul Smith <phhs80_at_gmail.com>
Date: Tue, 08 Jul 2008 17:46:07 +0100

On Tue, Jul 8, 2008 at 11:28 AM, Kanak Choudhury <kanak562265_at_gmail.com> wrote:
> i have a function like
>
> 1+sin(a+bx) where -pi/2<=a+bx<=pi/2
>
> i made a progrom using constrOptim() function but it is not giving good
> result. it depends on the initial value. but when i am doing simulation it
> is impossible of find the best initial value for every step. also i am not
> exactly sure how to input the restriction though i have read the help file
> of the function. here x is a set of values. would u please send me some
> instruction to find the best result from the obtimization.

Actually, there is no need to use R to optimize such a function. In truth, the analytical solution for your problem, in case you are wanting to maximize, is:

a + b x = pi/2;

in case of minimization, the solution is:

a + b x = - pi/2.

Paul



R-help_at_r-project.org 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 Jul 2008 - 16:50:30 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 Jul 2008 - 17:31:25 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.

list of date sections of archive