Package com.opttek.optquest
Class COptQuestSolution
java.lang.Object
com.opttek.optquest.COptQuestSolution
A COptQuestSolution object contains the values for one solution and provides
methods to access information on the solution. Before a solution is
evaluated, it contains the values for all decision variables. After the
solution has been evaluated, the solution will have the value for the objective,
constraints and requirements. It will also be marked as a feasible solution or
an infeasible solutions. A feasible solution satisfies all constraints and
requirements. An infeasible solution violates one or more constraints or
requirements.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether or not the solution is valid with respect to all constraints.booleanReturns whether or not the solution is valid with respect to all variables.double[]CalculateObservationsOnMeasure(int measure) Calculate portfolio metrics for this solution and measuredoubleCalculateStatisticOnMeasure(int measure, int statistic, double statisticValue) Using this solution, calculate the requested statistic on the specified measureintGetCompletionOrder(int replication) doubleGetConfidenceWidth(COptQuestRequirement requirement) Return the confidence width for the input requirement.doubleGetConfidenceWidth(COptQuestSingleObjective objective) Return the confidence width for the input objective.doubleReturns the value of the left hand side of the string constraint using this solution.doubleGetConstraintLHS(COptQuestStringConstraint con, int clause) Returns the value of the left hand side of the string constraint using this solution.doubleReturns the value of the right hand side of the constraint using this solution.doubleGetConstraintRHS(COptQuestStringConstraint con, int clause) Returns the value of the right hand side of the string constraint using this solution.doubleReturns a measure of infeasibility across all problem requirementsintReturns the iteration number that generated this solution.doubleDeprecated.doubleGetObjectiveValue(COptQuestSingleObjective singleObj) Returns the objective value for a specified objective.doubleGetObjectiveValue(COptQuestStringObjective stringObj) Returns the objective value for a specified objective.doubleReturns the objective value for a specified objective.doubleGetObjectiveValue(COptQuestWeightedMultiObjective weightedObj) Map<COptQuestObjective,com.opttek.optquest.OutputValues> intGetPID()For OptQuest versions 7.2 and earlier, solution replications were run serially and the PID could be used to map a solution to an evaluator so that all replications of a solution could be run on the same evaluator.booleanReturns true if you have marked the solution as rejected.intReturns the replication number for this solution.intReturns the number of completed replications.intReturns the reason replications were terminated for this solution.Returns a text string which describes the reason replications were terminated for this solution.GetReplicationValue(COptQuestRequirement requirement, int replication) Return the replication value for the input requirement and specified replication.GetReplicationValue(COptQuestSingleObjective objective, int replication) Return the replication value for the input objective and specified replication.GetReplicationValue(COptQuestStringObjective stringObj, int replication) Return the replication value for the input objective and specified replication.GetReplicationValue(COptQuestUserControlledObjective userObj, int replication) Return the replication value for the input objective and specified replication.GetReplicationValue(COptQuestUserControlledVariable userVar, int replication) Return the replication value for the input user controlled variable and specified replication.GetReplicationValue(COptQuestWeightedMultiObjective objective, int replication) Return the replication value for the input weighted objective and specified replication.GetReplicationValues(COptQuestRequirement requirement) Return the replication values for the input requirement.GetReplicationValues(COptQuestSingleObjective objective) Return the replication values for the input objective.GetReplicationValues(COptQuestStringObjective stringObj) Return the replication values for the input objective.Return the replication values for the input objective.Return the replication values for the input variable.Return the replication values for the input objective.doubleReturns the value of the requirement for this solutiondoubleReturns the value of the decision variable for this solutionbooleanIsConstraintFeasible(COptQuestCompoundConstraint constraint) Returns whether or not the solution is valid with respect to a single constraint.booleanIsConstraintFeasible(COptQuestConstraint constraint) Returns whether or not the solution is valid with respect to a single constraint.booleanIsConstraintFeasible(COptQuestStringConstraint constraint) Returns whether or not the solution is valid with respect to a single constraint.booleanReturns true if the solution has completed evaluation.booleanReturns true if the solution satisfies all constraints and requirements.booleanIsFeasible(COptQuestOrRequirement requirement) Returns true if this solution is feasible (satisfies) for the "or" requirement.booleanReturns true if this solution is feasible (satisfies) for the requirement.booleanIsFeasible(COptQuestStringConstraint constraint) Returns true if this solution is feasible (satisfies) for the input constraint.booleanReturn true if we have run the last replication for the this solution.booleanReturns true if the goal of the optimization is to maximize the objective value.booleanReturns true if the goal of the optimization is to mimimize the objective value.booleanReturns if the solution has been rejectedbooleanReturn true if the optimization is running replications.booleanReturns whether or not the solution is valid with respect to all variables and constraints.booleanIsVariableFeasible(COptQuestVariable variable) Returns whether or not the solution is valid with respect to a single variable.voidMarks this solution as rejected which means it may not be complete and it will not be considered as a candidate for the best solution.voidSetIterationAndReplication(int iteration, int replication) Used when adding a suggested solution and the suggested solution is for a specific iteration and replication.voidSetObjectiveValue(double objValue) Deprecated.voidSetObjectiveValue(COptQuestSingleObjective obj, double objValue) Sets the objective value for the specified objective.voidSetRequirementValue(COptQuestRequirement req, double reqValue) Sets the value of the requirement for this solution.voidSetVariableValue(COptQuestVariable var, double varValue) Sets the value of the decision variable for this solution.booleanReturns true if this solution met confidence level checks for replications.booleanReturns true if the input requirement met confidence level checks for replications.booleanSolutionMetConfidence(COptQuestSingleObjective objective) Returns true if the input objective met confidence level checks for replications.doubleSolveExpression(String str) Solves the input expression using this solution and returns the value of the expression.
-
Method Details
-
GetPID
public int GetPID()For OptQuest versions 7.2 and earlier, solution replications were run serially and the PID could be used to map a solution to an evaluator so that all replications of a solution could be run on the same evaluator.- Returns:
- the pID associated with this solution.
-
GetVariableValue
Returns the value of the decision variable for this solution -
SetVariableValue
Sets the value of the decision variable for this solution.- Throws:
COptQuestException- if solution cannot be modified
-
GetObjectiveValue
Deprecated.- Throws:
COptQuestException
-
SetObjectiveValue
Deprecated. -
SetObjectiveValue
Sets the objective value for the specified objective. Use this method to set the value for objectives that are used in a COptQuestMultipleObjective. You should not set the objective value for a COptQuestFrontierMultiObjective or COptQuestWeightedMultiObjective.- Parameters:
obj- - For a single objective optimization, the objective of the optimization For a multi-objective optimization, one of the objectives added to the multi-objective.objValue- - the value of the objective
-
GetObjectiveValue
Returns the objective value for a specified objective. Use this method to get the value for objectives that are used in a COptQuestMultipleObjective.- Parameters:
singleObj- - objective- Returns:
- value - value of the objective for this solutions
- Throws:
COptQuestException- if objective not found
-
GetObjectiveValue
public double GetObjectiveValue(COptQuestWeightedMultiObjective weightedObj) throws COptQuestException - Throws:
COptQuestException
-
GetObjectiveValue
Returns the objective value for a specified objective. Use this method to get the value for objectives that are used in a COptQuestMultipleObjective.- Parameters:
userObj- - the objective- Returns:
- value - value of the objective for this solutions
- Throws:
COptQuestException- if objective not found
-
GetObjectiveValue
Returns the objective value for a specified objective. Use this method to get the value for objectives that are used in a COptQuestMultipleObjective.- Parameters:
stringObj- - the objective- Returns:
- value - value of the objective for this solutions
- Throws:
COptQuestException- if objective not found
-
GetRequirementValue
Returns the value of the requirement for this solution -
SetRequirementValue
Sets the value of the requirement for this solution. -
GetConstraintLHS
Returns the value of the left hand side of the string constraint using this solution.- Parameters:
con- - The constraint to be evaluated- Returns:
- - the value of the left side using this solution
- Throws:
COptQuestException- if a problem is encountered
-
GetConstraintLHS
Returns the value of the left hand side of the string constraint using this solution. If the string constraint contains an Or operator or an implied And operation (5 ≤ Var1 + Var2 ≤ 10), the clause parameter identifies which clause to evaluate. For example, Var1 + Var2 ≤ 3 or Var3 + Var4 ≥ 5. The left hand side of clause 1 is Var1 + Var2.- Parameters:
con- - the constraint to be evaluatedclause- - One based value identifying the or clause to evaluate- Returns:
- the value of the left hand side.
- Throws:
COptQuestException- if a problem is encountered
-
GetConstraintRHS
Returns the value of the right hand side of the constraint using this solution.- Parameters:
con- - The constraint to be evaluated- Returns:
- - the value of the right side using this solution
- Throws:
COptQuestException- if a problem is encountered
-
GetConstraintRHS
Returns the value of the right hand side of the string constraint using this solution. If the string constraint contains an Or operator or an implied And operaton (5 ≤ Var1 + Var2 ≤ 10), the clause parameter identifies which clause to evaluate. For example, 3 ≥ Var1 + Var2 or 5 ≥ Var3 + Var4. The right hand side of clause 1 is Var1 + Var2.- Parameters:
con- - the constraint to be evaluatedclause- - One based value identifying the or clause to evaluate- Returns:
- the value of the right hand side
- Throws:
COptQuestException- if a problem is encountered
-
SolveExpression
Solves the input expression using this solution and returns the value of the expression.- Parameters:
str- - mathematical expression to be evaluated- Returns:
- result of the expression
- Throws:
COptQuestException- if there is an error in the expression that prevents it from being evaluated.
-
GetIteration
public int GetIteration()Returns the iteration number that generated this solution. -
IsFeasible
Returns true if the solution satisfies all constraints and requirements.- Throws:
COptQuestException- if the solution has not yet been evaluated
-
IsMinimize
Returns true if the goal of the optimization is to mimimize the objective value.- Returns:
- true if the goal of the optimization is to minimize the objective value.
- Throws:
COptQuestException- if the optimization objective is a COptQuestFrontierObjective
-
IsMaximize
Returns true if the goal of the optimization is to maximize the objective value.- Returns:
- true if the goal of the optimization is to maximize the objective value.
- Throws:
COptQuestException- if the optimization objective is a COptQuestFrontierObjective
-
IsFeasible
Returns true if this solution is feasible (satisfies) for the input constraint. -
IsFeasible
Returns true if this solution is feasible (satisfies) for the requirement. -
IsFeasible
Returns true if this solution is feasible (satisfies) for the "or" requirement. -
SolutionMetConfidence
public boolean SolutionMetConfidence()Returns true if this solution met confidence level checks for replications. If confidence was set on multiple requirements or objective, the method will return true if all objects met the confidence criteria.- Returns:
- true if the solution met the replication confidence testing criteria
-
SolutionMetConfidence
Returns true if the input objective met confidence level checks for replications. If the objective is a multi-objective, each objective of the multi-objective is checked.- Returns:
- true if confidence level checks were met.
- Throws:
COptQuestException- throws an exception if the optimization is not running replications or if the input objective does not have confidence settings.
-
SolutionMetConfidence
Returns true if the input requirement met confidence level checks for replications.- Throws:
COptQuestException- if the optimization is not running replications or if the input requirement does not have confidence settings.
-
GetConfidenceWidth
Return the confidence width for the input objective. If you are running a frontier multi-objective optimization, you must request the confidence width for an objective that has been added to the frontier objective.- Parameters:
objective- -- Returns:
- calculated confidence value
- Throws:
COptQuestException- if the input objective is a frontier objective or if the objective does not have confidence settings.
-
GetConfidenceWidth
Return the confidence width for the input requirement.- Returns:
- calculated confidence value.
- Throws:
COptQuestException- if a problem is encountered
-
GetRejectSolution
public boolean GetRejectSolution()Returns true if you have marked the solution as rejected. Rejected solutions have their objective value set to Double.NaN- Returns:
- true if the solution has been marked as rejected
-
RejectSolution
public void RejectSolution()Marks this solution as rejected which means it may not be complete and it will not be considered as a candidate for the best solution. Rejected solutions have their objective value set to Double.NaN -
CalculateStatisticOnMeasure
public double CalculateStatisticOnMeasure(int measure, int statistic, double statisticValue) throws COptQuestException Using this solution, calculate the requested statistic on the specified measure- Parameters:
measure-- OCLP_NPV = 1
- OCLP_IRR = 2
- OCLP_PBP = 3
statistic-- OCLP_MEAN = 1
- OCLP_MEDIAN = 2
- OCLP_PERCENTILE = 3
- OCLP_STDDEV = 4
- OCLP_SEMI1STDDEV = 5
- OCLP_VARIANCE = 6
- OCLP_SEMI1VARIANCE = 7
- OCLP_COEFFOFVAR = 8
- OCLP_COEFFOFSEMI1VAR = 9
- OCLP_PROBABILITY = 10
- OCLP_SEMI2STDDEV = 11
- OCLP_SEMI2VARIANCE = 12
- OCLP_COEFFOFSEMI2VAR = 13
statisticValue- target values for OCLP_PERCENTILE, OCLP_SEMI1STDDEV, OCLP_SEMI2STDDEV, OCLP_PROBABILITY- Returns:
- the result of the calculation
- Throws:
COptQuestException- if a problem is encountered
-
CalculateObservationsOnMeasure
Calculate portfolio metrics for this solution and measure- Returns:
- metrics array
- Throws:
COptQuestException- if a problem is encountered
-
GetReplication
public int GetReplication()Returns the replication number for this solution. During evaluation, it is the replication being evaluated. After evaluation has completed, it is the total number of replications run on this solution. The replication number will be between 1 and the maximum number of replications specified by the SetMaximumReplications() method.- Returns:
- the number of replications run thus far.
-
IsLastReplication
public boolean IsLastReplication()Return true if we have run the last replication for the this solution.- Returns:
- true if this is the last replication of the iteration
-
GetReplicationTerminationReason
Returns the reason replications were terminated for this solution.- 1 = REPLTERM_MAXREPLICATIONS = maximum replications were run
- 2 = REPLTERM_METCONFIDENCE = the confidence interval was met
- 3 = REPLTERM_NOTNEARBEST = the objective value was not near the best objective
- Returns:
- the termination reason as an integer
- Throws:
COptQuestException- if not running replications
-
GetReplicationTerminationReasonString
Returns a text string which describes the reason replications were terminated for this solution.- Returns:
- the termination reason as a string.
- Throws:
COptQuestException- if not running replications
-
IsValidSolution
public boolean IsValidSolution()Returns whether or not the solution is valid with respect to all variables and constraints.- Returns:
- true if the solution is valid, false if it is not valid.
-
IsConstraintFeasible
Returns whether or not the solution is valid with respect to a single constraint.- Returns:
- true if the solution is valid, false if it is not valid.
-
IsConstraintFeasible
Returns whether or not the solution is valid with respect to a single constraint.- Returns:
- true if the solution is valid, false if it is not valid.
-
IsConstraintFeasible
Returns whether or not the solution is valid with respect to a single constraint.- Returns:
- true if the solution is valid, false if it is not valid.
-
AreConstraintsValid
public boolean AreConstraintsValid()Returns whether or not the solution is valid with respect to all constraints.- Returns:
- true if the solution is valid, false if it is not valid.
-
IsVariableFeasible
Returns whether or not the solution is valid with respect to a single variable.- Returns:
- true if the solution is valid, false if it is not valid.
-
AreVariablesValid
public boolean AreVariablesValid()Returns whether or not the solution is valid with respect to all variables.- Returns:
- true if the solution is valid, false if it is not valid.
-
GetFeasibilityIndex
public double GetFeasibilityIndex()Returns a measure of infeasibility across all problem requirements- Returns:
- measure
-
IsEvaluated
public boolean IsEvaluated()Returns true if the solution has completed evaluation. False if it not completely evaluated.- Returns:
- true if the solution has completed evaluation.
-
IsRejected
public boolean IsRejected()Returns if the solution has been rejected- Returns:
- true if solution is rejected
-
IsUsingReplications
public boolean IsUsingReplications()Return true if the optimization is running replications. -
GetReplicationValues
public List<Double> GetReplicationValues(COptQuestSingleObjective objective) throws COptQuestException Return the replication values for the input objective. The returned list will be in replication order where the first value is from replication 1, second from replication 2 etc. If no replications have been run, an empty list will be returned. Missing replications will have a value of null. If replication 2 finished before replication 1, the list will contain null for replication 1 and the value for replication 2.- Parameters:
objective- - return the replication values for this objective- Returns:
- the values for the objective at each replication.
- Throws:
COptQuestException- throws an exception if replications have not been defined
-
GetReplicationValues
public List<Double> GetReplicationValues(COptQuestUserControlledObjective userObj) throws COptQuestException Return the replication values for the input objective. The returned list will be in replication order where the first value is from replication 1, second from replication 2 etc. If no replications have been run, an empty list will be returned. Missing replications will have a value of null. If replication 2 finished before replication 1, the list will contain null for replication 1 and the value for replication 2.- Parameters:
userObj- - return the replication values for this objective- Returns:
- the values for the objective at each replication.
- Throws:
COptQuestException- throws an exception if replications have not been defined
-
GetReplicationValues
public List<Double> GetReplicationValues(COptQuestStringObjective stringObj) throws COptQuestException Return the replication values for the input objective. The returned list will be in replication order where the first value is from replication 1, second from replication 2 etc. If no replications have been run, an empty list will be returned. Missing replications will have a value of null. If replication 2 finished before replication 1, the list will contain null for replication 1 and the value for replication 2.- Parameters:
stringObj- - return the replication values for this objective- Returns:
- the values for the objective at each replication.
- Throws:
COptQuestException- throws an exception if replications have not been defined
-
GetReplicationValues
public List<Double> GetReplicationValues(COptQuestWeightedMultiObjective objective) throws COptQuestException Return the replication values for the input objective. The returned list will be in replication order where the first value is from replication 1, second from replication 2 etc. If no replications have been run, an empty list will be returned. Missing replications will have a value of null. If replication 2 finished before replication 1, the list will contain null for replication 1 and the value for replication 2.- Parameters:
objective- - return the replication values for weighted objective- Returns:
- the values for the objective at each replication.
- Throws:
COptQuestException- throws an exception if replications have not been defined
-
GetReplicationValues
public List<Double> GetReplicationValues(COptQuestRequirement requirement) throws COptQuestException Return the replication values for the input requirement. The returned list will be in replication order where the first value is from replication 1, second from replication 2 etc. If no replications have been run, an empty list will be returned. Missing replications will have a value of null. If replication 2 finished before replication 1, the list will contain null for replication 1 and the value for replication 2.- Parameters:
requirement- - return the replication values for this requirement- Returns:
- the values for the requirement at each replication.
- Throws:
COptQuestException
-
GetReplicationValues
public List<Double> GetReplicationValues(COptQuestUserControlledVariable userVar) throws COptQuestException Return the replication values for the input variable. The returned list will be in replication order where the first value is from replication 1, second from replication 2 etc. If no replications have been run, an empty list will be returned. Missing replications will have a value of null. If replication 2 finished before replication 1, the list will contain null for replication 1 and the value for replication 2.- Throws:
COptQuestException- if a problem is encountered
-
GetReplicationCount
Returns the number of completed replications. If you need to know if all replications have completed, use the method IsLastReplication().- Throws:
COptQuestException- if not running replications
-
GetReplicationValue
public Double GetReplicationValue(COptQuestSingleObjective objective, int replication) throws COptQuestException Return the replication value for the input objective and specified replication.- Returns:
- The value at the specified replication. If the replication hasn't been evaluated, null is returned.
- Throws:
COptQuestException- not running replications
-
GetReplicationValue
public Double GetReplicationValue(COptQuestUserControlledObjective userObj, int replication) throws COptQuestException Return the replication value for the input objective and specified replication.- Returns:
- The value at the specified replication. If the replication hasn't been evaluated, null is returned.
- Throws:
COptQuestException- not running replications
-
GetReplicationValue
public Double GetReplicationValue(COptQuestStringObjective stringObj, int replication) throws COptQuestException Return the replication value for the input objective and specified replication.- Returns:
- The value at the specified replication. If the replication hasn't been evaluated, null is returned.
- Throws:
COptQuestException- if not running replications
-
GetReplicationValue
public Double GetReplicationValue(COptQuestWeightedMultiObjective objective, int replication) throws COptQuestException Return the replication value for the input weighted objective and specified replication.- Returns:
- The value at the specified replication. If the replication hasn't been evaluated, null is returned.
- Throws:
COptQuestException- if not running replications
-
GetReplicationValue
public Double GetReplicationValue(COptQuestRequirement requirement, int replication) throws COptQuestException Return the replication value for the input requirement and specified replication.- Returns:
- The value at the specified replication. If the replication hasn't been evaluated, null is returned.
- Throws:
COptQuestException- not running replications
-
GetReplicationValue
public Double GetReplicationValue(COptQuestUserControlledVariable userVar, int replication) throws COptQuestException Return the replication value for the input user controlled variable and specified replication.- Parameters:
userVar- controlled variablereplication- replication number- Returns:
- The value at the specified replication. If the replication hasn't been evaluated, null is returned.
- Throws:
COptQuestException- if not running replications
-
SetIterationAndReplication
public void SetIterationAndReplication(int iteration, int replication) Used when adding a suggested solution and the suggested solution is for a specific iteration and replication. -
GetCompletionOrder
public int GetCompletionOrder(int replication) -
getObjectiveValues
-