Class ModelEntity<ME extends ModelEntity<ME>>
java.lang.Object
org.ojalgo.optimisation.ModelEntity<ME>
- Type Parameters:
ME- The concrete subclass type, enabling a fluent API
- All Implemented Interfaces:
Comparable<ME>, Optimisation, Optimisation.Constraint, Optimisation.Objective
- Direct Known Subclasses:
Expression, Variable
public abstract class ModelEntity<ME extends ModelEntity<ME>>
extends Object
implements Optimisation.Constraint, Optimisation.Objective, Comparable<ME>
Abstract base for
Variable and Expression. A ModelEntity can act as a constraint (via
lower/upper limits) and/or contribute to the objective function (via a contribution weight).- Author:
- apete
-
Nested Class Summary
Nested classes/interfaces inherited from interface Optimisation
Optimisation.Constraint, Optimisation.ConstraintType, Optimisation.Environment, Optimisation.Integration<M,S>, Optimisation.Model, Optimisation.Objective, Optimisation.Options, Optimisation.ProblemStructure, Optimisation.Result, Optimisation.Sense, Optimisation.Solver, Optimisation.State -
Field Summary
Fields inherited from interface Optimisation
ENVIRONMENT -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedModelEntity(String name) protectedModelEntity(ME entityToCopy) -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddTo(Expression target, BigDecimal scale) final BigDecimaladjust(BigDecimal factor) protected voidappendLeftPart(StringBuilder builder, NumberContext display) protected voidappendMiddlePart(StringBuilder builder, NumberContext display) protected voidappendRightPart(StringBuilder builder, NumberContext display) protected voiddestroy()booleanprotected final intfinal doublefinal BigDecimalThe weight/factor by which this model entity's value contributes to the objective function - may return null.final BigDecimalThe lower limit/bound - may return null.final doublegetLowerLimit(boolean adjusted, double defaultValue) final BigDecimalgetLowerLimit(boolean adjusted, BigDecimal defaultValue) final StringgetName()final BigDecimalThe upper limit/bound - may return null.final doublegetUpperLimit(boolean adjusted, double defaultValue) final BigDecimalgetUpperLimit(boolean adjusted, BigDecimal defaultValue) inthashCode()final booleanThe Constraint has a lower or an upper limit actually set (possibly both) - it actually is constrained.final booleanfinal booleanThe Constraint has both a lower limit and an upper limit, and they are equal.abstract booleanIs this entity (all involved variables) integer?final booleanThe Constraint has a lower limit, and the upper limit (if it exists) is different.final booleanfinal booleanfinal booleanThe Constraint has an upper limit, and the lower limit (if it exists) is different.final booleanfinal MElevel(double level) final MElevel(long level) final MElevel(Comparable<?> level) Set both the lower and upper limits to the same value, creating an equality constraint.final MElower(double lower) final MElower(long lower) lower(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.final BigDecimalreverseAdjustment(BigDecimal adjusted) Reverses the scaling applied bytoAdjusted(BigDecimal), without enforcing limits or context.voidshift(BigDecimal shift) Adds the given shift to the lower and/or upper limits, if they are set.final doubletoAdjusted(BigDecimal unadjusted) Converts aBigDecimalmodel parameter to a corresponding double solver parameter, scaling it in the process.final StringtoString()final BigDecimaltoUnadjusted(double adjusted, NumberContext context) The inverse oftoAdjusted(BigDecimal).final MEupper(double upper) final MEupper(long upper) 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) protected final booleanvalidate(BasicLogger appender) Validate model parameters, like lower and upper limits.final MEweight(double weight) final MEweight(long weight) final MEweight(Comparable<?> weight) Set the contribution weight for the objective function.Methods inherited from interface Comparable
compareTo
-
Constructor Details
-
ModelEntity
-
ModelEntity
-
-
Method Details
-
addTo
- Parameters:
target- The targetExpressionscale- The scaling factor
-
adjust
-
equals
-
getAdjustmentFactor
public final double getAdjustmentFactor()- Returns:
- The scaling factor (10^exponent) used to adjust model parameters for numerical stability
-
getConstraintType
- Specified by:
getConstraintTypein interfaceOptimisation.Constraint
-
getContributionWeight
Description copied from interface:Optimisation.ObjectiveThe weight/factor by which this model entity's value contributes to the objective function - may return null.- Specified by:
getContributionWeightin interfaceOptimisation.Objective
-
getLowerLimit
Description copied from interface:Optimisation.ConstraintThe lower limit/bound - may return null.- Specified by:
getLowerLimitin interfaceOptimisation.Constraint
-
getLowerLimit
-
getLowerLimit
public final double getLowerLimit(boolean adjusted, double defaultValue) -
getName
-
getUpperLimit
Description copied from interface:Optimisation.ConstraintThe upper limit/bound - may return null.- Specified by:
getUpperLimitin interfaceOptimisation.Constraint
-
getUpperLimit
-
getUpperLimit
public final double getUpperLimit(boolean adjusted, double defaultValue) -
hashCode
-
isConstraint
public final boolean isConstraint()Description copied from interface:Optimisation.ConstraintThe Constraint has a lower or an upper limit actually set (possibly both) - it actually is constrained.- Specified by:
isConstraintin interfaceOptimisation.Constraint
-
isContributionWeightSet
public final boolean isContributionWeightSet() -
isEqualityConstraint
public final boolean isEqualityConstraint()Description copied from interface:Optimisation.ConstraintThe Constraint has both a lower limit and an upper limit, and they are equal.- Specified by:
isEqualityConstraintin interfaceOptimisation.Constraint
-
isInteger
public abstract boolean isInteger()Is this entity (all involved variables) integer? -
isLowerConstraint
public final boolean isLowerConstraint()Description copied from interface:Optimisation.ConstraintThe Constraint has a lower limit, and the upper limit (if it exists) is different.- Specified by:
isLowerConstraintin interfaceOptimisation.Constraint
-
isLowerLimitSet
public final boolean isLowerLimitSet() -
isObjective
public final boolean isObjective()- Specified by:
isObjectivein interfaceOptimisation.Objective- Returns:
- true if this Objective has a non zero contribution weight - it actually is contributing to the objective function.
-
isUpperConstraint
public final boolean isUpperConstraint()Description copied from interface:Optimisation.ConstraintThe Constraint has an upper limit, and the lower limit (if it exists) is different.- Specified by:
isUpperConstraintin interfaceOptimisation.Constraint
-
isUpperLimitSet
public final boolean isUpperLimitSet() -
level
Set both the lower and upper limits to the same value, creating an equality constraint. -
level
-
level
-
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.BigDecimalvalues are always used as they are. -
lower
-
lower
-
reverseAdjustment
Reverses the scaling applied bytoAdjusted(BigDecimal), without enforcing limits or context. -
shift
Adds the given shift to the lower and/or upper limits, if they are set. -
toAdjusted
Converts aBigDecimalmodel parameter to a corresponding double solver parameter, scaling it in the process. This operation is reversed bytoUnadjusted(double, NumberContext)and/orreverseAdjustment(BigDecimal). -
toString
-
toUnadjusted
The inverse oftoAdjusted(BigDecimal). Also enforces the lower/upper limits and theNumberContext. To reverse only the scaling, callreverseAdjustment(BigDecimal). -
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.BigDecimalvalues are always used as they are. -
upper
-
upper
-
weight
Set the contribution weight for the objective function. A zero weight is treated as "no weight" (null). -
weight
-
weight
-
appendLeftPart
-
appendMiddlePart
-
appendRightPart
-
destroy
protected void destroy() -
getAdjustmentExponent
protected final int getAdjustmentExponent() -
validate
Validate model parameters, like lower and upper limits. Does not validate the solution/value. -
validate
-