Documentation ¶
Index ¶
- type Constraint
- type Expression
- func (e *Expression) EQ(e2 *Expression) *Constraint
- func (e *Expression) GE(e2 *Expression) *Constraint
- func (e *Expression) LE(e2 *Expression) *Constraint
- func (e *Expression) MinusConst(c float64) *Expression
- func (e *Expression) MinusTerm(t *Term) *Expression
- func (e *Expression) MinusTerms(terms []*Term) *Expression
- func (e *Expression) PlusConst(c float64) *Expression
- func (e *Expression) PlusTerm(t *Term) *Expression
- func (e *Expression) PlusTerms(terms []*Term) *Expression
- func (e *Expression) String() string
- type LP
- type Term
- type Variable
- func (v *Variable) MinusTerm(t *Term) *Expression
- func (v *Variable) MinusVar(v2 *Variable) *Expression
- func (v *Variable) PlusConst(c float64) *Expression
- func (v *Variable) PlusTerm(t *Term) *Expression
- func (v *Variable) PlusVar(v2 *Variable) *Expression
- func (v *Variable) SetMaxBound(bound float64)
- func (v *Variable) SetMinBound(bound float64)
- func (v *Variable) SetUnbounded()
- func (v *Variable) String() string
- func (v *Variable) Times(c float64) *Term
- func (v *Variable) ToExpression() *Expression
- func (v *Variable) ToTerm() *Term
- func (v *Variable) Value() float64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Constraint ¶
type Constraint struct { Expression *Expression Constraint golp.ConstraintType RightHandSide float64 }
func (*Constraint) String ¶
func (e *Constraint) String() string
type Expression ¶
Expression represents a linear expression, as a sum of terms.
func NewConstExpression ¶
func NewConstExpression(c float64) *Expression
NewConstExpression creates a new expression with a constant term.
func (*Expression) EQ ¶
func (e *Expression) EQ(e2 *Expression) *Constraint
EQ creates a new constraint from two expressions, with the first equal to the second.
func (*Expression) GE ¶
func (e *Expression) GE(e2 *Expression) *Constraint
GE creates a new constraint from two expressions, with the first greater than or equal to the second.
func (*Expression) LE ¶
func (e *Expression) LE(e2 *Expression) *Constraint
LE creates a new constraint from two expressions, with the first less than or equal to the second.
func (*Expression) MinusConst ¶
func (e *Expression) MinusConst(c float64) *Expression
MinusConst subtracts a constant from the expression, modifying the same expression and returning itself.
func (*Expression) MinusTerm ¶
func (e *Expression) MinusTerm(t *Term) *Expression
MinusTermadds a term with inverted sign to the expression, modifying the same expression and returning itself.
func (*Expression) MinusTerms ¶
func (e *Expression) MinusTerms(terms []*Term) *Expression
MinusTerms adds multiple terms with inverted sign to the expression, modifying the same expression and returning itself.
func (*Expression) PlusConst ¶
func (e *Expression) PlusConst(c float64) *Expression
PlusConst adds a constant to the expression, modifying the same expression and returning itself.
func (*Expression) PlusTerm ¶
func (e *Expression) PlusTerm(t *Term) *Expression
PlusTerm adds a term to the expression, modifying the same expression and returning itself.
func (*Expression) PlusTerms ¶
func (e *Expression) PlusTerms(terms []*Term) *Expression
PlusTerms adds multiple terms to the expression, modifying the same expression and returning itself.
func (*Expression) String ¶
func (e *Expression) String() string
String returns a string representation of the expression.
type LP ¶
type LP struct {
// contains filtered or unexported fields
}
LP is a linear programming model, that wraps the golp library, with some additional functionality to help with creating models.
func (*LP) AddConstraint ¶
func (lp *LP) AddConstraint(constraint *Constraint)
AddConstraintLegacy adds a new constraint to the model.
func (*LP) AddVariable ¶
AddVariable adds a new variable to the model, with a name to help identify it.
func (*LP) SetVervoseLevel ¶
func (lp *LP) SetVervoseLevel(level golp.VerboseLevel)
SetVervoseLevel sets the verbose level of the model. Defaults to golp.IMPORTANT
type Term ¶
Term represents a term in a linear expression, as constant * variable.
func (*Term) Plus ¶
func (t *Term) Plus(t2 *Term) *Expression
Plus adds two terms together, creating a new expression.
func (*Term) PlusConst ¶
func (t *Term) PlusConst(c float64) *Expression
PlusConst adds a constant to the term, creating a new expression.
func (*Term) ToExpression ¶
func (t *Term) ToExpression() *Expression
ToExpression converts the term to an expression with only one term.
type Variable ¶
type Variable struct { Name string // contains filtered or unexported fields }
func (*Variable) MinusTerm ¶
func (v *Variable) MinusTerm(t *Term) *Expression
MinusTerm subtracts a term from the variable, creating an expression.
func (*Variable) MinusVar ¶
func (v *Variable) MinusVar(v2 *Variable) *Expression
MinusVar subtracts a variable from the variable, creating an expression.
func (*Variable) PlusConst ¶
func (v *Variable) PlusConst(c float64) *Expression
PlusConst adds a constant to the variable, creating an expression.
func (*Variable) PlusTerm ¶
func (v *Variable) PlusTerm(t *Term) *Expression
PlusTerm adds a term to the variable, creating an expression.
func (*Variable) PlusVar ¶
func (v *Variable) PlusVar(v2 *Variable) *Expression
PlusVar adds a variable to the variable, creating an expression of type 1*v1 + 1*v2.
func (*Variable) SetMaxBound ¶
SetMaxBound sets the maximum bound for the variable. By default it is +infinity.
func (*Variable) SetMinBound ¶
SetMinBound sets the minimum bound for the variable. By default it is 0.
func (*Variable) SetUnbounded ¶
func (v *Variable) SetUnbounded()
SetUnbounded sets the variable to be unbounded (-inf, +inf).
func (*Variable) ToExpression ¶
func (v *Variable) ToExpression() *Expression
ToExpression converts the variable to an expression with only one term.