bisec_optim: General-purpose Optimization (Minimization)

View source: R/bisec-optim.R

bisec_optimR Documentation

General-purpose Optimization (Minimization)

Description

bisec_optim() found parameters which minimize target function in a given space

Usage

bisec_optim(fun, space, partition, times, trim, enlarge)

Arguments

fun

function. the function to be optimized, i.e. find minimal value. fun(c(para1, para2, ..., paran)) should return a numeric scalar where para is a numeric vector, such as

space

numeric matrix. n*2 matrix, where n is the number of parameters to fit. space[i, ] should give a the range of ith parameter, i.e. c(para1.min, para2.max). space specifies a n-dimension space, this space is uniformly partitioned into subspaces, and those subspaces which have the highest score is reserved for further partitioning. Finally we get the best space, and the centre point of this space contains the parameters we want.

partition

integer scalar. how partitions are the original range divided per parameter.

times

integer scalar. how many times should the initial range be partitioned.

trim

numeric scalar. must be positive, determine what proportion of total subranges will be reserved for the next round of partition. Let n be the number of subspaces per space, if trim >= 1, as.integer(trim); otherwise, ceiling(n^trim).

enlarge

integer scalar. how many times is the selected subrange enlarged before the next round of partition.

Details

see paras.

Value

list.

  1. value, numeric saclar. smallest function value found

  2. para, numeric vector. best parameters.

  3. space, numeric matrix. best solution space.

to do

1. partition can be a integer vector, i.e. different parameter can be partitioned for different times

Examples

bisec_optim(sum, matrix(c(0,1,0,1,0,1), 3, byrow = T), 3, 10, 4, 1)
bisec_optim(sum, matrix(c(0,1,0,1,0,1), 3, byrow = T), 3, 10, 1/3, 1)


dongzhuoer/bisecpp documentation built on May 20, 2022, 10:52 a.m.