8.8.15. MDOQuadExpr

MDOQuadExpr

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

Properties

LinExpr

Retrieve the linear expression contained in the quadratic term

Size

Retrieve the number of quadratic terms contained in this quadratic expression

Value

Retrieve the value of this quadratic expression after solving the problem

LinExpr

Retrieve the linear expression contained in the quadratic term

Size

Retrieve the number of quadratic terms contained in this quadratic expression

Value

Retrieve the value of this quadratic expression after solving the problem

Methods

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

GetVar1

Retrieve the first variable of the ith quadratic term

GetVar2

Retrieve the second variable of the ith quadratic term

MDOQuadExpr

Construct a quadratic expression

MDOQuadExpr

Construct a quadratic expression with a constant

MDOQuadExpr

Construct a quadratic expression with a linear expression

MDOQuadExpr

Construct a quadratic expression with an existing quadratic expression

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

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

ToString

Convert the current quadratic expression to a string

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 term to be added.

  • MDOVar var2 – The second variable of the quadratic term 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 contains 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 contains the coefficients of quadratic terms to be added.

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

  • MDOVar[] var2 – An array of variables that contains 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 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 specified quadratic term.

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.

MDOQuadExpr()

Construct a quadratic expression

MDOQuadExpr(double c)

Construct a quadratic expression with a constant

Parameters

double c – The constant

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 MultAdd(double m, MDOLinExpr le)

Add a multiple of a linear expression to this quadratic expression.

Parameters
  • double m – The multiple factor to be applied to the quadratic expression..

  • MDOLinExpr le – The linear expression to add.

void MultAdd(double m, MDOQuadExpr qe)

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

Parameters
  • double m – The multiple factor to be applied to the quadratic expression.

  • MDOQuadExpr qe – 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)

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

Parameters

MDOVar v – Variable to remove.

Returns

True if at least one term is removed.

string ToString()

Convert the current quadratic expression to a string.

Returns

The string format of the quadratic expression.