I'm trying to optimize a function which depends on 2 variables. These variables are population repartition, so I set boundaries to them, but when I run the code, the given answer is out of the boundaries. I am probably doing something wrong but I can't figure it out:
f(x) = first(myfun([x[1], x[2], 1-x[1]-x[2]])[1]) #function whose output should be optimized
lower = [0.0, 0.0] #lower bound for variables
upper = [1.0, 1.0] #upper bound for variables
res = optimize(f, [0.25, 0.6], lower, upper, NelderMead(), Optim.Options(show_trace=true, iterations = 10))
Optim.minimizer(res)
To explain more clearly what is my aim. myfun is a function which simulates the spreading of a virus. So giving it a distribution of population, it'll create a graph and simulate how it spreads. So here i'm trying to get the optimal value of the distribution of population in order to get the minimum amount of infected computer. The input is the distribution of population as array and the output is the number of infected computers
Thanks you for helping !