LP: Simplex Draft

Leave a comment

[This blog was moved here]

Everybody solves some optimization problems – the airlines schedule flights, companies manage production facilities, salesman still looks for traveling options… When you need to achieve the best outcome minimizing/maximizing a linear cost functions you meet linear programming.

LP was developed for military purposes in 1939, so it has a long history. Now it is one of the most important problems in operations research and heavily used in different areas directly or as sub-problems.

Intro

The standard algorithm here is the simplex method. Lots of information is floating around, but let’s review the basics. There’re several forms for expressing linear programs. Standard form:

maximize {c}'x
subject to
Ax <= b
x >= 0

We assume that the rows of matrix A (m x n) are linearly independent.

The form above can be easily converted to slack form with a help of the new variables (slack variables):

s = b_{i} - \sum a_{ij}x_{j}
s >= 0

So the problem now is

maximize {c}'x
subject to
Ax = b
x >= 0

simplexGeometrical interpretation for 2 variables is very intuitive: all x_{1} and x_{2} satisfying the constraints are feasible solutions, and an optimal solution – maximum or minimum – is at a vertex. This feasible region, for n variables – in n-dimensional space, is called a simplex. The algorithm terminates when it reaches an optimal objective value at some vertex.

Why write a custom implementation? For me Excel solver is usually a solution 1, works like a charm – when it’s not a Mac version. The naïve version of algorithm is quite simple to implement, it’s also a nice refresher and managed to solve the problem, so why not?

Consider the following problem:

minimize x_{1} + 5*x_{2} - 2*x_{3}
subject to
x_{1} + x_{2} + x_{3} <= 4
x_{1} <= 2
x_{3} <= 3
3*x_{2} + x_{3} <= 6
x_{1}, x_{2}, x_{3} >= 0

The solution is very straightforward:
1. Convert to slack form

minimize x_{1} + 5x_{2} - 2x_{3}
subject to
x_{1} + x_{2} + x_{3} + x_{4} <= 4
x_{1} + x_{5} <= 2
x_{3} + x_{6} <= 3
3*x_{2} + x_{3} + x_{7} <= 6
x_{1}, x_{2}, x_{3}, x_{4}, x_{5}, x_{6}, x_{7} >= 0

2. We see that the cost can be reduced with increasing x_{3} (it’s also obvious that max x_{3} value is equal to 3). If the cost is already optimal the solution is found.

For each j the reduced cost is defined as

\bar{c_{j}} = c_{j} - {c_{b}}'B^{-1}A_{j}
where c_{b} – the vector of basic variables costs

3. Look for a direction of cost decrease, when moving into the new direction we replace a basic variable with a new one; go to the next iteration.

Implementation

The first version I came up with was entirely immutable – with all the costs of creating new sets, matrices etc. But there’s no sense to recreate the whole matrix when only one column is changed for the next iteration. This version is listed below – not that functional, more dangerous, with a mutable state, but cares about time/memory. Note, that this implementation doesn’t handle some corner-cases as it was not a part of my goal.

 1: (Math.Net references)
 2: 
 3: type SimplexResult =
 4:     | Success of Vector<float>
 5:     | Error of string
 6: 
 7: /// Simplex method implementation
 8: let simplexImpl (A: _ Matrix) b (c: _ Vector) (x: _ Vector, Ib: _[], In: _[]) =
 9:     ...
10:     // 1. start with basic matrix
11:     let B = Seq.map A.Column Ib |> DenseMatrix.ofColumns m m
12:     
13:     let rec calc (Binv: _ Matrix) iter =
14:         // 2. reduce costs and check optimality conditions
15:         let p = cb * Binv * A
16:         c.MapIndexedInplace (fun i ci -> ci - p.[i])
17: 
18:         match Seq.tryFindIndex (fun i -> c.[i] < 0.) In with
19:         | Some jind ->
20:             let j = In.[jind]
21:             // 3. unboundness check
22:             let u = Binv * A.Column j
23:             if Seq.forall (fun ui -> ui <= 0.) u then Error "cost unbounded"
24:             else
25:                 // 4. improvement
26:                 let l, theta =
27:                     Seq.mapi (fun i ui -> i, x.[i] / ui) u
28:                     |> Seq.filter (fun (_, di) -> di > 0.)
29:                     |> Seq.minBy snd
30:                
31:                 // 5. update solution
32:                 x.MapIndexedInplace (fun i xi -> if i=l then theta else xi - theta*u.[i])
33: 
34:                 // 6. update basis, indices and cost
35:                 B.SetColumn(l, A.Column j)
36:                 In.[jind] <- Ib.[l]
37:                 Ib.[l] <- j
38:                 cb.[l] <- c.[j]
39: 
40:                 let Binv = inverse B
41:                 calc Binv (iter + 1)
42:         | _ -> 
43:             // fill solution vector x0, x1, ..., xn
44:             let res = DenseVector.zeroCreate n
45:             Seq.iteri (fun i ib -> res.[ib] <- x.[i]) Ib
46:             Success res
47: 
48:     calc (B.Inverse()) 1F# Web Snippets

For simplicity we use the naïve initialization – all given variables become nonbasic, the slack ones – basic and their values are equal to constraints vector b. The full method returns the solution vector and cost function value:

 1: /// naive initialization function - simply set basic x to b
 2: let initSimplex (A0: _ Matrix) (b0: _ Vector) (c0: _ Vector) = (...)
 3: 
 4: /// Revised Simplex implementation: min cx, Ax <= b, x >= 0, b >= 0
 5: let simplex A0 b0 (c0: _ Vector) =
 6:     let A, b, c, x, Ib, In = initSimplex A0 b0 c0
 7:     match simplexImpl A b c (x, Ib, In) with
 8:     | Success xs -> 
 9:         let x0 = xs.[ .. c0.Count-1]
10:         let cx = c0 * x0
11:         Some (x0, cx)
12:     | _ -> NoneF# Web Snippets

And now time for my favorite part of the method and one the best ways to improve performance – reuse the data you already have to avoid recomputations whenever it’s possible. In this case it’s about inverting the basis matrix. We know that B at the next iteration is the same as current, except one column. There’s also the current B^{-1}. The naïve simplex + math = revised simplex method.

1: /// invert matrix given inverse of one column different matrix
2: let inv (a: _ Matrix) (aprev: _ Matrix, u: float Vector, l) iter =
3:     // recompute from scratch, because errors accumulate
4:     if iter % 20 = 0 then a.Inverse() 
5:     else
6:         let ul = u.[l]
7:         let lrow = aprev.Row l
8:         Matrix.mapRows (fun i row -> 
9:             if i = l then row / ul else row - lrow * u.[i] / ul) aprevF# Web Snippets

Sample

 1: standard problem form   
 2: let A = matrix [[1.; 1.; 1.]
 3:                 [1.; 0.; 0.]
 4:                 [0.; 0.; 1.]
 5:                 [0.; 3.; 1.]]
 6: 
 7: let c = vector [1.; 5.; -2.]
 8: let b = vector [4.; 2.; 3.; 6.]
 9:     
10: simplex A b c |> printfn "%A" //2,-6.0F# Web Snippets

Complete snippet version is available at github.

Summing up
– mutability may be evil, but sometimes it’s a way to go;
– reusing the computation results and the parts of datastructures ftw.

What to look at
MS Solver Foundation – quite a nice tool to check too (with msi downloads, but I tried it a long time ago with mono – and it worked)
– Some theory: Introduction to Linear Optimization book (Dimitris Bertsimas and John N. Tsitsiklis) or anything else.

 

 

val inv : Matrix<float> -> Matrix<float> * Vector<float> * int -> int -> Matrix<float>

Full name: Simplex2.inv

invert matrix given inverse of one column different matrix

val a : Matrix<float>

type: Matrix<float>
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable

Multiple items

type Matrix<‘T (requires default constructor and value type and ‘T :> System.ValueType and ‘T :> System.IEquatable<‘T> and ‘T :> System.IFormattable)> =
class
member Add : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Add : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member Append : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Append : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member At : int * int -> ‘T
member At : int * int * ‘T -> unit
member Clear : unit -> unit
member ClearColumn : int -> unit
member ClearRow : int -> unit
member ClearSubMatrix : int * int * int * int -> unit
member Clone : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Column : int -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Column : int * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member Column : int * int * int -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Column : int * int * int * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member ColumnCount : int with get, set
member ColumnEnumerator : unit -> System.Collections.Generic.IEnumerable<System.Tuple<int,MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>>>
member ColumnEnumerator : int * int -> System.Collections.Generic.IEnumerable<System.Tuple<int,MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>>>
member ConditionNumber : unit -> ‘T
member Conjugate : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Conjugate : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member ConjugateTranspose : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member CopyTo : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member CreateMatrix : int * int * bool -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member CreateVector : int * bool -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Determinant : unit -> ‘T
member Diagonal : unit -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member DiagonalStack : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member DiagonalStack : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member Divide : ‘T -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Divide : ‘T * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member Equals : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> bool
member Equals : obj -> bool
member FrobeniusNorm : unit -> ‘T
member GetHashCode : unit -> int
member IndexedEnumerator : unit -> System.Collections.Generic.IEnumerable<System.Tuple<int,int,’T>>
member InfinityNorm : unit -> ‘T
member InsertColumn : int * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member InsertRow : int * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Inverse : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member IsSymmetric : bool
member Item : int * int -> ‘T with get, set
member KroneckerProduct : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member KroneckerProduct : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member L1Norm : unit -> ‘T
member L2Norm : unit -> ‘T
member LeftMultiply : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member LeftMultiply : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member LowerTriangle : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member LowerTriangle : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member MapIndexedInplace : System.Func<int,int,’T,’T> * bool -> unit
member MapInplace : System.Func<‘T,’T> * bool -> unit
member Modulus : ‘T -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Modulus : ‘T * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member Multiply : ‘T -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Multiply : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Multiply : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Multiply : ‘T * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member Multiply : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member Multiply : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member Negate : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Negate : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member NormalizeColumns : int -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member NormalizeRows : int -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member PermuteColumns : MathNet.Numerics.Permutation -> unit
member PermuteRows : MathNet.Numerics.Permutation -> unit
member PointwiseDivide : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member PointwiseDivide : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member PointwiseMultiply : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member PointwiseMultiply : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member Rank : unit -> int
member Row : int -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Row : int * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member Row : int * int * int -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Row : int * int * int * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member RowCount : int with get, set
member RowEnumerator : unit -> System.Collections.Generic.IEnumerable<System.Tuple<int,MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>>>
member RowEnumerator : int * int -> System.Collections.Generic.IEnumerable<System.Tuple<int,MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>>>
member SetColumn : int * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member SetColumn : int * ‘T [] -> unit
member SetDiagonal : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member SetDiagonal : ‘T [] -> unit
member SetRow : int * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member SetRow : int * ‘T [] -> unit
member SetSubMatrix : int * int * int * int * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member Stack : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Stack : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member Storage : MathNet.Numerics.LinearAlgebra.Storage.MatrixStorage<‘T> with get, set
member StrictlyLowerTriangle : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member StrictlyLowerTriangle : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member StrictlyUpperTriangle : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member StrictlyUpperTriangle : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member SubMatrix : int * int * int * int -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Subtract : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Subtract : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member ToArray : unit -> ‘T [,]
member ToColumnWiseArray : unit -> ‘T []
member ToMatrixString : int * int * System.IFormatProvider -> string
member ToMatrixString : int * int * int * string * System.IFormatProvider -> string
member ToRowWiseArray : unit -> ‘T []
member ToString : unit -> string
member ToString : string * System.IFormatProvider -> string
member ToString : int * int * System.IFormatProvider -> string
member ToTypeString : unit -> string
member Trace : unit -> ‘T
member Transpose : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member TransposeAndMultiply : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member TransposeAndMultiply : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member TransposeThisAndMultiply : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member TransposeThisAndMultiply : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member TransposeThisAndMultiply : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member TransposeThisAndMultiply : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
member UpperTriangle : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member UpperTriangle : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> unit
static member CreateFromColumns : System.Collections.Generic.IList<MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
static member CreateFromRows : System.Collections.Generic.IList<MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
static member DimensionsDontMatch<‘TException> : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> -> System.Exception
static member DimensionsDontMatch<‘TException> : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * string -> System.Exception
static member DimensionsDontMatch<‘TException> : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * string -> System.Exception
static member DimensionsDontMatch<‘TException> : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * string -> System.Exception
static member DimensionsDontMatch<‘TException> : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * string -> System.Exception
static member DimensionsDontMatch<‘TException> : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * string -> System.Exception
static member DimensionsDontMatch<‘TException> : MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * string -> System.Exception
endFull name: MathNet.Numerics.LinearAlgebra.Generic.Matrix<_>

type: Matrix<‘T>
implements: System.IFormattable
implements: System.IEquatable<Matrix<‘T>>
implements: System.ICloneable

——————–

type Matrix =
class
inherit MathNet.Numerics.LinearAlgebra.Generic.Matrix<float>
member ConjugateTranspose : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<float>
member FrobeniusNorm : unit -> float
member InfinityNorm : unit -> float
member L1Norm : unit -> float
member Trace : unit -> float
end

Full name: MathNet.Numerics.LinearAlgebra.Double.Matrix

type: Matrix
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable
inherits: Matrix<float>

val aprev : Matrix<float>

type: Matrix<float>
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable

val u : Vector<float>

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

Multiple items

val float : ‘T -> float (requires member op_Explicit)Full name: Microsoft.FSharp.Core.Operators.float

——————–

type float<‘Measure> = float

Full name: Microsoft.FSharp.Core.float<_>

type: float<‘Measure>
implements: System.IComparable
implements: System.IConvertible
implements: System.IFormattable
implements: System.IComparable<float<‘Measure>>
implements: System.IEquatable<float<‘Measure>>
inherits: System.ValueType

——————–

type float = System.Double

Full name: Microsoft.FSharp.Core.float

type: float
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<float>
implements: System.IEquatable<float>
inherits: System.ValueType

Multiple items

type Vector<‘T (requires default constructor and value type and ‘T :> System.ValueType and ‘T :> System.IEquatable<‘T> and ‘T :> System.IFormattable)> =
class
member AbsoluteMaximum : unit -> ‘T
member AbsoluteMaximumIndex : unit -> int
member AbsoluteMinimum : unit -> ‘T
member AbsoluteMinimumIndex : unit -> int
member Add : ‘T -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Add : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Add : ‘T * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member Add : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member At : int -> ‘T
member At : int * ‘T -> unit
member Clear : unit -> unit
member ClearSubVector : int * int -> unit
member Clone : unit -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Conjugate : unit -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Conjugate : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member CopySubVectorTo : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * int * int * int -> unit
member CopyTo : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member CopyTo : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * int * int * int -> unit
member Count : int with get, set
member CreateMatrix : int * int -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member CreateVector : int -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Divide : ‘T -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Divide : ‘T * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member DotProduct : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> ‘T
member Equals : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> bool
member Equals : obj -> bool
member GetEnumerator : unit -> System.Collections.Generic.IEnumerator<‘T>
member GetHashCode : unit -> int
member GetIndexedEnumerator : unit -> System.Collections.Generic.IEnumerable<System.Tuple<int,’T>>
member Item : int -> ‘T with get, set
member MapIndexedInplace : System.Func<int,’T,’T> * bool -> unit
member MapInplace : System.Func<‘T,’T> * bool -> unit
member Maximum : unit -> ‘T
member MaximumIndex : unit -> int
member Minimum : unit -> ‘T
member MinimumIndex : unit -> int
member Modulus : ‘T -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Modulus : ‘T * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member Multiply : ‘T -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Multiply : ‘T * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member Negate : unit -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Negate : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member Norm : float -> ‘T
member Normalize : float -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member OuterProduct : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member Plus : unit -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member PointwiseDivide : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member PointwiseDivide : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member PointwiseMultiply : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member PointwiseMultiply : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member SetSubVector : int * int * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member SetValues : ‘T [] -> unit
member Storage : MathNet.Numerics.LinearAlgebra.Storage.VectorStorage<‘T> with get, set
member SubVector : int * int -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Subtract : ‘T -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Subtract : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T>
member Subtract : ‘T * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member Subtract : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> unit
member Sum : unit -> ‘T
member SumMagnitudes : unit -> ‘T
member ToArray : unit -> ‘T []
member ToColumnMatrix : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member ToRowMatrix : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
member ToString : unit -> string
member ToString : System.IFormatProvider -> string
member ToString : string * System.IFormatProvider -> string
member ToString : int * int * System.IFormatProvider -> string
member ToTypeString : unit -> string
member ToVectorString : int * int * System.IFormatProvider -> string
member ToVectorString : int * int * int * string * System.IFormatProvider -> string
static member OuterProduct : MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> * MathNet.Numerics.LinearAlgebra.Generic.Vector<‘T> -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<‘T>
endFull name: MathNet.Numerics.LinearAlgebra.Generic.Vector<_>

type: Vector<‘T>
implements: System.IFormattable
implements: System.IEquatable<Vector<‘T>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<‘T>
implements: System.Collections.Generic.ICollection<‘T>
implements: seq<‘T>
implements: System.Collections.IEnumerable
implements: System.ICloneable

——————–

type Vector =
class
inherit MathNet.Numerics.LinearAlgebra.Generic.Vector<float>
member AbsoluteMaximum : unit -> float
member AbsoluteMaximumIndex : unit -> int
member AbsoluteMinimum : unit -> float
member AbsoluteMinimumIndex : unit -> int
member MaximumIndex : unit -> int
member MinimumIndex : unit -> int
member Norm : float -> float
member Normalize : float -> MathNet.Numerics.LinearAlgebra.Generic.Vector<float>
member Sum : unit -> float
member SumMagnitudes : unit -> float
end

Full name: MathNet.Numerics.LinearAlgebra.Double.Vector

type: Vector
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable
inherits: Vector<float>

val l : int

type: int
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<int>
implements: System.IEquatable<int>
inherits: System.ValueType

val iter : int

type: int
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<int>
implements: System.IEquatable<int>
inherits: System.ValueType

Matrix.Inverse() : Matrix<float>

val ul : float

type: float
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<float>
implements: System.IEquatable<float>
inherits: System.ValueType

val lrow : Vector<float>

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

Multiple overloads

Matrix.Row(index: int) : Vector<float>

Matrix.Row(index: int, result: Vector<float>) : unit

Matrix.Row(rowIndex: int, columnIndex: int, length: int) : Vector<float>

Matrix.Row(rowIndex: int, columnIndex: int, length: int, result: Vector<float>) : unit

val mapRows : (int -> Vector<float> -> Vector<float>) -> #Matrix<float> -> Matrix<float>

Full name: MathNet.Numerics.LinearAlgebra.Double.Matrix.mapRows

val i : int

type: int
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<int>
implements: System.IEquatable<int>
inherits: System.ValueType

val row : Vector<float>

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

#r “MathNet.Numerics.dll”
#r “MathNet.Numerics.FSharp.dll”

open MathNet.Numerics.LinearAlgebra.Double
open MathNet.Numerics.LinearAlgebra.Generic

type SimplexResult =
| Success of Vector<float>
| Error of string

Full name: Simplex2.SimplexResult

type: SimplexResult
implements: System.IEquatable<SimplexResult>
implements: System.Collections.IStructuralEquatable

union case SimplexResult.Success: Vector<float> -> SimplexResult
union case SimplexResult.Error: string -> SimplexResult

Multiple items

val string : ‘T -> stringFull name: Microsoft.FSharp.Core.Operators.string

——————–

type string = System.String

Full name: Microsoft.FSharp.Core.string

type: string
implements: System.IComparable
implements: System.ICloneable
implements: System.IConvertible
implements: System.IComparable<string>
implements: seq<char>
implements: System.Collections.IEnumerable
implements: System.IEquatable<string>

val simplexImpl : Matrix<float> -> ‘a -> Vector<float> -> Vector<float> * int [] * int [] -> SimplexResult

Full name: Simplex2.simplexImpl

Simplex method implementation

Multiple items

val A : Matrix<float> type: Matrix<float>
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable

——————–

val A : Matrix<float>

type: Matrix<float>
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable

val b : ‘a

val c : Vector<float>

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

val x : Vector<float>

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

val Ib : int []

type: int []
implements: System.ICloneable
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.IStructuralComparable
implements: System.Collections.IStructuralEquatable
implements: System.Collections.Generic.IList<int>
implements: System.Collections.Generic.ICollection<int>
implements: seq<int>
implements: System.Collections.IEnumerable
inherits: System.Array

val In : int []

type: int []
implements: System.ICloneable
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.IStructuralComparable
implements: System.Collections.IStructuralEquatable
implements: System.Collections.Generic.IList<int>
implements: System.Collections.Generic.ICollection<int>
implements: seq<int>
implements: System.Collections.IEnumerable
inherits: System.Array

let cb = Seq.map c.At Ib |> DenseVector.ofSeq
let m, n = A.RowCount, A.ColumnCount

val B : DenseMatrix

type: DenseMatrix
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable
inherits: Matrix
inherits: Matrix<float>

module Seq

from Microsoft.FSharp.Collections

val map : (‘T -> ‘U) -> seq<‘T> -> seq<‘U>

Full name: Microsoft.FSharp.Collections.Seq.map

val A : Matrix<float>

type: Matrix<float>
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable

Multiple overloads

Matrix.Column(index: int) : Vector<float>

Matrix.Column(index: int, result: Vector<float>) : unit

Matrix.Column(columnIndex: int, rowIndex: int, length: int) : Vector<float>

Matrix.Column(columnIndex: int, rowIndex: int, length: int, result: Vector<float>) : unit

type DenseMatrix =
class
inherit MathNet.Numerics.LinearAlgebra.Double.Matrix
new : MathNet.Numerics.LinearAlgebra.Storage.DenseColumnMajorMatrixStorage<float> -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
new : int -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
new : int * int -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
new : int * int * float [] -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
new : int * int * float -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
new : float [,] -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
new : MathNet.Numerics.LinearAlgebra.Generic.Matrix<float> -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
member CreateMatrix : int * int * bool -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<float>
member CreateVector : int * bool -> MathNet.Numerics.LinearAlgebra.Generic.Vector<float>
member Data : float []
member FrobeniusNorm : unit -> float
member InfinityNorm : unit -> float
member L1Norm : unit -> float
member Trace : unit -> float
member Transpose : unit -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<float>
member Values : float []
static member Create : int * int * System.Func<int,int,float> -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
static member CreateRandom : int * int * MathNet.Numerics.Distributions.IContinuousDistribution -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
static member Identity : int -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
static member OfArray : float [,] -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
static member OfColumnMajor : int * int * System.Collections.Generic.IEnumerable<float> -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
static member OfColumns : int * int * System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<float>> -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
static member OfColumnsCovariant<‘TColumn> : int * int * System.Collections.Generic.IEnumerable<‘TColumn> -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
static member OfIndexed : int * int * System.Collections.Generic.IEnumerable<System.Tuple<int,int,float>> -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
static member OfMatrix : MathNet.Numerics.LinearAlgebra.Generic.Matrix<float> -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
static member OfRows : int * int * System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<float>> -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
static member OfRowsCovariant<‘TRow> : int * int * System.Collections.Generic.IEnumerable<‘TRow> -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
end

Full name: MathNet.Numerics.LinearAlgebra.Double.DenseMatrix

type: DenseMatrix
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable
inherits: Matrix
inherits: Matrix<float>

val ofColumns : int -> int -> #seq<‘b> -> DenseMatrix (requires ‘b :> seq<float>)

Full name: MathNet.Numerics.LinearAlgebra.Double.DenseMatrix.ofColumns

val m : int

type: int
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<int>
implements: System.IEquatable<int>
inherits: System.ValueType

val calc : (Matrix<float> -> int -> SimplexResult)

val Binv : Matrix<float>

type: Matrix<float>
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable

val p : Vector<float>

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

val cb : DenseVector

type: DenseVector
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable
inherits: Vector
inherits: Vector<float>

Vector.MapIndexedInplace(f: System.Func<int,float,float>, forceMapZeros: bool) : unit

val ci : float

type: float
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<float>
implements: System.IEquatable<float>
inherits: System.ValueType

val tryFindIndex : (‘T -> bool) -> seq<‘T> -> int option

Full name: Microsoft.FSharp.Collections.Seq.tryFindIndex

union case Option.Some: ‘T -> Option<‘T>

val jind : int

type: int
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<int>
implements: System.IEquatable<int>
inherits: System.ValueType

val j : int

type: int
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<int>
implements: System.IEquatable<int>
inherits: System.ValueType

val forall : (‘T -> bool) -> seq<‘T> -> bool

Full name: Microsoft.FSharp.Collections.Seq.forall

val ui : float

type: float
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<float>
implements: System.IEquatable<float>
inherits: System.ValueType

val theta : float

type: float
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<float>
implements: System.IEquatable<float>
inherits: System.ValueType

val mapi : (int -> ‘T -> ‘U) -> seq<‘T> -> seq<‘U>

Full name: Microsoft.FSharp.Collections.Seq.mapi

val filter : (‘T -> bool) -> seq<‘T> -> seq<‘T>

Full name: Microsoft.FSharp.Collections.Seq.filter

val di : float

type: float
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<float>
implements: System.IEquatable<float>
inherits: System.ValueType

val minBy : (‘T -> ‘U) -> seq<‘T> -> ‘T (requires comparison)

Full name: Microsoft.FSharp.Collections.Seq.minBy

val snd : (‘T1 * ‘T2) -> ‘T2

Full name: Microsoft.FSharp.Core.Operators.snd

val xi : float

type: float
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<float>
implements: System.IEquatable<float>
inherits: System.ValueType

Multiple overloads

Matrix.SetColumn(columnIndex: int, column: float []) : unit

Matrix.SetColumn(columnIndex: int, column: Vector<float>) : unit

inv B (Binv, u, l) iter

val res : DenseVector

type: DenseVector
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable
inherits: Vector
inherits: Vector<float>

type DenseVector =
class
inherit MathNet.Numerics.LinearAlgebra.Double.Vector
new : MathNet.Numerics.LinearAlgebra.Storage.DenseVectorStorage<float> -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
new : int -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
new : float [] -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
new : int * float -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
new : MathNet.Numerics.LinearAlgebra.Generic.Vector<float> -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
new : System.Collections.Generic.IEnumerable<float> -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
member AbsoluteMaximum : unit -> float
member AbsoluteMaximumIndex : unit -> int
member AbsoluteMinimum : unit -> float
member AbsoluteMinimumIndex : unit -> int
member CreateMatrix : int * int -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<float>
member CreateVector : int -> MathNet.Numerics.LinearAlgebra.Generic.Vector<float>
member MaximumIndex : unit -> int
member MinimumIndex : unit -> int
member Norm : float -> float
member OuterProduct : MathNet.Numerics.LinearAlgebra.Double.DenseVector -> MathNet.Numerics.LinearAlgebra.Generic.Matrix<float>
member Sum : unit -> float
member SumMagnitudes : unit -> float
member Values : float []
static member Create : int * System.Func<int,float> -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
static member CreateRandom : int * MathNet.Numerics.Distributions.IContinuousDistribution -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
static member OfEnumerable : System.Collections.Generic.IEnumerable<float> -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
static member OfIndexedEnumerable : int * System.Collections.Generic.IEnumerable<System.Tuple<int,float>> -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
static member OfVector : MathNet.Numerics.LinearAlgebra.Generic.Vector<float> -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
static member OuterProduct : MathNet.Numerics.LinearAlgebra.Double.DenseVector * MathNet.Numerics.LinearAlgebra.Double.DenseVector -> MathNet.Numerics.LinearAlgebra.Double.DenseMatrix
static member Parse : string -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
static member Parse : string * System.IFormatProvider -> MathNet.Numerics.LinearAlgebra.Double.DenseVector
static member TryParse : string * MathNet.Numerics.LinearAlgebra.Double.DenseVector -> bool
static member TryParse : string * System.IFormatProvider * MathNet.Numerics.LinearAlgebra.Double.DenseVector -> bool
end

Full name: MathNet.Numerics.LinearAlgebra.Double.DenseVector

type: DenseVector
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable
inherits: Vector
inherits: Vector<float>

val zeroCreate : int -> DenseVector

Full name: MathNet.Numerics.LinearAlgebra.Double.DenseVector.zeroCreate

val n : int

type: int
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<int>
implements: System.IEquatable<int>
inherits: System.ValueType

val iteri : (int -> ‘T -> unit) -> seq<‘T> -> unit

Full name: Microsoft.FSharp.Collections.Seq.iteri

val ib : int

type: int
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<int>
implements: System.IEquatable<int>
inherits: System.ValueType

val initSimplex : Matrix<float> -> Vector<float> -> Vector<float> -> DenseMatrix * DenseVector * DenseVector * DenseVector * int [] * int []

Full name: Simplex2.initSimplex

naive initialization function – simply set basic x to b

val A0 : Matrix<float>

type: Matrix<float>
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable

val b0 : Vector<float>

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

val c0 : Vector<float>

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

let m, n = A0.RowCount, A0.ColumnCount
let n’ = m + nif Seq.exists (fun bi -> bi < 0.) b0 then failwith “b should be > 0″// A0*x <= b —> A*x’ = b
let A = DenseMatrix.init m n’ (fun i j ->
if j < n then A0.[i, j]
elif i = j – n then 1.
else 0.)// copy b
let b = DenseVector.OfVector b0
// extend c
let c = DenseVector.init n’ (fun i -> if i < n then c0.[i] else 0.)
// default solution (basis xs)
let x = DenseVector.OfVector b0
let In, Ib = [| 0..n-1 |], [| n..n’-1 |]A, b, c, x, Ib, In

val simplex : Matrix<float> -> Vector<float> -> Vector<float> -> (Vector<float> * float) option

Full name: Simplex2.simplex

Revised Simplex implementation: min cx, Ax <= b, x >= 0, b >= 0

val A : DenseMatrix

type: DenseMatrix
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable
inherits: Matrix
inherits: Matrix<float>

val b : DenseVector

type: DenseVector
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable
inherits: Vector
inherits: Vector<float>

val c : DenseVector

type: DenseVector
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable
inherits: Vector
inherits: Vector<float>

val x : DenseVector

type: DenseVector
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable
inherits: Vector
inherits: Vector<float>

val xs : Vector<float>

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

val x0 : Vector<float>

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

property Vector.Count: int

val cx : float

type: float
implements: System.IComparable
implements: System.IFormattable
implements: System.IConvertible
implements: System.IComparable<float>
implements: System.IEquatable<float>
inherits: System.ValueType

union case Option.None: Option<‘T>
(*
min x1 + 5*x2 – 2*x3
subject to
x1 + x2 + x3 <= 4
x1 <= 2
x3 <= 3
3*x2 + x3 <= 6
x1, x2, x3 >= 0 *)

val A : Matrix<float>

Full name: Simplex2.A

type: Matrix<float>
implements: System.IFormattable
implements: System.IEquatable<Matrix<float>>
implements: System.ICloneable

val matrix : float list list -> Matrix<float>

Full name: MathNet.Numerics.LinearAlgebra.Double.Utility.matrix

val c : Vector<float>

Full name: Simplex2.c

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

val vector : float list -> Vector<float>

Full name: MathNet.Numerics.LinearAlgebra.Double.Utility.vector

val b : Vector<float>

Full name: Simplex2.b

type: Vector<float>
implements: System.IFormattable
implements: System.IEquatable<Vector<float>>
implements: System.Collections.IList
implements: System.Collections.ICollection
implements: System.Collections.Generic.IList<float>
implements: System.Collections.Generic.ICollection<float>
implements: seq<float>
implements: System.Collections.IEnumerable
implements: System.ICloneable

val printfn : Printf.TextWriterFormat<‘T> -> ‘T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn

  1. one of the side-effects of my work are numerous spreadsheets, and Solver proved to be incredibly helpful
  2. 0;0.0;3.0