How to: Make Investment Decisions using Mixed Integer Linear Programming
You can make investment decisions by modeling the problem as a mixed integer linear program. In this example, given an initial capital expenditure of $20 million and five different projects, you must decide which projects to invest in to maximize the total profit. This example is based on problem 12.1.3 in Hillier and Lieberman’s book Introduction to Operations Research. The following table shows the estimated profits and capital requirements for each project.
Project 
Estimated profits 
Capital requirements 
0 
$1 million 
$6 million 
1 
$1.8 million 
$12 million 
2 
$1.6 million 
$10 million 
3 
$0.8 million 
$4 million 
4 
$1.4 million 
$8 million 
The following steps show how to use Solver Foundation to create and solve the investment decision model using the simplex solver. The total profit is represented as a row to be maximized, and the total capital expenditure cannot be greater than the initial capital expenditure.
To make investment decisions by using a mixed integer linear program

Create a console application named InvestmentDecisions.

Add a reference to Microsoft Solver Foundation on the .NET tab of the Add Reference dialog box.

Add the following Imports or using statements to the top of the Program code file.

In the Main method, add a solver by typing the following code.

Create variables to store the data about the estimated profits, capital expenditures for each project, the initial capital expenditure, and the decision whether to invest in a project.

Create decision variables for the profit and capital expenditure, and then add row identifiers for both of these variables.

Add the project names to the solver, and then add coefficients to the constraint rows by using the SetCoefficient method. Set the bounds and choices for the investment decision by using the SetBounds and SetIntegrality methods.
for (int i = 0; i < 5; i++) { solver.AddVariable(string.Format("project{0}", i), out chooseProjectX[i]); solver.SetBounds(chooseProjectX[i], 0, 1); solver.SetIntegrality(chooseProjectX[i], true); solver.SetCoefficient(profit, chooseProjectX[i], estimatedProfitOfProjectX[i]); solver.SetCoefficient(expenditure, chooseProjectX[i], capitalRequiredForProjectX[i]); }

Configure the solver parameters to generate cuts, and then solve the model.

Show whether the solve process is optimal, and print the results of the solve process.
Console.WriteLine(solver.MipResult); for (int i = 0; i < 5; i++) { Console.WriteLine("Project {0} is {1} selected.", i, solver.GetValue(chooseProjectX[i]) == 1 ? "" : "not "); } Console.WriteLine("The estimated total profit is: ${0} million.", (double)solver.GetValue(profit).ToDouble()); Console.WriteLine("The total expenditure is: ${0} million.", solver.GetValue(expenditure).ToDouble());

Press F5 to build and run the code.
The command window shows the following results.
Optimal
Project 0 is selected.
Project 1 is not selected.
Project 2 is selected.
Project 3 is selected.
Project 4 is not selected.
The estimated total profit is: $3.4.
The total expenditure is: $20.