Skip to content

Basic optimization question (I'm a rookie)

5 messages · FAIL PEDIA, Sarah Goslee, Bert Gunter +2 more

#
Hello, and thanks to anyone who takes the time to read this

I'm trying to learn to properly optimize a function with a constraint using
R. For example, maximize the area of a terrain with a maximum perimeter.
For this example the function would be:

     Area <- function(x,y){x*y}

The restriction would be the following function:

     Perimeter <- function(x,y){2*(x+y)}

The idea is to give a desired value to "Perimeter" and get the values of x
& y that maximize the area and respect the constraint.

I've searched online for some time, and only found a video of a dude that
plotted the functions toggling the values to find the tangent optimum point
(something useless, because the idea is to make the optimization more
efficiently than using a paper and a pencil)

Thanks again, and sorry if this question is silly.
#
Hi,

R is quite good at optimization. Here's a basic tutorial:
https://www.is.uni-freiburg.de/resources/computational-economics/5_OptimizationR.pdf

There are a LOT of possibilities:
https://cran.r-project.org/web/views/Optimization.html

Sarah

On Tue, Nov 27, 2018 at 6:19 PM FAIL PEDIA
<soloparapaginas123456789 at gmail.com> wrote:

  
    
#
Of course, this particular example is trivially solvable by hand: x ==y
==p/4 , a square.
Note also that optimization with equality constraints are generally
solvable by the method of Lagrange multipliers for smooth functions and
constraints, so that numerical methods may not be needed for relatively
simple cases.

Cheers,
Bert





On Tue, Nov 27, 2018 at 3:19 PM FAIL PEDIA <
soloparapaginas123456789 at gmail.com> wrote:

            

  
  
#
Hi,

Sarah Goslee (jn reply to? Basic optimization question (I'm a rookie)):? 
"R is quite good at optimization."

I wonder what is the experience of the R user community with high 
dimensional problems, various objective functions and various numerical 
methods in R.

In my experience with my package CatDyn (which depends on optimx), I 
have fitted nonlinear models with nearly 50 free parameters using 
normal, lognormal, gamma, Poisson and negative binomial exact 
loglikelihoods, and adjusted profile normal and adjusted profile 
lognormal approximate loglikelihoods.

Most numerical methods crash, but CG and spg often, and BFGS, bobyqa, 
newuoa and Nelder-Mead sometimes, do yield good results (all numerical 
gradients less than 1)? after 1 day or more running in a normal 64 bit 
PC with Ubuntu 16.04 or Windows 7.

Ruben
1 day later
#
I fit also model with many variables (>100) and I get good result when I 
mix several method iteratively, for example: 500 iterations of 
Nelder-Mead followed by 500 iterations of BFGS followed by 500 
iterations of Nelder-Mead followed by 500 iterations of BFGS etc. until 
it stabilized. It can take several days.
I use or several rounds of optimx or simply succession of optim.

Marc


Le 28/11/2018 ? 09:29, Ruben a ?crit?: