Class COptQuestSolution

java.lang.Object
com.opttek.optquest.COptQuestSolution

public class COptQuestSolution extends Object
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 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

      public double GetVariableValue(COptQuestVariable var)
      Returns the value of the decision variable for this solution
    • SetVariableValue

      public void SetVariableValue(COptQuestVariable var, double varValue) throws COptQuestException
      Sets the value of the decision variable for this solution.
      Throws:
      COptQuestException - if solution cannot be modified
    • GetObjectiveValue

      @Deprecated public double GetObjectiveValue() throws COptQuestException
      Deprecated.
      Throws:
      COptQuestException
    • SetObjectiveValue

      @Deprecated public void SetObjectiveValue(double objValue)
      Deprecated.
    • SetObjectiveValue

      public void SetObjectiveValue(COptQuestSingleObjective obj, double objValue)
      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

      public double GetObjectiveValue(COptQuestSingleObjective singleObj) throws COptQuestException
      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

      public double GetObjectiveValue(COptQuestUserControlledObjective userObj) throws COptQuestException
      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

      public double GetObjectiveValue(COptQuestStringObjective stringObj) throws COptQuestException
      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

      public double GetRequirementValue(COptQuestRequirement req)
      Returns the value of the requirement for this solution
    • SetRequirementValue

      public void SetRequirementValue(COptQuestRequirement req, double reqValue)
      Sets the value of the requirement for this solution.
    • GetConstraintLHS

      public double GetConstraintLHS(COptQuestStringConstraint con) throws COptQuestException
      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

      public double GetConstraintLHS(COptQuestStringConstraint con, int clause) throws COptQuestException
      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 evaluated
      clause - - 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

      public double GetConstraintRHS(COptQuestStringConstraint con) throws COptQuestException
      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

      public double GetConstraintRHS(COptQuestStringConstraint con, int clause) throws COptQuestException
      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 evaluated
      clause - - 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

      public double SolveExpression(String str) throws COptQuestException
      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

      public boolean IsFeasible() throws COptQuestException
      Returns true if the solution satisfies all constraints and requirements.
      Throws:
      COptQuestException - if the solution has not yet been evaluated
    • IsMinimize

      public boolean IsMinimize() throws COptQuestException
      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

      public boolean IsMaximize() throws COptQuestException
      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

      public boolean IsFeasible(COptQuestStringConstraint constraint)
      Returns true if this solution is feasible (satisfies) for the input constraint.
    • IsFeasible

      public boolean IsFeasible(COptQuestRequirement req)
      Returns true if this solution is feasible (satisfies) for the requirement.
    • IsFeasible

      public boolean IsFeasible(COptQuestOrRequirement requirement)
      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

      public boolean SolutionMetConfidence(COptQuestSingleObjective objective) throws COptQuestException
      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

      public boolean SolutionMetConfidence(COptQuestRequirement theReq) throws COptQuestException
      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

      public double GetConfidenceWidth(COptQuestSingleObjective objective) throws COptQuestException
      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

      public double GetConfidenceWidth(COptQuestRequirement requirement) throws COptQuestException
      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

      public double[] CalculateObservationsOnMeasure(int measure) throws COptQuestException
      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

      public int GetReplicationTerminationReason() throws COptQuestException
      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

      public String GetReplicationTerminationReasonString() throws COptQuestException
      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

      public boolean IsConstraintFeasible(COptQuestConstraint constraint)
      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

      public boolean IsConstraintFeasible(COptQuestCompoundConstraint constraint)
      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

      public boolean IsConstraintFeasible(COptQuestStringConstraint constraint)
      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

      public boolean IsVariableFeasible(COptQuestVariable variable)
      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

      public int GetReplicationCount() throws COptQuestException
      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 variable
      replication - 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

      public Map<COptQuestObjective,com.opttek.optquest.OutputValues> getObjectiveValues()