Friday, September 23, 2011

Optimize portfolio with solver

Linear Programming

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.
Quadratic Programming

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.

Mixed Interger Linear Programming

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.

Unconstraing Non-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.

No comments:

Post a Comment