com.opttek.optquest
Class COptQuestSolution

java.lang.Object
  extended by com.opttek.optquest.COptQuestSolution
All Implemented Interfaces:
java.lang.Comparable<COptQuestSolution>

public class COptQuestSolution
extends java.lang.Object
implements java.lang.Comparable<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 viloates one or more constraints or requirements.


Method Summary
 boolean AreConstraintsValid()
          Returns whether or not the solution is valid with respect to all constraints.
 boolean AreVariablesValid()
          Returns whether or not the solution is valid with respect to all variables.
 double[] CalculateObservationsOnMeasure(int measure)
           
 double CalculateStatisticOnMeasure(int measure, int statistic, double statisticValue)
          Using this solution, calculate the requested statistic on the specified measure
 int compareTo(COptQuestSolution sol)
           
 double GetConstraintLHS(COptQuestStringConstraint con)
          Returns the value of the left hand side of the string constraint using this solution.
 double GetConstraintLHS(COptQuestStringConstraint con, int clause)
          Returns the value of the left hand side of the string constraint using this solution.
 double GetConstraintRHS(COptQuestStringConstraint con)
          Returns the value of the right hand side of the constraint using this solution.
 double GetConstraintRHS(COptQuestStringConstraint con, int clause)
          Returns the value of the right hand side of the string constraint using this solution.
 java.lang.String GetGeneratorString()
           
 int GetIteration()
          Returns the iteration number that generated this solution.
 double GetObjectiveValue()
          Returns the value of the objective for this solution.
 double GetObjectiveValue(COptQuestObjective obj)
          Returns the objective value for a specified objective.
 int GetPID()
          During evaluation, returns the pID associated with this solution.
 boolean GetRejectSolution()
          Returns true if you have marked the solution as rejected.
 int GetReplication()
          Returns the replication number for this solution.
 double GetReplicationStandardDeviation()
          Returns the standard of deviation for the replications of this solution.
 int GetReplicationTerminationReason()
          Returns the reason replications were terminated for this solution.
 java.lang.String GetReplicationTerminationReasonString()
          Returns a text string which describes the reason replications were terminated for this solution.
 double GetRequirementValue(COptQuestRequirement req)
          Returns the value of the requirement for this solution
 double GetVariableValue(COptQuestVariable var)
          Returns the value of the decision variable for this solution
 boolean IsConstraintFeasible(COptQuestCompoundConstraint con)
          Returns whether or not the solution is valid with respect to a single constraint.
 boolean IsConstraintFeasible(COptQuestConstraint con)
          Returns whether or not the solution is valid with respect to a single constraint.
 boolean IsConstraintFeasible(COptQuestStringConstraint con)
          Returns whether or not the solution is valid with respect to a single constraint.
 boolean IsEvaluated()
          Returns true if the solution has completed evaluation.
 boolean IsFeasible()
          Returns true if the solution satisfies all constraints and requirements.
 boolean IsFeasible(COptQuestRequirement req)
          Returns true if this solution is feasible (satisfies) for the input requirement.
 boolean IsFeasible(COptQuestStringConstraint constraint)
          Returns true if this solution is feasible (satisifies) for the input constraint.
 boolean IsLastReplication()
          Return true if we have run the last replication for the this solution.
 boolean IsMaximize()
          Returns true if the goal of the optimization is to maximize the objective value.
 boolean IsMinimize()
          Returns true if the goal of the optimization is to mimimize the objective value.
 boolean IsRequirementFeasible(COptQuestOrRequirement req)
          Returns whether or not the solution is valid with respect to a single requirement.
 boolean IsRequirementFeasible(COptQuestRequirement req)
          Returns whether or not the solution is valid with respect to a single requirement.
 boolean IsValidSolution()
          Returns whether or not the solution is valid with respect to all variables and constraints.
 boolean IsVariableFeasible(COptQuestVariable var)
          Returns whether or not the solution is valid with respect to a single variable.
 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.
 void SetObjectiveValue(COptQuestObjective obj, double objValue)
          Sets the objective value for the specified objective.
 void SetObjectiveValue(double objValue)
          Sets the objective value for this solution
 void SetRequirementValue(COptQuestRequirement req, double reqValue)
          Sets the value of the requirement for this solution.
 void SetVariableValue(COptQuestVariable var, double varValue)
          Sets the value of the decision variable for this solution.
 boolean SolutionMetConfidence()
          Returns true if this solution met confidence level checks for replications.
 double SolveExpression(java.lang.String str)
          Solves the input expression using this solution and returns the value of the expression.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

compareTo

public int compareTo(COptQuestSolution sol)
Specified by:
compareTo in interface java.lang.Comparable<COptQuestSolution>

GetPID

public int GetPID()
During evaluation, returns the pID associated with this solution. Returns -1 after a solution has been evaluated.

Returns:
the pID associated with this solution. Returns -1 after the solution has been evaluated.

GetVariableValue

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

Parameters:
var -
Returns:
the value of the specified decision variable
Throws:
COptQuestException

SetVariableValue

public void SetVariableValue(COptQuestVariable var,
                             double varValue)
                      throws COptQuestException
Sets the value of the decision variable for this solution.

Parameters:
var -
varValue -
Throws:
COptQuestException

GetObjectiveValue

public double GetObjectiveValue()
                         throws COptQuestException
Returns the value of the objective for this solution.

Returns:
the value of the objective
Throws:
COptQuestException

SetObjectiveValue

public void SetObjectiveValue(double objValue)
Sets the objective value for this solution

Parameters:
objValue -

SetObjectiveValue

public void SetObjectiveValue(COptQuestObjective 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

Parameters:
obj -
objValue -

GetObjectiveValue

public double GetObjectiveValue(COptQuestObjective obj)
                         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:
obj -
Throws:
COptQuestException

GetRequirementValue

public double GetRequirementValue(COptQuestRequirement req)
                           throws COptQuestException
Returns the value of the requirement for this solution

Parameters:
req -
Returns:
the value of the specified requirement
Throws:
COptQuestException

SetRequirementValue

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

Parameters:
req -
reqValue -
Throws:
COptQuestException

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

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 operaton (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

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

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

SolveExpression

public double SolveExpression(java.lang.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.

Returns:
the iteration number that generated this solution.

IsFeasible

public boolean IsFeasible()
                   throws COptQuestException
Returns true if the solution satisfies all constraints and requirements.

Returns:
true if the solution is feasible.
Throws:
COptQuestException

IsMinimize

public boolean 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.

IsMaximize

public boolean 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.

IsFeasible

public boolean IsFeasible(COptQuestStringConstraint constraint)
                   throws COptQuestException
Returns true if this solution is feasible (satisifies) for the input constraint.

Parameters:
constraint -
Returns:
true if the solution is feasible
Throws:
COptQuestException

IsFeasible

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

Parameters:
req - requirement
Returns:
true if the solution is feasible
Throws:
COptQuestException

SolutionMetConfidence

public boolean SolutionMetConfidence()
                              throws COptQuestException
Returns true if this solution met confidence level checks for replications.

Returns:
true if the solution met the replication confidence testing criteria
Throws:
COptQuestException

GetRejectSolution

public boolean GetRejectSolution()
                          throws COptQuestException
Returns true if you have marked the solution as rejected. Rejected solutions have their objective value sent to Double.NaN

Returns:
true if the solution has been marked as rejected
Throws:
COptQuestException

RejectSolution

public void RejectSolution()
                    throws COptQuestException
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 sent to Double.NaN

Throws:
COptQuestException

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

CalculateObservationsOnMeasure

public double[] CalculateObservationsOnMeasure(int measure)
                                        throws COptQuestException
Throws:
COptQuestException

GetReplication

public int GetReplication()
                   throws COptQuestException
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.
Throws:
COptQuestException

IsLastReplication

public boolean IsLastReplication()
                          throws COptQuestException
Return true if we have run the last replication for the this solution.

Returns:
true if this is the last replication of the iteration
Throws:
COptQuestException

GetReplicationStandardDeviation

public double GetReplicationStandardDeviation()
                                       throws COptQuestException
Returns the standard of deviation for the replications of this solution.

Returns:
the standard of deviation of the replications for the best solution
Throws:
COptQuestException

GetReplicationTerminationReason

public int GetReplicationTerminationReason()
                                    throws COptQuestException
Returns the reason replications were terminated for this solution.

Returns:
the termination reason as an integer
Throws:
COptQuestException

GetReplicationTerminationReasonString

public java.lang.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

IsValidSolution

public boolean IsValidSolution()
                        throws COptQuestException
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.
Throws:
COptQuestException

IsConstraintFeasible

public boolean IsConstraintFeasible(COptQuestConstraint con)
                             throws COptQuestException
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.
Throws:
COptQuestException

IsConstraintFeasible

public boolean IsConstraintFeasible(COptQuestCompoundConstraint con)
                             throws COptQuestException
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.
Throws:
COptQuestException

IsConstraintFeasible

public boolean IsConstraintFeasible(COptQuestStringConstraint con)
                             throws COptQuestException
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.
Throws:
COptQuestException

IsRequirementFeasible

public boolean IsRequirementFeasible(COptQuestRequirement req)
                              throws COptQuestException
Returns whether or not the solution is valid with respect to a single requirement.

Returns:
true if the solution is valid, false if it is not valid.
Throws:
COptQuestException

IsRequirementFeasible

public boolean IsRequirementFeasible(COptQuestOrRequirement req)
                              throws COptQuestException
Returns whether or not the solution is valid with respect to a single requirement.

Returns:
true if the solution is valid, false if it is not valid.
Throws:
COptQuestException

AreConstraintsValid

public boolean AreConstraintsValid()
                            throws COptQuestException
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.
Throws:
COptQuestException

IsVariableFeasible

public boolean IsVariableFeasible(COptQuestVariable var)
                           throws COptQuestException
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.
Throws:
COptQuestException

AreVariablesValid

public boolean AreVariablesValid()
                          throws COptQuestException
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.
Throws:
COptQuestException

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.

GetGeneratorString

public java.lang.String GetGeneratorString()