diff --git a/optim/constant.go b/optim/constant.go index 9b5f01f..0e7b343 100644 --- a/optim/constant.go +++ b/optim/constant.go @@ -8,45 +8,63 @@ import ( const ( // Zero is a constant expression representing the value 0. + // + // Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. Zero = K(0) // One is a constant expression representing the value 1. + // + // Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. One = K(1) ) // K is a constant expression type for an MIP (Mixed Integer Program). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type K float64 // Variables returns all variables included in the expression. // For constant K, there are no variables, so it returns an empty slice. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) Variables() []Variable { return []Variable{} } // NumVars returns the number of variables in the expression. // For constant K, this is always 0. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) NumVars() int { return 0 } // IDs returns a slice of the variable IDs in the expression. // For constant K, this is always nil. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) IDs() []uint64 { return nil } // Coeffs returns a slice of the coefficients in the expression. // For constant K, this is always nil. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) Coeffs() []float64 { return nil } // Constant returns the constant additive value in the expression. // For constant K, this is just the constant's value. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) Constant() float64 { return float64(c) } // Plus adds the current expression to another and returns the resulting expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) Plus(rightIn interface{}, errors ...error) (Expression, error) { // Input Processing err := CheckErrors(errors) @@ -78,21 +96,29 @@ func (c K) Plus(rightIn interface{}, errors ...error) (Expression, error) { } // LessEq returns a less than or equal to (<=) constraint between the current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) LessEq(rightIn interface{}, errors ...error) (Constraint, error) { return c.Comparison(rightIn, SenseLessThanEqual, errors...) } // GreaterEq returns a greater than or equal to (>=) constraint between the current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error) { return c.Comparison(rightIn, SenseGreaterThanEqual, errors...) } // Eq returns an equality (==) constraint between the current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) Eq(rightIn interface{}, errors ...error) (Constraint, error) { return c.Comparison(rightIn, SenseEqual, errors...) } // Comparison compares the receiver with expression rhs in the sense provided by sense. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) { // InputProcessing err := CheckErrors(errors) @@ -112,6 +138,8 @@ func (c K) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Co } // Multiply multiplies the input constant by another expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) Multiply(term1 interface{}, errors ...error) (Expression, error) { // Constants @@ -217,19 +245,30 @@ func (c K) Multiply(term1 interface{}, errors ...error) (Expression, error) { } } +// Dims returns the dimensions of the constant K expression, which is always [1, 1] for a scalar. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) Dims() []int { return []int{1, 1} // Signifies scalar } +// Check verifies that the constant K expression is valid. For K, this always returns nil. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) Check() error { return nil } +// Transpose returns the transpose of the constant K expression, which is the constant itself. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) Transpose() Expression { return c } // ToSymbolic converts the constant to a symbolic expression (i.e., one that uses the symbolic math toolbox). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (c K) ToSymbolic() (symbolic.Expression, error) { return symbolic.K(c), nil } diff --git a/optim/constr_sense.go b/optim/constr_sense.go index 0f511a7..3112f6c 100644 --- a/optim/constr_sense.go +++ b/optim/constr_sense.go @@ -3,24 +3,32 @@ package optim import "github.com/MatProGo-dev/SymbolicMath.go/symbolic" // 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 +// integration with Gurobi, the senses have been encoded using a byte in // the same way Gurobi encodes the constraint senses. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type ConstrSense byte // Different constraint senses conforming to Gurobi's encoding. const ( - SenseEqual ConstrSense = '=' - SenseLessThanEqual = '<' - SenseGreaterThanEqual = '>' + // SenseEqual represents the equality constraint sense (==). + // + // Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. + SenseEqual ConstrSense = '=' + // SenseLessThanEqual represents the less-than-or-equal constraint sense (<=). + // + // Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. + SenseLessThanEqual = '<' + // SenseGreaterThanEqual represents the greater-than-or-equal constraint sense (>=). + // + // Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. + SenseGreaterThanEqual = '>' ) -/* -ToSymbolic -Description: - - Converts a constraint sense to a the appropriate representation - in the symbolic math toolbox. -*/ +// ToSymbolic converts a constraint sense to the appropriate representation +// in the symbolic math toolbox. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (cs ConstrSense) ToSymbolic() symbolic.ConstrSense { switch cs { case SenseEqual: @@ -33,12 +41,9 @@ func (cs ConstrSense) ToSymbolic() symbolic.ConstrSense { return '1' } -/* -String -Description: - - Returns the string representation of the constraint sense. -*/ +// String returns the string representation of the constraint sense. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (cs ConstrSense) String() string { switch cs { case SenseEqual: diff --git a/optim/constraint.go b/optim/constraint.go index 3460296..f11b888 100644 --- a/optim/constraint.go +++ b/optim/constraint.go @@ -1,12 +1,9 @@ package optim -/* -constraint.go -Description: - Defines an interface that we are meant to use with the ScalarContraint and VectorConstraint - objects. -*/ - +// Constraint is an interface for use with the ScalarConstraint and +// VectorConstraint objects. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type Constraint interface { Left() Expression Right() Expression @@ -14,6 +11,10 @@ type Constraint interface { Check() error } +// IsConstraint returns true if the input is a valid Constraint type +// (ScalarConstraint or VectorConstraint). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func IsConstraint(c interface{}) bool { switch c.(type) { case ScalarConstraint: diff --git a/optim/doc.go b/optim/doc.go new file mode 100644 index 0000000..0d14503 --- /dev/null +++ b/optim/doc.go @@ -0,0 +1,7 @@ +// Package optim provides interfaces and types for modeling Mathematical Programs +// (e.g., Convex Optimization problems) in Go. +// +// Deprecated: This package is deprecated and will not receive further updates. +// Users should migrate to github.com/MatProGo-dev/SymbolicMath.go which provides +// improved functionality and ongoing support. +package optim diff --git a/optim/errors.go b/optim/errors.go index b65cab8..4e5396e 100644 --- a/optim/errors.go +++ b/optim/errors.go @@ -10,12 +10,20 @@ dimension.go /* Type Definitions */ +// DimensionError represents an error that occurs when two expressions have +// incompatible dimensions for a given operation. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type DimensionError struct { Arg1 Expression Arg2 Expression Operation string // Either multiply or Plus } +// UnexpectedInputError represents an error that occurs when an unexpected +// input type is provided to an operation. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type UnexpectedInputError struct { InputInQuestion interface{} Operation string @@ -23,6 +31,9 @@ type UnexpectedInputError struct { /* Methods */ +// Error returns a string representation of the DimensionError. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (de DimensionError) Error() string { dimStrings := de.ArgDimsAsStrings() return fmt.Sprintf( @@ -33,6 +44,9 @@ func (de DimensionError) Error() string { ) } +// ArgDimsAsStrings returns the dimensions of both arguments as a slice of strings. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (de DimensionError) ArgDimsAsStrings() []string { // Create string for arg 1 arg1DimsAsString := "(" @@ -58,6 +72,9 @@ func (de DimensionError) ArgDimsAsStrings() []string { } +// Error returns a string representation of the UnexpectedInputError. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (uie UnexpectedInputError) Error() string { return fmt.Sprintf( "Unexpected input to \"%v\" operation: %T", diff --git a/optim/expression.go b/optim/expression.go index 85dff6f..38a004e 100644 --- a/optim/expression.go +++ b/optim/expression.go @@ -4,20 +4,11 @@ import ( "fmt" "github.com/MatProGo-dev/SymbolicMath.go/symbolic" ) - -/* -matrix_expression.go -Description: - This file holds all of the functions and methods related to the Expression - interface. -*/ - -/* -Expression -Description: - - This interface should be implemented by and ScalarExpression and VectorExpression -*/ +// Expression is an interface that should be implemented by any ScalarExpression +// and VectorExpression. It provides methods for arithmetic operations and +// constraint creation. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type Expression interface { // NumVars returns the number of variables in the expression NumVars() int @@ -59,16 +50,17 @@ type Expression interface { ToSymbolic() (symbolic.Expression, error) } -/* -IsExpression -Description: - - Tests whether or not the input variable is one of the expression types. -*/ +// IsExpression tests whether or not the input variable is one of the expression types. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func IsExpression(e interface{}) bool { return IsScalarExpression(e) || IsVectorExpression(e) } +// ToExpression converts the input to an Expression, returning an error if the +// input is not a recognized scalar or vector expression type. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func ToExpression(e interface{}) (Expression, error) { switch { case IsScalarExpression(e): @@ -80,6 +72,11 @@ func ToExpression(e interface{}) (Expression, error) { } } +// CheckDimensionsInMultiplication checks that the dimensions of the two +// expressions are compatible for multiplication. It returns an error if the +// number of columns in left does not match the number of rows in right. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func CheckDimensionsInMultiplication(left, right Expression) error { // Check that the # of columns in left // matches the # of rows in right @@ -94,6 +91,11 @@ func CheckDimensionsInMultiplication(left, right Expression) error { return nil } +// CheckDimensionsInAddition checks that the dimensions of the two expressions +// are compatible for addition. It returns an error if the dimensions do not match, +// unless one of the expressions is a scalar expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func CheckDimensionsInAddition(left, right Expression) error { // Check that the size of columns in left and right agree dimsAreMatched := (left.Dims()[0] == right.Dims()[0]) && (left.Dims()[1] == right.Dims()[1]) diff --git a/optim/model.go b/optim/model.go index df3bca9..7eb48bd 100644 --- a/optim/model.go +++ b/optim/model.go @@ -5,9 +5,11 @@ import ( ) // Model represents the overall constrained linear optimization model to be -// solved. Model contains all the variables associated with the optimization +// solved. It contains all variables associated with the optimization // problem, constraints, objective, and parameters. New variables can only be // created using an instantiated Model. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type Model struct { Name string Variables []Variable @@ -15,34 +17,31 @@ type Model struct { Obj *Objective } -// NewModel returns a new model with some default arguments such as not to show -// the log. +// NewModel returns a new model with the given name. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func NewModel(name string) *Model { return &Model{Name: name} } -/* -AddVariable -Description: - - This method adds an "unbounded" continuous variable to the model. -*/ +// AddVariable adds an "unbounded" continuous variable to the model. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) AddVariable() Variable { return m.AddRealVariable() } -/* -AddRealVariable -Description: - - Adds a Real variable to the model and returns said variable. -*/ +// AddRealVariable adds a real-valued variable to the model and returns said variable. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) AddRealVariable() Variable { return m.AddVariableClassic(-INFINITY, INFINITY, Continuous) } -// AddVariableClassic AddVariable adds a variable of a given variable type to the model given the lower +// AddVariableClassic adds a variable of a given variable type to the model given the lower // and upper value limits. This variable is returned. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) AddVariableClassic(lower, upper float64, vtype VarType) Variable { id := uint64(len(m.Variables)) newVar := Variable{id, lower, upper, vtype} @@ -50,18 +49,17 @@ func (m *Model) AddVariableClassic(lower, upper float64, vtype VarType) Variable return newVar } -// AddBinaryVariable AddBinaryVar adds a binary variable to the model and returns said variable. +// AddBinaryVariable adds a binary variable to the model and returns said variable. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) AddBinaryVariable() Variable { return m.AddVariableClassic(0, 1, Binary) } -/* -AddVariableVector -Description: - - Creates a VarVector object using a constructor that assumes you want an "unbounded" vector of real optimization - variables. -*/ +// AddVariableVector creates a VarVector of the given dimension containing +// unbounded real optimization variables. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) AddVariableVector(dim int) VarVector { // Constants @@ -73,12 +71,10 @@ func (m *Model) AddVariableVector(dim int) VarVector { return VarVector{varSlice} } -/* -AddVariableVectorClassic -Description: - - The classic version of AddVariableVector defined in the original goop. -*/ +// AddVariableVectorClassic adds a vector of num variables with the given lower +// bound, upper bound, and variable type to the model. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) AddVariableVectorClassic( num int, lower, upper float64, vtype VarType, ) VarVector { @@ -94,12 +90,16 @@ func (m *Model) AddVariableVectorClassic( // AddBinaryVariableVector adds a vector of binary variables to the model and // returns the slice. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) AddBinaryVariableVector(num int) VarVector { return m.AddVariableVectorClassic(num, 0, 1, Binary) } // AddVariableMatrix adds a matrix of variables of a given type to the model with // lower and upper value limits and returns the resulting slice. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) AddVariableMatrix( rows, cols int, lower, upper float64, vtype VarType, ) [][]Variable { @@ -114,11 +114,15 @@ func (m *Model) AddVariableMatrix( // AddBinaryVariableMatrix adds a matrix of binary variables to the model and returns // the resulting slice. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) AddBinaryVariableMatrix(rows, cols int) [][]Variable { return m.AddVariableMatrix(rows, cols, 0, 1, Binary) } -// AddConstraint AddConstr adds the given constraint to the model. +// AddConstraint adds the given constraint to the model. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) AddConstraint(constr Constraint, errors ...error) error { // Constants @@ -133,16 +137,10 @@ func (m *Model) AddConstraint(constr Constraint, errors ...error) error { return nil } -/* -SetObjective -Description: - sets the objective of the model given an expression and - objective sense. -Notes: - To make this function easier to parse, we will assume an expression - is given, even though objectives are normally scalars. -*/ - +// SetObjective sets the objective of the model given an expression and +// objective sense. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) SetObjective(e Expression, sense ObjSense) error { // Input Processing se, err := ToScalarExpression(e) @@ -155,12 +153,9 @@ func (m *Model) SetObjective(e Expression, sense ObjSense) error { return nil } -/* -Check -Description: - - Checks the model for errors. -*/ +// Check checks the model for errors, ensuring that at least one variable exists. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (m *Model) Check() error { // Constants diff --git a/optim/objective.go b/optim/objective.go index c61698d..723f03e 100644 --- a/optim/objective.go +++ b/optim/objective.go @@ -2,23 +2,35 @@ package optim // Objective represents an optimization objective given an expression and // objective sense (maximize or minimize). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type Objective struct { ScalarExpression Sense ObjSense } // NewObjective returns a new optimization objective given an expression and -// objective sense +// objective sense. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func NewObjective(e ScalarExpression, sense ObjSense) *Objective { return &Objective{e, sense} } // ObjSense represents whether an optimization objective is to be maximized or -// minimized. This implementation conforms to the Gurobi encoding +// minimized. This implementation conforms to the Gurobi encoding. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type ObjSense int -// Objective senses (minimize and maximize) encoding using Gurobi's standard +// Objective senses (minimize and maximize) encoding using Gurobi's standard. const ( + // SenseMinimize indicates that the objective should be minimized. + // + // Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. SenseMinimize ObjSense = 1 - SenseMaximize = -1 + // SenseMaximize indicates that the objective should be maximized. + // + // Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. + SenseMaximize = -1 ) diff --git a/optim/operators.go b/optim/operators.go index 6bf770c..09b7d60 100644 --- a/optim/operators.go +++ b/optim/operators.go @@ -4,43 +4,31 @@ import ( "fmt" "gonum.org/v1/gonum/mat" ) - -/* -operators.go -Description: - Defines the operators that transform variables and expressions into expressions or constraints. -*/ - -/* -Eq -Description: - - Returns a constraint representing lhs == rhs -*/ +// Eq returns a constraint representing lhs == rhs. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func Eq(lhs, rhs interface{}) (Constraint, error) { return Comparison(lhs, rhs, SenseEqual) } -// LessEq returns a constraint representing lhs <= rhs +// LessEq returns a constraint representing lhs <= rhs. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func LessEq(lhs, rhs interface{}) (Constraint, error) { return Comparison(lhs, rhs, SenseLessThanEqual) } -// GreaterEq returns a constraint representing lhs >= rhs +// GreaterEq returns a constraint representing lhs >= rhs. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func GreaterEq(lhs, rhs interface{}) (Constraint, error) { return Comparison(lhs, rhs, SenseGreaterThanEqual) } -/* -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) -*/ +// Comparison compares the two inputs lhs (Left Hand Side) and rhs (Right Hand Side) +// in the sense provided in sense. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func Comparison(lhs, rhs interface{}, sense ConstrSense) (Constraint, error) { // Input Processing var err error @@ -66,12 +54,10 @@ func Comparison(lhs, rhs interface{}, sense ConstrSense) (Constraint, error) { } -/* -Multiply -Description: - - Defines the multiplication between two objects. -*/ +// Multiply defines the multiplication between two objects, returning the +// resulting expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func Multiply(term1, term2 interface{}) (Expression, error) { // Constants @@ -121,6 +107,8 @@ func Multiply(term1, term2 interface{}) (Expression, error) { // Sum returns the sum of the given expressions. It creates a new empty // expression and adds to it the given expressions. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func Sum(exprs ...interface{}) (Expression, error) { // Constants diff --git a/optim/scalar_constraint.go b/optim/scalar_constraint.go index 049a7d0..1c98c4d 100644 --- a/optim/scalar_constraint.go +++ b/optim/scalar_constraint.go @@ -2,34 +2,42 @@ package optim import "fmt" -// 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 +// ScalarConstraint represents a linear constraint of the form x <= y, x >= y, or +// x == y. ScalarConstraint uses a left and right hand side expression along with a +// constraint sense (<=, >=, ==) to represent a generalized linear constraint. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type ScalarConstraint struct { LeftHandSide ScalarExpression RightHandSide ScalarExpression Sense ConstrSense } +// Left returns the left hand side expression of the scalar constraint. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sc ScalarConstraint) Left() Expression { return sc.LeftHandSide } +// Right returns the right hand side expression of the scalar constraint. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sc ScalarConstraint) Right() Expression { return sc.RightHandSide } +// ConstrSense returns the sense of the scalar constraint. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sc ScalarConstraint) ConstrSense() ConstrSense { return sc.Sense } -/* -IsLinear -Description: - - Describes whether or not a given linear constraint is - linear or not. -*/ +// IsLinear returns true if the scalar constraint is linear (i.e., neither side +// is a ScalarQuadraticExpression). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sc ScalarConstraint) IsLinear() (bool, error) { // Check left and right side. if _, tf := sc.LeftHandSide.(ScalarQuadraticExpression); tf { @@ -46,13 +54,10 @@ func (sc ScalarConstraint) IsLinear() (bool, error) { return true, nil } -/* -Simplify -Description: - - Moves all of the variables of the ScalarConstraint to its - left hand side. -*/ +// Simplify moves all of the variables of the ScalarConstraint to its +// left hand side. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sc ScalarConstraint) Simplify() (ScalarConstraint, error) { // Create LHS newLHS := sc.LeftHandSide @@ -110,13 +115,10 @@ func (sc ScalarConstraint) Simplify() (ScalarConstraint, error) { } -/* -Check -Description: - - Checks the validity of the ScalarConstraint, this makes sure that: - - The Sense if either SenseEqual, SenseLessThanEqual, or SenseGreaterThanEqual -*/ +// Check checks the validity of the ScalarConstraint, ensuring the sense is +// recognized and both hand sides are valid. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sc ScalarConstraint) Check() error { // Check sense switch sc.Sense { diff --git a/optim/scalar_expression.go b/optim/scalar_expression.go index 5035c85..a16d3b2 100644 --- a/optim/scalar_expression.go +++ b/optim/scalar_expression.go @@ -9,6 +9,8 @@ import ( // 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. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type ScalarExpression interface { // Variables returns the variables included in the scalar expression Variables() []Variable @@ -68,21 +70,19 @@ type ScalarExpression interface { Check() error } -// NewScalarExpression 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 +// NewScalarExpression returns a new expression with a single additive constant value, c, +// and no variables. Creating an expression like sum := NewScalarExpression(0) is useful +// for creating new empty expressions that you can perform operations on later. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func NewScalarExpression(c float64) ScalarExpression { return ScalarLinearExpr{C: c} } -/* -IsScalarExpression -Description: - - Determines whether or not an input object is a - valid "ScalarExpression" according to MatProInterface. -*/ +// IsScalarExpression determines whether or not an input object is a +// valid ScalarExpression according to MatProInterface. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func IsScalarExpression(e interface{}) bool { // Check each type switch e.(type) { @@ -102,13 +102,10 @@ func IsScalarExpression(e interface{}) bool { } } -/* -ToScalarExpression -Description: - - Converts the input expression to a valid type that - implements "ScalarExpression". -*/ +// ToScalarExpression converts the input expression to a valid type that +// implements ScalarExpression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func ToScalarExpression(e interface{}) (ScalarExpression, error) { // Input Processing if !IsScalarExpression(e) { diff --git a/optim/scalar_linear_expr.go b/optim/scalar_linear_expr.go index 8c74d4e..54605e7 100644 --- a/optim/scalar_linear_expr.go +++ b/optim/scalar_linear_expr.go @@ -10,8 +10,10 @@ import ( // // 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 +// where L is a vector of coefficients that matches the dimension of x, the vector of variables, +// and C is a constant. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type ScalarLinearExpr struct { X VarVector L mat.VecDense // Vector of coefficients. Should match the dimensions of XIndices @@ -20,31 +22,36 @@ type ScalarLinearExpr struct { // NewLinearExpr returns a new expression with a single additive constant // value, c, and no variables. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func NewLinearExpr(c float64) ScalarExpression { return ScalarLinearExpr{C: c} } -/* -Variables -Description: - - This function returns a slice containing all unique variables in the linear expression le. -*/ +// Variables returns a slice containing all unique variables in the linear expression sle. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) Variables() []Variable { return UniqueVars(sle.X.Elements) } -// NumVars returns the number of variables in the expression +// NumVars returns the number of variables in the expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) NumVars() int { return sle.X.Len() } -// IDs Vars returns a slice of the Var ids in the expression +// IDs returns a slice of the Var ids in the expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) IDs() []uint64 { return sle.X.IDs() } -// Coeffs returns a slice of the coefficients in the expression +// Coeffs returns a slice of the coefficients in the expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) Coeffs() []float64 { var coeffsOut []float64 for i := 0; i < sle.L.Len(); i++ { @@ -53,15 +60,17 @@ func (sle ScalarLinearExpr) Coeffs() []float64 { return coeffsOut } -// Constant returns the constant additive value in the expression +// Constant returns the constant additive value in the expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) Constant() float64 { return sle.C } -/* -Check -Description: -*/ +// Check verifies that the ScalarLinearExpr is well-formed, ensuring the +// length of L matches the length of X. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) Check() error { // Compare lengths of X and L if sle.L.Len() != sle.X.Len() { @@ -77,7 +86,9 @@ func (sle ScalarLinearExpr) Check() error { } // Plus adds the current expression to another and returns the resulting -// expression +// expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) Plus(e interface{}, errors ...error) (Expression, error) { // Input Processing err := sle.Check() @@ -150,33 +161,32 @@ func (sle ScalarLinearExpr) Plus(e interface{}, errors ...error) (Expression, er } // LessEq returns a less than or equal to (<=) constraint between the -// current expression and another +// current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) LessEq(rightIn interface{}, errors ...error) (Constraint, error) { return sle.Comparison(rightIn, SenseLessThanEqual, errors...) } // GreaterEq returns a greater than or equal to (>=) constraint between the -// current expression and another +// current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error) { return sle.Comparison(rightIn, SenseGreaterThanEqual, errors...) } // Eq returns an equality (==) constraint between the current expression -// and another +// and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) Eq(rightIn interface{}, errors ...error) (Constraint, error) { return sle.Comparison(rightIn, SenseEqual, errors...) } -/* -Comparison -Description: - - This method compares the receiver with expression rhs in the sense provided by sense. - -Usage: - - constr, err := e.Comparison(expr1,SenseGreaterThanEqual) -*/ +// Comparison compares the receiver with expression rhs in the sense provided by sense. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) { // Input Processing err := sle.Check() @@ -197,16 +207,10 @@ func (sle ScalarLinearExpr) Comparison(rhsIn interface{}, sense ConstrSense, err return ScalarConstraint{sle, rhs, sense}, nil } -/* -RewriteInTermsOf -Description: - - Rewrites the current linear expression in terms of the new variables. - -Usage: - - rewrittenLE, err := orignalLE.RewriteInTermsOfIndices(newXIndices1) -*/ +// RewriteInTermsOf rewrites the current linear expression in terms of the new +// variables newX. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) RewriteInTermsOf(newX VarVector) (ScalarLinearExpr, error) { // Create new Linear Express var newLE ScalarLinearExpr = ScalarLinearExpr{ @@ -250,12 +254,9 @@ func (sle ScalarLinearExpr) RewriteInTermsOf(newX VarVector) (ScalarLinearExpr, } -/* -Multiply -Description: - - multiplies the current expression to another and returns the resulting expression -*/ +// Multiply multiplies the current expression to another and returns the resulting expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) Multiply(rightInput interface{}, errors ...error) (Expression, error) { // Input Processing err := sle.Check() @@ -386,10 +387,9 @@ func (sle ScalarLinearExpr) Multiply(rightInput interface{}, errors ...error) (E } } -/* -Copy -Description: -*/ +// Copy returns a copy of the ScalarLinearExpr. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) Copy() ScalarLinearExpr { // Constants @@ -405,31 +405,24 @@ func (sle ScalarLinearExpr) Copy() ScalarLinearExpr { return sleOut } -/* -Dims -Description: - - Dimensions of a -*/ +// Dims returns the dimensions of the ScalarLinearExpr, which is always [1, 1]. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) Dims() []int { return []int{1, 1} // Represents scalar } -/* -Transpose -Description: -*/ +// Transpose returns the transpose of the ScalarLinearExpr, which is the expression itself. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) Transpose() Expression { return sle } -/* -ToSymbolic -Description: - - Converts the constant to a symbolic expression (i.e., one that uses the - symbolic math toolbox). -*/ +// ToSymbolic converts the scalar linear expression to a symbolic expression +// (i.e., one that uses the symbolic math toolbox). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (sle ScalarLinearExpr) ToSymbolic() (symbolic.Expression, error) { // Check for errors err := sle.Check() diff --git a/optim/scalar_quadratic_expression.go b/optim/scalar_quadratic_expression.go index c4d5754..d9d579e 100644 --- a/optim/scalar_quadratic_expression.go +++ b/optim/scalar_quadratic_expression.go @@ -16,14 +16,15 @@ Description: // Type Definitions // ================ -/* -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 -*/ +// ScalarQuadraticExpression represents a quadratic expression of optimization +// variables written as: +// +// x' * Q * x + L * x + C +// +// where Q is the quadratic term matrix, L is the linear term vector, and C is +// the constant term. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type ScalarQuadraticExpression struct { Q mat.Dense // Quadratic Term L mat.VecDense // Linear Term @@ -34,13 +35,10 @@ type ScalarQuadraticExpression struct { // Member Functions // ================ -/* -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. -*/ +// NewQuadraticExpr_qb0 returns a basic ScalarQuadraticExpression with only +// the matrix Q being defined; all other values are assumed to be zero. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func NewQuadraticExpr_qb0(QIn mat.Dense, xIn VarVector) (ScalarQuadraticExpression, error) { // Constants numXIndices := xIn.Len() @@ -57,12 +55,10 @@ func NewQuadraticExpr_qb0(QIn mat.Dense, xIn VarVector) (ScalarQuadraticExpressi return NewQuadraticExpr(QIn, *q, 0.0, xIn) } -/* -NewQuadraticExpr -Description: - - NewQuadraticExpr returns a basic Quadratic expression whuch is defined by QIn, qIn and bIn. -*/ +// NewQuadraticExpr returns a ScalarQuadraticExpression defined by QIn, qIn, bIn, +// and xIn. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func NewQuadraticExpr(QIn mat.Dense, qIn mat.VecDense, bIn float64, xIn VarVector) (ScalarQuadraticExpression, error) { // Constants @@ -83,13 +79,10 @@ func NewQuadraticExpr(QIn mat.Dense, qIn mat.VecDense, bIn float64, xIn VarVecto return tempExpr, nil } -/* -Check -Description: - - This function checks the dimensions of all of the members of the quadratic expression which are slices. - They should have compatible dimensions. -*/ +// Check verifies the dimensions of all members of the quadratic expression, +// ensuring they have compatible dimensions. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) Check() error { // Make the number of elements in q be the dimension of the x in the expression. xLen := qe.X.Len() @@ -108,53 +101,32 @@ func (qe ScalarQuadraticExpression) Check() error { return nil } -/* -Variables -Description: - - This function returns a slice containing all unique variables in the expression qe. -*/ +// Variables returns a slice containing all unique variables in the expression qe. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) Variables() []Variable { return UniqueVars(qe.X.Elements) } -/* -NumVars -Description: - - Returns the number of variables in the expression. - To make this actually meaningful, we only count the unique vars. -*/ +// NumVars returns the number of unique variables in the expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) NumVars() int { return len(qe.IDs()) } -/* -Vars -Description: - - Returns the ids of all of the variables in the quadratic expression. -*/ +// IDs returns the ids of all of the variables in the quadratic expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) IDs() []uint64 { return qe.X.IDs() } -/* -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] ] -*/ +// Coeffs returns the slice of all coefficient values for each pair of variable +// tuples in the quadratic expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) Coeffs() []float64 { // Create container for all coefficients var coefficientList []float64 @@ -181,25 +153,16 @@ func (qe ScalarQuadraticExpression) Coeffs() []float64 { return coefficientList } -/* -Constant -Description: - - Returns the constant value associated with a quadratic expression. -*/ +// Constant returns the constant value associated with the quadratic expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) Constant() float64 { return qe.C } -/* -Plus -Description: - - Adds a quadratic expression to either: - - A Quadratic Expression, - - A Linear Expression, or - - A Constant -*/ +// Plus adds the quadratic expression to another expression and returns the result. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) Plus(e interface{}, errors ...error) (Expression, error) { // Constants @@ -268,50 +231,33 @@ func (qe ScalarQuadraticExpression) Plus(e interface{}, errors ...error) (Expres } -/* -LessEq -Description: - - LessEq returns a less than or equal to (<=) constraint between the - current expression and another -*/ +// LessEq returns a less than or equal to (<=) constraint between the +// current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) LessEq(rightIn interface{}, errors ...error) (Constraint, error) { return qe.Comparison(rightIn, SenseLessThanEqual, errors...) } -/* -GreaterEq -Description: - - GreaterEq returns a greater than or equal to (>=) constraint between the - current expression and another -*/ +// GreaterEq returns a greater than or equal to (>=) constraint between the +// current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error) { return qe.Comparison(rightIn, SenseGreaterThanEqual, errors...) } -/* -Eq -Description: - - Form an equality constraint with this equality constraint and another - Eq returns an equality (==) constraint between the current expression - and another -*/ +// Eq returns an equality (==) constraint between the current expression +// and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) Eq(rightIn interface{}, errors ...error) (Constraint, error) { return qe.Comparison(rightIn, SenseEqual, errors...) } -/* -Comparison -Description: - - This method compares the receiver with expression rhs in the sense provided by sense. - -Usage: - - constr, err := qe.Comparison(expr1,SenseGreaterThanEqual) -*/ +// Comparison compares the receiver with expression rhs in the sense provided by sense. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) { // Input Processing rhs, err := ToScalarExpression(rhsIn) @@ -327,16 +273,10 @@ func (qe ScalarQuadraticExpression) Comparison(rhsIn interface{}, sense ConstrSe return ScalarConstraint{qe, rhs, sense}, nil } -/* -RewriteInTermsOfIndices -Description: - - Rewrites the current quadratic expression in terms of the new variables. - -Usage: - - rewrittenQE, err := orignalQE.RewriteInTermsOfIndices(newXIndices1) -*/ +// RewriteInTermsOf rewrites the current quadratic expression in terms of the +// new variables newX. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) RewriteInTermsOf(newX VarVector) (ScalarQuadraticExpression, error) { // Create new Quadratic Expression // =============================== @@ -402,13 +342,10 @@ func (qe ScalarQuadraticExpression) RewriteInTermsOf(newX VarVector) (ScalarQuad } -/* -Multiply -Description: - - Multiply() multiplies the current expression to another and returns the - resulting expression -*/ +// Multiply multiplies the current expression to another and returns the +// resulting expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) Multiply(val interface{}, errors ...error) (Expression, error) { // Input Processing if len(errors) > 0 { @@ -458,27 +395,25 @@ func (qe ScalarQuadraticExpression) Multiply(val interface{}, errors ...error) ( } } +// Dims returns the dimensions of the ScalarQuadraticExpression, which is always [1, 1]. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) Dims() []int { return []int{1, 1} } -/* -Transpose -Description: - - TBD -*/ +// Transpose returns the transpose of the ScalarQuadraticExpression, which is +// the expression itself. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) Transpose() Expression { return qe } -/* -ToSymbolic -Description: - - This function converts the quadratic expression into a symbolic expression. - (i.e., one that uses the symbolic math toolbox). -*/ +// ToSymbolic converts the quadratic expression into a symbolic expression +// (i.e., one that uses the symbolic math toolbox). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (qe ScalarQuadraticExpression) ToSymbolic() (symbolic.Expression, error) { // Input Checking err := qe.Check() diff --git a/optim/util.go b/optim/util.go index d6fe98d..c23f1e2 100644 --- a/optim/util.go +++ b/optim/util.go @@ -5,13 +5,15 @@ import ( "gonum.org/v1/gonum/mat" ) -// Constants -// ========= - +// INFINITY represents a large constant value used for unbounded constraints. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. const INFINITY = 1e100 -// SumVars returns the sum of the given variables. It creates a new empty -// expression and adds to it the given variables. +// SumVars returns the sum of the given variables by creating a new empty +// expression and adding the given variables to it. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func SumVars(vs ...Variable) ScalarExpression { newExpr := NewScalarExpression(0) for _, v := range vs { @@ -23,6 +25,8 @@ func SumVars(vs ...Variable) ScalarExpression { // SumRow returns the sum of all the variables in a single specified row of // a variable matrix. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func SumRow(vs [][]Variable, row int) ScalarExpression { newExpr := NewScalarExpression(0) for col := 0; col < len(vs[0]); col++ { @@ -34,6 +38,8 @@ func SumRow(vs [][]Variable, row int) ScalarExpression { // SumCol returns the sum of all variables in a single specified column of // a variable matrix. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func SumCol(vs [][]Variable, col int) ScalarExpression { newExpr := NewScalarExpression(0) for row := 0; row < len(vs); row++ { @@ -43,14 +49,11 @@ func SumCol(vs [][]Variable, col int) ScalarExpression { return newExpr } -/* -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. -*/ +// FindInSlice 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 an error. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func FindInSlice(xIn interface{}, sliceIn interface{}) (int, error) { // Constants allowedTypes := []string{"string", "int", "uint64", "Variable"} @@ -129,12 +132,9 @@ func FindInSlice(xIn interface{}, sliceIn interface{}) (int, error) { } -/* -Unique -Description: - - Returns the unique list of variables in a slice of uint64's. -*/ +// Unique returns the unique list of uint64 values in the given slice. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func Unique(listIn []uint64) []uint64 { // Create unique list var uniqueList []uint64 @@ -158,13 +158,9 @@ func Unique(listIn []uint64) []uint64 { return uniqueList } -/* -OnesVector -Description: - - Returns a vector of ones with length lengthIn. - Note: this function assumes lengthIn is a positive number. -*/ +// OnesVector returns a vector of ones with the given length. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func OnesVector(lengthIn int) mat.VecDense { // Create the empty slice. elts := make([]float64, lengthIn) @@ -175,13 +171,9 @@ func OnesVector(lengthIn int) mat.VecDense { return *mat.NewVecDense(lengthIn, elts) } -/* -ZerosVector -Description: - - Returns a vector of zeros with length lengthIn. - Note: this function assumes lengthIn is a positive number. -*/ +// ZerosVector returns a vector of zeros with the given length. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func ZerosVector(lengthIn int) mat.VecDense { // Create the empty slice. elts := make([]float64, lengthIn) @@ -192,12 +184,10 @@ func ZerosVector(lengthIn int) mat.VecDense { return *mat.NewVecDense(lengthIn, elts) } -/* -ZerosMatrix -Description: - - Returns a dense matrix of all zeros. -*/ +// ZerosMatrix returns a dense matrix of all zeros with the given number of +// rows and columns. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func ZerosMatrix(nR, nC int) mat.Dense { // Create empty slice elts := make([]float64, nR*nC) @@ -210,13 +200,9 @@ func ZerosMatrix(nR, nC int) mat.Dense { return *mat.NewDense(nR, nC, elts) } -/* -Identity -Description: - - Returns a symmetric matrix that is the identity matrix. - Note: this function assumes lengthIn is a positive number. -*/ +// Identity returns a square identity matrix of the given dimension. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func Identity(dim int) mat.Dense { // Create the empty matrix. zeroBase := ZerosMatrix(dim, dim) @@ -229,10 +215,10 @@ func Identity(dim int) mat.Dense { return zeroBase } -/* -CheckExtras -Description: -*/ +// CheckExtras checks the extras slice for any errors. It returns an error if +// one of the extras is an error, or if there are more than one extras. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func CheckExtras(extras []interface{}) error { // Constants @@ -265,10 +251,10 @@ func CheckExtras(extras []interface{}) error { return nil } -/* -CheckErrors -Description: -*/ +// CheckErrors checks the extras slice of errors. It returns an error if one +// of the extras is non-nil, or if there are more than one extras. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func CheckErrors(extras []error) error { // Constants diff --git a/optim/var_vector.go b/optim/var_vector.go index f379a90..19f6533 100644 --- a/optim/var_vector.go +++ b/optim/var_vector.go @@ -6,52 +6,32 @@ import ( "gonum.org/v1/gonum/mat" ) -/* -var_vector.go -Description: - The VarVector type will represent a -*/ - -/* -VarVector -Description: - - Represnts a variable in a optimization problem. The variable is -*/ +// VarVector represents a vector of optimization variables. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type VarVector struct { Elements []Variable } -// ========= -// Functions -// ========= - -/* -Length -Description: - - Returns the length of the vector of optimization variables. -*/ +// Length returns the length of the vector of optimization variables. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Length() int { return len(vv.Elements) } -/* -Len -Description: - - This function is created to mirror the GoNum Vector API. Does the same thing as Length. -*/ +// Len returns the length of the vector of optimization variables. +// This mirrors the GoNum Vector API and does the same thing as Length. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Len() int { return vv.Length() } -/* -At -Description: - - Mirrors the gonum api for vectors. This extracts the element of the variable vector at the index x. -*/ +// AtVec mirrors the gonum API for vectors and extracts the element of the +// variable vector at the given index. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) AtVec(idx int) ScalarExpression { // Constants @@ -59,12 +39,9 @@ func (vv VarVector) AtVec(idx int) ScalarExpression { return vv.Elements[idx] } -/* -IDs -Description: - - Returns the unique indices -*/ +// IDs returns the unique variable IDs in the variable vector. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) IDs() []uint64 { // Algorithm var IDSlice []uint64 @@ -77,45 +54,33 @@ func (vv VarVector) IDs() []uint64 { } -/* -NumVars -Description: - - The number of unique variables inside the variable vector. -*/ +// NumVars returns the number of unique variables inside the variable vector. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) NumVars() int { return len(vv.IDs()) } -/* -Constant -Description: - - Returns an all zeros vector as output from the method. -*/ +// Constant returns an all-zeros vector as the constant component of the expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Constant() mat.VecDense { zerosOut := ZerosVector(vv.Len()) return zerosOut } -/* -LinearCoeff -Description: - - Returns the matrix which is multiplied by Variables to get the current "expression". - For a single vector, this is an identity matrix. -*/ +// LinearCoeff returns the matrix which is multiplied by Variables to get the +// current expression. For a single vector, this is an identity matrix. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) LinearCoeff() mat.Dense { return Identity(vv.Len()) } -/* -Plus -Description: - - This member function computes the addition of the receiver vector var with the - incoming vector expression ve. -*/ +// Plus computes the addition of the receiver VarVector with the incoming +// vector expression e. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Plus(e interface{}, errors ...error) (Expression, error) { // Constants vvLen := vv.Len() @@ -185,23 +150,17 @@ func (vv VarVector) Plus(e interface{}, errors ...error) (Expression, error) { } } -/* -Mult -Description: - - This member function computest the multiplication of the receiver vector var with some - incoming vector expression (may result in quadratic?). -*/ +// Mult computes the multiplication of the receiver VarVector with a scalar +// float64 value. This method is not yet implemented. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Mult(c float64) (VectorExpression, error) { return vv, fmt.Errorf("The Mult() method for VarVector is not implemented yet!") } -/* -Multiply -Description: - - Multiplication of a VarVector with another expression. -*/ +// Multiply performs multiplication of a VarVector with another expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Multiply(rightIn interface{}, errors ...error) (Expression, error) { //Input Processing err := vv.Check() @@ -264,47 +223,35 @@ func (vv VarVector) Multiply(rightIn interface{}, errors ...error) (Expression, } } -/* -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. -*/ +// LessEq 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. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) LessEq(rightIn interface{}, errors ...error) (Constraint, error) { return vv.Comparison(rightIn, SenseLessThanEqual, errors...) } -/* -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. -*/ +// GreaterEq 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. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error) { return vv.Comparison(rightIn, SenseGreaterThanEqual, errors...) } -/* -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. -*/ +// Eq creates an equal to vector constraint using the receiver as the left hand +// side and the input rhs as the right hand side. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Eq(rightIn interface{}, errors ...error) (Constraint, error) { return vv.Comparison(rightIn, SenseEqual, errors...) } -/* -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. -*/ +// Comparison creates a constraint of type sense between the receiver (as left +// hand side) and rhs (as right hand side). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Comparison(rhs interface{}, sense ConstrSense, errors ...error) (Constraint, error) { // Constants @@ -378,6 +325,9 @@ func (vv VarVector) Comparison(rhs interface{}, sense ConstrSense, errors ...err } } +// Copy creates a copy of the VarVector. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Copy() VarVector { // Constants @@ -392,33 +342,25 @@ func (vv VarVector) Copy() VarVector { } -/* -Transpose -Description: - - This method creates the transpose of the current vector and returns it. -*/ +// Transpose creates the transpose of the current vector and returns it. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Transpose() Expression { vvCopy := vv.Copy() return VarVectorTranspose(vvCopy) } -/* -Dims -Description: - - Dimensions of the variable vector. -*/ +// Dims returns the dimensions of the variable vector. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Dims() []int { return []int{vv.Len(), 1} } -/* -Check -Description: - - Checks whether or not the VarVector has a sensible initialization. -*/ +// Check checks whether or not the VarVector has a sensible initialization, +// returning an error if any element is not properly defined. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) Check() error { // Check that each variable is properly defined for ii, element := range vv.Elements { @@ -435,13 +377,10 @@ func (vv VarVector) Check() error { return nil } -/* -ToSymbolic -Description: - - Converts the variable vector to a symbolic expression. - (i.e., one that uses the symbolic math toolbox). -*/ +// ToSymbolic converts the variable vector to a symbolic expression +// (i.e., one that uses the symbolic math toolbox). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vv VarVector) ToSymbolic() (symbolic.Expression, error) { // Input Checking err := vv.Check() diff --git a/optim/var_vector_transpose.go b/optim/var_vector_transpose.go index 8d1faf6..ac67015 100644 --- a/optim/var_vector_transpose.go +++ b/optim/var_vector_transpose.go @@ -6,53 +6,31 @@ import ( "gonum.org/v1/gonum/mat" ) -/* -var_vector_transpose.go -Description: - The VarVectorTranspose type will represent a transposed vector of all - variables. -*/ - -/* -VarVectorTranspose -Description: - - Represnts a variable in a optimization problem. The variable is -*/ +// VarVectorTranspose represents a transposed vector of all optimization variables. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type VarVectorTranspose struct { Elements []Variable } - -// ========= -// Functions -// ========= - -/* -Length -Description: - - Returns the length of the vector of optimization variables. -*/ +// Length returns the length of the vector of optimization variables. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) Length() int { return len(vvt.Elements) } -/* -Len -Description: - - This function is created to mirror the GoNum Vector API. Does the same thing as Length. -*/ +// Len returns the length of the vector of optimization variables. +// This mirrors the GoNum Vector API and does the same thing as Length. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) Len() int { return vvt.Length() } -/* -At -Description: - - Mirrors the gonum api for vectors. This extracts the element of the variable vector at the index x. -*/ +// AtVec mirrors the gonum API for vectors and extracts the element of the +// variable vector at the given index. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) AtVec(idx int) ScalarExpression { // Constants @@ -60,12 +38,9 @@ func (vvt VarVectorTranspose) AtVec(idx int) ScalarExpression { return vvt.Elements[idx] } -/* -IDs -Description: - - Returns the unique indices -*/ +// IDs returns the unique variable IDs in the transposed variable vector. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) IDs() []uint64 { // Algorithm var IDSlice []uint64 @@ -78,45 +53,33 @@ func (vvt VarVectorTranspose) IDs() []uint64 { } -/* -NumVars -Description: - - The number of unique variables inside the variable vector. -*/ +// NumVars returns the number of unique variables inside the transposed variable vector. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) NumVars() int { return len(vvt.IDs()) } -/* -Constant -Description: - - Returns an all zeros vector as output from the method. -*/ +// Constant returns an all-zeros vector as the constant component of the expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) Constant() mat.VecDense { zerosOut := ZerosVector(vvt.Len()) return zerosOut } -/* -LinearCoeff -Description: - - Returns the matrix which is multiplied by Variables to get the current "expression". - For a single vector, this is an identity matrix. -*/ +// LinearCoeff returns the matrix which is multiplied by Variables to get the +// current expression. For a single vector, this is an identity matrix. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) LinearCoeff() mat.Dense { return Identity(vvt.Len()) } -/* -Plus -Description: - - This member function computes the addition of the receiver vector var with the - incoming vector expression ve. -*/ +// Plus computes the addition of the receiver VarVectorTranspose with the +// incoming vector expression eIn. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) Plus(eIn interface{}, errors ...error) (Expression, error) { // Constants vvLen := vvt.Len() @@ -184,12 +147,9 @@ func (vvt VarVectorTranspose) Plus(eIn interface{}, errors ...error) (Expression } } -/* -Multiply -Description: - - Multiplication of a VarVectorTranspose with another expression. -*/ +// Multiply performs multiplication of a VarVectorTranspose with another expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) Multiply(e interface{}, errors ...error) (Expression, error) { // Input Processing err := CheckErrors(errors) @@ -325,47 +285,35 @@ func (vvt VarVectorTranspose) Multiply(e interface{}, errors ...error) (Expressi } } -/* -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. -*/ +// LessEq 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. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) LessEq(rightIn interface{}, errors ...error) (Constraint, error) { return vvt.Comparison(rightIn, SenseLessThanEqual, errors...) } -/* -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. -*/ +// GreaterEq 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. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error) { return vvt.Comparison(rightIn, SenseGreaterThanEqual, errors...) } -/* -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. -*/ +// Eq creates an equal to vector constraint using the receiver as the left hand +// side and the input rhs as the right hand side. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) Eq(rightIn interface{}, errors ...error) (Constraint, error) { return vvt.Comparison(rightIn, SenseEqual, errors...) } -/* -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. -*/ +// Comparison creates a constraint of type sense between the receiver (as left +// hand side) and rhs (as right hand side). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) { // Input Processing err := CheckErrors(errors) @@ -434,6 +382,9 @@ func (vvt VarVectorTranspose) Comparison(rightIn interface{}, sense ConstrSense, } } +// Copy creates a copy of the VarVectorTranspose. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) Copy() VarVectorTranspose { // Constants @@ -448,33 +399,25 @@ func (vvt VarVectorTranspose) Copy() VarVectorTranspose { } -/* -Transpose -Description: - - This method creates the transpose of the current vector and returns it. -*/ +// Transpose creates the transpose of the current vector and returns it. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) Transpose() Expression { vvtCopy := vvt.Copy() return VarVector{vvtCopy.Elements} } -/* -Dims -Description: - - This method returns the dimension of the VarVectorTranspose object. -*/ +// Dims returns the dimension of the VarVectorTranspose object. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) Dims() []int { return []int{1, vvt.Len()} } -/* -Check -Description: - - Checks whether or not the VarVector has a sensible initialization. -*/ +// Check checks whether or not the VarVectorTranspose has a sensible +// initialization, returning an error if any element is not properly defined. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) Check() error { // Check that each variable is properly defined for ii, element := range vvt.Elements { @@ -491,13 +434,10 @@ func (vvt VarVectorTranspose) Check() error { return nil } -/* -ToSymbolic -Description: - - This method converts the VarVectorTranspose to a symbolic expression - (i.e., an expression made using SymbolicMath.go). -*/ +// ToSymbolic converts the VarVectorTranspose to a symbolic expression +// (i.e., an expression made using SymbolicMath.go). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vvt VarVectorTranspose) ToSymbolic() (symbolic.Expression, error) { // Input Processing err := vvt.Check() diff --git a/optim/vars.go b/optim/vars.go index 94270e8..ebe1bac 100644 --- a/optim/vars.go +++ b/optim/vars.go @@ -6,8 +6,10 @@ import ( "gonum.org/v1/gonum/mat" ) -// Var represnts a variable in a optimization problem. The variable is -// identified with an uint64. +// Variable represents a variable in an optimization problem. The variable is +// identified with a uint64. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type Variable struct { ID uint64 Lower float64 @@ -15,42 +17,49 @@ type Variable struct { Vtype VarType } -/* -Variables -Description: - - This function returns a slice containing all unique variables in the variable expression v. -*/ +// Variables returns a slice containing all unique variables in the variable expression v. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) Variables() []Variable { return []Variable{v} } // NumVars returns the number of variables in the expression. For a variable, it // always returns one. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) NumVars() int { return 1 } -// IDs Vars returns a slice of the Var ids in the expression. For a variable, it +// IDs returns a slice of the Var ids in the expression. For a variable, it // always returns a singleton slice with the given variable ID. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) IDs() []uint64 { return []uint64{v.ID} } // Coeffs returns a slice of the coefficients in the expression. For a variable, // it always returns a singleton slice containing the value one. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) Coeffs() []float64 { return []float64{1} } // Constant returns the constant additive value in the expression. For a // variable, it always returns zero. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) Constant() float64 { return 0 } // Plus adds the current expression to another and returns the resulting // expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) Plus(e interface{}, errors ...error) (Expression, error) { // Input Processing err := v.Check() @@ -159,33 +168,32 @@ func (v Variable) Plus(e interface{}, errors ...error) (Expression, error) { //} // LessEq returns a less than or equal to (<=) constraint between the -// current expression and another +// current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) LessEq(rhsIn interface{}, errors ...error) (Constraint, error) { return v.Comparison(rhsIn, SenseLessThanEqual, errors...) } // GreaterEq returns a greater than or equal to (>=) constraint between the -// current expression and another +// current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) GreaterEq(rhsIn interface{}, errors ...error) (Constraint, error) { return v.Comparison(rhsIn, SenseGreaterThanEqual, errors...) } // Eq returns an equality (==) constraint between the current expression -// and another +// and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) Eq(rhsIn interface{}, errors ...error) (Constraint, error) { return v.Comparison(rhsIn, SenseEqual, errors...) } -/* -Comparison -Description: - - This method compares the receiver with expression rhs in the sense provided by sense. - -Usage: - - constr, err := v.Comparison(expr1,SenseGreaterThanEqual) -*/ +// Comparison compares the receiver with expression rhs in the sense provided by sense. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) { // Input Processing err := CheckErrors(errors) @@ -227,23 +235,30 @@ func (v *Variable) Type() VarType { // VarType represents the type of the variable (continuous, binary, // integer, etc) and uses Gurobi's encoding. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type VarType byte // Multiple common variable types have been included as constants that conform // to Gurobi's encoding. const ( + // Continuous represents a continuous variable type. + // + // Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. Continuous VarType = 'C' - Binary = 'B' - Integer = 'I' + // Binary represents a binary variable type. + // + // Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. + Binary = 'B' + // Integer represents an integer variable type. + // + // Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. + Integer = 'I' ) -/* -UniqueVars -Description: - - This function creates a slice of unique variables from the slice given in - varsIn -*/ +// UniqueVars creates a slice of unique variables from the slice given in varsIn. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func UniqueVars(varsIn []Variable) []Variable { // Constants @@ -259,12 +274,9 @@ func UniqueVars(varsIn []Variable) []Variable { } -/* -Multiply -Description: - - multiplies the current expression to another and returns the resulting expression -*/ +// Multiply multiplies the current expression to another and returns the resulting expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) Multiply(val interface{}, errors ...error) (Expression, error) { // Input Processing err := v.Check() @@ -359,12 +371,9 @@ func (v Variable) Multiply(val interface{}, errors ...error) (Expression, error) } } -/* -ToScalarLinearExpression -Description: - - Converting the variable into a scalar linear Expression. -*/ +// ToScalarLinearExpression converts the variable into a scalar linear expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) ToScalarLinearExpression() ScalarLinearExpr { // Constants @@ -380,22 +389,17 @@ func (v Variable) ToScalarLinearExpression() ScalarLinearExpr { } } -/* -Dims -Description: - - Returns the dimension of the Variable object (should be scalar). -*/ +// Dims returns the dimension of the Variable object, which is always [1, 1] for a scalar. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) Dims() []int { return []int{1, 1} } -/* -Check -Description: - - Checks whether or not the Variable has a sensible initialization. -*/ +// Check checks whether or not the Variable has a sensible initialization, +// returning an error if the lower bound is greater than the upper bound. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) Check() error { // Check that the lower bound is below is the upper bound if v.Lower > v.Upper { @@ -409,17 +413,17 @@ func (v Variable) Check() error { return nil } +// Transpose returns the transpose of the variable, which is the variable itself. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) Transpose() Expression { return v } -/* -ToSymbolic -Description: - - Converts the variable into a symbolic variable - (from the symbolic math toolbox). -*/ +// ToSymbolic converts the variable into a symbolic variable +// (from the symbolic math toolbox). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (v Variable) ToSymbolic() (symbolic.Expression, error) { // Input Checking err := v.Check() diff --git a/optim/vector_constant.go b/optim/vector_constant.go index ef9890e..882f9da 100644 --- a/optim/vector_constant.go +++ b/optim/vector_constant.go @@ -1,105 +1,71 @@ package optim import ( + "fmt" "github.com/MatProGo-dev/SymbolicMath.go/symbolic" "gonum.org/v1/gonum/mat" ) -/* -vector_constant_test.go -Description: - Creates a vector extension of the constant type K from the original goop. -*/ - -import ( - "fmt" -) - -/* -KVector - - A type which is built on top of the KVector() - a constant expression type for an MIP. K for short ¯\_(ツ)_/¯ -*/ +// KVector is a constant vector expression type for an MIP (Mixed Integer Program). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type KVector mat.VecDense // Inherit all methods from mat.VecDense -/* -Check -Description: - - This method checks for errors in the KVector type. - There should never be any. -*/ +// Check verifies that the KVector expression is valid. For KVector, this always returns nil. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) Check() error { return nil } -/* -Len - - Computes the length of the KVector given. -*/ +// Len computes the length of the KVector. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) Len() int { kvAsVector := mat.VecDense(kv) return kvAsVector.Len() } -/* -AtVec -Description: - - This function returns the value at the k index. -*/ +// AtVec returns the scalar expression value at the given index k. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) AtVec(idx int) ScalarExpression { kvAsVector := mat.VecDense(kv) return K(kvAsVector.AtVec(idx)) } -/* -NumVars -Description: - - This returns the number of variables in the expression. For constants, this is 0. -*/ +// NumVars returns the number of variables in the expression. For KVector, this is always 0. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) NumVars() int { return 0 } -/* -Vars -Description: - - This function returns a slice of the Var ids in the expression. For constants, this is always nil. -*/ +// IDs returns a slice of the Var ids in the expression. For KVector, this is always nil. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) IDs() []uint64 { return nil } -/* -LinearCoeff -Description: - - This function returns a slice of the coefficients in the expression. For constants, this is always nil. -*/ +// LinearCoeff returns the zero matrix of coefficients. For KVector, this is always a zero matrix. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) LinearCoeff() mat.Dense { return ZerosMatrix(kv.Len(), kv.Len()) } -/* -Constant - - Returns the constant additive value in the expression. For constants, this is just the constants value -*/ +// Constant returns the constant additive value in the expression, which is +// the vector itself. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) Constant() mat.VecDense { return mat.VecDense(kv) } -/* -Plus -Description: - - Adds the current expression to another and returns the resulting expression -*/ +// Plus adds the current expression to another and returns the resulting expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) Plus(rightIn interface{}, errors ...error) (Expression, error) { // Input Processing err := CheckErrors(errors) @@ -180,12 +146,10 @@ func (kv KVector) Plus(rightIn interface{}, errors ...error) (Expression, error) } } -/* -Mult -Description: - - This method multiplies the current expression to another and returns the resulting expression. -*/ +// Mult multiplies the current expression by a scalar float64 and returns +// the resulting expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) Mult(val float64) (VectorExpression, error) { // Use mat.Vector's multiplication method @@ -196,36 +160,32 @@ func (kv KVector) Mult(val float64) (VectorExpression, error) { return KVector(result), nil } -/* -LessEq -Description: - - Returns a less than or equal to (<=) constraint between the current expression and another -*/ +// LessEq returns a less than or equal to (<=) constraint between the current +// expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) LessEq(rightIn interface{}, errors ...error) (Constraint, error) { return kv.Comparison(rightIn, SenseLessThanEqual, errors...) } -/* -GreaterEq -Description: - - This method returns a greater than or equal to (>=) constraint between the current expression and another -*/ +// GreaterEq returns a greater than or equal to (>=) constraint between the +// current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error) { return kv.Comparison(rightIn, SenseGreaterThanEqual, errors...) } -/* -Eq -Description: - - This method returns an equality (==) constraint between the current expression and another -*/ +// Eq returns an equality (==) constraint between the current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) Eq(rightIn interface{}, errors ...error) (Constraint, error) { return kv.Comparison(rightIn, SenseEqual, errors...) } +// Comparison compares the KVector with the given expression in the given sense. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) { switch rhsConverted := rightIn.(type) { case KVector: @@ -280,12 +240,9 @@ func (kv KVector) Comparison(rightIn interface{}, sense ConstrSense, errors ...e } } -/* -Multiply -Description: - - This method is used to compute the multiplication of the input vector constant with another term. -*/ +// Multiply computes the multiplication of the input vector constant with another term. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) Multiply(rightIn interface{}, errors ...error) (Expression, error) { // Input Processing err := CheckErrors(errors) @@ -408,32 +365,23 @@ func (kv KVector) Multiply(rightIn interface{}, errors ...error) (Expression, er } } -/* -Transpose -Description: - - This method creates the transpose of the current vector and returns it. -*/ +// Transpose creates the transpose of the current vector and returns it. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) Transpose() Expression { return KVectorTranspose(kv) } -/* -Dims -Description: - - Returns the dimension of the constant vector. -*/ +// Dims returns the dimension of the constant vector. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) Dims() []int { return []int{kv.Len(), 1} } -/* -ToSymbolic -Description: - - This method returns the symbolic version of the constant vector. -*/ +// ToSymbolic returns the symbolic version of the constant vector. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kv KVector) ToSymbolic() (symbolic.Expression, error) { // Constants kvAsVec := mat.VecDense(kv) diff --git a/optim/vector_constant_transpose.go b/optim/vector_constant_transpose.go index c55cc87..b5f35a0 100644 --- a/optim/vector_constant_transpose.go +++ b/optim/vector_constant_transpose.go @@ -1,105 +1,72 @@ package optim import ( + "fmt" "github.com/MatProGo-dev/SymbolicMath.go/symbolic" "gonum.org/v1/gonum/mat" ) -/* -vector_constant_test.go -Description: - Creates a vector extension of the constant type K from the original goop. -*/ - -import ( - "fmt" -) - -/* -KVectorTranspose - - A type which is built on top of the KVector() - a constant expression type for an MIP. K for short ¯\_(ツ)_/¯ -*/ +// KVectorTranspose is a transposed constant vector expression type for an MIP +// (Mixed Integer Program). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type KVectorTranspose mat.VecDense // Inherit all methods from mat.VecDense -/* -Check -Description: - - This method checks for errors in the KVectorTranspose type. - There should never be any. -*/ +// Check verifies that the KVectorTranspose expression is valid. For KVectorTranspose, this always returns nil. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) Check() error { return nil } -/* -Len - - Computes the length of the KVector given. -*/ +// Len computes the length of the KVectorTranspose. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) Len() int { kvAsVector := mat.VecDense(kvt) return kvAsVector.Len() } -/* -AtVec -Description: - - This function returns the value at the k index. -*/ +// AtVec returns the scalar expression value at the given index idx. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) AtVec(idx int) ScalarExpression { kvAsVector := mat.VecDense(kvt) return K(kvAsVector.AtVec(idx)) } -/* -NumVars -Description: - - This returns the number of variables in the expression. For constants, this is 0. -*/ +// NumVars returns the number of variables in the expression. For KVectorTranspose, this is always 0. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) NumVars() int { return 0 } -/* -Vars -Description: - - This function returns a slice of the Var ids in the expression. For constants, this is always nil. -*/ +// IDs returns a slice of the Var ids in the expression. For KVectorTranspose, this is always nil. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) IDs() []uint64 { return nil } -/* -LinearCoeff -Description: - - This function returns a slice of the coefficients in the expression. For constants, this is always nil. -*/ +// LinearCoeff returns the zero matrix of coefficients. For KVectorTranspose, this is always a zero matrix. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) LinearCoeff() mat.Dense { return ZerosMatrix(kvt.Len(), kvt.Len()) } -/* -Constant - - Returns the constant additive value in the expression. For constants, this is just the constants value -*/ +// Constant returns the constant additive value in the expression, which is +// the vector itself. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) Constant() mat.VecDense { return mat.VecDense(kvt) } -/* -Plus -Description: - - Adds the current expression to another and returns the resulting expression -*/ +// Plus adds the current expression to another and returns the resulting expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) Plus(rightIn interface{}, errors ...error) (Expression, error) { // Constants kvLen := kvt.Len() @@ -188,12 +155,10 @@ func (kvt KVectorTranspose) Plus(rightIn interface{}, errors ...error) (Expressi } } -/* -Mult -Description: - - This method multiplies the current expression to another and returns the resulting expression. -*/ +// Mult multiplies the current expression by a scalar float64 and returns +// the resulting expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) Mult(val float64) (VectorExpression, error) { // Use mat.Vector's multiplication method @@ -204,36 +169,32 @@ func (kvt KVectorTranspose) Mult(val float64) (VectorExpression, error) { return KVectorTranspose(result), nil } -/* -LessEq -Description: - - Returns a less than or equal to (<=) constraint between the current expression and another -*/ +// LessEq returns a less than or equal to (<=) constraint between the current +// expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) LessEq(rightIn interface{}, errors ...error) (Constraint, error) { return kvt.Comparison(rightIn, SenseLessThanEqual, errors...) } -/* -GreaterEq -Description: - - This method returns a greater than or equal to (>=) constraint between the current expression and another -*/ +// GreaterEq returns a greater than or equal to (>=) constraint between the +// current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error) { return kvt.Comparison(rightIn, SenseGreaterThanEqual, errors...) } -/* -Eq -Description: - - This method returns an equality (==) constraint between the current expression and another -*/ +// Eq returns an equality (==) constraint between the current expression and another. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) Eq(rightIn interface{}, errors ...error) (Constraint, error) { return kvt.Comparison(rightIn, SenseEqual, errors...) } +// Comparison compares the KVectorTranspose with the given expression in the given sense. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) { switch rhs0 := rightIn.(type) { case KVector: @@ -292,12 +253,9 @@ func (kvt KVectorTranspose) Comparison(rightIn interface{}, sense ConstrSense, e } } -/* -Multiply -Description: - - This method is used to compute the multiplication of the input vector constant with another term. -*/ +// Multiply computes the multiplication of the KVectorTranspose with another term. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) Multiply(rightIn interface{}, errors ...error) (Expression, error) { // Input Processing err := CheckErrors(errors) @@ -378,32 +336,23 @@ func (kvt KVectorTranspose) Multiply(rightIn interface{}, errors ...error) (Expr } } -/* -Transpose -Description: - - This method creates the transpose of the current vector and returns it. -*/ +// Transpose creates the transpose of the current vector and returns it. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) Transpose() Expression { return KVector(kvt) } -/* -Dims -Description: - - This method returns the dimensions of the KVectorTranspose object. -*/ +// Dims returns the dimensions of the KVectorTranspose object. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) Dims() []int { return []int{1, kvt.Len()} } -/* -ToSymbolic -Description: - - This method returns the symbolic version of the KVectorTranspose expression. -*/ +// ToSymbolic returns the symbolic version of the KVectorTranspose expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (kvt KVectorTranspose) ToSymbolic() (symbolic.Expression, error) { // Constants kvLen := kvt.Len() diff --git a/optim/vector_constraint.go b/optim/vector_constraint.go index 5cf853e..ea374c6 100644 --- a/optim/vector_constraint.go +++ b/optim/vector_constraint.go @@ -2,24 +2,18 @@ package optim import "fmt" -/* -vector_constraint.go -Description: - -*/ - +// VectorConstraint represents a vector constraint relating two vector expressions. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type VectorConstraint struct { LeftHandSide VectorExpression RightHandSide VectorExpression Sense ConstrSense } -/* -AtVec -Description: - - Retrieves the constraint formed by one element of the "vector" constraint. -*/ +// AtVec retrieves the scalar constraint formed by one element of the vector constraint. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vc VectorConstraint) AtVec(i int) (ScalarConstraint, error) { // Input Processing if vc.Check() != nil { @@ -42,12 +36,10 @@ func (vc VectorConstraint) AtVec(i int) (ScalarConstraint, error) { return ScalarConstraint{lhsAtI, rhsAtI, vc.Sense}, nil } -/* -Check -Description: - - Checks that the VectorConstraint is valid. -*/ +// Check checks that the VectorConstraint is valid, ensuring dimensions of both +// sides match and each side is well-defined. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vc VectorConstraint) Check() error { // Constants @@ -75,20 +67,23 @@ func (vc VectorConstraint) Check() error { return nil } +// Left returns the left hand side expression of the vector constraint. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vc VectorConstraint) Left() Expression { return vc.LeftHandSide } +// Right returns the right hand side expression of the vector constraint. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vc VectorConstraint) Right() Expression { return vc.RightHandSide } -/* -ConstrSense -Description: - - Returns the sense of the constraint. -*/ +// ConstrSense returns the sense of the vector constraint. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vc VectorConstraint) ConstrSense() ConstrSense { return vc.Sense } diff --git a/optim/vector_expression.go b/optim/vector_expression.go index 1c8e286..a895afb 100644 --- a/optim/vector_expression.go +++ b/optim/vector_expression.go @@ -1,27 +1,20 @@ package optim -/* -vector_expression.go -Description: - An improvement/successor to the scalar expr interface. -*/ - import ( "fmt" "github.com/MatProGo-dev/SymbolicMath.go/symbolic" "gonum.org/v1/gonum/mat" ) -/* -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. -*/ +// VectorExpression represents a vector expression of the form +// +// L * x + C +// +// where L is a matrix of coefficients, x is a vector of variables, and C is a +// constant vector. This is a base interface implemented by variable vectors, +// constant vectors, and general vector linear expressions. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type VectorExpression interface { // NumVars returns the number of variables in the expression NumVars() int @@ -81,14 +74,10 @@ type VectorExpression interface { Check() error } -/* -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 -*/ +// NewVectorExpression returns a new vector expression with a constant vector c +// and no variables. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func NewVectorExpression(c mat.VecDense) VectorLinearExpr { return VectorLinearExpr{C: c} } @@ -110,12 +99,10 @@ func NewVectorExpression(c mat.VecDense) VectorLinearExpr { // return nil //} -/* -IsVectorExpression -Description: - - Determines whether or not an input object is a valid "VectorExpression" according to MatProInterface. -*/ +// IsVectorExpression determines whether or not an input object is a valid +// VectorExpression according to MatProInterface. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func IsVectorExpression(e interface{}) bool { // Check each type switch e.(type) { @@ -139,12 +126,10 @@ func IsVectorExpression(e interface{}) bool { } } -/* -ToVectorExpression -Description: - - Converts the input expression to a valid type that implements "VectorExpression". -*/ +// ToVectorExpression converts the input expression to a valid type that +// implements VectorExpression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func ToVectorExpression(e interface{}) (VectorExpression, error) { // Input Processing if !IsVectorExpression(e) { diff --git a/optim/vector_linear_expression.go b/optim/vector_linear_expression.go index 2d6f254..fbc1bf6 100644 --- a/optim/vector_linear_expression.go +++ b/optim/vector_linear_expression.go @@ -1,11 +1,5 @@ package optim -/* -vector_linear_expression.go -Description: - -*/ - import ( "fmt" "github.com/MatProGo-dev/SymbolicMath.go/symbolic" @@ -14,22 +8,21 @@ import ( // VectorLinearExpr represents a linear general expression of the form // -// L' * x + C +// 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. // -// 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 +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type VectorLinearExpr struct { X VarVector L mat.Dense // Matrix of coefficients. Should match the dimensions of XIndices C mat.VecDense } -/* -Check -Description: - - Checks to see if the VectorLinearExpression is well-defined. -*/ +// Check checks to see if the VectorLinearExpr is well-defined. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) Check() error { // Extract the dimension of the vector x m := vle.X.Length() @@ -50,75 +43,56 @@ func (vle VectorLinearExpr) Check() error { return nil } -/* -IDs -Description: - - Returns the MatProInterface ID of each variable in the current vector linear expression. -*/ +// IDs returns the MatProInterface ID of each variable in the current vector linear expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) IDs() []uint64 { return vle.X.IDs() } -/* -NumVars -Description: - - Returns the goop2 ID of each variable in the current vector linear expression. -*/ +// NumVars returns the number of unique variables in the current vector linear expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) NumVars() int { return len(vle.IDs()) } -/* -LinearCoeff -Description: - - Returns the matrix which is applied as a coefficient to the vector X in our expression. -*/ +// LinearCoeff returns the matrix which is applied as a coefficient to the vector X in the expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) LinearCoeff() mat.Dense { return vle.L } -/* -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). -*/ +// Constant returns the vector which is given as an offset vector in the linear +// expression (the C in L*x + C). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) Constant() mat.VecDense { return vle.C } -/* -GreaterEq -Description: - - Creates a VectorConstraint that declares vle is greater than or equal to the value to the right hand side rhs. -*/ +// GreaterEq creates a VectorConstraint that declares vle is greater than or +// equal to the value to the right hand side rhs. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error) { return vle.Comparison(rightIn, SenseGreaterThanEqual, errors...) } -/* -LessEq -Description: - - Creates a VectorConstraint that declares vle is less than or equal to the value to the right hand side rhs. -*/ +// LessEq creates a VectorConstraint that declares vle is less than or equal to +// the value to the right hand side rhs. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) LessEq(rightIn interface{}, errors ...error) (Constraint, error) { return vle.Comparison(rightIn, SenseLessThanEqual, errors...) } -/* -Multiply -Description: - - Multiplication of a VarVector with another expression. -*/ +// Multiply performs multiplication of a VectorLinearExpr with another expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) Multiply(rightIn interface{}, errors ...error) (Expression, error) { // Input Processing err := CheckErrors(errors) @@ -186,12 +160,9 @@ func (vle VectorLinearExpr) Multiply(rightIn interface{}, errors ...error) (Expr } } -/* -Plus -Description: - - Returns an expression which adds the expression e to the vector linear expression at hand. -*/ +// Plus returns an expression which adds the expression e to the vector linear expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) Plus(rightIn interface{}, errors ...error) (Expression, error) { // Constants vleLen := vle.Len() @@ -348,23 +319,17 @@ Description: // return nil, fmt.Errorf("Unexpected type of right hand side %v: %T", rhsIn, rhsIn) //} -/* -Eq -Description: - - Creates a constraint between the current vector linear expression v and the - rhs given by rhs. -*/ +// Eq creates a constraint between the current vector linear expression and +// the rhs given by rhs. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) Eq(rightIn interface{}, errors ...error) (Constraint, error) { return vle.Comparison(rightIn, SenseEqual, errors...) } -/* -Len -Description: - - The size of the constraint. -*/ +// Len returns the number of rows in the vector linear expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) Len() int { // Constants @@ -372,13 +337,10 @@ func (vle VectorLinearExpr) Len() int { return vle.C.Len() } -/* -Comparison -Description: - - Compares the input vector linear expression with respect to the expression rhsIn and the sense - senseIn. -*/ +// Comparison compares the input vector linear expression with respect to the +// expression rhsIn and the sense senseIn. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) { // Constants @@ -461,17 +423,11 @@ func (vle VectorLinearExpr) Comparison(rightIn interface{}, sense ConstrSense, e } } -/* -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. -*/ +// RewriteInTermsOf rewrites the VectorLinearExpr in terms of a new set of +// variables vv. It assumes vv contains all unique variables and all elements +// of vle.X are in vv. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) RewriteInTermsOf(vv VarVector) VectorLinearExpr { // Constants @@ -502,10 +458,9 @@ func (vle VectorLinearExpr) RewriteInTermsOf(vv VarVector) VectorLinearExpr { } -/* -AtVec -Description: -*/ +// AtVec returns the scalar expression at the given index idx. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) AtVec(idx int) ScalarExpression { // Constants Li := vle.L.RowView(idx) @@ -522,12 +477,9 @@ func (vle VectorLinearExpr) AtVec(idx int) ScalarExpression { } -/* -Transpose -Description: - - This method creates the transpose of the current vector and returns it. -*/ +// Transpose creates the transpose of the current vector and returns it. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) Transpose() Expression { return VectorLinearExpressionTranspose{ L: vle.L, @@ -536,12 +488,9 @@ func (vle VectorLinearExpr) Transpose() Expression { } } -/* -Copy -Description: - - This method copies the contents of a Vector Linear Expression. -*/ +// Copy returns a copy of the VectorLinearExpr. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) Copy() VectorLinearExpr { // Constants nRows := vle.Len() @@ -558,22 +507,16 @@ func (vle VectorLinearExpr) Copy() VectorLinearExpr { return out } -/* -Dims -Description: - - This method returns the dimensions of the KVectorTranspose object. -*/ +// Dims returns the dimensions of the VectorLinearExpr. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) Dims() []int { return []int{vle.Len(), 1} } -/* -ToSymbolic -Description: - - This method returns the symbolic version of the KVectorTranspose expression. -*/ +// ToSymbolic returns the symbolic version of the VectorLinearExpr expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vle VectorLinearExpr) ToSymbolic() (symbolic.Expression, error) { // Input Processing err := vle.Check() diff --git a/optim/vector_linear_expression_transpose.go b/optim/vector_linear_expression_transpose.go index 43e1c96..138402a 100644 --- a/optim/vector_linear_expression_transpose.go +++ b/optim/vector_linear_expression_transpose.go @@ -1,35 +1,29 @@ package optim -/* -vector_linear_expression_transpose.go -Description: - -*/ - import ( "fmt" "github.com/MatProGo-dev/SymbolicMath.go/symbolic" "gonum.org/v1/gonum/mat" ) -// VectorLinearExpressionTranspose represents a linear general expression of the form +// VectorLinearExpressionTranspose represents a transposed 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 +// 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. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. type VectorLinearExpressionTranspose struct { X VarVector L mat.Dense // Matrix of coefficients. Should match the dimensions of XIndices C mat.VecDense } -/* -Check -Description: - - Checks to see if the VectorLinearExpressionTransposeession is well-defined. -*/ +// Check checks to see if the VectorLinearExpressionTranspose is well-defined. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) Check() error { // Extract the dimension of the vector x m := vlet.X.Length() @@ -50,84 +44,63 @@ func (vlet VectorLinearExpressionTranspose) Check() error { return nil } -/* -IDs -Description: - - Returns the MatProInterface ID of each variable in the current vector linear expression. -*/ +// IDs returns the MatProInterface ID of each variable in the current vector linear expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) IDs() []uint64 { return vlet.X.IDs() } -/* -NumVars -Description: - - Returns the goop2 ID of each variable in the current vector linear expression. -*/ +// NumVars returns the number of unique variables in the current vector linear expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) NumVars() int { return len(vlet.IDs()) } -/* -LinearCoeff -Description: - - Returns the matrix which is applied as a coefficient to the vector X in our expression. -*/ +// LinearCoeff returns the matrix which is applied as a coefficient to the vector X in the expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) LinearCoeff() mat.Dense { return vlet.L } -/* -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). -*/ +// Constant returns the vector which is given as an offset vector in the linear +// expression (the C in x^T * L^T + C^T). +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) Constant() mat.VecDense { return vlet.C } -/* -GreaterEq -Description: - - Creates a VectorConstraint that declares vle is greater than or equal to the value to the right hand side rhs. -*/ +// GreaterEq creates a VectorConstraint that declares vlet is greater than or +// equal to the value to the right hand side rhs. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error) { return vlet.Comparison(rightIn, SenseGreaterThanEqual, errors...) } -/* -LessEq -Description: - - Creates a VectorConstraint that declares vle is less than or equal to the value to the right hand side rhs. -*/ +// LessEq creates a VectorConstraint that declares vlet is less than or equal +// to the value to the right hand side rhs. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) LessEq(rightIn interface{}, errors ...error) (Constraint, error) { return vlet.Comparison(rightIn, SenseLessThanEqual, errors...) } -/* -Mult -Description: - - Returns an expression which scales every dimension of the vector linear expression by the input. -*/ +// Mult returns an expression which scales every dimension of the vector linear +// expression by the input. This method is not yet implemented. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) Mult(c float64) (VectorExpression, error) { return vlet, fmt.Errorf("The multiplication method has not yet been implemented!") } -/* -Multiply -Description: - - Multiplication of a VarVector with another expression. -*/ +// Multiply performs multiplication of a VectorLinearExpressionTranspose with another expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) Multiply(rightIn interface{}, errors ...error) (Expression, error) { // Input Processing err := vlet.Check() @@ -213,12 +186,10 @@ func (vlet VectorLinearExpressionTranspose) Multiply(rightIn interface{}, errors } } -/* -Plus -Description: - - Returns an expression which adds the expression e to the vector linear expression at hand. -*/ +// Plus returns an expression which adds the expression e to the vector linear +// expression at hand. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) Plus(rightIn interface{}, errors ...error) (Expression, error) { // Input Processing err := vlet.Check() @@ -347,23 +318,17 @@ Description: // return nil, fmt.Errorf("Unexpected type of right hand side %v: %T", rhsIn, rhsIn) //} -/* -Eq -Description: - - Creates a constraint between the current vector linear expression v and the - rhs given by rhs. -*/ +// Eq creates a constraint between the current vector linear expression and +// the rhs given by rhs. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) Eq(rightIn interface{}, errors ...error) (Constraint, error) { return vlet.Comparison(rightIn, SenseEqual, errors...) } -/* -Len -Description: - - The size of the constraint. -*/ +// Len returns the number of elements in the transposed vector linear expression. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) Len() int { // Constants @@ -371,13 +336,10 @@ func (vlet VectorLinearExpressionTranspose) Len() int { return vlet.C.Len() } -/* -Comparison -Description: - - Compares the input vector linear expression with respect to the expression rhsIn and the sense - senseIn. -*/ +// Comparison compares the input vector linear expression transpose with respect +// to the expression rightIn and the sense senseIn. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) Comparison(rightIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) { // Constants @@ -464,17 +426,11 @@ func (vlet VectorLinearExpressionTranspose) Comparison(rightIn interface{}, sens } } -/* -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. -*/ +// RewriteInTermsOf rewrites the VectorLinearExpressionTranspose in terms of a +// new set of variables vv. It assumes vv contains all unique variables and all +// elements of vlet.X are in vv. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) RewriteInTermsOf(vv VarVector) VectorLinearExpressionTranspose { // Constants @@ -505,10 +461,9 @@ func (vlet VectorLinearExpressionTranspose) RewriteInTermsOf(vv VarVector) Vecto } -/* -AtVec -Description: -*/ +// AtVec returns the scalar expression at the given index idx. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) AtVec(idx int) ScalarExpression { // Constants Li := vlet.L.RowView(idx) @@ -525,12 +480,9 @@ func (vlet VectorLinearExpressionTranspose) AtVec(idx int) ScalarExpression { } -/* -Transpose -Description: - - This method creates the transpose of the current vector and returns it. -*/ +// Transpose creates the transpose of the current expression and returns it. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) Transpose() Expression { return VectorLinearExpr{ L: vlet.L, @@ -539,17 +491,17 @@ func (vlet VectorLinearExpressionTranspose) Transpose() Expression { } } -/* -Dims -Description: - - Returns the dimensions of the VectorLinearExpressionTranspose - object. -*/ +// Dims returns the dimensions of the VectorLinearExpressionTranspose object. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) Dims() []int { return []int{1, vlet.Len()} } +// ToScalarLinearExpression converts the VectorLinearExpressionTranspose to a +// ScalarLinearExpr. This only works when the dimension is 1. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) ToScalarLinearExpression() (ScalarLinearExpr, error) { // Check Errors err := vlet.Check() @@ -573,13 +525,10 @@ func (vlet VectorLinearExpressionTranspose) ToScalarLinearExpression() (ScalarLi return ScalarLinearExpr{L: L, X: vlet.X.Copy(), C: C}, nil } -/* -ToSymbolic -Description: - - Returns the symbolic version of the vector linear expression - transpose. -*/ +// ToSymbolic returns the symbolic version of the vector linear expression +// transpose. +// +// Deprecated: This package is deprecated. Please use github.com/MatProGo-dev/SymbolicMath.go instead. func (vlet VectorLinearExpressionTranspose) ToSymbolic() (symbolic.Expression, error) { // Check err := vlet.Check()