≡ Menu

Optimization in graduate business programs, including the MBA and CFA programs, has mostly been Linear Programming using Solver. Today, most business schools increase expectations and teach more in operations, including optimization using specialized software. Our operations management tutors can help you learning optimization using R programming/R Studio.

The basic optimizing functions inbuilt into base R are optimize and optim. Optimize is used when working with a single function, and Optim is used when you are working with multiple functions.

One Dimension Optimizing in R

The basic structure of an optimization function includes an objective, constraints, bounds=NULL, types=NULL, and maximum =FALSE. The optimize function also allows you to set constraints. The R documentation of optimize is available here.

Once you have defined the function using the Optimize function, you are usually interested to see the the value that maximizes the function and the maximum value of the function. The R function name$maximum give you the variable (decision variable) that maximizes the function. Use the R function name$objective give you the maximum value of the objective function.

Optimizing Multi-Dimensional Problems

If you need to optimize multiple dimensions, you can use the inbuilt function Optim. The R documentation of optim is available here. Optim requires you to specify the par values and the function at the minimum. It has many other optional features including the method of optimization to be used. The default optimization method is Nelder and Mead (1965), This method works for most uses but can be quite slow. Currently other methods you can specify include “Nelder-Mead”, “BFGS”, “CG”, “L-BFGS-B”, “SANN”, and “Brent”. This level of understanding is not covered in most MBA/CFA courses and so we do not expect to tutor the different types of optimization methods.

Another interesting feature of the optim function in R programing is that the default is set to minimize the function. If you are interested in maximizing the function, you are instructed to “invert” – or to change the signs!

To examine the results, name$par gives you the optimal par values and name$value gives you the objective value for the optimal par values. There is a lot more detail to the optim function in R. Please visit the R documentation page of optim for more.

Other Optimization Packages in R

The basic optimizing functions inbuilt into base R are optimize and optim. However, There are a number of other packages that are built for specific types of optimization. These include lpSolve for Linear Programming using the function lp(…), quadprog for Quadratic Programming using the function solve.QP(…), optimx for Non-Linear Programming using the function optimx(…), etc.