Decide Between Problem-Based and Solver-Based Approach
Use a Global Optimization Toolbox solver to optimize a nonsmooth function, search for a global solution, or solve a multiobjective problem. Use the problem-based approach for a simpler way to set up and solve problems.
The problem-based approach has these general advantages:
Easier to set up and debug. In the problem-based approach, you use symbolic-style variables to create optimization expressions and constraints. In the solver-based approach, you must place all variables into a single vector, which can be awkward, especially with variables of large or differing dimensions.
Easier to run different solvers on the same problem. Some solvers have different calling syntaxes. For example, the syntax for nonlinear constraints in
surrogateoptis different from the syntax in all other solvers. To run a problem using both
surrogateoptand another solver in the solver-based approach, you have to create different versions of the objective function. In contrast, the problem-based approach takes care of translating syntaxes, so you need to change only the solver name and possibly some options.
Able to obtain an appropriate solver automatically. The
solvefunction automatically chooses a solver that can handle your objective and constraints. In the solver-based approach you must choose an appropriate solver.
Able to automatically speed the solution of problems where the objective and nonlinear constraints are calculated in the same time-consuming function (typically simulations). Frequently, a simulation or ODE solver calculates the objective and nonlinear constraints in the same function. When you convert the time-consuming function to an optimization expression using
fcn2optimexpr, you can save solution time by setting the
true. This setting causes the solver to avoid recalculating the time-consuming function when evaluating the objective and nonlinear constraints. Achieving this time savings in the solver-based approach can require extra programming, as shown in the example Objective and Nonlinear Constraints in the Same Function.
The problem-based approach has these limitations when used with Global Optimization Toolbox solvers:
No equation problems. You cannot use a Global Optimization Toolbox solver to solve an equation problem of type
EquationProblem. However, you can solve a feasibility problem by specifying a zero objective function and any constraints accepted by the solver. For an example, see Solve Feasibility Problem Using surrogateopt, Problem-Based.
No custom data types. To use a custom data type with
simulannealbnd, you must use the solver-based approach. For examples, see Custom Data Type Optimization Using the Genetic Algorithm and Multiprocessor Scheduling Using Simulated Annealing with a Custom Data Type.
No vectorization (see Using Vectorization). If your objective function and any nonlinear constraint functions are written in a vectorized fashion, you must use the solver-based workflow to gain the benefits of vectorization. If you set the
UseVectorizedoption in the problem-based approach, you get a warning, not improved performance.
No initial point or population for
surrogateopt. See Initial Points for Global Optimization Toolbox Solvers.
You must convert variables for options that relate to the solver-based approach. For example, custom output functions use solver-based syntax. Use
varindexto convert problem-based variables to solver-based indices. For an example, see Set Options in Problem-Based Approach Using varindex.
No visual interface. The Optimize Live Editor task currently applies only to the solver-based approach.