Documentation ¶
Index ¶
- Constants
- func CheckDimensionsInAddition(left, right Expression) error
- func CheckDimensionsInMultiplication(left, right Expression) error
- func CheckErrors(extras []error) error
- func CheckExtras(extras []interface{}) error
- func FindInSlice(xIn interface{}, sliceIn interface{}) (int, error)
- func Identity(dim int) mat.Dense
- func IsConstraint(c interface{}) bool
- func IsExpression(e interface{}) bool
- func IsScalarExpression(e interface{}) bool
- func IsVectorExpression(e interface{}) bool
- func OnesVector(lengthIn int) mat.VecDense
- func Unique(listIn []uint64) []uint64
- func ZerosMatrix(nR, nC int) mat.Dense
- func ZerosVector(lengthIn int) mat.VecDense
- type ConstrSense
- type Constraint
- type DimensionError
- type Expression
- type K
- func (c K) Check() error
- func (c K) Coeffs() []float64
- func (c K) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
- func (c K) Constant() float64
- func (c K) Dims() []int
- func (c K) Eq(rightIn interface{}, errors ...error) (Constraint, error)
- func (c K) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (c K) IDs() []uint64
- func (c K) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (c K) Multiply(term1 interface{}, errors ...error) (Expression, error)
- func (c K) NumVars() int
- func (c K) Plus(rightIn interface{}, errors ...error) (Expression, error)
- func (c K) ToSymbolic() (symbolic.Expression, error)
- func (c K) Transpose() Expression
- func (c K) Variables() []Variable
- type KVector
- func (kv KVector) AtVec(idx int) ScalarExpression
- func (kv KVector) Check() error
- func (kv KVector) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
- func (kv KVector) Constant() mat.VecDense
- func (kv KVector) Dims() []int
- func (kv KVector) Eq(rightIn interface{}, errors ...error) (Constraint, error)
- func (kv KVector) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (kv KVector) IDs() []uint64
- func (kv KVector) Len() int
- func (kv KVector) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (kv KVector) LinearCoeff() mat.Dense
- func (kv KVector) Mult(val float64) (VectorExpression, error)
- func (kv KVector) Multiply(rightIn interface{}, errors ...error) (Expression, error)
- func (kv KVector) NumVars() int
- func (kv KVector) Plus(rightIn interface{}, errors ...error) (Expression, error)
- func (kv KVector) ToSymbolic() (symbolic.Expression, error)
- func (kv KVector) Transpose() Expression
- type KVectorTranspose
- func (kvt KVectorTranspose) AtVec(idx int) ScalarExpression
- func (kvt KVectorTranspose) Check() error
- func (kvt KVectorTranspose) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
- func (kvt KVectorTranspose) Constant() mat.VecDense
- func (kvt KVectorTranspose) Dims() []int
- func (kvt KVectorTranspose) Eq(rightIn interface{}, errors ...error) (Constraint, error)
- func (kvt KVectorTranspose) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (kvt KVectorTranspose) IDs() []uint64
- func (kvt KVectorTranspose) Len() int
- func (kvt KVectorTranspose) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (kvt KVectorTranspose) LinearCoeff() mat.Dense
- func (kvt KVectorTranspose) Mult(val float64) (VectorExpression, error)
- func (kvt KVectorTranspose) Multiply(rightIn interface{}, errors ...error) (Expression, error)
- func (kvt KVectorTranspose) NumVars() int
- func (kvt KVectorTranspose) Plus(rightIn interface{}, errors ...error) (Expression, error)
- func (kvt KVectorTranspose) ToSymbolic() (symbolic.Expression, error)
- func (kvt KVectorTranspose) Transpose() Expression
- type Model
- func (m *Model) AddBinaryVariable() Variable
- func (m *Model) AddBinaryVariableMatrix(rows, cols int) [][]Variable
- func (m *Model) AddBinaryVariableVector(num int) VarVector
- func (m *Model) AddConstraint(constr Constraint, errors ...error) error
- func (m *Model) AddRealVariable() Variable
- func (m *Model) AddVariable() Variable
- func (m *Model) AddVariableClassic(lower, upper float64, vtype VarType) Variable
- func (m *Model) AddVariableMatrix(rows, cols int, lower, upper float64, vtype VarType) [][]Variable
- func (m *Model) AddVariableVector(dim int) VarVector
- func (m *Model) AddVariableVectorClassic(num int, lower, upper float64, vtype VarType) VarVector
- func (m *Model) Check() error
- func (m *Model) SetObjective(e Expression, sense ObjSense) error
- type ObjSense
- type Objective
- type ScalarConstraint
- func (sc ScalarConstraint) Check() error
- func (sc ScalarConstraint) ConstrSense() ConstrSense
- func (sc ScalarConstraint) IsLinear() (bool, error)
- func (sc ScalarConstraint) Left() Expression
- func (sc ScalarConstraint) Right() Expression
- func (sc ScalarConstraint) Simplify() (ScalarConstraint, error)
- type ScalarExpression
- func NewLinearExpr(c float64) ScalarExpression
- func NewScalarExpression(c float64) ScalarExpression
- func SumCol(vs [][]Variable, col int) ScalarExpression
- func SumRow(vs [][]Variable, row int) ScalarExpression
- func SumVars(vs ...Variable) ScalarExpression
- func ToScalarExpression(e interface{}) (ScalarExpression, error)
- type ScalarLinearExpr
- func (sle ScalarLinearExpr) Check() error
- func (sle ScalarLinearExpr) Coeffs() []float64
- func (sle ScalarLinearExpr) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
- func (sle ScalarLinearExpr) Constant() float64
- func (sle ScalarLinearExpr) Copy() ScalarLinearExpr
- func (sle ScalarLinearExpr) Dims() []int
- func (sle ScalarLinearExpr) Eq(rightIn interface{}, errors ...error) (Constraint, error)
- func (sle ScalarLinearExpr) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (sle ScalarLinearExpr) IDs() []uint64
- func (sle ScalarLinearExpr) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (sle ScalarLinearExpr) Multiply(rightInput interface{}, errors ...error) (Expression, error)
- func (sle ScalarLinearExpr) NumVars() int
- func (sle ScalarLinearExpr) Plus(e interface{}, errors ...error) (Expression, error)
- func (sle ScalarLinearExpr) RewriteInTermsOf(newX VarVector) (ScalarLinearExpr, error)
- func (sle ScalarLinearExpr) ToSymbolic() (symbolic.Expression, error)
- func (sle ScalarLinearExpr) Transpose() Expression
- func (sle ScalarLinearExpr) Variables() []Variable
- type ScalarQuadraticExpression
- func (qe ScalarQuadraticExpression) Check() error
- func (qe ScalarQuadraticExpression) Coeffs() []float64
- func (qe ScalarQuadraticExpression) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
- func (qe ScalarQuadraticExpression) Constant() float64
- func (qe ScalarQuadraticExpression) Dims() []int
- func (qe ScalarQuadraticExpression) Eq(rightIn interface{}, errors ...error) (Constraint, error)
- func (qe ScalarQuadraticExpression) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (qe ScalarQuadraticExpression) IDs() []uint64
- func (qe ScalarQuadraticExpression) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (qe ScalarQuadraticExpression) Multiply(val interface{}, errors ...error) (Expression, error)
- func (qe ScalarQuadraticExpression) NumVars() int
- func (qe ScalarQuadraticExpression) Plus(e interface{}, errors ...error) (Expression, error)
- func (qe ScalarQuadraticExpression) RewriteInTermsOf(newX VarVector) (ScalarQuadraticExpression, error)
- func (qe ScalarQuadraticExpression) ToSymbolic() (symbolic.Expression, error)
- func (qe ScalarQuadraticExpression) Transpose() Expression
- func (qe ScalarQuadraticExpression) Variables() []Variable
- type UnexpectedInputError
- type VarType
- type VarVector
- func (vv VarVector) AtVec(idx int) ScalarExpression
- func (vv VarVector) Check() error
- func (vv VarVector) Comparison(rhs interface{}, sense ConstrSense, errors ...error) (Constraint, error)
- func (vv VarVector) Constant() mat.VecDense
- func (vv VarVector) Copy() VarVector
- func (vv VarVector) Dims() []int
- func (vv VarVector) Eq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vv VarVector) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vv VarVector) IDs() []uint64
- func (vv VarVector) Len() int
- func (vv VarVector) Length() int
- func (vv VarVector) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vv VarVector) LinearCoeff() mat.Dense
- func (vv VarVector) Mult(c float64) (VectorExpression, error)
- func (vv VarVector) Multiply(rightIn interface{}, errors ...error) (Expression, error)
- func (vv VarVector) NumVars() int
- func (vv VarVector) Plus(e interface{}, errors ...error) (Expression, error)
- func (vv VarVector) ToSymbolic() (symbolic.Expression, error)
- func (vv VarVector) Transpose() Expression
- type VarVectorTranspose
- func (vvt VarVectorTranspose) AtVec(idx int) ScalarExpression
- func (vvt VarVectorTranspose) Check() error
- func (vvt VarVectorTranspose) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
- func (vvt VarVectorTranspose) Constant() mat.VecDense
- func (vvt VarVectorTranspose) Copy() VarVectorTranspose
- func (vvt VarVectorTranspose) Dims() []int
- func (vvt VarVectorTranspose) Eq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vvt VarVectorTranspose) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vvt VarVectorTranspose) IDs() []uint64
- func (vvt VarVectorTranspose) Len() int
- func (vvt VarVectorTranspose) Length() int
- func (vvt VarVectorTranspose) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vvt VarVectorTranspose) LinearCoeff() mat.Dense
- func (vvt VarVectorTranspose) Multiply(e interface{}, errors ...error) (Expression, error)
- func (vvt VarVectorTranspose) NumVars() int
- func (vvt VarVectorTranspose) Plus(eIn interface{}, errors ...error) (Expression, error)
- func (vvt VarVectorTranspose) ToSymbolic() (symbolic.Expression, error)
- func (vvt VarVectorTranspose) Transpose() Expression
- type Variable
- func (v Variable) Check() error
- func (v Variable) Coeffs() []float64
- func (v Variable) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
- func (v Variable) Constant() float64
- func (v Variable) Dims() []int
- func (v Variable) Eq(rhsIn interface{}, errors ...error) (Constraint, error)
- func (v Variable) GreaterEq(rhsIn interface{}, errors ...error) (Constraint, error)
- func (v Variable) IDs() []uint64
- func (v Variable) LessEq(rhsIn interface{}, errors ...error) (Constraint, error)
- func (v Variable) Multiply(val interface{}, errors ...error) (Expression, error)
- func (v Variable) NumVars() int
- func (v Variable) Plus(e interface{}, errors ...error) (Expression, error)
- func (v Variable) ToScalarLinearExpression() ScalarLinearExpr
- func (v Variable) ToSymbolic() (symbolic.Expression, error)
- func (v Variable) Transpose() Expression
- func (v Variable) Variables() []Variable
- type VectorConstraint
- type VectorExpression
- type VectorLinearExpr
- func (vle VectorLinearExpr) AtVec(idx int) ScalarExpression
- func (vle VectorLinearExpr) Check() error
- func (vle VectorLinearExpr) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
- func (vle VectorLinearExpr) Constant() mat.VecDense
- func (vle VectorLinearExpr) Copy() VectorLinearExpr
- func (vle VectorLinearExpr) Dims() []int
- func (vle VectorLinearExpr) Eq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vle VectorLinearExpr) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vle VectorLinearExpr) IDs() []uint64
- func (vle VectorLinearExpr) Len() int
- func (vle VectorLinearExpr) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vle VectorLinearExpr) LinearCoeff() mat.Dense
- func (vle VectorLinearExpr) Multiply(rightIn interface{}, errors ...error) (Expression, error)
- func (vle VectorLinearExpr) NumVars() int
- func (vle VectorLinearExpr) Plus(rightIn interface{}, errors ...error) (Expression, error)
- func (vle VectorLinearExpr) RewriteInTermsOf(vv VarVector) VectorLinearExpr
- func (vle VectorLinearExpr) ToSymbolic() (symbolic.Expression, error)
- func (vle VectorLinearExpr) Transpose() Expression
- type VectorLinearExpressionTranspose
- func (vlet VectorLinearExpressionTranspose) AtVec(idx int) ScalarExpression
- func (vlet VectorLinearExpressionTranspose) Check() error
- func (vlet VectorLinearExpressionTranspose) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
- func (vlet VectorLinearExpressionTranspose) Constant() mat.VecDense
- func (vlet VectorLinearExpressionTranspose) Dims() []int
- func (vlet VectorLinearExpressionTranspose) Eq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vlet VectorLinearExpressionTranspose) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vlet VectorLinearExpressionTranspose) IDs() []uint64
- func (vlet VectorLinearExpressionTranspose) Len() int
- func (vlet VectorLinearExpressionTranspose) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
- func (vlet VectorLinearExpressionTranspose) LinearCoeff() mat.Dense
- func (vlet VectorLinearExpressionTranspose) Mult(c float64) (VectorExpression, error)
- func (vlet VectorLinearExpressionTranspose) Multiply(rightIn interface{}, errors ...error) (Expression, error)
- func (vlet VectorLinearExpressionTranspose) NumVars() int
- func (vlet VectorLinearExpressionTranspose) Plus(rightIn interface{}, errors ...error) (Expression, error)
- func (vlet VectorLinearExpressionTranspose) RewriteInTermsOf(vv VarVector) VectorLinearExpressionTranspose
- func (vlet VectorLinearExpressionTranspose) ToScalarLinearExpression() (ScalarLinearExpr, error)
- func (vlet VectorLinearExpressionTranspose) ToSymbolic() (symbolic.Expression, error)
- func (vlet VectorLinearExpressionTranspose) Transpose() Expression
Constants ¶
const ( Zero = K(0) One = K(1) )
Integer constants represnting commonly used numbers. Makes for better readability
const ( SenseEqual ConstrSense = '=' SenseLessThanEqual = '<' SenseGreaterThanEqual = '>' )
Different constraint senses conforming to Gurobi's encoding.
const ( Continuous VarType = 'C' Binary = 'B' Integer = 'I' )
Multiple common variable types have been included as constants that conform to Gurobi's encoding.
const INFINITY = 1e100
Variables ¶
This section is empty.
Functions ¶
func CheckDimensionsInAddition ¶ added in v0.4.1
func CheckDimensionsInAddition(left, right Expression) error
func CheckDimensionsInMultiplication ¶ added in v0.4.0
func CheckDimensionsInMultiplication(left, right Expression) error
func CheckExtras ¶ added in v0.4.0
func CheckExtras(extras []interface{}) error
CheckExtras Description:
func FindInSlice ¶
FindInSlice Description:
Identifies if the input xIn is in the slice sliceIn. If it is, then this function returns the index such that xIn = sliceIn[index] and no errors. If it is not, then this function returns the index -1 and the boolean value false.
func Identity ¶
Identity Description:
Returns a symmetric matrix that is the identity matrix. Note: this function assumes lengthIn is a positive number.
func IsConstraint ¶
func IsConstraint(c interface{}) bool
func IsExpression ¶
func IsExpression(e interface{}) bool
IsExpression Description:
Tests whether or not the input variable is one of the expression types.
func IsScalarExpression ¶ added in v0.4.0
func IsScalarExpression(e interface{}) bool
IsScalarExpression Description:
Determines whether or not an input object is a valid "ScalarExpression" according to MatProInterface.
func IsVectorExpression ¶ added in v0.4.0
func IsVectorExpression(e interface{}) bool
IsVectorExpression Description:
Determines whether or not an input object is a valid "VectorExpression" according to MatProInterface.
func OnesVector ¶
OnesVector Description:
Returns a vector of ones with length lengthIn. Note: this function assumes lengthIn is a positive number.
func ZerosVector ¶
ZerosVector Description:
Returns a vector of zeros with length lengthIn. Note: this function assumes lengthIn is a positive number.
Types ¶
type ConstrSense ¶
type ConstrSense byte
ConstrSense represents if the constraint x <= y, x >= y, or x == y. For easy integration with Gurobi, the senses have been encoding using a byte in the same way Gurobi encodes the constraint senses.
func (ConstrSense) String ¶ added in v0.5.0
func (cs ConstrSense) String() string
String Description:
Returns the string representation of the constraint sense.
func (ConstrSense) ToSymbolic ¶ added in v0.5.0
func (cs ConstrSense) ToSymbolic() symbolic.ConstrSense
ToSymbolic Description:
Converts a constraint sense to a the appropriate representation in the symbolic math toolbox.
type Constraint ¶
type Constraint interface { Left() Expression Right() Expression ConstrSense() ConstrSense Check() error }
func Comparison ¶
func Comparison(lhs, rhs interface{}, sense ConstrSense) (Constraint, error)
Comparison Description:
Compares the two inputs lhs (Left Hand Side) and rhs (Right Hand Side) in the sense provided in sense.
Usage:
constr, err := Comparison(expr1, expr2, SenseGreaterThanEqual)
func Eq ¶
func Eq(lhs, rhs interface{}) (Constraint, error)
Eq Description:
Returns a constraint representing lhs == rhs
func GreaterEq ¶
func GreaterEq(lhs, rhs interface{}) (Constraint, error)
GreaterEq returns a constraint representing lhs >= rhs
func LessEq ¶
func LessEq(lhs, rhs interface{}) (Constraint, error)
LessEq returns a constraint representing lhs <= rhs
type DimensionError ¶ added in v0.4.0
type DimensionError struct { Arg1 Expression Arg2 Expression Operation string // Either multiply or Plus }
func (DimensionError) ArgDimsAsStrings ¶ added in v0.4.0
func (de DimensionError) ArgDimsAsStrings() []string
func (DimensionError) Error ¶ added in v0.4.0
func (de DimensionError) Error() string
type Expression ¶
type Expression interface { // NumVars returns the number of variables in the expression NumVars() int // Vars returns a slice of the Var ids in the expression IDs() []uint64 // Dims returns a slice describing the true dimensions of a given expression (scalar, vector, or matrix) Dims() []int // Plus adds the current expression to another and returns the resulting // expression Plus(e interface{}, errors ...error) (Expression, error) // Multiply multiplies the current expression to another and returns the // resulting expression Multiply(c interface{}, errors ...error) (Expression, error) // Transpose transposes the given expression Transpose() Expression // LessEq returns a less than or equal to (<=) constraint between the // current expression and another LessEq(rightIn interface{}, errors ...error) (Constraint, error) // GreaterEq returns a greater than or equal to (>=) constraint between the // current expression and another GreaterEq(rightIn interface{}, errors ...error) (Constraint, error) // Eq returns an equality (==) constraint between the current expression // and another Eq(rightIn interface{}, errors ...error) (Constraint, error) // Comparison Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) //ToSymbolic // Converts the expression to a symbolic expression (in SymbolicMath.go) ToSymbolic() (symbolic.Expression, error) }
Expression Description:
This interface should be implemented by and ScalarExpression and VectorExpression
func Multiply ¶
func Multiply(term1, term2 interface{}) (Expression, error)
Multiply Description:
Defines the multiplication between two objects.
func Sum ¶
func Sum(exprs ...interface{}) (Expression, error)
Sum returns the sum of the given expressions. It creates a new empty expression and adds to it the given expressions.
func ToExpression ¶
func ToExpression(e interface{}) (Expression, error)
type K ¶
type K float64
K is a constant expression type for an MIP. K for short ¯\_(ツ)_/¯
func (K) Coeffs ¶
Coeffs returns a slice of the coefficients in the expression. For constants, this is always nil
func (K) Comparison ¶
func (c K) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
Comparison Description:
This method compares the receiver with expression rhs in the sense provided by sense.
func (K) Constant ¶
Constant returns the constant additive value in the expression. For constants, this is just the constants value
func (K) Eq ¶
func (c K) Eq(rightIn interface{}, errors ...error) (Constraint, error)
Eq returns an equality (==) constraint between the current expression and another
func (K) GreaterEq ¶
func (c K) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
GreaterEq returns a greater than or equal to (>=) constraint between the current expression and another
func (K) IDs ¶
Vars returns a slice of the Var ids in the expression. For constants, this is always nil
func (K) LessEq ¶
func (c K) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
LessEq returns a less than or equal to (<=) constraint between the current expression and another
func (K) Multiply ¶
func (c K) Multiply(term1 interface{}, errors ...error) (Expression, error)
Multiply Description:
This method multiplies the input constant by another expression.
func (K) NumVars ¶
NumVars returns the number of variables in the expression. For constants, this is always 0
func (K) Plus ¶
func (c K) Plus(rightIn interface{}, errors ...error) (Expression, error)
Plus adds the current expression to another and returns the resulting expression
func (K) ToSymbolic ¶ added in v0.5.0
func (c K) ToSymbolic() (symbolic.Expression, error)
ToSymbolic Description:
Converts the constant to a symbolic expression (i.e., one that uses the symbolic math toolbox).
func (K) Transpose ¶ added in v0.4.1
func (c K) Transpose() Expression
type KVector ¶
KVector
A type which is built on top of the KVector() a constant expression type for an MIP. K for short ¯\_(ツ)_/¯
func (KVector) AtVec ¶
func (kv KVector) AtVec(idx int) ScalarExpression
AtVec Description:
This function returns the value at the k index.
func (KVector) Check ¶ added in v0.5.0
Check Description:
This method checks for errors in the KVector type. There should never be any.
func (KVector) Comparison ¶
func (kv KVector) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
func (KVector) Constant ¶
Constant
Returns the constant additive value in the expression. For constants, this is just the constants value
func (KVector) Dims ¶ added in v0.4.0
Dims Description:
Returns the dimension of the constant vector.
func (KVector) Eq ¶
func (kv KVector) Eq(rightIn interface{}, errors ...error) (Constraint, error)
Eq Description:
This method returns an equality (==) constraint between the current expression and another
func (KVector) GreaterEq ¶
func (kv KVector) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
GreaterEq Description:
This method returns a greater than or equal to (>=) constraint between the current expression and another
func (KVector) IDs ¶
Vars Description:
This function returns a slice of the Var ids in the expression. For constants, this is always nil.
func (KVector) LessEq ¶
func (kv KVector) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
LessEq Description:
Returns a less than or equal to (<=) constraint between the current expression and another
func (KVector) LinearCoeff ¶
LinearCoeff Description:
This function returns a slice of the coefficients in the expression. For constants, this is always nil.
func (KVector) Mult ¶
func (kv KVector) Mult(val float64) (VectorExpression, error)
Mult Description:
This method multiplies the current expression to another and returns the resulting expression.
func (KVector) Multiply ¶
func (kv KVector) Multiply(rightIn interface{}, errors ...error) (Expression, error)
Multiply Description:
This method is used to compute the multiplication of the input vector constant with another term.
func (KVector) NumVars ¶
NumVars Description:
This returns the number of variables in the expression. For constants, this is 0.
func (KVector) Plus ¶
func (kv KVector) Plus(rightIn interface{}, errors ...error) (Expression, error)
Plus Description:
Adds the current expression to another and returns the resulting expression
func (KVector) ToSymbolic ¶ added in v0.5.0
func (kv KVector) ToSymbolic() (symbolic.Expression, error)
ToSymbolic Description:
This method returns the symbolic version of the constant vector.
func (KVector) Transpose ¶ added in v0.3.0
func (kv KVector) Transpose() Expression
Transpose Description:
This method creates the transpose of the current vector and returns it.
type KVectorTranspose ¶ added in v0.3.0
KVectorTranspose
A type which is built on top of the KVector() a constant expression type for an MIP. K for short ¯\_(ツ)_/¯
func (KVectorTranspose) AtVec ¶ added in v0.3.0
func (kvt KVectorTranspose) AtVec(idx int) ScalarExpression
AtVec Description:
This function returns the value at the k index.
func (KVectorTranspose) Check ¶ added in v0.5.0
func (kvt KVectorTranspose) Check() error
Check Description:
This method checks for errors in the KVectorTranspose type. There should never be any.
func (KVectorTranspose) Comparison ¶ added in v0.3.0
func (kvt KVectorTranspose) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
func (KVectorTranspose) Constant ¶ added in v0.3.0
func (kvt KVectorTranspose) Constant() mat.VecDense
Constant
Returns the constant additive value in the expression. For constants, this is just the constants value
func (KVectorTranspose) Dims ¶ added in v0.4.0
func (kvt KVectorTranspose) Dims() []int
Dims Description:
This method returns the dimensions of the KVectorTranspose object.
func (KVectorTranspose) Eq ¶ added in v0.3.0
func (kvt KVectorTranspose) Eq(rightIn interface{}, errors ...error) (Constraint, error)
Eq Description:
This method returns an equality (==) constraint between the current expression and another
func (KVectorTranspose) GreaterEq ¶ added in v0.3.0
func (kvt KVectorTranspose) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
GreaterEq Description:
This method returns a greater than or equal to (>=) constraint between the current expression and another
func (KVectorTranspose) IDs ¶ added in v0.3.0
func (kvt KVectorTranspose) IDs() []uint64
Vars Description:
This function returns a slice of the Var ids in the expression. For constants, this is always nil.
func (KVectorTranspose) Len ¶ added in v0.3.0
func (kvt KVectorTranspose) Len() int
Len
Computes the length of the KVector given.
func (KVectorTranspose) LessEq ¶ added in v0.3.0
func (kvt KVectorTranspose) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
LessEq Description:
Returns a less than or equal to (<=) constraint between the current expression and another
func (KVectorTranspose) LinearCoeff ¶ added in v0.3.0
func (kvt KVectorTranspose) LinearCoeff() mat.Dense
LinearCoeff Description:
This function returns a slice of the coefficients in the expression. For constants, this is always nil.
func (KVectorTranspose) Mult ¶ added in v0.3.0
func (kvt KVectorTranspose) Mult(val float64) (VectorExpression, error)
Mult Description:
This method multiplies the current expression to another and returns the resulting expression.
func (KVectorTranspose) Multiply ¶ added in v0.3.0
func (kvt KVectorTranspose) Multiply(rightIn interface{}, errors ...error) (Expression, error)
Multiply Description:
This method is used to compute the multiplication of the input vector constant with another term.
func (KVectorTranspose) NumVars ¶ added in v0.3.0
func (kvt KVectorTranspose) NumVars() int
NumVars Description:
This returns the number of variables in the expression. For constants, this is 0.
func (KVectorTranspose) Plus ¶ added in v0.3.0
func (kvt KVectorTranspose) Plus(rightIn interface{}, errors ...error) (Expression, error)
Plus Description:
Adds the current expression to another and returns the resulting expression
func (KVectorTranspose) ToSymbolic ¶ added in v0.5.0
func (kvt KVectorTranspose) ToSymbolic() (symbolic.Expression, error)
ToSymbolic Description:
This method returns the symbolic version of the KVectorTranspose expression.
func (KVectorTranspose) Transpose ¶ added in v0.3.0
func (kvt KVectorTranspose) Transpose() Expression
Transpose Description:
This method creates the transpose of the current vector and returns it.
type Model ¶
type Model struct { Name string Variables []Variable Constraints []Constraint Obj *Objective }
Model represents the overall constrained linear optimization model to be solved. Model contains all the variables associated with the optimization problem, constraints, objective, and parameters. New variables can only be created using an instantiated Model.
func NewModel ¶
NewModel returns a new model with some default arguments such as not to show the log.
func (*Model) AddBinaryVariable ¶
AddBinaryVar adds a binary variable to the model and returns said variable.
func (*Model) AddBinaryVariableMatrix ¶
AddBinaryVariableMatrix adds a matrix of binary variables to the model and returns the resulting slice.
func (*Model) AddBinaryVariableVector ¶
AddBinaryVariableVector adds a vector of binary variables to the model and returns the slice.
func (*Model) AddConstraint ¶ added in v0.2.0
func (m *Model) AddConstraint(constr Constraint, errors ...error) error
AddConstr adds the given constraint to the model.
func (*Model) AddRealVariable ¶
AddRealVariable Description:
Adds a Real variable to the model and returns said variable.
func (*Model) AddVariable ¶
AddVariable Description:
This method adds an "unbounded" continuous variable to the model.
func (*Model) AddVariableClassic ¶
AddVariable adds a variable of a given variable type to the model given the lower and upper value limits. This variable is returned.
func (*Model) AddVariableMatrix ¶
func (m *Model) AddVariableMatrix( rows, cols int, lower, upper float64, vtype VarType, ) [][]Variable
AddVariableMatrix adds a matrix of variables of a given type to the model with lower and upper value limits and returns the resulting slice.
func (*Model) AddVariableVector ¶
AddVariableVector Description:
Creates a VarVector object using a constructor that assumes you want an "unbounded" vector of real optimization variables.
func (*Model) AddVariableVectorClassic ¶
AddVariableVectorClassic Description:
The classic version of AddVariableVector defined in the original goop.
func (*Model) SetObjective ¶
func (m *Model) SetObjective(e Expression, sense ObjSense) error
type ObjSense ¶
type ObjSense int
ObjSense represents whether an optimization objective is to be maximized or minimized. This implementation conforms to the Gurobi encoding
const ( SenseMinimize ObjSense = 1 SenseMaximize = -1 )
Objective senses (minimize and maximize) encoding using Gurobi's standard
type Objective ¶
type Objective struct { ScalarExpression Sense ObjSense }
Objective represents an optimization objective given an expression and objective sense (maximize or minimize).
func NewObjective ¶
func NewObjective(e ScalarExpression, sense ObjSense) *Objective
NewObjective returns a new optimization objective given an expression and objective sense
type ScalarConstraint ¶
type ScalarConstraint struct { LeftHandSide ScalarExpression RightHandSide ScalarExpression Sense ConstrSense }
ScalarConstraint represnts a linear constraint of the form x <= y, x >= y, or x == y. ScalarConstraint uses a left and right hand side expressions along with a constraint sense (<=, >=, ==) to represent a generalized linear constraint
func (ScalarConstraint) Check ¶ added in v0.5.0
func (sc ScalarConstraint) Check() error
Check Description:
Checks the validity of the ScalarConstraint, this makes sure that: - The Sense if either SenseEqual, SenseLessThanEqual, or SenseGreaterThanEqual
func (ScalarConstraint) ConstrSense ¶ added in v0.5.0
func (sc ScalarConstraint) ConstrSense() ConstrSense
func (ScalarConstraint) IsLinear ¶ added in v0.4.2
func (sc ScalarConstraint) IsLinear() (bool, error)
IsLinear Description:
Describes whether or not a given linear constraint is linear or not.
func (ScalarConstraint) Left ¶ added in v0.4.1
func (sc ScalarConstraint) Left() Expression
func (ScalarConstraint) Right ¶ added in v0.4.1
func (sc ScalarConstraint) Right() Expression
func (ScalarConstraint) Simplify ¶ added in v0.4.2
func (sc ScalarConstraint) Simplify() (ScalarConstraint, error)
Simplify Description:
Moves all of the variables of the ScalarConstraint to its left hand side.
type ScalarExpression ¶
type ScalarExpression interface { // Variables returns the variables included in the scalar expression Variables() []Variable // NumVars returns the number of variables in the expression NumVars() int // Vars returns a slice of the Var ids in the expression IDs() []uint64 // Coeffs returns a slice of the coefficients in the expression Coeffs() []float64 // Constant returns the constant additive value in the expression Constant() float64 // Plus adds the current expression to another and returns the resulting // expression Plus(rightIn interface{}, errors ...error) (Expression, error) // LessEq returns a less than or equal to (<=) constraint between the // current expression and another LessEq(rhsIn interface{}, errors ...error) (Constraint, error) // GreaterEq returns a greater than or equal to (>=) constraint between the // current expression and another GreaterEq(rhsIn interface{}, errors ...error) (Constraint, error) // Eq returns an equality (==) constraint between the current expression // and another Eq(rhsIn interface{}, errors ...error) (Constraint, error) //Comparison // Compares the receiver expression rhs with the expression rhs in the sense of sense. Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) //Multiply // Multiplies the given scalar expression with another expression Multiply(rightIn interface{}, errors ...error) (Expression, error) //Dims // Returns the dimensions of the scalar expression (should always be 1,1) Dims() []int //Transpose returns the transpose of the given vector expression Transpose() Expression //ToSymbolic Returns the symbolic version of the scalar expression // (i.e., the expression when declared using the symbolic math toolbox). ToSymbolic() (symbolic.Expression, error) // Check, checks the expression for any errors Check() error }
ScalarExpression represents a linear general expression of the form c0 * x0 + c1 * x1 + ... + cn * xn + k where ci are coefficients and xi are variables and k is a constant. This is a base interface that is implemented by single variables, constants, and general linear expressions.
func NewLinearExpr ¶
func NewLinearExpr(c float64) ScalarExpression
NewLinearExpr returns a new expression with a single additive constant value, c, and no variables.
func NewScalarExpression ¶ added in v0.2.0
func NewScalarExpression(c float64) ScalarExpression
NewExpr returns a new expression with a single additive constant value, c, and no variables. Creating an expression like sum := NewExpr(0) is useful for creating new empty expressions that you can perform operatotions on later
func SumCol ¶
func SumCol(vs [][]Variable, col int) ScalarExpression
SumCol returns the sum of all variables in a single specified column of a variable matrix.
func SumRow ¶
func SumRow(vs [][]Variable, row int) ScalarExpression
SumRow returns the sum of all the variables in a single specified row of a variable matrix.
func SumVars ¶
func SumVars(vs ...Variable) ScalarExpression
SumVars returns the sum of the given variables. It creates a new empty expression and adds to it the given variables.
func ToScalarExpression ¶ added in v0.4.0
func ToScalarExpression(e interface{}) (ScalarExpression, error)
ToScalarExpression Description:
Converts the input expression to a valid type that implements "ScalarExpression".
type ScalarLinearExpr ¶
type ScalarLinearExpr struct { X VarVector L mat.VecDense // Vector of coefficients. Should match the dimensions of XIndices C float64 }
ScalarLinearExpr represents a linear general expression of the form
L' * x + C
where L is a vector of coefficients that matches the dimension of x, the vector of variables variables and C is a constant
func (ScalarLinearExpr) Check ¶ added in v0.4.0
func (sle ScalarLinearExpr) Check() error
Check Description:
func (ScalarLinearExpr) Coeffs ¶
func (sle ScalarLinearExpr) Coeffs() []float64
Coeffs returns a slice of the coefficients in the expression
func (ScalarLinearExpr) Comparison ¶
func (sle ScalarLinearExpr) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
Comparison Description:
This method compares the receiver with expression rhs in the sense provided by sense.
Usage:
constr, err := e.Comparison(expr1,SenseGreaterThanEqual)
func (ScalarLinearExpr) Constant ¶
func (sle ScalarLinearExpr) Constant() float64
Constant returns the constant additive value in the expression
func (ScalarLinearExpr) Copy ¶ added in v0.2.0
func (sle ScalarLinearExpr) Copy() ScalarLinearExpr
Copy Description:
func (ScalarLinearExpr) Dims ¶ added in v0.4.0
func (sle ScalarLinearExpr) Dims() []int
Dims Description:
Dimensions of a
func (ScalarLinearExpr) Eq ¶
func (sle ScalarLinearExpr) Eq(rightIn interface{}, errors ...error) (Constraint, error)
Eq returns an equality (==) constraint between the current expression and another
func (ScalarLinearExpr) GreaterEq ¶
func (sle ScalarLinearExpr) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
GreaterEq returns a greater than or equal to (>=) constraint between the current expression and another
func (ScalarLinearExpr) IDs ¶
func (sle ScalarLinearExpr) IDs() []uint64
Vars returns a slice of the Var ids in the expression
func (ScalarLinearExpr) LessEq ¶
func (sle ScalarLinearExpr) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
LessEq returns a less than or equal to (<=) constraint between the current expression and another
func (ScalarLinearExpr) Multiply ¶ added in v0.2.0
func (sle ScalarLinearExpr) Multiply(rightInput interface{}, errors ...error) (Expression, error)
Multiply Description:
multiplies the current expression to another and returns the resulting expression
func (ScalarLinearExpr) NumVars ¶
func (sle ScalarLinearExpr) NumVars() int
NumVars returns the number of variables in the expression
func (ScalarLinearExpr) Plus ¶
func (sle ScalarLinearExpr) Plus(e interface{}, errors ...error) (Expression, error)
Plus adds the current expression to another and returns the resulting expression
func (ScalarLinearExpr) RewriteInTermsOf ¶
func (sle ScalarLinearExpr) RewriteInTermsOf(newX VarVector) (ScalarLinearExpr, error)
RewriteInTermsOf Description:
Rewrites the current linear expression in terms of the new variables.
Usage:
rewrittenLE, err := orignalLE.RewriteInTermsOfIndices(newXIndices1)
func (ScalarLinearExpr) ToSymbolic ¶ added in v0.5.0
func (sle ScalarLinearExpr) ToSymbolic() (symbolic.Expression, error)
ToSymbolic Description:
Converts the constant to a symbolic expression (i.e., one that uses the symbolic math toolbox).
func (ScalarLinearExpr) Transpose ¶ added in v0.4.1
func (sle ScalarLinearExpr) Transpose() Expression
Transpose Description:
func (ScalarLinearExpr) Variables ¶
func (sle ScalarLinearExpr) Variables() []Variable
Variables Description:
This function returns a slice containing all unique variables in the linear expression le.
type ScalarQuadraticExpression ¶
type ScalarQuadraticExpression struct { Q mat.Dense // Quadratic Term L mat.VecDense // Linear Term C float64 // Constant Term X VarVector }
QuadraticExpr Description:
A quadratic expression of optimization variables (given by their indices). The quadratic expression object defines a quadratic written as follows: x' * Q * x + L * x + C
func NewQuadraticExpr ¶
func NewQuadraticExpr(QIn mat.Dense, qIn mat.VecDense, bIn float64, xIn VarVector) (ScalarQuadraticExpression, error)
NewQuadraticExpr Description:
NewQuadraticExpr returns a basic Quadratic expression whuch is defined by QIn, qIn and bIn.
func NewQuadraticExpr_qb0 ¶
func NewQuadraticExpr_qb0(QIn mat.Dense, xIn VarVector) (ScalarQuadraticExpression, error)
NewQuadraticExpr_qb0 Description:
NewQuadraticExpr_q0 returns a basic Quadratic expression with only the matrix Q being defined, all other values are assumed to be zero.
func (ScalarQuadraticExpression) Check ¶
func (qe ScalarQuadraticExpression) Check() error
Check Description:
This function checks the dimensions of all of the members of the quadratic expression which are slices. They should have compatible dimensions.
func (ScalarQuadraticExpression) Coeffs ¶
func (qe ScalarQuadraticExpression) Coeffs() []float64
Coeffs Description:
Returns the slice of all coefficient values for each pair of variable tuples. The coefficients of the quadratic expression are created in an ordering that comes from the following vector. Consider xI (the indices of the input expression e). The output coefficients will be c. The coefficients of the expression e = x' Q x + q' * x + b will be e = c' mx + b where mx = [ x[0]*x[0], x[0]*x[1], ... , x[0]*x[N-1], x[1]*x[1] , x[1]*x[2], ... , x[1]*x[N-1], x[2]*x[2], ... , x[N-1]*x[N-1], x[0], x[1], ... , x[N-1] ]
func (ScalarQuadraticExpression) Comparison ¶
func (qe ScalarQuadraticExpression) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
Comparison Description:
This method compares the receiver with expression rhs in the sense provided by sense.
Usage:
constr, err := qe.Comparison(expr1,SenseGreaterThanEqual)
func (ScalarQuadraticExpression) Constant ¶
func (qe ScalarQuadraticExpression) Constant() float64
Constant Description:
Returns the constant value associated with a quadratic expression.
func (ScalarQuadraticExpression) Dims ¶ added in v0.4.0
func (qe ScalarQuadraticExpression) Dims() []int
func (ScalarQuadraticExpression) Eq ¶
func (qe ScalarQuadraticExpression) Eq(rightIn interface{}, errors ...error) (Constraint, error)
Eq Description:
Form an equality constraint with this equality constraint and another Eq returns an equality (==) constraint between the current expression and another
func (ScalarQuadraticExpression) GreaterEq ¶
func (qe ScalarQuadraticExpression) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
GreaterEq Description:
GreaterEq returns a greater than or equal to (>=) constraint between the current expression and another
func (ScalarQuadraticExpression) IDs ¶
func (qe ScalarQuadraticExpression) IDs() []uint64
Vars Description:
Returns the ids of all of the variables in the quadratic expression.
func (ScalarQuadraticExpression) LessEq ¶
func (qe ScalarQuadraticExpression) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
LessEq Description:
LessEq returns a less than or equal to (<=) constraint between the current expression and another
func (ScalarQuadraticExpression) Multiply ¶ added in v0.2.0
func (qe ScalarQuadraticExpression) Multiply(val interface{}, errors ...error) (Expression, error)
Multiply Description:
Multiply() multiplies the current expression to another and returns the resulting expression
func (ScalarQuadraticExpression) NumVars ¶
func (qe ScalarQuadraticExpression) NumVars() int
NumVars Description:
Returns the number of variables in the expression. To make this actually meaningful, we only count the unique vars.
func (ScalarQuadraticExpression) Plus ¶
func (qe ScalarQuadraticExpression) Plus(e interface{}, errors ...error) (Expression, error)
Plus Description:
Adds a quadratic expression to either: - A Quadratic Expression, - A Linear Expression, or - A Constant
func (ScalarQuadraticExpression) RewriteInTermsOf ¶
func (qe ScalarQuadraticExpression) RewriteInTermsOf(newX VarVector) (ScalarQuadraticExpression, error)
RewriteInTermsOfIndices Description:
Rewrites the current quadratic expression in terms of the new variables.
Usage:
rewrittenQE, err := orignalQE.RewriteInTermsOfIndices(newXIndices1)
func (ScalarQuadraticExpression) ToSymbolic ¶ added in v0.5.0
func (qe ScalarQuadraticExpression) ToSymbolic() (symbolic.Expression, error)
ToSymbolic Description:
This function converts the quadratic expression into a symbolic expression. (i.e., one that uses the symbolic math toolbox).
func (ScalarQuadraticExpression) Transpose ¶ added in v0.4.1
func (qe ScalarQuadraticExpression) Transpose() Expression
Transpose Description:
TBD
func (ScalarQuadraticExpression) Variables ¶
func (qe ScalarQuadraticExpression) Variables() []Variable
Variables Description:
This function returns a slice containing all unique variables in the expression qe.
type UnexpectedInputError ¶ added in v0.4.0
type UnexpectedInputError struct { InputInQuestion interface{} Operation string }
func (UnexpectedInputError) Error ¶ added in v0.4.0
func (uie UnexpectedInputError) Error() string
type VarType ¶
type VarType byte
VarType represents the type of the variable (continuous, binary, integer, etc) and uses Gurobi's encoding.
type VarVector ¶
type VarVector struct {
Elements []Variable
}
VarVector Description:
Represnts a variable in a optimization problem. The variable is
func (VarVector) AtVec ¶
func (vv VarVector) AtVec(idx int) ScalarExpression
At Description:
Mirrors the gonum api for vectors. This extracts the element of the variable vector at the index x.
func (VarVector) Check ¶ added in v0.4.0
Check Description:
Checks whether or not the VarVector has a sensible initialization.
func (VarVector) Comparison ¶
func (vv VarVector) Comparison(rhs interface{}, sense ConstrSense, errors ...error) (Constraint, error)
Comparison Description:
This method creates a constraint of type sense between the receiver (as left hand side) and rhs (as right hand side) if both are valid.
func (VarVector) Constant ¶
Constant Description:
Returns an all zeros vector as output from the method.
func (VarVector) Eq ¶
func (vv VarVector) Eq(rightIn interface{}, errors ...error) (Constraint, error)
Eq Description:
This method creates an equal to vector constraint using the receiver as the left hand side and the input rhs as the right hand side if it is valid.
func (VarVector) GreaterEq ¶
func (vv VarVector) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
GreaterEq Description:
This method creates a greater than or equal to vector constraint using the receiver as the left hand side and the input rhs as the right hand side if it is valid.
func (VarVector) Len ¶
Len Description:
This function is created to mirror the GoNum Vector API. Does the same thing as Length.
func (VarVector) Length ¶
Length Description:
Returns the length of the vector of optimization variables.
func (VarVector) LessEq ¶
func (vv VarVector) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
LessEq Description:
This method creates a less than or equal to vector constraint using the receiver as the left hand side and the input rhs as the right hand side if it is valid.
func (VarVector) LinearCoeff ¶
LinearCoeff Description:
Returns the matrix which is multiplied by Variables to get the current "expression". For a single vector, this is an identity matrix.
func (VarVector) Mult ¶
func (vv VarVector) Mult(c float64) (VectorExpression, error)
Mult Description:
This member function computest the multiplication of the receiver vector var with some incoming vector expression (may result in quadratic?).
func (VarVector) Multiply ¶ added in v0.4.0
func (vv VarVector) Multiply(rightIn interface{}, errors ...error) (Expression, error)
Multiply Description:
Multiplication of a VarVector with another expression.
func (VarVector) NumVars ¶
NumVars Description:
The number of unique variables inside the variable vector.
func (VarVector) Plus ¶
func (vv VarVector) Plus(e interface{}, errors ...error) (Expression, error)
Plus Description:
This member function computes the addition of the receiver vector var with the incoming vector expression ve.
func (VarVector) ToSymbolic ¶ added in v0.5.0
func (vv VarVector) ToSymbolic() (symbolic.Expression, error)
ToSymbolic Description:
Converts the variable vector to a symbolic expression. (i.e., one that uses the symbolic math toolbox).
func (VarVector) Transpose ¶ added in v0.3.0
func (vv VarVector) Transpose() Expression
Transpose Description:
This method creates the transpose of the current vector and returns it.
type VarVectorTranspose ¶ added in v0.3.0
type VarVectorTranspose struct {
Elements []Variable
}
VarVectorTranspose Description:
Represnts a variable in a optimization problem. The variable is
func (VarVectorTranspose) AtVec ¶ added in v0.3.0
func (vvt VarVectorTranspose) AtVec(idx int) ScalarExpression
At Description:
Mirrors the gonum api for vectors. This extracts the element of the variable vector at the index x.
func (VarVectorTranspose) Check ¶ added in v0.5.0
func (vvt VarVectorTranspose) Check() error
Check Description:
Checks whether or not the VarVector has a sensible initialization.
func (VarVectorTranspose) Comparison ¶ added in v0.3.0
func (vvt VarVectorTranspose) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
Comparison Description:
This method creates a constraint of type sense between the receiver (as left hand side) and rhs (as right hand side) if both are valid.
func (VarVectorTranspose) Constant ¶ added in v0.3.0
func (vvt VarVectorTranspose) Constant() mat.VecDense
Constant Description:
Returns an all zeros vector as output from the method.
func (VarVectorTranspose) Copy ¶ added in v0.3.0
func (vvt VarVectorTranspose) Copy() VarVectorTranspose
func (VarVectorTranspose) Dims ¶ added in v0.4.0
func (vvt VarVectorTranspose) Dims() []int
Dims Description:
This method returns the dimension of the VarVectorTranspose object.
func (VarVectorTranspose) Eq ¶ added in v0.3.0
func (vvt VarVectorTranspose) Eq(rightIn interface{}, errors ...error) (Constraint, error)
Eq Description:
This method creates an equal to vector constraint using the receiver as the left hand side and the input rhs as the right hand side if it is valid.
func (VarVectorTranspose) GreaterEq ¶ added in v0.3.0
func (vvt VarVectorTranspose) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
GreaterEq Description:
This method creates a greater than or equal to vector constraint using the receiver as the left hand side and the input rhs as the right hand side if it is valid.
func (VarVectorTranspose) IDs ¶ added in v0.3.0
func (vvt VarVectorTranspose) IDs() []uint64
IDs Description:
Returns the unique indices
func (VarVectorTranspose) Len ¶ added in v0.3.0
func (vvt VarVectorTranspose) Len() int
Len Description:
This function is created to mirror the GoNum Vector API. Does the same thing as Length.
func (VarVectorTranspose) Length ¶ added in v0.3.0
func (vvt VarVectorTranspose) Length() int
Length Description:
Returns the length of the vector of optimization variables.
func (VarVectorTranspose) LessEq ¶ added in v0.3.0
func (vvt VarVectorTranspose) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
LessEq Description:
This method creates a less than or equal to vector constraint using the receiver as the left hand side and the input rhs as the right hand side if it is valid.
func (VarVectorTranspose) LinearCoeff ¶ added in v0.3.0
func (vvt VarVectorTranspose) LinearCoeff() mat.Dense
LinearCoeff Description:
Returns the matrix which is multiplied by Variables to get the current "expression". For a single vector, this is an identity matrix.
func (VarVectorTranspose) Multiply ¶ added in v0.4.0
func (vvt VarVectorTranspose) Multiply(e interface{}, errors ...error) (Expression, error)
Multiply Description:
Multiplication of a VarVectorTranspose with another expression.
func (VarVectorTranspose) NumVars ¶ added in v0.3.0
func (vvt VarVectorTranspose) NumVars() int
NumVars Description:
The number of unique variables inside the variable vector.
func (VarVectorTranspose) Plus ¶ added in v0.3.0
func (vvt VarVectorTranspose) Plus(eIn interface{}, errors ...error) (Expression, error)
Plus Description:
This member function computes the addition of the receiver vector var with the incoming vector expression ve.
func (VarVectorTranspose) ToSymbolic ¶ added in v0.5.0
func (vvt VarVectorTranspose) ToSymbolic() (symbolic.Expression, error)
ToSymbolic Description:
This method converts the VarVectorTranspose to a symbolic expression (i.e., an expression made using SymbolicMath.go).
func (VarVectorTranspose) Transpose ¶ added in v0.3.0
func (vvt VarVectorTranspose) Transpose() Expression
Transpose Description:
This method creates the transpose of the current vector and returns it.
type Variable ¶
Var represnts a variable in a optimization problem. The variable is identified with an uint64.
func UniqueVars ¶
UniqueVars Description:
This function creates a slice of unique variables from the slice given in varsIn
func (Variable) Check ¶ added in v0.4.0
Check Description:
Checks whether or not the Variable has a sensible initialization.
func (Variable) Coeffs ¶
Coeffs returns a slice of the coefficients in the expression. For a variable, it always returns a singleton slice containing the value one.
func (Variable) Comparison ¶
func (v Variable) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
Comparison Description:
This method compares the receiver with expression rhs in the sense provided by sense.
Usage:
constr, err := v.Comparison(expr1,SenseGreaterThanEqual)
func (Variable) Constant ¶
Constant returns the constant additive value in the expression. For a variable, it always returns zero.
func (Variable) Dims ¶ added in v0.4.0
Dims Description:
Returns the dimension of the Variable object (should be scalar).
func (Variable) Eq ¶
func (v Variable) Eq(rhsIn interface{}, errors ...error) (Constraint, error)
Eq returns an equality (==) constraint between the current expression and another
func (Variable) GreaterEq ¶
func (v Variable) GreaterEq(rhsIn interface{}, errors ...error) (Constraint, error)
GreaterEq returns a greater than or equal to (>=) constraint between the current expression and another
func (Variable) IDs ¶
Vars returns a slice of the Var ids in the expression. For a variable, it always returns a singleton slice with the given variable ID.
func (Variable) LessEq ¶
func (v Variable) LessEq(rhsIn interface{}, errors ...error) (Constraint, error)
LessEq returns a less than or equal to (<=) constraint between the current expression and another
func (Variable) Multiply ¶ added in v0.2.0
func (v Variable) Multiply(val interface{}, errors ...error) (Expression, error)
Multiply Description:
multiplies the current expression to another and returns the resulting expression
func (Variable) NumVars ¶
NumVars returns the number of variables in the expression. For a variable, it always returns one.
func (Variable) Plus ¶
func (v Variable) Plus(e interface{}, errors ...error) (Expression, error)
Plus adds the current expression to another and returns the resulting expression.
func (Variable) ToScalarLinearExpression ¶ added in v0.2.0
func (v Variable) ToScalarLinearExpression() ScalarLinearExpr
ToScalarLinearExpression Description:
Converting the variable into a scalar linear Expression.
func (Variable) ToSymbolic ¶ added in v0.5.0
func (v Variable) ToSymbolic() (symbolic.Expression, error)
ToSymbolic Description:
Converts the variable into a symbolic variable (from the symbolic math toolbox).
func (Variable) Transpose ¶ added in v0.4.1
func (v Variable) Transpose() Expression
type VectorConstraint ¶
type VectorConstraint struct { LeftHandSide VectorExpression RightHandSide VectorExpression Sense ConstrSense }
func (VectorConstraint) AtVec ¶
func (vc VectorConstraint) AtVec(i int) (ScalarConstraint, error)
AtVec Description:
Retrieves the constraint formed by one element of the "vector" constraint.
func (VectorConstraint) Check ¶
func (vc VectorConstraint) Check() error
Check Description:
Checks that the VectorConstraint is valid.
func (VectorConstraint) ConstrSense ¶ added in v0.5.0
func (vc VectorConstraint) ConstrSense() ConstrSense
ConstrSense Description:
Returns the sense of the constraint.
func (VectorConstraint) Left ¶ added in v0.4.1
func (vc VectorConstraint) Left() Expression
func (VectorConstraint) Right ¶ added in v0.4.1
func (vc VectorConstraint) Right() Expression
type VectorExpression ¶
type VectorExpression interface { // NumVars returns the number of variables in the expression NumVars() int // IDs returns a slice of the Var ids in the expression IDs() []uint64 // Coeffs returns a slice of the coefficients in the expression LinearCoeff() mat.Dense // Constant returns the constant additive value in the expression Constant() mat.VecDense // Plus adds the current expression to another and returns the resulting // expression Plus(e interface{}, errors ...error) (Expression, error) // Mult multiplies the current expression with another and returns the // resulting expression Multiply(e interface{}, errors ...error) (Expression, error) // LessEq returns a less than or equal to (<=) constraint between the // current expression and another LessEq(rhs interface{}, errors ...error) (Constraint, error) // GreaterEq returns a greater than or equal to (>=) constraint between the // current expression and another GreaterEq(rhs interface{}, errors ...error) (Constraint, error) // Comparison // Returns a constraint with respect to the sense (senseIn) between the // current expression and another. Comparison(rhs interface{}, sense ConstrSense, errors ...error) (Constraint, error) // Eq returns an equality (==) constraint between the current expression // and another Eq(rhs interface{}, errors ...error) (Constraint, error) // Len returns the length of the vector expression. Len() int //AtVec returns the expression at a given index AtVec(idx int) ScalarExpression //Transpose returns the transpose of the given vector expression Transpose() Expression // Dims returns the dimensions of the given expression Dims() []int //ToSymbolic // Converts the expression to a symbolic expression (in SymbolicMath.go) ToSymbolic() (symbolic.Expression, error) //Check // Checks the expression for any errors Check() error }
VectorExpression Description:
This interface represents any expression written in terms of a vector of represents a linear general expression of the form c0 * x0 + c1 * x1 + ... + cn * xn + k where ci are coefficients and xi are variables and k is a constant. This is a base interface that is implemented by single variables, constants, and general linear expressions.
func ToVectorExpression ¶ added in v0.4.0
func ToVectorExpression(e interface{}) (VectorExpression, error)
ToVectorExpression Description:
Converts the input expression to a valid type that implements "VectorExpression".
type VectorLinearExpr ¶
type VectorLinearExpr struct { X VarVector L mat.Dense // Matrix of coefficients. Should match the dimensions of XIndices C mat.VecDense }
VectorLinearExpr represents a linear general expression of the form
L' * x + C
where L is an n x m matrix of coefficients that matches the dimension of x, the vector of variables and C is a constant vector
func NewVectorExpression ¶
func NewVectorExpression(c mat.VecDense) VectorLinearExpr
NewVectorExpression Description:
NewExpr returns a new expression with a single additive constant value, c, and no variables. Creating an expression like sum := NewVectorExpr(0) is useful for creating new empty expressions that you can perform operatotions on later
func (VectorLinearExpr) AtVec ¶
func (vle VectorLinearExpr) AtVec(idx int) ScalarExpression
AtVec Description:
func (VectorLinearExpr) Check ¶
func (vle VectorLinearExpr) Check() error
Check Description:
Checks to see if the VectorLinearExpression is well-defined.
func (VectorLinearExpr) Comparison ¶
func (vle VectorLinearExpr) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
Comparison Description:
Compares the input vector linear expression with respect to the expression rhsIn and the sense senseIn.
func (VectorLinearExpr) Constant ¶
func (vle VectorLinearExpr) Constant() mat.VecDense
Constant Description:
Returns the vector which is given as an offset vector in the linear expression represented by v (the c in the above expression).
func (VectorLinearExpr) Copy ¶ added in v0.4.0
func (vle VectorLinearExpr) Copy() VectorLinearExpr
Copy Description:
This method copies the contents of a Vector Linear Expression.
func (VectorLinearExpr) Dims ¶ added in v0.4.0
func (vle VectorLinearExpr) Dims() []int
Dims Description:
This method returns the dimensions of the KVectorTranspose object.
func (VectorLinearExpr) Eq ¶
func (vle VectorLinearExpr) Eq(rightIn interface{}, errors ...error) (Constraint, error)
Eq Description:
Creates a constraint between the current vector linear expression v and the rhs given by rhs.
func (VectorLinearExpr) GreaterEq ¶
func (vle VectorLinearExpr) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
GreaterEq Description:
Creates a VectorConstraint that declares vle is greater than or equal to the value to the right hand side rhs.
func (VectorLinearExpr) IDs ¶
func (vle VectorLinearExpr) IDs() []uint64
IDs Description:
Returns the MatProInterface ID of each variable in the current vector linear expression.
func (VectorLinearExpr) Len ¶
func (vle VectorLinearExpr) Len() int
Len Description:
The size of the constraint.
func (VectorLinearExpr) LessEq ¶
func (vle VectorLinearExpr) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
LessEq Description:
Creates a VectorConstraint that declares vle is less than or equal to the value to the right hand side rhs.
func (VectorLinearExpr) LinearCoeff ¶
func (vle VectorLinearExpr) LinearCoeff() mat.Dense
LinearCoeff Description:
Returns the matrix which is applied as a coefficient to the vector X in our expression.
func (VectorLinearExpr) Multiply ¶ added in v0.4.0
func (vle VectorLinearExpr) Multiply(rightIn interface{}, errors ...error) (Expression, error)
Multiply Description:
Multiplication of a VarVector with another expression.
func (VectorLinearExpr) NumVars ¶
func (vle VectorLinearExpr) NumVars() int
NumVars Description:
Returns the goop2 ID of each variable in the current vector linear expression.
func (VectorLinearExpr) Plus ¶
func (vle VectorLinearExpr) Plus(rightIn interface{}, errors ...error) (Expression, error)
Plus Description:
Returns an expression which adds the expression e to the vector linear expression at hand.
func (VectorLinearExpr) RewriteInTermsOf ¶
func (vle VectorLinearExpr) RewriteInTermsOf(vv VarVector) VectorLinearExpr
RewriteInTermsOf Description:
Rewrites the VectorLinearExpression in terms of a new set of variables vv
Assumes:
vv contains all unique variables. All elements of vle.X are in vv.
func (VectorLinearExpr) ToSymbolic ¶ added in v0.5.0
func (vle VectorLinearExpr) ToSymbolic() (symbolic.Expression, error)
ToSymbolic Description:
This method returns the symbolic version of the KVectorTranspose expression.
func (VectorLinearExpr) Transpose ¶ added in v0.3.0
func (vle VectorLinearExpr) Transpose() Expression
Transpose Description:
This method creates the transpose of the current vector and returns it.
type VectorLinearExpressionTranspose ¶ added in v0.3.0
type VectorLinearExpressionTranspose struct { X VarVector L mat.Dense // Matrix of coefficients. Should match the dimensions of XIndices C mat.VecDense }
VectorLinearExpressionTranspose represents a linear general expression of the form
x^T * L^T + C^T
where L is an n x m matrix of coefficients that matches the dimension of x, the vector of variables and C is a constant vector
func (VectorLinearExpressionTranspose) AtVec ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) AtVec(idx int) ScalarExpression
AtVec Description:
func (VectorLinearExpressionTranspose) Check ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) Check() error
Check Description:
Checks to see if the VectorLinearExpressionTransposeession is well-defined.
func (VectorLinearExpressionTranspose) Comparison ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error)
Comparison Description:
Compares the input vector linear expression with respect to the expression rhsIn and the sense senseIn.
func (VectorLinearExpressionTranspose) Constant ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) Constant() mat.VecDense
Constant Description:
Returns the vector which is given as an offset vector in the linear expression represented by v (the c in the above expression).
func (VectorLinearExpressionTranspose) Dims ¶ added in v0.4.0
func (vlet VectorLinearExpressionTranspose) Dims() []int
Dims Description:
Returns the dimensions of the VectorLinearExpressionTranspose object.
func (VectorLinearExpressionTranspose) Eq ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) Eq(rightIn interface{}, errors ...error) (Constraint, error)
Eq Description:
Creates a constraint between the current vector linear expression v and the rhs given by rhs.
func (VectorLinearExpressionTranspose) GreaterEq ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error)
GreaterEq Description:
Creates a VectorConstraint that declares vle is greater than or equal to the value to the right hand side rhs.
func (VectorLinearExpressionTranspose) IDs ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) IDs() []uint64
IDs Description:
Returns the MatProInterface ID of each variable in the current vector linear expression.
func (VectorLinearExpressionTranspose) Len ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) Len() int
Len Description:
The size of the constraint.
func (VectorLinearExpressionTranspose) LessEq ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) LessEq(rightIn interface{}, errors ...error) (Constraint, error)
LessEq Description:
Creates a VectorConstraint that declares vle is less than or equal to the value to the right hand side rhs.
func (VectorLinearExpressionTranspose) LinearCoeff ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) LinearCoeff() mat.Dense
LinearCoeff Description:
Returns the matrix which is applied as a coefficient to the vector X in our expression.
func (VectorLinearExpressionTranspose) Mult ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) Mult(c float64) (VectorExpression, error)
Mult Description:
Returns an expression which scales every dimension of the vector linear expression by the input.
func (VectorLinearExpressionTranspose) Multiply ¶ added in v0.4.0
func (vlet VectorLinearExpressionTranspose) Multiply(rightIn interface{}, errors ...error) (Expression, error)
Multiply Description:
Multiplication of a VarVector with another expression.
func (VectorLinearExpressionTranspose) NumVars ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) NumVars() int
NumVars Description:
Returns the goop2 ID of each variable in the current vector linear expression.
func (VectorLinearExpressionTranspose) Plus ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) Plus(rightIn interface{}, errors ...error) (Expression, error)
Plus Description:
Returns an expression which adds the expression e to the vector linear expression at hand.
func (VectorLinearExpressionTranspose) RewriteInTermsOf ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) RewriteInTermsOf(vv VarVector) VectorLinearExpressionTranspose
RewriteInTermsOf Description:
Rewrites the VectorLinearExpressionTransposeession in terms of a new set of variables vv
Assumes:
vv contains all unique variables. All elements of vle.X are in vv.
func (VectorLinearExpressionTranspose) ToScalarLinearExpression ¶ added in v0.4.0
func (vlet VectorLinearExpressionTranspose) ToScalarLinearExpression() (ScalarLinearExpr, error)
func (VectorLinearExpressionTranspose) ToSymbolic ¶ added in v0.5.0
func (vlet VectorLinearExpressionTranspose) ToSymbolic() (symbolic.Expression, error)
ToSymbolic Description:
Returns the symbolic version of the vector linear expression transpose.
func (VectorLinearExpressionTranspose) Transpose ¶ added in v0.3.0
func (vlet VectorLinearExpressionTranspose) Transpose() Expression
Transpose Description:
This method creates the transpose of the current vector and returns it.
Source Files ¶
- constant.go
- constr_sense.go
- constraint.go
- errors.go
- expression.go
- model.go
- objective.go
- operators.go
- scalar_constraint.go
- scalar_expression.go
- scalar_linear_expr.go
- scalar_quadratic_expression.go
- util.go
- var_vector.go
- var_vector_transpose.go
- vars.go
- vector_constant.go
- vector_constant_transpose.go
- vector_constraint.go
- vector_expression.go
- vector_linear_expression.go
- vector_linear_expression_transpose.go