knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

INTRODUCTION

This is a short guide for adapting functions, constraints and parameters used in experiments to search the optimum solution (or approximation) of restricted and unrestricted nonlinear optimization problems.

LISTS AND PARAMETERS

Some parameters passed to the functions inside the package need to have a specific format to ensure the correct results and operations of it.

Parameter "x.list"

In the backtracking, gradientproj, quasiNewton functions the user must have information about the initial point for the method to perform a search for the optimal point of the objective function.

This information must be passed in the form of a list that must contain the starting point, function value, and gradient evaluated at that point. In grandientproj and quasiNewton, there is verification of the correct format of the list. If the user pass only the value of the point, the function check_parameters creates a complete list with all the necessary.

#example:
#The popular Rosenbrock function 
fun1 <- function(x) 
{
  x1 <- x[1]
  x2 <- x[2]
  return( 100 * (x2 - x1)^2 + (1 - x1)^2)
}

f1 <- fun1(c(-1.2,1))
x1.list <- list(x = c(-1.2,1),
                fx = f1)
#In this case, in gradientproj and quasiNewton, the check_parameters complete the x1.list with the argument "dfx"

#other example:
#A simple quadratic function
fun2 <- function(x) 
{
  return(sum(x^2))
}

dfun2 <- function(x) 
{
  return(2*x)
}

f2 <- fun2(c(1,1))
dfx2 <- dfun2(c(1,1))
x2.list <- list(x = c(1,1), fx = f2, dfx = dfx2)

Parameter "phi"

The phi variable used in bracketing, goldensection, quadraticinterpolation, represents unimodal functions. Thus, for the operation of these numerical methods correctly, the parameter phi must be passed as a function that depends only on a unimodal variable (one-dimensional) and returns the value of the objective function evaluated at the point.

phi <- function(x) { return(x^2 + 5*x + 6) }

Parameter "obj.list"

"obj.list" is a list that has two important instances for the non-linear optimization methods: obj, which is the objective function for non-linear optimization, and df, the objective function gradient in the format of a function.

In gradientproj and quasiNewton, there is a verification of the obj.list. If the objective function is passed, the function check_parameters creates a complete list with the df function. The df function uses, by default, the calculation for central finite differences. To change this, the user must modify the parameters for calculation of the numerical gradient int the "..." parameter from the calls of a gradientproj and quasiNewton. It is recommended to read the documentation of each function.

#example:
#A simple quadratic function
obj1.list <- list(f = function(x) return(sum(x^2)),
                  df = function(x) return(2*x))

#other example:
obj2 <- function(x) {
  obj2 <- x[1]^2 + 2*x[2]^2 + 3*x[3]^2 - 2*x[1] -4*x[2] -6*x[3] + 6

  return(obj2)
}

df2 <- function(x) {
  df2 <- c(2*(x[1] - 1), 4*(x[3] - 1), 6*(x[3] - 1))
  return(df2)
}

obj2.list <- list(f = obj2,
                  df = df2)

#In gradientproj and quasiNewton, the user can pass as a parameter only the objective function:
obj3.list <- list(f = function(x) return(x[1]^4 - 8*x[1]^3 + 25*(x[1]^2) + 4*(x[2]^2) -4*x[1]*x[2] -32*x[1] + 16))

Parameter "constraint"

This list is necessary for functions with box constraints and has the following elements: xmin and xmax. The function hjalgorithm could use both for functions under constraints and unconstraints problems. Thus, when is not passed for the function, the constraints are considered that as $xmin = -Inf$ and $xmax = +Inf$.

#to avoid error messages the point must be in the range between xmin and xmax

x <- c(2.3, 4.7)
constraint <- list(xmax = c(5,5), xmin = c(-2.1, -1.0))

IMPORTANT NOTES

Maximum number of iterations

The maxNI parameter represents a maximum limit for the iterations of a method. That is, if is passed for the function a bad condition problem or that the method don't converge for the optimum point or that it is realizing a excessive number of avaliations, the process will finished for the maximum number of iterations. The value of maxNI, by default, can be verified in the documentation of each function of this package.



brunasqz/NonlinearOpMethods documentation built on Oct. 27, 2019, 5:46 a.m.