Developing By Using Solver Foundation Solvers
Solver Foundation supports continuous model programming that has linear constraints, gradient search unconstrained non-linear programming, and constraint satisfaction programming. You can use the solver-specific APIs if you know the solver that your model requires and know how to translate a model into a sequence of API calls. If the solvers are embedded in an application, it must capture the model and supply the data. Use the following steps to solve a model:
Create an instance of a solver.
Construct a model and specify goals or objectives.
Initialize solver parameters to control the logging and pivoting strategy.
Invoke the solver by using parameters to solve the model.
Process the results and report the answers.
The most basic form of optimization programming is to write a linear program (LP) to find an answer that is based on a set of decision variables, linear constraints, and limited ranges. For example, a petroleum refinery could procure crude oil from two sources, minimize the purchase costs of crude oils that differ in quality, and meet minimum production levels of gasoline, jet fuel, and machine lubricant. You can use Solver Foundation to solve this problem by using variables, bounds, and the simplex solver. You can construct the model by using the AddVariable, AddRow, and AddGoal methods. For more information, see How to: Use Linear Programming using the Solver Foundation Solver APIs.
You can configure a solver to provide statistics about the solving and then use the statistics to modify the model. For example, you can use the BranchCount, FactorCount, InnerIndexCount, PivotCount, and other properties to provide statistics about the solving. You can also use methods such as RemoveGoal to iterate and adjust the model.
Reporting Solver Results
You can configure the solver to return reports about sensitivity, infeasibility, and more. For example, you can show the sensitivity and infeasibility reports for the petroleum refining example by configuring the simplex solver parameter. For more information, see How to: Create a Custom Solver Report using the Solver APIs.
You can use quadratic programs to solve economics problems such as optimizing a portfolio. A quadratic portfolio is a technique that economist Harry Markowitz developed to balance risk and return by mixing alternative investments. In this technique, the initial data is the performance history of a set of different investments. Linear calculations are performed on this data to determine the average rates of gain or loss, and then quadratic calculations are performed to determine the covariances, which are the amounts by which the average rates vary from one another over time. By using the Markowitz formulation, you can calculate a mix of investments to lower risk and achieve a relatively high average rate of return. For example, you could solve a portfolio to determine the lowest risk given a specific rate of return. For more information, see How to: Use Quadratic Programming to Optimize a Stock Portfolio.
Linear programs where some or all variables are required to be integers are known as mixed integer linear programs (MILP). This is applicable to problems where decisions are binary such as yes/no or items cannot be fractional. MILP problems can take an exponential time to solve due to the combinatorial solving process. To reduce the complexity, you can change the algorithm heuristics or use techniques such as branch-and-bound, efficient restarts, feasibility pumps, and cutting planes.
You can also use solution quality, or the gap, to reduce the time required to find a solution. A solve that is configured to find the best strict solution may take a long time, whereas a relaxed solution is one where not all the integer constraints are satisfied. The difference between the best strict solution and a relaxed solution is known as the gap, which can be adjusted to an acceptable tolerance level.
Cutting planes can be used to remove solutions that are not integer feasible and reduce the search space. You can enable this ability by setting the MixedIntegerGenerateCuts property to true. For more information, see How to: Make Investment Decisions using Mixed Integer Linear Programming.
To find the local optimum of a general unbound and unconstrained objective function, you can use the compact quasi-newton (CQN) solver. It uses a variant of Newton’s method by twice differentiating the function to find the local optimum most steeply connected to the starting point. The solver stops computation when the ToleranceDifference and Tolerance properties are equal. For more information, see How to: Use Unconstrained Non-Linear Programming.