# Constraint Solver

The Constraint Solver enhances RISKOptimizer's ability to handle model constraints. When RISKOptimizer runs an optimization, it is assumed that the initial adjustable cell values satisfy all of the hard constraints, that is, the initial solution is valid. If this is not the case, the algorithm can run many simulations before finding a first valid solution. The problem is that if a model contains multiple constraints, it can be difficult to find an initial valid solution.

**Please note**: The Constraint Solver is useful when optimizing using the Genetic Algorithm, whereas OptQuest optimizations do not generally require the use of the Constraint Solver. Therefore, the information in this section is relevant only for the Genetic Algorithm.

If a RISKOptimizer model contains multiple hard constraints, and the optimization process fails with all solutions invalid, a notification will be displayed so that the Constraint Solver can be run. The Constraint Solver runs an optimization in a special mode, in which the goal is to find a solution that satisfies all the hard constraints. The optimization progress is shown in the same way as in regular optimizations. The Progress Window shows the number of constraints that are met in the original and best solutions.

A Constraint Solver optimization stops automatically when a solution meeting all the hard constraints is found; it can also be stopped by clicking a button in the progress window or in the RISKOptimizer Watcher.

There is no need to set up the Constraint Solver before a run. It uses the settings specified in the model. The only difference is the optimization goal, to find a solution that satisfies all the hard constraints.

When running the Constraint Solver, the **Stopping Options** tab has an additional *recommended* option to Set Seed to Value Used in this Optimization. This option is provided because if the random number generator seed is not fixed, then constraints that were met during a Constraint Solver run might not be met during a regular-mode run, even if adjustable cell values are the same (since simulation results depend on the seed). This option is disabled if the seed was fixed in the **Sampling Settings** dialog before a Constraint Solver run.