# LP: Simplex Draft

## June 22, 2013

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.

[Originally posted here].

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:

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):

So the problem now is

Geometrical 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:

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

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

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

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

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

### Sample

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

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

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

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

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.

### How to Name a Cat

A fun conversation about mountains, monads, types and heels reminded me about the first University years and one of our favourite math jo...… Continue reading

#### Keywords Mix

Published on March 15, 2016