Skip to content

Commit

Permalink
Modified find_max_indices
Browse files Browse the repository at this point in the history
  • Loading branch information
ShrayanRoy committed Apr 9, 2024
1 parent 757cd6b commit 219cd41
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/optimizer.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
find_max_indices <- function(vec,k = 3) {

sorted_indices <- order(vec, decreasing = TRUE)
max_indices <- sorted_indices[1:k]
max_indices <- sorted_indices[1:min(length(vec),k)]

return(max_indices)
}
Expand Down Expand Up @@ -61,7 +61,7 @@ f <- function(x) {
return(-(sin(x) + sin(2*x) + cos(3*x) + log(x + 1) + sqrt(x)))
}

result <- gridStepSearch(f, lower_bound = 1, upper_bound = 10,
result <- gridStepSearch(f,lower_bound = 7, upper_bound = 8.2,show.prog = TRUE,
initial_step_size = 1, min_step_size = 0.001, max_iter = 20)
print(result)
curve(f(x),from = 1,to = 10)
Expand Down

0 comments on commit 219cd41

Please sign in to comment.