Solving Nonlinear Models using the Default Solver

Microsoft Solver Foundation provides support for solving nonlinear models. To solve constrained nonlinear models, Solver Foundation includes the hybrid local search (HLS) solver. The HLS solver is a general purpose solver that can attempt to solve any Optimization Modeling Language (OML) model, or any model that you create by using Solver Foundation Services. The HLS solver is the default solver for nonlinear programming models, mixed integer nonlinear programming models, and for any model that includes the trigonometric functions added in Microsoft Solver Foundation 3.0.

Important noteImportant

Although you can use the HLS solver with any model type by using an HLS directive or by registering the HLS solver in a configuration file, in most scenarios you achieve better results by using a more specific solver, such as the simplex solver.

The following considerations apply to the HLS solver:

  • It does not guarantee optimal results.

  • It does not match the support for linear terms that are provided by some other Solver Foundation solvers.

  • It does not provide infeasibility detection, but continues solving until it finds an optimal solution.

You can use the RunUntilTimeout property in the HybridLocalSearchDirective class to specify when a solver should stop solving. If RunUntilTimeout is set to true, the solver continues to search for better solutions until the timeout expires. Whenever the solver finds a better solution, it invokes the callback function provided by the Solving event. If RunUntilTimeout is set to false, the solver stops solving when it finds a local optimal solution.

Although the Excel add-in does not support event-based programming, you can set a similar property by using a Hybrid Local Search directive on the Directives tab of the Modeling Pane.

Use the following recommendations to improve the performance of the HLS solver:

  • Provide a range for decision variables if you can. Set the range of a decision instead of using a constraint, if the same effect can be achieved in a decision.

    For example, in OML use

    Decisions[Reals[-10, 10], x]

    instead of

    Decisions[Reals, x]
    Constraints[ -10 <= x <= 10]
  • If you are using Solver Foundation Services, try to use SetInitialValue(Rational, Object[]).

  • The HLS solver typically finds solutions quickly when there is a dense solution space, that is, the model is underconstrained.

  • Review your model and remove nonessential constraints, or change the model if possible so that a more specific solver, such as the Simplex solver, can accept it.


    In the Excel add-in, click Summary to verify the model type determined by Solver Foundation.

  • When you debug, add constraints one at a time or in small groups, and test the performance impact with each new addition.