- I hope you have a FUNCTION, not a script. Learn to use functions.
- You will need to provide a VECTOR of three inputs, not three distinct inputs, as any optimizer will work with vectors of numbers. But they do not want to deal with functions that take multiple inputs, as then the interface would be far too complicated. So package your three variables into one vector. If neccesary, the easy solution is to just wrap your function inside another that takes a vector, then unpacks them into three variables, and passes them into your existing function.
- Do these three unknowns have constraints? Are there bounds? Are there constraints on some combination of the unknowns? Must they come from some set, such as the integers? Positive integers? All of these factors will influence what kind of optimization tool you can use, because they powerfully impact the algorithm employed.
- What kinds of mathematical manipulations are employed INSIDE your function? This part is crucial, since it will strongly impact the tool you can then use. Is everything TRULY linear inside? If so, then you should use tools that understand how to work with linear problems, because they are far more efficiently solved when you can assume linearity. Are your operations at least continuous and differentiable? If not, then you dramatically impact what solver you could use, as most presume continuity and differentiability. Lacking that forces you to use tools that can survive major issues with your function.
- Yes, the fact that you have THREE outputs, all of which are simultaneously minimized makes this an impossible problem to solve, unless you are willing to accept some form of compromise. The classical solution is called multi-criteria oprimization, where you will probably minimize a weighted sum of the objectives. You will need to choose the weights. Is one more important than the others? Are they scaled wildly differently, so a direct equally weighted sum would effectively ignore one variable compared to the others? In context of the optimization toolbox, that is the domain of the function fgoalattain. But other tools can be used as long as you are willing to combine the objectives into one on your own.
- Oh. I almost forgot to mention the question of local solutions, versus a possible global optimum. Most nonlinear objectives will have multiple solutions, thus mutiple points where the function has a minimum value, but it is likely that only one of them will be the best overall value. Since optimizers take your objective as a black box, they pass in points to the objective function, and then use the output to determine where to look next. This means they can easily stop in a local minimizer, where any direction searched away from there will yield a worse solution. (This is an important reason to understand if your objective satisfies properties of linearity and even continuity. A linear objective is far easier to work with, since then multiple solutions are not a problem, as long as there are no complex constraints to deal with.) But this last point will take you into learning ideas about basins of attraction and the importance of good starting values for any optimization. Intelligently provided constraints can be hugely valuable, both to reduce the search space (making the solver more efficient) as well as to avoid nonsensical results.