Package org.ojalgo.optimisation
Class ModelEntity<ME extends ModelEntity<ME>>
java.lang.Object
org.ojalgo.optimisation.ModelEntity<ME>
- 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>
Model entities are identified and compared by their names only. Any/all other members/attributes are NOT
part of equals(), hashCode() or compareTo().
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ojalgo.optimisation.Optimisation
Optimisation.Constraint, Optimisation.ConstraintType, Optimisation.Integration<M extends Optimisation.Model,
S extends Optimisation.Solver>, Optimisation.Model, Optimisation.Objective, Optimisation.Options, Optimisation.ProblemStructure, Optimisation.Result, Optimisation.Sense, Optimisation.Solver, Optimisation.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final BigDecimal
private int
private BigDecimal
private BigDecimal
private final String
private BigDecimal
(package private) static final NumberContext
(package private) static final int
private static final BigDecimal
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
protected
ModelEntity
(String name) protected
ModelEntity
(ME entityToCopy) -
Method Summary
Modifier and TypeMethodDescriptionabstract void
addTo
(Expression target, BigDecimal scale) final BigDecimal
adjust
(BigDecimal factor) protected void
appendLeftPart
(StringBuilder builder, NumberContext display) protected void
appendMiddlePart
(StringBuilder builder, NumberContext display) protected void
appendRightPart
(StringBuilder builder, NumberContext display) (package private) final void
appendToString
(StringBuilder builder, NumberContext display) (package private) abstract int
(package private) static int
deriveAdjustmentExponent
(AggregatorFunction<BigDecimal> largest, AggregatorFunction<BigDecimal> smallest, int range) protected void
destroy()
(package private) abstract void
If necessary this method should first determine if thisModelEntity
is "integer" or not.final boolean
protected final int
(package private) final int
final double
(package private) final BigDecimal
getCompensatedLowerLimit
(BigDecimal compensation) (package private) final BigDecimal
getCompensatedLowerLimit
(BigDecimal compensation, NumberContext precision) (package private) final BigDecimal
getCompensatedUpperLimit
(BigDecimal compensation) (package private) final BigDecimal
getCompensatedUpperLimit
(BigDecimal compensation, NumberContext precision) final BigDecimal
The weight/factor by which this model entity's value contributes to the objective function - may return null.private BigDecimal
getLower
(boolean adjusted) final BigDecimal
The lower limit/bound - may return null.final double
getLowerLimit
(boolean adjusted, double defaultValue) final BigDecimal
getLowerLimit
(boolean adjusted, BigDecimal defaultValue) final String
getName()
private BigDecimal
getUpper
(boolean adjusted) final BigDecimal
The upper limit/bound - may return null.final double
getUpperLimit
(boolean adjusted, double defaultValue) final BigDecimal
getUpperLimit
(boolean adjusted, BigDecimal defaultValue) final int
hashCode()
(package private) boolean
isClosedRange
(BigDecimal lower, BigDecimal upper) final boolean
The Constraint has a lower or an upper limit actually set (possibly both) - it actually is constrained.final boolean
final boolean
The Constraint has both a lower limit and an upper limit, and they are equal.(package private) boolean
(package private) static boolean
isInfeasible
(BigDecimal lower, BigDecimal upper) abstract boolean
Is this entity (all involved variables) integer?final boolean
The Constraint has a lower limit, and the upper limit (if it exists) is different.final boolean
final boolean
final boolean
The Constraint has an upper limit, and the lower limit (if it exists) is different.final boolean
final ME
level
(double level) final ME
level
(long level) final ME
level
(Comparable<?> level) final ME
lower
(double lower) final ME
lower
(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 BigDecimal
reverseAdjustment
(BigDecimal adjusted) Purely the reverse scaling part oftoUnadjusted(double, NumberContext)
void
shift
(BigDecimal shift) Add this shift to the lower/upper limits, if they exist.final double
toAdjusted
(BigDecimal unadjusted) Will convert aBigDecimal
model parameter to a corresponinginvalid reference
double
(package private) static BigDecimal
toBigDecimal
(Comparable<?> number) final String
toString()
final BigDecimal
toUnadjusted
(double adjusted, NumberContext context) The inverse oftoAdjusted(BigDecimal)
.final ME
upper
(double upper) final ME
upper
(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 boolean
validate
(BigDecimal value, NumberContext context, BasicLogger appender) protected final boolean
validate
(BasicLogger appender) Validate model parameters, like lower and upper limits.final ME
weight
(double weight) final ME
weight
(long weight) final ME
weight
(Comparable<?> weight) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
-
Field Details
-
LARGEST
-
SMALLEST
-
PRINT
-
RANGE
static final int RANGE- See Also:
-
myAdjustmentExponent
private transient int myAdjustmentExponent -
myContributionWeight
-
myLowerLimit
-
myName
-
myUpperLimit
-
-
Constructor Details
-
ModelEntity
private ModelEntity() -
ModelEntity
-
ModelEntity
-
-
Method Details
-
deriveAdjustmentExponent
static int deriveAdjustmentExponent(AggregatorFunction<BigDecimal> largest, AggregatorFunction<BigDecimal> smallest, int range) -
isInfeasible
-
toBigDecimal
-
addTo
- Parameters:
target
- The targetExpression
scale
- The scaling factor
-
adjust
-
equals
-
getAdjustmentFactor
public final double getAdjustmentFactor()- Returns:
- Adjusted "1"
-
getContributionWeight
Description copied from interface:Optimisation.Objective
The weight/factor by which this model entity's value contributes to the objective function - may return null.- Specified by:
getContributionWeight
in interfaceOptimisation.Objective
-
getLowerLimit
Description copied from interface:Optimisation.Constraint
The lower limit/bound - may return null.- Specified by:
getLowerLimit
in interfaceOptimisation.Constraint
-
getLowerLimit
-
getLowerLimit
public final double getLowerLimit(boolean adjusted, double defaultValue) -
getName
-
getUpperLimit
Description copied from interface:Optimisation.Constraint
The upper limit/bound - may return null.- Specified by:
getUpperLimit
in interfaceOptimisation.Constraint
-
getUpperLimit
-
getUpperLimit
public final double getUpperLimit(boolean adjusted, double defaultValue) -
hashCode
public final int hashCode() -
isConstraint
public final boolean isConstraint()Description copied from interface:Optimisation.Constraint
The Constraint has a lower or an upper limit actually set (possibly both) - it actually is constrained.- Specified by:
isConstraint
in interfaceOptimisation.Constraint
-
isContributionWeightSet
public final boolean isContributionWeightSet() -
isEqualityConstraint
public final boolean isEqualityConstraint()Description copied from interface:Optimisation.Constraint
The Constraint has both a lower limit and an upper limit, and they are equal.- Specified by:
isEqualityConstraint
in interfaceOptimisation.Constraint
-
isInteger
public abstract boolean isInteger()Is this entity (all involved variables) integer? -
isLowerConstraint
public final boolean isLowerConstraint()Description copied from interface:Optimisation.Constraint
The Constraint has a lower limit, and the upper limit (if it exists) is different.- Specified by:
isLowerConstraint
in interfaceOptimisation.Constraint
-
isLowerLimitSet
public final boolean isLowerLimitSet() -
isObjective
public final boolean isObjective()- Specified by:
isObjective
in 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.Constraint
The Constraint has an upper limit, and the lower limit (if it exists) is different.- Specified by:
isUpperConstraint
in interfaceOptimisation.Constraint
-
isUpperLimitSet
public final boolean isUpperLimitSet() -
level
- See Also:
-
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
.BigDecimal
values are always used as they are. -
lower
-
lower
-
reverseAdjustment
Purely the reverse scaling part oftoUnadjusted(double, NumberContext)
-
shift
Add this shift to the lower/upper limits, if they exist. -
toAdjusted
Will convert aBigDecimal
model parameter to a corresponinginvalid reference
double
toUnadjusted(double, NumberContext)
and/orreverseAdjustment(BigDecimal)
. -
toString
-
toUnadjusted
The inverse oftoAdjusted(BigDecimal)
. This will also enforce the lower and upper limits as well as theNumberContext
. To "only" do the reverse adjustment 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
.BigDecimal
values are always used as they are. -
upper
-
upper
-
weight
- See Also:
-
weight
-
weight
-
getLower
-
getUpper
-
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
-
appendToString
-
deriveAdjustmentExponent
abstract int deriveAdjustmentExponent() -
doIntegerRounding
abstract void doIntegerRounding()If necessary this method should first determine if thisModelEntity
is "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".
-
getAdjustmentExponentValue
final int getAdjustmentExponentValue() -
getCompensatedLowerLimit
-
getCompensatedLowerLimit
-
getCompensatedUpperLimit
-
getCompensatedUpperLimit
-
isClosedRange
- Returns:
- true if both the lower and upper limits are defined, and the range is defined by lower and upper.
-
isInfeasible
boolean isInfeasible()
-