[R] optimization subject to constraints
Gildas Mazo
gildas.mazo at curie.fr
Tue Aug 10 14:59:54 CEST 2010
Thanks, but I still cannot get to solve my problem: consider this simple
example:
########
f <- function(x){
return(x[1]+x[2])
} # objective function
g <- function(x){
return(x[1]^2+x[2]^2)
} # constraint
#########
I wanna Maximize f(x) subject to g(x) = 1. By hand the solution is
(1/sqrt(2), 1/sqrt(2), sqrt(2)). This is to maximizing a linear function
subject to a nonlinear equality constraint. I didn't find any suitable
function in the packages I went through.
Thanks in advance,
Gildas
Spencer Graves a écrit :
> To find every help page containing the term "constrained
> optimization", you can try the following:
>
>
> library(sos)
> co <- findFn('constrained optimization')
>
>
> "Printing" this "co" object opens a table in a web browser with
> all matches sorted first by the package with the most matches and with
> hot links to the documentation page.
>
>
> writeFindFn2xls(co)
>
>
> This writes an excel file, with the browser table as the second
> tab and the first being a summary of the packages. This summary table
> can be made more complete and useful using the "installPackages"
> function, as noted in the "sos" vignette.
>
>
> A shameless plug from the lead author of the "sos" package.
> Spencer Graves
>
>
> On 8/9/2010 10:01 AM, Ravi Varadhan wrote:
>> constrOptim can only handle linear inequality constraints. It cannot
>> handle
>> equality (linear or nonlinear) as well as nonlinear inequality
>> constraints.
>>
>> Ravi.
>>
>> -----Original Message-----
>> From: r-help-bounces at r-project.org
>> [mailto:r-help-bounces at r-project.org] On
>> Behalf Of Dwayne Blind
>> Sent: Monday, August 09, 2010 12:56 PM
>> To: Gildas Mazo
>> Cc: r-help at r-project.org
>> Subject: Re: [R] optimization subject to constraints
>>
>> Hi !
>>
>> Why not constrOptim ?
>>
>> Dwayne
>>
>> 2010/8/9 Gildas Mazo<gildas.mazo at curie.fr>
>>
>>> Dear R users,
>>>
>>> I'm looking for tools to perform optimization subject to constraints,
>>> both linear and non-linear. I don't mind which algorithm may be
>>> used, my
>>> primary aim is to get something general and easy-to-use to study
>>> simples
>>> examples.
>>>
>>> Thanks for helping,
>>>
>>> Gildas
>>>
>>> ______________________________________________
>>> 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<http://www.r-project.org/posting
>>
>> -guide.html>
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>>
>> ______________________________________________
>> 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.
>
More information about the R-help
mailing list