8.9.14. MDOLinExpr¶
- MDOLinExpr¶
Represents a linear expression in a MindOpt application. A linear expression can contain linear terms and a constant.
Methods
Construct a MDOLinExpr with an existing MDOLinExpr
Add another linear term to the current linear term
Add a value to the constant contained in linear expression
Add a linear term to this linear expression
Add linear terms to this linear expression
Add linear terms to this linear expression
Clear this linear expression to delete all items and reset its constants to zero
Retrieve the coefficients contained in the ith linear term
Retrieve the value of constant contained in linear expression
Calculate the value of this linear expression after problem solved
Retrieve the variable contained in ith linear term
Add a constant multiple of another linear term to the current linear term
Remove a linear term from this linear expression by its index
Remove all linear terms containing a specified variable
Retrieve the total number of linear terms contained in a linear expression
Convert the current linear term to its String format
- MDOLinExpr(MDOLinExpr le)¶
Construct a MDOLinExpr with an existing MDOLinExpr.
- Parameters
MDOLinExpr le – Existing MDOLinExpr
- void add(MDOLinExpr le)¶
Add another linear term to the current linear term
- Parameters
MDOLinExpr le – Added linear term
- void addConstant(double c)¶
Add a value to the constant contained in linear expression.
- Parameters
double c – The value to be added.
- void addTerm(double coeff, MDOVar var)¶
Add a linear term to this linear expression
- Parameters
double coeff – Coefficient of the term to be added
MDOVar var – The variable of the term to be added
- void addTerms(double[] coeff, MDOVar[] var)¶
Add linear terms to this linear expression.
- Parameters
double[] coeff – The coefficients of terms to be added.
MDOVar[] var – The variables of terms to be added.
- void addTerms(double[] coeff, MDOVar[] var, int start, int len)¶
Add linear terms to this linear expression.
- Parameters
double[] coeff – Coefficients of the terms to be added
MDOVar[] var – The variables of the terms to be added
int start – Start position
int len – The number of items to add
- void clear()¶
Clear this linear expression to delete all items and reset its constants to zero
- double getCoeff(int i)¶
Retrieve the coefficients contained in the ith linear term
- Parameters
int i – The index of linear term
- Returns
Coefficient contained in the ith linear term
- double getConstant()¶
Retrieve the value of constant contained in linear expression.
- Returns
The value of constant contained in linear expression.
- double getValue()¶
Calculate the value of this linear expression after problem solved.
- Returns
The value of this linear expression.
- MDOVar getVar(int i)¶
Retrieve the variable contained in ith linear term.
- Parameters
int i – The index of linear term.
- Returns
The variable contained in ith linear term.
- void multAdd(double m, MDOLinExpr le)¶
Add a constant multiple of another linear term to the current linear term
- Parameters
double m – Constant multiplier
MDOLinExpr le – The linear term to be added
- void remove(int i)¶
Remove a linear term from this linear expression by its index.
- Parameters
int i – The index of the item to be deleted.
- boolean remove(MDOVar v)¶
Remove all linear terms containing a specified variable.
- Parameters
MDOVar v – The contained variable to be removed.
- Returns
True if at least 1 term was removed.
- int size()¶
Retrieve the total number of linear terms contained in a linear expression
- Returns
The total number of linear terms
- String toString()¶
Convert the current linear term to its String format
- Returns
The String format of the linear term.