## Integer Constraints in Nonlinear Problem-Based Optimization

To solve a nonlinear optimization problem with integer constraints using the problem-based approach, follow one of these processes:

When you use an external solver and call `prob2struct`, you might need to specify the `Solver` name-value argument.

Note

For a nonlinear problem with integer constraints, if you do not have a Global Optimization Toolbox license, you must include the `Solver` argument.

Even if you have a Global Optimization Toolbox license, you still might need to specify the `Solver` name-value argument. An external solver can expect the problem structure to be in a form that corresponds to a particular solver. For example, for a problem with linear and integer constraints and a quadratic objective function, an external solver might require the objective function to be expressed as matrices H and f in the expression ½xTHx + fTx. To obtain these matrices, specify the `'quadprog'` solver by using the `Solver` name-value argument.

`problem = prob2struct(prob,"Solver","quadprog");`

If you do not specify the `quadprog` solver, the resulting problem structure can contain a function handle for the objective function rather than matrices. In either case, the resulting problem structure contains the integer variables in the `intcon` field.

Note

For a nonlinear problem with integer constraints, when you specify a solver that does not handle integer constraints, `prob2struct` issues a warning that the solver cannot solve the resulting structure. If you then try to solve the problem by calling the solver on the problem structure, the solver ignores the integer constraints. In this case, the solution is not the solution to the original problem, but is instead the solution to the problem without integer constraints.