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.
problem-based characteristics
advantages | limitations |
---|---|
easier to set up and debug | no equation problems |
easier to run different solvers on the same problem | no custom data types |
obtain an appropriate solver automatically | no checkpoint file for
surrogateopt |
automatically speed the solution of problems where the objective and nonlinear constraints are calculated in the same time-consuming function (typically simulations) | no vectorization |
you must convert variables for options that relate to the solver-based approach |
advantages:
easier to set up and debug. in the problem-based approach, you use symbolic-style variables to create optimization expressions and constraints. see problem-based global optimization setup. 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
surrogateopt
is different from the syntax in all other solvers. to run a problem using bothsurrogateopt
and 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.obtain an appropriate solver automatically. the function automatically chooses a solver that can handle your objective and constraints. in the solver-based approach you must choose an appropriate solver.
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 argument totrue
. 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 .
limitations:
no equation problems. you cannot use a global optimization toolbox solver to solve an equation problem of type . however, you can solve a feasibility problem by specifying a zero objective function and any constraints accepted by the solver. for an example, see .
no custom data types. to use a custom data type with
ga
orsimulannealbnd
, 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 checkpoint file for
surrogateopt
. use the solver-based approach for checkpoint files in . for details, see work with checkpoint files.no vectorization (see ). 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
usevectorized
option in the problem-based approach, you get a warning, not improved performance.you must convert variables for options that relate to the solver-based approach. for example, custom output functions use solver-based syntax. use to convert problem-based variables to solver-based indices. for an example, see .