Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
b38c0c3
Initial plan
Copilot Feb 22, 2026
6dc3b34
Fix all godoc documentation comment issues in symbolic package
Copilot Feb 22, 2026
0b3df80
Fix all godoc documentation comments in symbolic package
Copilot Feb 22, 2026
f6ada6c
Update symbolic/matrix_expression.go
kwesiRutledge Mar 5, 2026
090c916
Update symbolic/matrix_expression.go
kwesiRutledge Mar 5, 2026
e6d674b
Update symbolic/constant_matrix.go
kwesiRutledge Mar 5, 2026
a3a1df0
Update symbolic/matrix_expression.go
kwesiRutledge Mar 5, 2026
8f6aeb2
Update symbolic/matrix_expression.go
kwesiRutledge Mar 5, 2026
3661d3f
Update symbolic/matrix_expression.go
kwesiRutledge Mar 5, 2026
b41675f
Update symbolic/constant_matrix.go
kwesiRutledge Mar 5, 2026
916d7cb
Update symbolic/constant_matrix.go
kwesiRutledge Mar 5, 2026
fdd29a8
Update symbolic/constant_matrix.go
kwesiRutledge Mar 5, 2026
c85732e
Update symbolic/constant_matrix.go
kwesiRutledge Mar 5, 2026
3630867
Update symbolic/constant_matrix.go
kwesiRutledge Mar 5, 2026
162f304
Update symbolic/constant_matrix.go
kwesiRutledge Mar 5, 2026
a6e9477
Update symbolic/constant_matrix.go
kwesiRutledge Mar 5, 2026
00b4bba
Update symbolic/constant_matrix.go
kwesiRutledge Mar 5, 2026
1981d89
Update symbolic/constant_matrix.go
kwesiRutledge Mar 5, 2026
b56aa2e
Update symbolic/constant_vector.go
kwesiRutledge Mar 5, 2026
5a6d0b4
Update symbolic/constant_vector.go
kwesiRutledge Mar 5, 2026
fcb72f4
Update symbolic/constant_vector.go
kwesiRutledge Mar 5, 2026
731ac29
Update symbolic/constant_vector.go
kwesiRutledge Mar 5, 2026
75389cc
Update symbolic/constant_vector.go
kwesiRutledge Mar 5, 2026
7946186
Update symbolic/constant_vector.go
kwesiRutledge Mar 5, 2026
96a5582
Update symbolic/constant_vector.go
kwesiRutledge Mar 5, 2026
b519c6f
Update symbolic/constant_vector.go
kwesiRutledge Mar 5, 2026
7a7e6b1
Update symbolic/constant_vector.go
kwesiRutledge Mar 5, 2026
7a5093b
Update symbolic/constant_vector.go
kwesiRutledge Mar 5, 2026
405f261
Update symbolic/constant_vector.go
kwesiRutledge Mar 5, 2026
cd4c9c1
Update symbolic/constraint.go
kwesiRutledge Mar 5, 2026
5cac0f7
Update symbolic/expression.go
kwesiRutledge Mar 5, 2026
30f226d
Update symbolic/expression.go
kwesiRutledge Mar 5, 2026
64eae24
Update symbolic/expression.go
kwesiRutledge Mar 5, 2026
942c9a5
Update symbolic/expression.go
kwesiRutledge Mar 5, 2026
217f5d9
Update symbolic/matrix_constraint.go
kwesiRutledge Mar 5, 2026
a500125
Update symbolic/matrix_expression.go
kwesiRutledge Mar 5, 2026
e6c9f7d
Update symbolic/matrix_expression.go
kwesiRutledge Mar 5, 2026
818ab66
Update symbolic/monomial.go
kwesiRutledge Mar 7, 2026
8c5d27a
Update symbolic/constant.go
kwesiRutledge Mar 7, 2026
ac237d6
Update symbolic/constant_matrix.go
kwesiRutledge Mar 7, 2026
6d5a144
Update symbolic/monomial.go
kwesiRutledge Mar 7, 2026
4d39d41
Update symbolic/monomial.go
kwesiRutledge Mar 7, 2026
d579cea
Update symbolic/monomial.go
kwesiRutledge Mar 7, 2026
ad8ee36
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
ae70464
Update symbolic/monomial.go
kwesiRutledge Mar 7, 2026
12f5c80
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
2ca6817
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
63257db
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
0b7fa5e
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
c5e18e6
Update symbolic/monomial.go
kwesiRutledge Mar 7, 2026
6bb1f29
Update symbolic/monomial.go
kwesiRutledge Mar 7, 2026
41a42d2
Update symbolic/monomial.go
kwesiRutledge Mar 7, 2026
7c23da4
Update symbolic/monomial.go
kwesiRutledge Mar 7, 2026
48742fe
Update symbolic/monomial.go
kwesiRutledge Mar 7, 2026
8df5bdb
Update symbolic/monomial.go
kwesiRutledge Mar 7, 2026
9184b77
Update symbolic/monomial_matrix.go
kwesiRutledge Mar 7, 2026
3609084
Update symbolic/monomial_matrix.go
kwesiRutledge Mar 7, 2026
8a1fafc
Update symbolic/monomial_matrix.go
kwesiRutledge Mar 7, 2026
1930c6d
Update symbolic/monomial_matrix.go
kwesiRutledge Mar 7, 2026
58b8e7d
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
9aed591
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
c9002ec
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
5436ea1
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
da369f3
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
388c18b
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
0a3b9f1
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
9f2045e
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
6b7aa53
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
9aa2c03
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
5ed06e4
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
4a8c597
Update symbolic/monomial_vector.go
kwesiRutledge Mar 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions symbolic/basic_environment.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package symbolic

// BasicEnvironment is a simple implementation of the Environment interface
// that tracks variables in a slice.
type BasicEnvironment struct {
name string
Variables []Variable
}

// GetName returns the name of the environment.
func (be *BasicEnvironment) GetName() string {
return be.name
}

// TrackVariable adds the variable to the environment if it is not already
// tracked. Returns true if the variable was added, false if it already exists.
func (be *BasicEnvironment) TrackVariable(v Variable) bool {
// Check if the variable is already in the environment
for _, existingVar := range be.Variables {
Expand All @@ -23,23 +28,18 @@ func (be *BasicEnvironment) TrackVariable(v Variable) bool {
return true // Variable was added successfully
}

// AllTrackedVariables returns a slice of all variables tracked by the environment.
func (be *BasicEnvironment) AllTrackedVariables() []Variable {
return be.Variables
}

/*
Public Functions
*/

// MakeBasicEnvironment creates a new BasicEnvironment with the given name.
func MakeBasicEnvironment(nameIn string) BasicEnvironment {
return BasicEnvironment{
name: nameIn,
Variables: []Variable{},
}
}

/*
DefaultEnvironment
A variable that exists in the background and used to store information about the variables currently created.
*/
// DefaultEnvironment A variable that exists in the background and used to store information about the variables currently created.
var DefaultEnvironment = MakeBasicEnvironment("DefaultEnvironment")
138 changes: 27 additions & 111 deletions symbolic/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,15 @@ const (
// K is a constant expression type for an MIP. K for short ¯\_(ツ)_/¯
type K float64

/*
Check
Description:

Checks to make sure that the constant is initialized properly.
Constants are always initialized properly, so this should always return
no error.
*/
// Check Checks to make sure that the constant is initialized properly.
// Constants are always initialized properly, so this should always return
// no error.
func (c K) Check() error {
return nil
}

/*
Variables
Description:

Shares all variables included in the expression that is K.
It is a constant, so there are none.
*/
// Variables Shares all variables included in the expression that is K.
// It is a constant, so there are none.
func (c K) Variables() []Variable {
return []Variable{}
}
Expand All @@ -49,13 +39,8 @@ func (c K) Constant() float64 {
return float64(c)
}

/*
LinearCoeff
Description

Returns the coefficient of the linear term in the expression. For a constant,
this is always a matrix of zeros.
*/
// LinearCoeff Returns the coefficient of the linear term in the expression. For a constant,
// this is always a matrix of zeros.
func (c K) LinearCoeff(wrt ...[]Variable) mat.VecDense {
// Constants

Expand All @@ -78,12 +63,7 @@ func (c K) LinearCoeff(wrt ...[]Variable) mat.VecDense {
return ZerosVector(len(wrtVars))
}

/*
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
func (c K) Plus(rightIn interface{}) Expression {
// Input Processing
if IsExpression(rightIn) {
Expand Down Expand Up @@ -141,12 +121,7 @@ func (c K) Plus(rightIn interface{}) Expression {
)
}

/*
Minus
Description:

This function subtracts the current expression from another and returns the resulting expression.
*/
// Minus This function subtracts the current expression from another and returns the resulting expression.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a typo? In this case, we subtract another expression from the current one.

func (c K) Minus(rightIn interface{}) Expression {
// Input Processing
if IsExpression(rightIn) {
Expand Down Expand Up @@ -198,12 +173,7 @@ func (c K) Eq(rightIn interface{}) Constraint {
return c.Comparison(rightIn, SenseEqual)
}

/*
Comparison
Description:

This method compares the receiver with expression rhs in the sense provided by sense.
*/
// Comparison This method compares the receiver with expression rhs in the sense provided by sense.
func (c K) Comparison(rhsIn interface{}, sense ConstrSense) Constraint {
// InputProcessing
if IsExpression(rhsIn) {
Expand Down Expand Up @@ -271,12 +241,7 @@ func (c K) Comparison(rhsIn interface{}, sense ConstrSense) Constraint {

}

/*
Multiply
Description:

This method multiplies the input constant by another expression.
*/
// Multiply This method multiplies the input constant by another expression.
func (c K) Multiply(term1 interface{}) Expression {
// Constants

Expand Down Expand Up @@ -321,20 +286,17 @@ func (c K) Multiply(term1 interface{}) Expression {
)
}

// Dims returns the dimensions of the constant K as a scalar [1, 1].
func (c K) Dims() []int {
return []int{1, 1} // Signifies scalar
}

// Transpose returns the constant itself, as the transpose of a scalar is itself.
func (c K) Transpose() Expression {
return c
}

/*
ToMonomial
Description:

Converts the constant into a monomial.
*/
// ToMonomial Converts the constant into a monomial.
func (c K) ToMonomial() Monomial {
return Monomial{
Coefficient: float64(c),
Expand All @@ -343,89 +305,48 @@ func (c K) ToMonomial() Monomial {
}
}

/*
ToPolynomial
Description:

Converts the constant into a polynomial.
*/
// ToPolynomial Converts the constant into a polynomial.
func (c K) ToPolynomial() Polynomial {
return Polynomial{
Monomials: []Monomial{c.ToMonomial()},
}
}

/*
DerivativeWrt
Description:

Computes the derivative of a constant, which should be 0 for any constant.
*/
// DerivativeWrt Computes the derivative of a constant, which should be 0 for any constant.
func (c K) DerivativeWrt(vIn Variable) Expression {
return Zero
}

/*
Degree
Description:

The degree of a constant is always 0.
*/
// Degree The degree of a constant is always 0.
func (c K) Degree() int {
return 0
}

/*
String
Description:

Returns a string representation of the constant.
*/
// String Returns a string representation of the constant.
func (c K) String() string {
return fmt.Sprintf("%v", float64(c))
}

/*
Substitute
Description:

Substitutes the variable vIn with the expression eIn.
*/
// Substitute Substitutes the variable vIn with the expression eIn.
func (c K) Substitute(vIn Variable, eIn ScalarExpression) Expression {
return c
}

/*
SubstituteAccordingTo
Description:

Substitutes the variables in the map with the corresponding expressions.
*/
// SubstituteAccordingTo Substitutes the variables in the map with the corresponding expressions.
func (c K) SubstituteAccordingTo(subMap map[Variable]Expression) Expression {
return c
}

/*
Power
Description:

Computes the power of the constant.
*/
// Power computes the result of the constant taken to the given exponent.
func (c K) Power(exponent int) Expression {
return ScalarPowerTemplate(c, exponent)
}

/*
At
Description:

Returns the value at the given row and column index.

Note:

For a constant, this is always the constant itself.
The value of ii and jj should always be 0.
*/
// At Returns the value at the given row and column index.
// Note:
//
// For a constant, this is always the constant itself.
// The value of ii and jj should always be 0.
func (c K) At(ii, jj int) ScalarExpression {
// Input Processing

Expand All @@ -438,12 +359,7 @@ func (c K) At(ii, jj int) ScalarExpression {
return c
}

/*
AsSimplifiedExpression
Description:

Returns the simplest form of the expression.
*/
// AsSimplifiedExpression Returns the simplest form of the expression.
func (c K) AsSimplifiedExpression() Expression {
return c
}
Loading