Example 1: Dense Linear Programming

The linear programming problem in the standard form

{\rm {min}} \,\, f(x) = -x_1 - 3x_2

subject to:

x_1 + x_2 + x_3 = 1.5
x_1 + x_2 - x_4 = 0.5
x_1 + x_5 = 1.0
x_2 + x_6 = 1.0
x_i \ge 0, \,\,\,\, {\rm {for}} \,\,\, i = 1, \ldots , 6

is solved.

using System;
using Imsl.Math;

public class DenseLPEx1
{
    public static void  Main(String[] args)
    {
        double[,] a = {{1.0, 1.0, 1.0, 0.0, 0.0, 0.0}, 
                           {1.0, 1.0, 0.0, - 1.0, 0.0, 0.0}, 
                           {1.0, 0.0, 0.0, 0.0, 1.0, 0.0}, 
                           {0.0, 1.0, 0.0, 0.0, 0.0, 1.0}};
        double[] b = new double[]{1.5, 0.5, 1.0, 1.0};
        double[] c = new double[]{- 1.0, - 3.0, 0.0, 0.0, 0.0, 0.0};
        
        DenseLP zf = new DenseLP(a, b, c);
        
        zf.Solve();
        new PrintMatrix("Solution").Print(zf.GetSolution());
    }
}

Output

Solution
    0   
0  0.5  
1  1    
2  0    
3  1    
4  0.5  
5  0    


Link to C# source.