8.5.13. MDOLinExpr

MDOLinExpr

Represents a linear expression in a MindOpt application. A linear expression can contain linear terms and a constant.

Methods

MDOLinExpr

Construct a MDOLinExpr with an existing MDOLinExpr

add

Addanother linear term to the current linear term

addConstant

Add a value to the constant contained in linear expression

addTerm

Adda linear term to this linear expression

addTerms

Add linear terms to this linear expression

addTerms

Add linear terms to this linear expression

clear

Clear this linear expression to delete all items and reset its constants to zero

getCoeff

Retrieve the coefficients contained in the ith linear term

getConstant

Retrieve the value of constant contained in linear expression

getValue

Calculate the value of this linear expression after problem solved

getVar

Retrieve the variable contained in ith linear term

multAdd

Adda constant multiple of another linear term to the current linear term

remove

Remove a linear term from this linear expression by its index

remove

Remove all linear terms containing a specified variable

size

Retrieves the total number of linear terms contained in a linear expression

toString

Converts 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)

Addanother 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)

Adda 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)

Adda 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()

Retrieves the total number of linear terms contained in a linear expression

Returns

The total number of linear terms

String toString()

Converts the current linear term to its String format

Returns

The String format of the linear term.