8.9.15. MDOQuadExpr

MDOQuadExpr

Represents a quadratic expression in a MindOpt application. A quadratic expression has a quadratic term outside a linear expression.

Methods

MDOQuadExpr

Construct a quadratic expression with a linear expression

MDOQuadExpr

Construct a quadratic expression with an existing quadratic expression

add

Add a linear expression to this quadratic expression

add

Add a new quadratic expression to this quadratic expression

addConstant

Add a constant to a quadratic expression

addTerm

Add a linear term to this quadratic expression

addTerm

Add a quadratic term to this quadratic expression

addTerms

Add linear terms to this quadratic expression

addTerms

Add quadratic terms to this quadratic expression

addTerms

Add multiple linear terms to this quadratic expression

addTerms

Add quadratic terms to this quadratic expression

clear

Clear all items contained in the quadratic expression and reset the constant to zero

getCoeff

Retrieve the coefficient of the ith quadratic term

getLinExpr

Retrieve the linear expression contained in the quadratic term

getValue

Retrieve the value of this quadratic expression after solving the problem

getVar1

Retrieve the first variable of the ith quadratic term

getVar2

Retrieve the second variable of the ith quadratic term

multAdd

Add a multiple of a linear expression to this quadratic expression

multAdd

Add a multiple of a new quadratic expression to this quadratic expression

remove

Delete the ith quadratic term from this quadratic expression

remove

Deletes all terms (including linear and quadratic terms) that contain the specified variable

size

Retrieve the number of quadratic terms contained in this quadratic expression

toString

Convert the current quadratic expression to a string

MDOQuadExpr(MDOLinExpr le)

Construct a quadratic expression with a linear expression

Parameters

MDOLinExpr le – Linear expression

MDOQuadExpr(MDOQuadExpr qe)

Construct a quadratic expression with an existing quadratic expression

Parameters

MDOQuadExpr qe – Existing quadratic expression

void add(MDOLinExpr le)

Add a linear expression to this quadratic expression

Parameters

MDOLinExpr le – The linear expression to add.

void add(MDOQuadExpr qe)

Add a new quadratic expression to this quadratic expression

Parameters

MDOQuadExpr qe – The linear expression to add.

void addConstant(double c)

Add a constant to a quadratic expression

Parameters

double c – The constant to be added.

void addTerm(double coeff, MDOVar var)

Add a linear term to this quadratic expression

Parameters
  • double coeff – The coefficient of the linear term to be added

  • MDOVar var – The variable of the linear term to be added

void addTerm(double coeff, MDOVar var1, MDOVar var2)

Add a quadratic term to this quadratic expression

Parameters
  • double coeff – The coefficient of the quadratic term to be added

  • MDOVar var1 – The first variable of the quadratic item to be added

  • MDOVar var2 – The second variable of the quadratic item to be added

void addTerms(double[] coeff, MDOVar[] var)

Add linear terms to this quadratic expression

Parameters
  • double[] coeff – The coefficients of the linear terms to be added

  • MDOVar[] var – The variables of the linear terms to be added

void addTerms(double[] coeff, MDOVar[] var1, MDOVar[] var2)

Add quadratic terms to this quadratic expression

Parameters
  • double[] coeff – The coefficients of the quadratic term to be added

  • MDOVar[] var1 – The first variables of the quadratic item to be added

  • MDOVar[] var2 – The second variables of the quadratic item to be added

void addTerms(double[] coeff, MDOVar[] var, int start, int len)

Add multiple linear terms to this quadratic expression

Parameters
  • double[] coeff – An array of coefficients that contain the coefficients of linear terms to be added

  • MDOVar[] var – An array of variables that contain the variables of linear items to be added

  • int start – The starting index to be added to the array.

  • int len – The number of linear items to add

void addTerms(double[] coeff, MDOVar[] var1, MDOVar[] var2, int start, int len)

Add quadratic terms to this quadratic expression

Parameters
  • double[] coeff – An array of coefficients that contain the coefficients of quadratic terms to be added.

  • MDOVar[] var1 – An array of variables that contain the first variable of quadratic items to be added

  • MDOVar[] var2 – An array of variables that contain the second variable of quadratic items to be added

  • int start – The starting index of the items to be added to the array.

  • int len – The number of the quadratic terms to be added.

void clear()

Clear all items contained in the quadratic expression and reset the constant to zero

double getCoeff(int i)

Retrieve the coefficient of the ith quadratic term

Parameters

int i – Index of the quadratic term

Returns

The coefficient of the quadratic term

MDOLinExpr getLinExpr()

Retrieve the linear expression contained in the quadratic term

Returns

The linear expression contained in the quadratic terms

double getValue()

Retrieve the value of this quadratic expression after solving the problem

Returns

The value of the quadratic expression after solving the problem

MDOVar getVar1(int i)

Retrieve the first variable of the ith quadratic term

Parameters

int i – Index of the quadratic term

Returns

The first variable of the ith quadratic term

MDOVar getVar2(int i)

Retrieve the second variable of the ith quadratic term

Parameters

int i – Index of the quadratic term

Returns

The second variable of the ith quadratic term

void multAdd(double m, MDOLinExpr le)

Add a multiple of a linear expression to this quadratic expression

Parameters
  • double m – Multiple

  • MDOLinExpr le – The linear expression to add.

void multAdd(double m, MDOLinExpr le)

Add a multiple of a new quadratic expression to this quadratic expression

Parameters
  • double m – Multiple

  • MDOLinExpr le – The quadratic expression to be added.

void remove(int i)

Delete the ith quadratic term from this quadratic expression

Parameters

int i – The index of the quadratic term to be deleted.

bool remove(MDOVar v)

Deletes all terms (including linear and quadratic terms) that contain the specified variable.

Parameters

MDOVar v – Variable to delete

Returns

True if at least one item is deleted

int size()

Retrieve the number of quadratic terms contained in this quadratic expression

Returns

The number of quadratic terms contained in this quadratic expression

String toString()

Convert the current quadratic expression to a string.

Returns

The string format of the quadratic expression.