Initializing help system before first use

# Variable

A reference to a variable. More...

Inheritance diagram for xpress::objects::Variable:

## Public Member Functions
auto | absOf (Variable x) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the absolute value of `x`.
template<typename Strm_variables , is-stream(Strm_variables) >
auto | andOf (Strm_variables const &variables) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the and of the specified arguments.
template<typename Strm_variables , is-stream(Strm_variables) >
auto | andOf (Strm_variables const &variables, std::optional< std::string > name) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the and of the specified arguments.
template<typename... VARIABLES, typename RestrictPack = typename std::enable_if<xpress::AllConvertible<Variable, VARIABLES...>::value>::type>
auto | andOf (VARIABLES... variables) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the and of the specified other variables.
auto | chgCoef (Inequality r, double newCoef) -> void
| Change the coefficient for this variable in a row.
auto | chgCoefs (xpress::SizedArray< Inequality const > const &r, xpress::SizedArray< double const > const &newCoef) -> void
| Change the coefficients for this variable in multiple rows.
auto | chgObj (double newCoef) -> Variable &
| Change objective coefficient for this variable.
auto | chgObjN (int objidx, double newCoef) -> Variable &
| Change objective coefficient for this variable.
virtual auto | compareTo (Variable const &other) const -> int final
auto | div (ConstantExpression arg) const -> xpress::objects::LinTerm
| Create a expression that represents the quotient of `this` and `arg`.
virtual auto | div (double arg) const -> xpress::objects::Expression override
  | Create a expression that represents the quotient of `this` and `arg`. Parameters
  arg | Divisor.
Returns Quotient of `this` and `arg`. Since 44.00
virtual auto | div (xpress::objects::Expression arg) const -> xpress::objects::Expression override
  | Create a expression that represents the quotient of `this` and `arg`. Parameters
  arg | Divisor.
Returns Quotient of `this` and `arg`. Since 44.00
virtual auto | eq (double rhs) const -> xpress::objects::InequalityDefinition override
  | Create an "equals" constraint with this expression as left-hand side.Examples using `eq`: BoolVars.cpp Parameters
  rhs | Right-hand side of constraint.
Returns The constraint. Since 44.00 Examples using `eq`:
virtual auto | eq (Expression const &rhs) const -> xpress::objects::InequalityDefinition override
  | Create an "equals" constraint with this expression as left-hand side.Examples using `eq`: BoolVars.cpp Parameters
  rhs | Right-hand side of constraint.
Returns The constraint. Since 44.00 Examples using `eq`:
virtual auto | evaluate (xpress::SizedArray< double const > const &solution) const -> double override
  | Compute the value of this expression with respect to the given solution vector (which is not required to be feasible).Examples using `evaluate`: CapitalBudgeting.cpp PolygonObjects.cpp Parameters
  solution | Solution values for which the expression is evaluated.
Returns The value of this expression evaluated at `solution`. Since 44.00 Examples using `evaluate`:
auto | fix (double value) -> Variable &
| Fix this variable to a value.
virtual auto | geq (double rhs) const -> xpress::objects::InequalityDefinition override
  | Create a "greater than or equal" constraint with this expression as left-hand side. Parameters
  rhs | Right-hand side of constraint.
Returns The constraint. Since 44.00
virtual auto | geq (Expression const &rhs) const -> xpress::objects::InequalityDefinition override
  | Create a "greater than or equal" constraint with this expression as left-hand side. Parameters
  rhs | Right-hand side of constraint.
Returns The constraint. Since 44.00
auto | getCallbackRedCost () -> double
| Get reduced cost value for this variable from the solution associated with the current callback.
auto | getCallbackSolution () -> double
| Get value for this variable from the solution associated with the current callback.
virtual auto | getHashCode () const -> std::size_t final
virtual auto | getIndex () const -> int final
virtual auto | getIndexForProb (XpressProblem const *xprob) const -> int final
auto | getLB () const -> double
| Get the lower bound for this variable.
virtual auto | getName () const -> std::string final
| Examples using `getName`:
auto | getObj () const -> double
| Get objective coefficient for this variable.
auto | getObjN (int objIdx) const -> double
| Get objective coefficient for this variable.
virtual auto | getProblem () const -> xpress::objects::XpressProblem *final
auto | getRedCost () const -> double
| Get the current reduced cost value for this variable.
auto | getSolution () const -> double
| Get the current solution value for this variable.
auto | getType () const -> xpress::ColumnType
| Get the type for this variable.
auto | getUB () const -> double
| Get the upper bound for this variable.
auto | getValue (xpress::SizedArray< double const > const &data) const -> double
| Get the value of this variable from an array.
auto | ifNotThen (InequalityDefinition implied) const -> xpress::objects::IndicatorDescription
| Create an indicator constraint with this variable as indicator variable.
auto | ifThen (InequalityDefinition implied) const -> xpress::objects::IndicatorDescription
| Create an indicator constraint with this variable as indicator variable.
virtual auto | in (double lb, double ub) -> xpress::objects::InequalityDefinition override
  | Create a range constraint that bounds this expression from below and above.Examples using `in`: Folio.cpp FolioCB.cpp FolioMipIIS.cpp QuadraticProgramming.cpp Parameters
  lb | Lower bound for this expression.
  ub | Upper bound for this expression.
Returns The constraint. Since 44.00 Examples using `in`:
virtual auto | leq (double rhs) const -> xpress::objects::InequalityDefinition override
  | Create a "less than or equal" constraint with this expression as left-hand side.Examples using `leq`: TravelingSalesPerson.cpp Parameters
  rhs | Right-hand side of constraint.
Returns The constraint. Since 44.00 Examples using `leq`:
virtual auto | leq (Expression const &rhs) const -> xpress::objects::InequalityDefinition override
  | Create a "less than or equal" constraint with this expression as left-hand side.Examples using `leq`: TravelingSalesPerson.cpp Parameters
  rhs | Right-hand side of constraint.
Returns The constraint. Since 44.00 Examples using `leq`:
template<typename Strm_variables , typename Strm_values , is-stream(Strm_variables) , is-stream(Strm_values) >
auto | maxOf (Strm_variables const &variables, Strm_values const &values) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the maximum of the specified arguments.
template<typename Strm_variables , typename Strm_values , is-stream(Strm_variables) , is-stream(Strm_values) >
auto | maxOf (Strm_variables const &variables, Strm_values const &values, std::optional< std::string > name) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the maximum of the specified arguments.
template<typename... VARIABLES, typename RestrictPack = typename std::enable_if<xpress::AllConvertible<Variable, VARIABLES...>::value>::type>
auto | maxOf (VARIABLES... variables) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the maximum of the specified other variables.
template<typename... VALUES, typename RestrictPack = typename std::enable_if<xpress::AllConvertible<double, VALUES...>::value>::type>
auto | maxOf (xpress::SizedArray< Variable const > const &variables, VALUES... values) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the maximum of the specified other variables and values.
template<typename Strm_variables , typename Strm_values , is-stream(Strm_variables) , is-stream(Strm_values) >
auto | minOf (Strm_variables const &variables, Strm_values const &values) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the minimum of the specified arguments.
template<typename Strm_variables , typename Strm_values , is-stream(Strm_variables) , is-stream(Strm_values) >
auto | minOf (Strm_variables const &variables, Strm_values const &values, std::optional< std::string > name) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the minimum of the specified arguments.
template<typename... VARIABLES, typename RestrictPack = typename std::enable_if<xpress::AllConvertible<Variable, VARIABLES...>::value>::type>
auto | minOf (VARIABLES... variables) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the minimum of the specified other variables.
template<typename... VALUES, typename RestrictPack = typename std::enable_if<xpress::AllConvertible<double, VALUES...>::value>::type>
auto | minOf (xpress::SizedArray< Variable const > const &variables, VALUES... values) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the minimum of the specified other variables and values.
auto | mul (ConstantExpression arg) const -> xpress::objects::LinTerm
| Create a expression that represents the product of `this` and `arg`.
virtual auto | mul (double arg) const -> xpress::objects::Expression override
  | Create a expression that represents the product of `this` and `arg`.Examples using `mul`: Capbgt2l.cpp Parameters
  arg | Factor.
Returns Product of `this` and `arg`. Since 44.00 Examples using `mul`:
virtual auto | mul (Expression arg) const -> xpress::objects::Expression override
  | Create a expression that represents the product of `this` and `arg`.Examples using `mul`: Capbgt2l.cpp Parameters
  arg | Factor.
Returns Product of `this` and `arg`. Since 44.00 Examples using `mul`:
auto | mul (LinTerm arg) const -> xpress::objects::QuadTerm
| Create a expression that represents the product of `this` and `arg`.
auto | mul (Variable arg) const -> xpress::objects::QuadTerm
| Create a expression that represents the product of `this` and `arg`.
template<typename Strm_variables , is-stream(Strm_variables) >
auto | orOf (Strm_variables const &variables) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the or of the specified arguments.
template<typename Strm_variables , is-stream(Strm_variables) >
auto | orOf (Strm_variables const &variables, std::optional< std::string > name) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the or of the specified arguments.
template<typename... VARIABLES, typename RestrictPack = typename std::enable_if<xpress::AllConvertible<Variable, VARIABLES...>::value>::type>
auto | orOf (VARIABLES... variables) const -> xpress::objects::GeneralConstraintDefinition
| Create a constraint that requires this variable to be the or of the specified other variables.
template<typename... BREAKPOINTS, typename RestrictPack = typename std::enable_if<xpress::AllConvertible<xpress::PwlBreakpoint, BREAKPOINTS...>::value>::type>
auto | pwlOf (Variable input, BREAKPOINTS... breakpoints) const -> xpress::objects::PWLDefinition
| Create a piecewise linear constraint that requires this variable to be the value of the piecewise linear function specified by `breakpoints` evaluated for `input`.
template<typename Strm_breakpoints , is-stream(Strm_breakpoints) >
auto | pwlOf (Variable input, Strm_breakpoints const &breakpoints) const -> xpress::objects::PWLDefinition
| Create a piecewise linear constraint that requires this variable to be the value of the piecewise linear function specified by `breakpoints` evaluated for `input`.
template<typename Strm_breakpoints , is-stream(Strm_breakpoints) >
auto | pwlOf (Variable input, Strm_breakpoints const &breakpoints, std::optional< std::string > name) const -> xpress::objects::PWLDefinition
| Create a piecewise linear constraint that requires this variable to be the value of the piecewise linear function specified by `breakpoints` evaluated for `input`.
auto | pwlOf (Variable input, xpress::SizedArray< double const > const &xval, xpress::SizedArray< double const > const &yval) const -> xpress::objects::PWLDefinition
| Create a piecewise linear constraint that requires this variable to be the value of the piecewise linear function specified by `xval`/`yval` evaluated for `input`.
auto | pwlOf (Variable input, xpress::SizedArray< double const > const &xval, xpress::SizedArray< double const > const &yval, std::optional< std::string > name) const -> xpress::objects::PWLDefinition
| Create a piecewise linear constraint that requires this variable to be the value of the piecewise linear function specified by `xval`/`yval` evaluated for `input`.
auto | setLB (double newLB) -> Variable &
| Set the lower bound for this variable.
auto | setLimit (double newLimit) -> Variable &
| Set the limit for this variable.
auto | setName (std::optional< std::string > newName) -> Variable &
| Set the name of this variable.
auto | setType (xpress::ColumnType newType) -> Variable &
| Set the type for this variable.
auto | setUB (double newUB) -> Variable &
| Set the upper bound for this variable.
auto | square () -> xpress::objects::QuadTerm
| Create a quadratic term by multiplying this variable with itself.
virtual auto | toString () const -> std::string override
| Returns the name from `getName()`.
virtual auto | uminus () const -> xpress::objects::Expression override
| Create a expression that represents the unary minus of this one. Returns Expression representing `-this`. Since 44.00
Public Member Functions inherited from xpress::objects::Expression
virtual auto | minus (double arg) const -> xpress::objects::Expression
| Create a expression that represents the difference of `this` and `arg`.
virtual auto | minus (xpress::objects::Expression arg) const -> xpress::objects::Expression
| Create a expression that represents the difference of `this` and `arg`.
virtual auto | plus (double arg) const -> xpress::objects::Expression
| Create a expression that represents the sum of `this` and `arg`.
virtual auto | plus (xpress::objects::Expression arg) const -> xpress::objects::Expression
| Create a expression that represents the sum of `this` and `arg`.
Public Member Functions inherited from xpress::objects::Index

## Detailed Description

A reference to a variable.

Since
  44.00

## Member Function Documentation

## absOf()

auto xpress::objects::Variable::absOf | ( | Variable | x | ) | const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the absolute value of `x`.

Examples using `absOf`:

- GeneralConstraints.cpp

Parameters

  x | Argument for the absolute value constraint.

Returns
  `this = abs(x)`.

Since
  44.00

## andOf() [1/3]

template<typename Strm_variables , typename Strm_variablesIsStream >

auto xpress::objects::Variable::andOf | ( | Strm_variables const & | variables | ) | const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the and of the specified arguments.

Examples using `andOf`:

- BoolVars.cpp

Parameters

  variables | Variables in the and constraint.

Template Parameters

  Strm_variables | Something that supports `begin()` and `end()` and contains values of type `Variable`.

Returns
  `this = and(variables, value)`.

Since
  44.00

## andOf() [2/3]

template<typename Strm_variables , typename Strm_variablesIsStream >

auto xpress::objects::Variable::andOf | ( | Strm_variables const & | variables,
|  | std::optional< std::string > | name ) const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the and of the specified arguments.

Examples using `andOf`:

- BoolVars.cpp

Parameters

  variables | Variables in the and constraint.
  name | Constraint name, can be `std::nullopt` to indicate the constraint has no name.

Template Parameters

  Strm_variables | Something that supports `begin()` and `end()` and contains values of type `Variable`.

Returns
  `this = and(variables, value)`.

Since
  44.00

## andOf() [3/3]

template<typename... VARIABLES, typename RestrictPack >

auto xpress::objects::Variable::andOf | ( | VARIABLES... | variables | ) | const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the and of the specified other variables.

Examples using `andOf`:

- BoolVars.cpp

Parameters

  variables | Variables in the and constraint.

Returns
  `this = and(variables)`.

Since
  44.00

## chgCoef()

auto xpress::objects::Variable::chgCoef | ( | Inequality | r,
|  | double | newCoef ) -> void
| inline

Change the coefficient for this variable in a row.

Examples using `chgCoef`:

- CuttingStock.cpp
- RecursiveFinancialPlanning.cpp

Parameters

  r | Inequality for which to change the coefficient.
  newCoef | New coefficient.

Since
  44.00

## chgCoefs()

auto xpress::objects::Variable::chgCoefs | ( | xpress::SizedArray< Inequality const > const & | r,
|  | xpress::SizedArray< double const > const & | newCoef ) -> void
| inline

Change the coefficients for this variable in multiple rows.

Parameters

  r | Inequalities for which to change the coefficient.
  newCoef | New coefficients.

Since
  44.00

## chgObj()

auto xpress::objects::Variable::chgObj | ( | double | newCoef | ) | -> Variable&
| inline

Change objective coefficient for this variable.

Examples using `chgObj`:

- CuttingStock.cpp
- tsp.cpp

Parameters

  newCoef | New objective coefficient.

Returns
  Always returns this instance.

Since
  44.00

## chgObjN()

auto xpress::objects::Variable::chgObjN | ( | int | objidx,
|  | double | newCoef ) -> Variable&
| inline

Change objective coefficient for this variable.

Parameters

  objidx | Index of objective function to change.
  newCoef | New objective coefficient.

Returns
  Always returns this instance.

Since
  44.00

## compareTo()

auto xpress::objects::Variable::compareTo | ( | Variable const & | other | ) | const -> int
| inline final virtual

Since
  44.00

## div() [1/3]

auto xpress::objects::Variable::div | ( | ConstantExpression | arg | ) | const -> xpress::objects::LinTerm
| inline

Create a expression that represents the quotient of `this` and `arg`.

Parameters

  arg | Divisor.

Returns
  The expression.

Since
  44.00

## div() [2/3]

auto xpress::objects::Variable::div | ( | double | arg | ) | const -> xpress::objects::Expression
| inline override virtual

Create a expression that represents the quotient of `this` and `arg`.

Parameters

  arg | Divisor.

Returns
  Quotient of `this` and `arg`.

Since
  44.00

Since
  44.00

Reimplemented from xpress::objects::Expression.

## div() [3/3]

auto xpress::objects::Variable::div | ( | xpress::objects::Expression | arg | ) | const -> xpress::objects::Expression
| inline override virtual

Create a expression that represents the quotient of `this` and `arg`.

Parameters

  arg | Divisor.

Returns
  Quotient of `this` and `arg`.

Since
  44.00

Since
  44.00

Reimplemented from xpress::objects::Expression.

## eq() [1/2]

auto xpress::objects::Variable::eq | ( | double | rhs | ) | const -> xpress::objects::InequalityDefinition
| inline override virtual

Create an "equals" constraint with this expression as left-hand side.Examples using `eq`:

- BoolVars.cpp

Parameters

  rhs | Right-hand side of constraint.

Returns
  The constraint.

Since
  44.00

Examples using `eq`:

- BoolVars.cpp

Since
  44.00

Reimplemented from xpress::objects::Expression.

## eq() [2/2]

auto xpress::objects::Variable::eq | ( | Expression const & | rhs | ) | const -> xpress::objects::InequalityDefinition
| inline override virtual

Create an "equals" constraint with this expression as left-hand side.Examples using `eq`:

- BoolVars.cpp

Parameters

  rhs | Right-hand side of constraint.

Returns
  The constraint.

Since
  44.00

Examples using `eq`:

- BoolVars.cpp

Since
  44.00

Reimplemented from xpress::objects::Expression.

## evaluate()

auto xpress::objects::Variable::evaluate | ( | xpress::SizedArray< double const > const & | solution | ) | const -> double
| inline override virtual

Compute the value of this expression with respect to the given solution vector (which is not required to be feasible).Examples using `evaluate`:

- CapitalBudgeting.cpp
- PolygonObjects.cpp

Parameters

  solution | Solution values for which the expression is evaluated.

Returns
  The value of this expression evaluated at `solution`.

Since
  44.00

Examples using `evaluate`:

- CapitalBudgeting.cpp
- PolygonObjects.cpp

Parameters

  solution | Solution values for which the expression is evaluated.

Since
  44.00

Reimplemented from xpress::objects::Expression.

## fix()

auto xpress::objects::Variable::fix | ( | double | value | ) | -> Variable&
| inline

Fix this variable to a value.

Set the lower bound and upper bound in the `XpressProblem` instance to which this variable belongs.

Examples using `fix`:

- BoolVars.cpp
- Catenary.cpp
- FolioHeuristic.cpp
- RecursiveFinancialPlanning.cpp

Parameters

  value | New lower and upper bound.

Returns
  This variable

Since
  44.00

## geq() [1/2]

auto xpress::objects::Variable::geq | ( | double | rhs | ) | const -> xpress::objects::InequalityDefinition
| inline override virtual

Create a "greater than or equal" constraint with this expression as left-hand side.

Parameters

  rhs | Right-hand side of constraint.

Returns
  The constraint.

Since
  44.00

Since
  44.00

Reimplemented from xpress::objects::Expression.

## geq() [2/2]

auto xpress::objects::Variable::geq | ( | Expression const & | rhs | ) | const -> xpress::objects::InequalityDefinition
| inline override virtual

Create a "greater than or equal" constraint with this expression as left-hand side.

Parameters

  rhs | Right-hand side of constraint.

Returns
  The constraint.

Since
  44.00

Since
  44.00

Reimplemented from xpress::objects::Expression.

## getCallbackRedCost()

auto xpress::objects::Variable::getCallbackRedCost | ( |  | ) | -> double
| inline

Get reduced cost value for this variable from the solution associated with the current callback.

Note: This functions uses `xpress::XPRSProblem#getCallbackRedCosts(bool *, Array<double> const &, int, int) const` under the hood.

Note: Calling this function for multiple variables is not efficient. If you need to get values for multiple variables then consider using `xpress::objects::XpressProblem#getCallbackRedCosts() const` to get the values for all variables and then use `getValue(SizedArray<double const> const &) const` to extract the value for a particular variable.

Returns
  Reduced cost for this variable.

Since
  44.00

## getCallbackSolution()

auto xpress::objects::Variable::getCallbackSolution | ( |  | ) | -> double
| inline

Get value for this variable from the solution associated with the current callback.

Note: This functions uses `xpress::XPRSProblem#getCallbackSolution(bool *, Array<double> const &, int, int) const` under the hood.

Note: Calling this function for multiple variables is not efficient. If you need to get values for multiple variables then consider using `xpress::objects::XpressProblem#getCallbackSolution() const` to get the values for all variables and then use `getValue(SizedArray<double const> const &) const` to extract the value for a particular variable.

Examples using `getCallbackSolution`:

- ELSCut.cpp
- ELSManagedCuts.cpp
- FolioCB.cpp

Returns
  Solution value for this variable.

Since
  44.00

## getHashCode()

auto xpress::objects::Variable::getHashCode | ( |  | ) | const -> std::size_t
| inline final virtual

Since
  44.00

## getIndex()

auto xpress::objects::Variable::getIndex | ( |  | ) | const -> int
| inline final virtual

Since
  44.00

## getIndexForProb()

auto xpress::objects::Variable::getIndexForProb | ( | XpressProblem const * | xprob | ) | const -> int
| inline final virtual

Since
  44.00

## getLB()

auto xpress::objects::Variable::getLB | ( |  | ) | const -> double
| inline

Get the lower bound for this variable.

Queries the `xpress::objects::XpressProblem` instance to which this variable belongs and returns the lower bound obtained from that instance.

Since
  44.00

## getName()

auto xpress::objects::Variable::getName | ( |  | ) | const -> std::string
| inline final virtual

Examples using `getName`:

- BinBurglar.cpp
- BoolVars.cpp
- ContractAllocation.cpp
- CuttingStock.cpp
- FolioHeuristic.cpp
- FolioIIS.cpp
- FolioInit.cpp
- FolioMip1.cpp
- FolioMip2.cpp
- FolioMipIIS.cpp
- FolioQC.cpp
- FolioQP.cpp
- PolygonObjects.cpp
- QuadraticProgramming.cpp
- RecursiveFinancialPlanning.cpp

Since
  44.00

## getObj()

auto xpress::objects::Variable::getObj | ( |  | ) | const -> double
| inline

Get objective coefficient for this variable.

Returns
  Objective coefficient for this variable.

Since
  44.00

## getObjN()

auto xpress::objects::Variable::getObjN | ( | int | objIdx | ) | const -> double
| inline

Get objective coefficient for this variable.

Parameters

  objIdx | Index of objective function to query.

Returns
  Objective coefficient for this variable.

Since
  44.00

## getProblem()

auto xpress::objects::Variable::getProblem | ( |  | ) | const -> xpress::objects::XpressProblem *
| inline final virtual

Returns
  The problem to which this element belongs. This will be `nullptr` if the element was deleted.

Since
  44.00

## getRedCost()

auto xpress::objects::Variable::getRedCost | ( |  | ) | const -> double
| inline

Get the current reduced cost value for this variable.

Note: This functions uses `xpress::XPRSProblem#getRedCosts(int *, Array<double> const &, int, int) const` under the hood. This is only valid to call if the `xpress::objects::XpressProblem` instance owning this variable is currently not under optimization.

Note: Calling this function for multiple variables is not efficient. If you need to get values for multiple variables then consider using `xpress::objects::XpressProblem#getRedCosts() const` to get the values for all variables and then use `getValue(SizedArray<double const> const &) const` to extract the value for a particular variable. This strategy is also valid from callbacks.

Returns
  Reduced cost for this variable.

Since
  44.00

## getSolution()

auto xpress::objects::Variable::getSolution | ( |  | ) | const -> double
| inline

Get the current solution value for this variable.

Note: This functions uses `xpress::XPRSProblem#getSolution(int *, Array<double> const &, int, int) const` under the hood. This is only valid to call if the `XpressProblem` instance owning this variable is currently not under optimization.

Note: Calling this function for multiple variables is not efficient. If you need to get values for multiple variables then consider using `xpress::objects::XpressProblem#getSolution() const` to get the values for all variables and then use `getValue(SizedArray<double const> const &) const` to extract the value for a particular variable. This strategy is also valid from callbacks.

Examples using `getSolution`:

- BinBurglar.cpp
- BoolVars.cpp
- Boxes02.cpp
- Capbgt2l.cpp
- CapitalBudgeting.cpp
- Catenary.cpp
- ContractAllocation.cpp
- CuttingStock.cpp
- ELS.cpp
- ELSCut.cpp
- FacilityLocationArray.cpp
- FacilityLocationCollection.cpp
- Folio.cpp
- FolioCB.cpp
- FolioHeuristic.cpp
- FolioInit.cpp
- FolioMip1.cpp
- FolioMip2.cpp
- FolioQC.cpp
- FolioQP.cpp
- GeneralConstraints.cpp
- Glidert.cpp
- MultipleKnapsack_Arrays.cpp
- MultipleKnapsack_Collections.cpp
- PiecewiseLinear.cpp
- PolygonObjects.cpp
- Pplan.cpp
- Pplan2.cpp
- ProductionPlanning_Index.cpp
- PurchasePWL.cpp
- PurchaseSOS2.cpp
- QuadraticProgramming.cpp
- RecursiveFinancialPlanning.cpp
- Sangraalind.cpp
- SpecialOrderedSets.cpp
- SpecialOrderedSetsQuadratic.cpp
- TravelingSalesPerson.cpp
- Wagon.cpp
- tsp.cpp

Returns
  Solution value for this variable.

Since
  44.00

## getType()

auto xpress::objects::Variable::getType | ( |  | ) | const -> xpress::ColumnType
| inline

Get the type for this variable.

Queries the `XpressProblem` instance to which this variable belongs and returns the name obtained from that instance.

Returns
  Type of this variable.

Since
  44.00

## getUB()

auto xpress::objects::Variable::getUB | ( |  | ) | const -> double
| inline

Get the upper bound for this variable.

Queries the `XpressProblem` instance to which this variable belongs and returns the upper bound obtained from that instance.

Returns
  The upper bound for this variable.

Since
  44.00

## getValue()

auto xpress::objects::Variable::getValue | ( | xpress::SizedArray< double const > const & | data | ) | const -> double
| inline

Get the value of this variable from an array.

The function assumes that `data` is an array that stores a value for each variable in the underlying problem and returns the value from this array that corresponds to this variable. `data` arrays can be obtained for example from `prob.getSolution()` or `prob.getCallbackSolution()`.

Examples using `getValue`:

- BinBurglar.cpp
- BoolVars.cpp
- Boxes02.cpp
- Capbgt2l.cpp
- Catenary.cpp
- ContractAllocation.cpp
- CuttingStock.cpp
- ELS.cpp
- ELSCut.cpp
- ELSManagedCuts.cpp
- FacilityLocationArray.cpp
- FacilityLocationCollection.cpp
- Folio.cpp
- FolioCB.cpp
- FolioHeuristic.cpp
- FolioInit.cpp
- FolioMip1.cpp
- FolioMip2.cpp
- FolioQC.cpp
- FolioQP.cpp
- GeneralConstraints.cpp
- Glidert.cpp
- MultipleKnapsack_Arrays.cpp
- MultipleKnapsack_Collections.cpp
- PiecewiseLinear.cpp
- PolygonObjects.cpp
- Pplan.cpp
- Pplan2.cpp
- ProductionPlanning_Index.cpp
- PurchasePWL.cpp
- PurchaseSOS2.cpp
- QuadraticProgramming.cpp
- RecursiveFinancialPlanning.cpp
- Sangraalind.cpp
- SpecialOrderedSets.cpp
- SpecialOrderedSetsQuadratic.cpp
- TravelingSalesPerson.cpp
- Wagon.cpp

Parameters

  data | Data for all variables.

Returns
  The value for this variable in `data`.

Since
  44.00

## ifNotThen()

auto xpress::objects::Variable::ifNotThen | ( | InequalityDefinition | implied | ) | const -> xpress::objects::IndicatorDescription
| inline

Create an indicator constraint with this variable as indicator variable.

The constraint will enforce `implied` if this variable is set to 0.

Examples using `ifNotThen`:

- BinBurglar.cpp
- Capbgt2l.cpp
- MultipleKnapsack_Arrays.cpp
- MultipleKnapsack_Collections.cpp

Parameters

  implied | The constraint that should be enforced if this variable is 0.

Returns
  Definition for the constraint described by the arguments.

Since
  44.00

## ifThen()

auto xpress::objects::Variable::ifThen | ( | InequalityDefinition | implied | ) | const -> xpress::objects::IndicatorDescription
| inline

Create an indicator constraint with this variable as indicator variable.

The constraint will enforce `implied` if this variable is set to 1.

Examples using `ifThen`:

- BinBurglar.cpp
- Capbgt2l.cpp

Parameters

  implied | The constraint that should be enforced if this variable is 1.

Returns
  Definition for the constraint described by the arguments.

Since
  44.00

## in()

auto xpress::objects::Variable::in | ( | double | lb,
|  | double | ub ) -> xpress::objects::InequalityDefinition
| inline override virtual

Create a range constraint that bounds this expression from below and above.Examples using `in`:

- Folio.cpp
- FolioCB.cpp
- FolioMipIIS.cpp
- QuadraticProgramming.cpp

Parameters

  lb | Lower bound for this expression.
  ub | Upper bound for this expression.

Returns
  The constraint.

Since
  44.00

Examples using `in`:

- Folio.cpp
- FolioCB.cpp
- FolioMipIIS.cpp
- QuadraticProgramming.cpp

Since
  44.00

Reimplemented from xpress::objects::Expression.

## leq() [1/2]

auto xpress::objects::Variable::leq | ( | double | rhs | ) | const -> xpress::objects::InequalityDefinition
| inline override virtual

Create a "less than or equal" constraint with this expression as left-hand side.Examples using `leq`:

- TravelingSalesPerson.cpp

Parameters

  rhs | Right-hand side of constraint.

Returns
  The constraint.

Since
  44.00

Examples using `leq`:

- TravelingSalesPerson.cpp

Since
  44.00

Reimplemented from xpress::objects::Expression.

## leq() [2/2]

auto xpress::objects::Variable::leq | ( | Expression const & | rhs | ) | const -> xpress::objects::InequalityDefinition
| inline override virtual

Create a "less than or equal" constraint with this expression as left-hand side.Examples using `leq`:

- TravelingSalesPerson.cpp

Parameters

  rhs | Right-hand side of constraint.

Returns
  The constraint.

Since
  44.00

Examples using `leq`:

- TravelingSalesPerson.cpp

Since
  44.00

Reimplemented from xpress::objects::Expression.

## maxOf() [1/4]

template<typename Strm_variables , typename Strm_values , typename Strm_variablesIsStream , typename Strm_valuesIsStream >

auto xpress::objects::Variable::maxOf | ( | Strm_variables const & | variables,
|  | Strm_values const & | values ) const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the maximum of the specified arguments.

Examples using `maxOf`:

- GeneralConstraints.cpp

Parameters

  variables | Variables in the maximum constraint.
  values | Values in the maximum constraint.

Template Parameters

  Strm_variables | Something that supports `begin()` and `end()` and contains values of type `Variable`.
  Strm_values | Something that supports `begin()` and `end()` and contains values of type `double`.

Returns
  `this = max(variables, value)`.

Since
  44.00

## maxOf() [2/4]

template<typename Strm_variables , typename Strm_values , typename Strm_variablesIsStream , typename Strm_valuesIsStream >

auto xpress::objects::Variable::maxOf | ( | Strm_variables const & | variables,
|  | Strm_values const & | values,
|  | std::optional< std::string > | name ) const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the maximum of the specified arguments.

Examples using `maxOf`:

- GeneralConstraints.cpp

Parameters

  variables | Variables in the maximum constraint.
  values | Values in the maximum constraint.
  name | Constraint name, can be `std::nullopt` to indicate the constraint has no name.

Template Parameters

  Strm_variables | Something that supports `begin()` and `end()` and contains values of type `Variable`.
  Strm_values | Something that supports `begin()` and `end()` and contains values of type `double`.

Returns
  `this = max(variables, value)`.

Since
  44.00

## maxOf() [3/4]

template<typename... VARIABLES, typename RestrictPack >

auto xpress::objects::Variable::maxOf | ( | VARIABLES... | variables | ) | const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the maximum of the specified other variables.

Examples using `maxOf`:

- GeneralConstraints.cpp

Parameters

  variables | Variables in the maximum constraint.

Returns
  `this = max(variables)`.

Since
  44.00

## maxOf() [4/4]

template<typename... VALUES, typename RestrictPack >

auto xpress::objects::Variable::maxOf | ( | xpress::SizedArray< Variable const > const & | variables,
|  | VALUES... | values ) const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the maximum of the specified other variables and values.

Examples using `maxOf`:

- GeneralConstraints.cpp

Parameters

  variables | Variables in the maximum constraint.
  values | Values in the maximum constraint.

Returns
  `this = max(variables, value)`.

Since
  44.00

## minOf() [1/4]

template<typename Strm_variables , typename Strm_values , typename Strm_variablesIsStream , typename Strm_valuesIsStream >

auto xpress::objects::Variable::minOf | ( | Strm_variables const & | variables,
|  | Strm_values const & | values ) const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the minimum of the specified arguments.

Examples using `minOf`:

- GeneralConstraints.cpp

Parameters

  variables | Variables in the minimum constraint.
  values | Values in the minimum constraint.

Template Parameters

  Strm_variables | Something that supports `begin()` and `end()` and contains values of type `Variable`.
  Strm_values | Something that supports `begin()` and `end()` and contains values of type `double`.

Returns
  `this = min(variables, value)`.

Since
  44.00

## minOf() [2/4]

template<typename Strm_variables , typename Strm_values , typename Strm_variablesIsStream , typename Strm_valuesIsStream >

auto xpress::objects::Variable::minOf | ( | Strm_variables const & | variables,
|  | Strm_values const & | values,
|  | std::optional< std::string > | name ) const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the minimum of the specified arguments.

Examples using `minOf`:

- GeneralConstraints.cpp

Parameters

  variables | Variables in the minimum constraint.
  values | Values in the minimum constraint.
  name | Constraint name, can be `std::nullopt` to indicate the constraint has no name.

Template Parameters

  Strm_variables | Something that supports `begin()` and `end()` and contains values of type `Variable`.
  Strm_values | Something that supports `begin()` and `end()` and contains values of type `double`.

Returns
  `this = min(variables, value)`.

Since
  44.00

## minOf() [3/4]

template<typename... VARIABLES, typename RestrictPack >

auto xpress::objects::Variable::minOf | ( | VARIABLES... | variables | ) | const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the minimum of the specified other variables.

Examples using `minOf`:

- GeneralConstraints.cpp

Parameters

  variables | Variables in the minimum constraint.

Returns
  `this = min(variables)`.

Since
  44.00

## minOf() [4/4]

template<typename... VALUES, typename RestrictPack >

auto xpress::objects::Variable::minOf | ( | xpress::SizedArray< Variable const > const & | variables,
|  | VALUES... | values ) const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the minimum of the specified other variables and values.

Examples using `minOf`:

- GeneralConstraints.cpp

Parameters

  variables | Variables in the minimum constraint.
  values | Values in the minimum constraint.

Returns
  `this = min(variables, value)`.

Since
  44.00

## mul() [1/5]

auto xpress::objects::Variable::mul | ( | ConstantExpression | arg | ) | const -> xpress::objects::LinTerm
| inline

Create a expression that represents the product of `this` and `arg`.

Examples using `mul`:

- Capbgt2l.cpp

Parameters

  arg | Factor.

Returns
  The expression.

Since
  44.00

## mul() [2/5]

auto xpress::objects::Variable::mul | ( | double | arg | ) | const -> xpress::objects::Expression
| inline override virtual

Create a expression that represents the product of `this` and `arg`.Examples using `mul`:

- Capbgt2l.cpp

Parameters

  arg | Factor.

Returns
  Product of `this` and `arg`.

Since
  44.00

Examples using `mul`:

- Capbgt2l.cpp

Since
  44.00

Reimplemented from xpress::objects::Expression.

## mul() [3/5]

auto xpress::objects::Variable::mul | ( | Expression | arg | ) | const -> xpress::objects::Expression
| inline override virtual

Create a expression that represents the product of `this` and `arg`.Examples using `mul`:

- Capbgt2l.cpp

Parameters

  arg | Factor.

Returns
  Product of `this` and `arg`.

Since
  44.00

Examples using `mul`:

- Capbgt2l.cpp

Since
  44.00

Reimplemented from xpress::objects::Expression.

## mul() [4/5]

auto xpress::objects::Variable::mul | ( | LinTerm | arg | ) | const -> xpress::objects::QuadTerm
| inline

Create a expression that represents the product of `this` and `arg`.

Examples using `mul`:

- Capbgt2l.cpp

Parameters

  arg | Factor.

Returns
  The expression.

Since
  44.00

## mul() [5/5]

auto xpress::objects::Variable::mul | ( | Variable | arg | ) | const -> xpress::objects::QuadTerm
| inline

Create a expression that represents the product of `this` and `arg`.

Examples using `mul`:

- Capbgt2l.cpp

Parameters

  arg | Factor.

Returns
  The expression.

Since
  44.00

## orOf() [1/3]

template<typename Strm_variables , typename Strm_variablesIsStream >

auto xpress::objects::Variable::orOf | ( | Strm_variables const & | variables | ) | const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the or of the specified arguments.

Examples using `orOf`:

- BoolVars.cpp

Parameters

  variables | Variables in the or constraint.

Template Parameters

  Strm_variables | Something that supports `begin()` and `end()` and contains values of type `Variable`.

Returns
  `this = or(variables, value)`.

Since
  44.00

## orOf() [2/3]

template<typename Strm_variables , typename Strm_variablesIsStream >

auto xpress::objects::Variable::orOf | ( | Strm_variables const & | variables,
|  | std::optional< std::string > | name ) const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the or of the specified arguments.

Examples using `orOf`:

- BoolVars.cpp

Parameters

  variables | Variables in the or constraint.
  name | Constraint name, can be `std::nullopt` to indicate the constraint has no name.

Template Parameters

  Strm_variables | Something that supports `begin()` and `end()` and contains values of type `Variable`.

Returns
  `this = or(variables, value)`.

Since
  44.00

## orOf() [3/3]

template<typename... VARIABLES, typename RestrictPack >

auto xpress::objects::Variable::orOf | ( | VARIABLES... | variables | ) | const -> xpress::objects::GeneralConstraintDefinition
| inline

Create a constraint that requires this variable to be the or of the specified other variables.

Examples using `orOf`:

- BoolVars.cpp

Parameters

  variables | Variables in the or constraint.

Returns
  `this = or(variables)`.

Since
  44.00

## pwlOf() [1/5]

template<typename... BREAKPOINTS, typename RestrictPack >

auto xpress::objects::Variable::pwlOf | ( | Variable | input,
|  | BREAKPOINTS... | breakpoints ) const -> xpress::objects::PWLDefinition
| inline

Create a piecewise linear constraint that requires this variable to be the value of the piecewise linear function specified by `breakpoints` evaluated for `input`.

Examples using `pwlOf`:

- MultipleKnapsack_Arrays.cpp
- MultipleKnapsack_Collections.cpp
- PiecewiseLinear.cpp
- PurchasePWL.cpp

Parameters

  input | Input for piecewise linear constraint.
  breakpoints | Breakpoints for constraint.

Returns
  Definition for the constraint described by the arguments.

Since
  44.00

## pwlOf() [2/5]

template<typename Strm_breakpoints , typename Strm_breakpointsIsStream >

auto xpress::objects::Variable::pwlOf | ( | Variable | input,
|  | Strm_breakpoints const & | breakpoints ) const -> xpress::objects::PWLDefinition
| inline

Create a piecewise linear constraint that requires this variable to be the value of the piecewise linear function specified by `breakpoints` evaluated for `input`.

Examples using `pwlOf`:

- MultipleKnapsack_Arrays.cpp
- MultipleKnapsack_Collections.cpp
- PiecewiseLinear.cpp
- PurchasePWL.cpp

Parameters

  input | Input for piecewise linear constraint.
  breakpoints | Breakpoints for constraint.

Template Parameters

  Strm_breakpoints | Something that supports `begin()` and `end()` and contains values of type `xpress::PwlBreakpoint`.

Returns
  Definition for the constraint described by the arguments.

Since
  44.00

## pwlOf() [3/5]

template<typename Strm_breakpoints , typename Strm_breakpointsIsStream >

auto xpress::objects::Variable::pwlOf | ( | Variable | input,
|  | Strm_breakpoints const & | breakpoints,
|  | std::optional< std::string > | name ) const -> xpress::objects::PWLDefinition
| inline

Create a piecewise linear constraint that requires this variable to be the value of the piecewise linear function specified by `breakpoints` evaluated for `input`.

Examples using `pwlOf`:

- MultipleKnapsack_Arrays.cpp
- MultipleKnapsack_Collections.cpp
- PiecewiseLinear.cpp
- PurchasePWL.cpp

Parameters

  input | Input for piecewise linear constraint.
  breakpoints | Breakpoints for constraint.
  name | Name for constraint, can be `std::nullopt`.

Template Parameters

  Strm_breakpoints | Something that supports `begin()` and `end()` and contains values of type `xpress::PwlBreakpoint`.

Returns
  Definition for the constraint described by the arguments.

Since
  44.00

## pwlOf() [4/5]

auto xpress::objects::Variable::pwlOf | ( | Variable | input,
|  | xpress::SizedArray< double const > const & | xval,
|  | xpress::SizedArray< double const > const & | yval ) const -> xpress::objects::PWLDefinition
| inline

Create a piecewise linear constraint that requires this variable to be the value of the piecewise linear function specified by `xval`/`yval` evaluated for `input`.

Examples using `pwlOf`:

- MultipleKnapsack_Arrays.cpp
- MultipleKnapsack_Collections.cpp
- PiecewiseLinear.cpp
- PurchasePWL.cpp

Parameters

  input | Input for piecewise linear constraint.
  xval | X coordinates of breakpoints.
  yval | X coordinates of breakpoints.

Returns
  Definition for the constraint described by the arguments.

Since
  44.00

## pwlOf() [5/5]

auto xpress::objects::Variable::pwlOf | ( | Variable | input,
|  | xpress::SizedArray< double const > const & | xval,
|  | xpress::SizedArray< double const > const & | yval,
|  | std::optional< std::string > | name ) const -> xpress::objects::PWLDefinition
| inline

Create a piecewise linear constraint that requires this variable to be the value of the piecewise linear function specified by `xval`/`yval` evaluated for `input`.

Examples using `pwlOf`:

- MultipleKnapsack_Arrays.cpp
- MultipleKnapsack_Collections.cpp
- PiecewiseLinear.cpp
- PurchasePWL.cpp

Parameters

  input | Input for piecewise linear constraint.
  xval | X coordinates of breakpoints.
  yval | X coordinates of breakpoints.
  name | Name of the constraint, can be `std::nullopt`.

Returns
  Definition for the constraint described by the arguments.

Since
  44.00

## setLB()

auto xpress::objects::Variable::setLB | ( | double | newLB | ) | -> Variable&
| inline

Set the lower bound for this variable.

Set the lower bound in the `XpressProblem` instance to which this variable belongs.

Examples using `setLB`:

- FolioHeuristic.cpp
- PiecewiseLinear.cpp
- SpecialOrderedSets.cpp
- SpecialOrderedSetsQuadratic.cpp

Parameters

  newLB | New lower bound.

Returns
  This variable

Since
  44.00

## setLimit()

auto xpress::objects::Variable::setLimit | ( | double | newLimit | ) | -> Variable&
| inline

Set the limit for this variable.

Set the limit in the `XpressProblem` instance to which this variable belongs. Note that limits are ignored unless the variable is semi-continuous, semi-integer, or partial integer.

Parameters

  newLimit | New limit.

Returns
  This variable

Since
  44.00

## setName()

auto xpress::objects::Variable::setName | ( | std::optional< std::string > | newName | ) | -> Variable&
| inline

Set the name of this variable.

Sets the name of this variable in the problem instance that owns the object.

Examples using `setName`:

- Catenary.cpp
- ContractAllocation.cpp
- CuttingStock.cpp
- FolioIIS.cpp
- FolioInit.cpp
- FolioMip1.cpp
- FolioMipIIS.cpp
- FolioQC.cpp
- GeneralConstraints.cpp
- ProductionPlanning_Index.cpp
- RecursiveFinancialPlanning.cpp

Parameters

  newName | The name to be set.

Returns
  Always returns this instance.

Since
  44.00

## setType()

auto xpress::objects::Variable::setType | ( | xpress::ColumnType | newType | ) | -> Variable&
| inline

Set the type for this variable.

Set the type in the `XpressProblem` instance to which this variable belongs.

Parameters

  newType | New type.

Returns
  This variable

Since
  44.00

## setUB()

auto xpress::objects::Variable::setUB | ( | double | newUB | ) | -> Variable&
| inline

Set the upper bound for this variable.

Set the upper bound in the `XpressProblem` instance to which this variable belongs.

Examples using `setUB`:

- FolioHeuristic.cpp
- SpecialOrderedSets.cpp
- SpecialOrderedSetsQuadratic.cpp

Parameters

  newUB | New upper bound.

Returns
  This variable

Since
  44.00

## square()

auto xpress::objects::Variable::square | ( |  | ) | -> xpress::objects::QuadTerm
| inline

Create a quadratic term by multiplying this variable with itself.

Examples using `square`:

- PolygonObjects.cpp
- QuadraticProgramming.cpp

Returns
  The term representing the product of this variable with itself.

Since
  44.00

## toString()

auto xpress::objects::Variable::toString | ( |  | ) | const -> std::string
| inline override virtual

Returns the name from `getName()`.

Examples using `toString`:

- Boxes02.cpp
- Capbgt2l.cpp

Returns
  This variable's name.

Since
  44.00

Reimplemented from xpress::objects::Expression.

## uminus()

auto xpress::objects::Variable::uminus | ( |  | ) | const -> xpress::objects::Expression
| inline override virtual

Create a expression that represents the unary minus of this one.

Returns
  Expression representing `-this`.

Since
  44.00

Since
  44.00

Reimplemented from xpress::objects::Expression.

The documentation for this class was generated from the following file:

- xpress_objects.hpp

Parent Topic objects

© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.