Class Variable
- All Implemented Interfaces:
Comparable<Variable>, Optimisation, Optimisation.Constraint, Optimisation.Objective
Variable represents a decision variable in an optimization model.
Each variable has a unique index in the model and can have:
- Lower and upper bounds (constraints)
- A contribution weight in the objective function
- An integer or continuous domain
- A current value
Variables can be configured as:
- Binary (0-1 integer variables)
- Integer (whole number values only)
- Continuous (any value within bounds)
- Fixed (equal lower and upper bounds)
- Unbounded (no effective limits)
As a subclass of ModelEntity, a Variable can function both as a constraint (through lower/upper bounds) and as an objective function component (through its contribution weight).
Variables are typically created and managed through ExpressionsBasedModel, which assigns their
indices and incorporates them into the optimization problem.
-
Nested Class Summary
Nested classes/interfaces inherited from interface Optimisation
Optimisation.Constraint, Optimisation.ConstraintType, Optimisation.Integration<M,S>, Optimisation.Model, Optimisation.Objective, Optimisation.Options, Optimisation.ProblemStructure, Optimisation.Result, Optimisation.Sense, Optimisation.Solver, Optimisation.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Structure1D.IntIndexprivate booleanprivate booleanprivate BigDecimalFields inherited from class ModelEntity
PRINT, RANGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTo(Expression target, BigDecimal scale) protected voidappendMiddlePart(StringBuilder builder, NumberContext display) private voidbinary()SeeisBinary().int(package private) Variablecopy()Internal copy that includes the index(package private) intprotected voiddestroy()(package private) voidIf necessary this method should first determine if thisModelEntityis "integer" or not.boolean(package private) Structure1D.IntIndexgetIndex()getValue()inthashCode()integer()integer(boolean integer) SeeisInteger().booleanisBinary()Variable can only be 0 or 1.(package private) booleanisFixed()booleanIs this entity (all involved variables) integer?booleanThe range includes something invalid input: '<' 0.0booleanThe range includes something > 0.0(package private) booleanbooleanlower(Comparable<?> lower) Extremely large (absolute value) values are treated as "no limit" (null) and extremely small values are treated as exactly 0.0, unless the input number type isBigDecimal.relax()(package private) voidsetFixed(BigDecimal value) voidsetInteger(boolean integer) (package private) voidsetUnbounded(boolean uncorrelated) voidsetValue(Comparable<?> value) upper(Comparable<?> upper) Extremely large (absolute value) values are treated as "no limit" (null) and extremely small values are treated as exactly 0.0, unless the input number type isBigDecimal.protected booleanvalidate(BigDecimal value, NumberContext context, BasicLogger appender) (package private) booleanvalidate(BigDecimal value, NumberContext context, BasicLogger appender, boolean relaxed) value(BigDecimal value) Methods inherited from class ModelEntity
adjust, appendLeftPart, appendRightPart, appendToString, deriveAdjustmentExponent, getAdjustmentExponent, getAdjustmentExponentValue, getAdjustmentFactor, getCompensatedLowerLimit, getCompensatedLowerLimit, getCompensatedUpperLimit, getCompensatedUpperLimit, getContributionWeight, getLowerLimit, getLowerLimit, getLowerLimit, getName, getUpperLimit, getUpperLimit, getUpperLimit, isClosedRange, isConstraint, isContributionWeightSet, isEqualityConstraint, isInfeasible, isInfeasible, isLowerConstraint, isLowerLimitSet, isObjective, isUpperConstraint, isUpperLimitSet, level, level, level, lower, lower, reverseAdjustment, shift, toAdjusted, toBigDecimal, toString, toUnadjusted, upper, upper, validate, weight, weight, weight
-
Field Details
-
myIndex
-
myInteger
private boolean myInteger -
myUnbounded
private transient boolean myUnbounded -
myValue
-
-
Constructor Details
-
Method Details
-
addTo
Description copied from class:ModelEntity- Specified by:
addToin classModelEntity<Variable>- Parameters:
target- The targetExpressionscale- The scaling factor
-
binary
-
compareTo
-
equals
- Overrides:
equalsin classModelEntity<Variable>
-
getLowerSlack
-
getUpperSlack
-
getValue
-
hashCode
public int hashCode()- Overrides:
hashCodein classModelEntity<Variable>
-
integer
-
integer
SeeisInteger(). -
isBinary
public boolean isBinary()Variable can only be 0 or 1. -
isInteger
public boolean isInteger()Description copied from class:ModelEntityIs this entity (all involved variables) integer?- Specified by:
isIntegerin classModelEntity<Variable>- Returns:
- true if this is an integer variable, otherwise false
-
isNegative
public boolean isNegative()The range includes something invalid input: '<' 0.0 -
isPositive
public boolean isPositive()The range includes something > 0.0 -
isValueSet
public boolean isValueSet() -
lower
Description copied from class:ModelEntityExtremely large (absolute value) values are treated as "no limit" (null) and extremely small values are treated as exactly 0.0, unless the input number type isBigDecimal.BigDecimalvalues are always used as they are.- Overrides:
lowerin classModelEntity<Variable>
-
quantifyContribution
-
relax
-
setInteger
public void setInteger(boolean integer) -
setValue
-
upper
Description copied from class:ModelEntityExtremely large (absolute value) values are treated as "no limit" (null) and extremely small values are treated as exactly 0.0, unless the input number type isBigDecimal.BigDecimalvalues are always used as they are.- Overrides:
upperin classModelEntity<Variable>
-
value
-
assertFixedValue
private void assertFixedValue() -
appendMiddlePart
- Overrides:
appendMiddlePartin classModelEntity<Variable>
-
destroy
protected void destroy()- Overrides:
destroyin classModelEntity<Variable>
-
validate
- Overrides:
validatein classModelEntity<Variable>
-
copy
Variable copy()Internal copy that includes the index -
deriveAdjustmentExponent
int deriveAdjustmentExponent()- Specified by:
deriveAdjustmentExponentin classModelEntity<Variable>
-
doIntegerRounding
void doIntegerRounding()Description copied from class:ModelEntityIf necessary this method should first determine if thisModelEntityis "integer" or not.If it is, then verify if all variable factors are integers or if there exists a simple scalar that will make it so. If so, the lower/upper limits are "integer rounded".
- Specified by:
doIntegerRoundingin classModelEntity<Variable>
-
getIndex
Structure1D.IntIndex getIndex() -
isFixed
boolean isFixed() -
isUnbounded
boolean isUnbounded() -
setFixed
-
setUnbounded
void setUnbounded(boolean uncorrelated) -
validate
-