8.5.12. MDOPsdExpr

class MDOPsdExpr

Represent a PSD expression in MindOpt application. A PSD expression contains PSD terms, and optionally, a linear expression.

Methods

MDOPsdExpr

Construct a MDOPsdExpr with a constant value

MDOPsdExpr

Construct a MDOPsdExpr with a linear expression

MDOPsdExpr

Construct a MDOPsdExpr with a PSD term

addTerm

Add a PSD term to this PSD expression

addTerms

Add linear terms to this PSD expression

clear

Clear all terms contained in this PSD expression, that is, remove all PSD terms, linear terms from this PSD expression and reset its constant to zero

getCoeff

Retrieve the coefficient contained in ith PSD term

getLinExpr

Retrieve the linear expression contained in this PSD expression

getPsdVar

Retrieve the PSD variable contained in ith PSD term

getValue

Calculate the value of this PSD expression after problem solved

remove

Remove the ith PSD term from this PSD expression

remove

Remove all PSD terms that contain a specified PSD variable

size

Retrieve the number of PSD terms contained in PSD expression

MDOPsdExpr(double constant = 0.0)

Construct a MDOPsdExpr with a constant value.

Parameters

double constant=0.0 – The initial constant value.

MDOPsdExpr(const MDOLinExpr &le)

Construct a MDOPsdExpr with a linear expression.

Parameters

const MDOLinExpr& le – The initial linear expression.

MDOPsdExpr(MDOPsdVar var, MDOMatrix coeff)

Construct a MDOPsdExpr with a PSD term.

Parameters
  • MDOPsdVar var – The PSD variable of PSD term.

  • MDOMatrix coeff – The coefficient of PSD term.

void addTerm(const MDOMatrix &coeff, const MDOPsdVar var)

Add a PSD term to this PSD expression.

Parameters
  • const MDOMatrix& coeff – The coefficient of new PSD term to be added.

  • const MDOPsdVar var – The PSD variable of new PSD term to be added.

void addTerms(const double *coeff, const MDOVar *var, int cnt)

Add linear terms to this PSD expression.

Parameters
  • const double* coeff – The coefficients of new linear terms to be added.

  • const MDOVar* var – The variables of new linear terms to be added.

  • int cnt – The number of linear terms to be added.

void clear()

Clear all terms contained in this PSD expression, that is, remove all PSD terms, linear terms from this PSD expression and reset its constant to zero.

MDOMatrix getCoeff(int i)

Retrieve the coefficient contained in ith PSD term.

Parameters

int i – The index of PSD term.

Returns

The coefficient contained in ith PSD term.

MDOLinExpr getLinExpr()

Retrieve the linear expression contained in this PSD expression.

Returns

The linear expression contained in this PSD expression.

MDOPsdVar getPsdVar(int i)

Retrieve the PSD variable contained in ith PSD term.

Parameters

int i – The index of PSD term.

Returns

The PSD variable contained in ith PSD term.

double getValue()

Calculate the value of this PSD expression after problem solved.

Returns

The value of this PSD expression after problem solved.

void remove(int i)

Remove the ith PSD term from this PSD expression.

Parameters

int i – The index of PSD term to be removed

bool remove(MDOPsdVar v)

Remove all PSD terms that contain a specified PSD variable

Parameters

MDOPsdVar v – The contained PSD variable to be removed

Returns

True if at least 1 term was removed.

unsigned int size()

Retrieve the number of PSD terms contained in PSD expression.

Returns

The number of PSD terms contained in PSD expression.