Class COptQuestMixtureVariable
sumTo. Use a mixture variable when the decision is a set of
proportions, such as portfolio weights, blend fractions or allocation ratios.
In every solution that the engine generates, the weights sum to sumTo within 1e-12,
and each weight is within the bounds of its component.
Variable names: <name>@<component> for each component, in the order of
components. The value of each name is the weight of that component. The constructors that
take k name the components 1 to k.
With a negative lower bound, a weight can be below zero, down to that bound.
In most programs, you add this variable with
OptQuestModel.AddMixtureVariable
and read its values with OptQuestSolution.GetValue(String) and the generated names.
Construct this class only when you add the variable with
COptQuestOptimization.AddVariable(COptQuestVariable).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCOptQuestMixtureVariable(String name, int k) Creates a mixture variable withkcomponents named 1 to k.COptQuestMixtureVariable(String name, int k, double[] lowerBounds, double[] upperBounds, double sumTo) Creates a mixture variable withkcomponents named 1 to k, optional bounds for each component, and the sum of the weights.COptQuestMixtureVariable(String name, String[] components) Creates a mixture variable with the given component names.COptQuestMixtureVariable(String name, String[] components, double[] lowerBounds, double[] upperBounds, double sumTo) Creates a mixture variable with the given component names, optional bounds for each component, and the sum of the weights. -
Method Summary
Modifier and TypeMethodDescriptionReturns an empty list, because a mixture variable has no ordinary input variables.Returns an empty list, because a mixture variable has no output variables.Returns the decision values of this manifold variable that are not ordinary decision variables.Methods inherited from class com.opttek.optquest.COptQuestManifoldVariable
getConstraintsMethods inherited from class com.opttek.optquest.COptQuestUserControlledVariable
GetReplicationStatistic, GetReplicationStatisticValue, SetExclusiveRange, SetLowerBound, SetReplicationStatistic, SetUpperBoundMethods inherited from class com.opttek.optquest.COptQuestVariable
equals, GetDOELowerBound, GetDOEUpperBound, GetExclusiveLowerBoundAt, GetExclusiveUpperBoundAt, getID, GetLowerBound, GetName, GetNumberOfExclusiveRanges, GetStepSize, GetSuggestedValue, GetUpperBound, getVarRange, hashCode, isZeroOne, SetName
-
Constructor Details
-
COptQuestMixtureVariable
Creates a mixture variable withkcomponents named 1 to k. The weights sum to 1.0, every lower bound is 0, and there are no upper bounds.- Parameters:
name- base name of the variablek- number of components; must be at least 1- Throws:
COptQuestException- ifkis less than 1
-
COptQuestMixtureVariable
Creates a mixture variable with the given component names. The weights sum to 1.0, every lower bound is 0, and there are no upper bounds.- Parameters:
name- base name of the variablecomponents- names of the components; each must be unique and must not contain whitespace, a semicolon, a comma or@- Throws:
COptQuestException- ifcomponentsis null or empty, or holds a name that is not valid
-
COptQuestMixtureVariable
public COptQuestMixtureVariable(String name, int k, double[] lowerBounds, double[] upperBounds, double sumTo) throws COptQuestException Creates a mixture variable withkcomponents named 1 to k, optional bounds for each component, and the sum of the weights.- Parameters:
name- base name of the variablek- number of components; must be at least 1lowerBounds- lower bound of each component, or null for a lower bound of 0 on every componentupperBounds- upper bound of each component, or null for no upper boundssumTo- sum of the weights; must be greater than 0- Throws:
COptQuestException- ifkis less than 1, ifsumTois not greater than 0, if a bound array does not havekentries, if a lower bound is greater than its upper bound, or if no set of weights within the bounds sums tosumTo
-
COptQuestMixtureVariable
public COptQuestMixtureVariable(String name, String[] components, double[] lowerBounds, double[] upperBounds, double sumTo) throws COptQuestException Creates a mixture variable with the given component names, optional bounds for each component, and the sum of the weights.- Parameters:
name- base name of the variablecomponents- names of the components; each must be unique and must not contain whitespace, a semicolon, a comma or@lowerBounds- lower bound of each component, or null for a lower bound of 0 on every componentupperBounds- upper bound of each component, or null for no upper boundssumTo- sum of the weights; must be greater than 0- Throws:
COptQuestException- ifcomponentsis null or empty or holds a name that is not valid, ifsumTois not greater than 0, if a bound array does not have one entry for each component, if a lower bound is greater than its upper bound, or if no set of weights within the bounds sums tosumTo
-
-
Method Details
-
getInputVariables
Returns an empty list, because a mixture variable has no ordinary input variables.The values of a mixture variable are in the list that
getProjectedInputVariables()returns. That list has one variable<name>@<component>for each component.- Returns:
- an empty list
-
getOutputVariables
Returns an empty list, because a mixture variable has no output variables.The values of a mixture variable are in the list that
getProjectedInputVariables()returns. That list has one variable<name>@<component>for each component.- Returns:
- an empty list
-
getProjectedInputVariables
Description copied from class:COptQuestManifoldVariableReturns the decision values of this manifold variable that are not ordinary decision variables.For example, an angle variable returns
angle@theta, and a mixture variable returns onemix@<component>name for each component. In every solution that the engine generates, and in every suggested solution, these values are inside the set of the variable. Your evaluator reads them as inputs:OptQuestSolution.GetInputNames()returns them.A constraint that uses one of these names is checked after the evaluation, like a constraint on an output. Your evaluator can receive values that break the constraint, and the solution is then infeasible.
- Specified by:
getProjectedInputVariablesin classCOptQuestManifoldVariable- Returns:
- fixed-size or immutable list of these variables; never
null
-